Skip to content

Commit

Permalink
adjust static pod CRD spec
Browse files Browse the repository at this point in the history
Signed-off-by: hxcGit <[email protected]>
  • Loading branch information
xavier-hou committed Mar 24, 2023
1 parent 811b382 commit 8bf25d0
Show file tree
Hide file tree
Showing 6 changed files with 553 additions and 85 deletions.
235 changes: 235 additions & 0 deletions charts/openyurt/templates/yurt-manager-auto-generated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,161 @@ status:
conditions: []
storedVersions: []
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.7.0
creationTimestamp: null
name: staticpods.apps.openyurt.io
spec:
group: apps.openyurt.io
names:
kind: StaticPod
listKind: StaticPodList
plural: staticpods
shortNames:
- sp
singular: staticpod
scope: Namespaced
versions:
- additionalPrinterColumns:
- description: CreationTimestamp is a timestamp representing the server time when
this object was created. It is not guaranteed to be set in happens-before
order across separate operations. Clients may not set this value. It is represented
in RFC3339 form and is in UTC.
jsonPath: .metadata.creationTimestamp
name: AGE
type: date
- description: The total number of static pods
jsonPath: .status.totalNumber
name: TotalNumber
type: integer
- description: The number of static pods that desired to be upgraded
jsonPath: .status.desiredNumber
name: DesiredNumber
type: integer
- description: The number of static pods that have been upgraded
jsonPath: .status.upgradedNumber
name: UpgradedNumber
type: integer
- jsonPath: .status.conditions[0].type
name: Status
type: string
name: v1alpha1
schema:
openAPIV3Schema:
description: StaticPod is the Schema for the staticpods API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: StaticPodSpec defines the desired state of StaticPod
properties:
revisionHistoryLimit:
description: The number of old history to retain to allow rollback.
Defaults to 10.
format: int32
type: integer
staticPodManifest:
description: StaticPodManifest indicates the Static Pod desired to
be upgraded. The corresponding manifest file name is `StaticPodManifest.yaml`.
type: string
template:
description: An object that describes the desired upgrade static pod.
x-kubernetes-preserve-unknown-fields: true
upgradeStrategy:
description: An upgrade strategy to replace existing static pods with
new ones.
properties:
maxUnavailable:
anyOf:
- type: integer
- type: string
description: Auto upgrade config params. Present only if type
= "auto".
x-kubernetes-int-or-string: true
type:
description: Type of Static Pod upgrade. Can be "auto" or "ota".
type: string
type: object
type: object
status:
description: StaticPodStatus defines the observed state of StaticPod
properties:
conditions:
description: Represents the latest available observations of StaticPod's
current state.
items:
description: StaticPodCondition describes the state of a StaticPodCondition
at a certain point.
properties:
lastTransitionTime:
description: Last time the condition transitioned from one status
to another.
format: date-time
type: string
message:
description: A human-readable message indicating details about
the transition.
type: string
reason:
description: The reason for the condition's last transition.
type: string
status:
description: Status of the condition, one of True, False, Unknown.
type: string
type:
description: Type of StaticPod condition.
type: string
type: object
type: array
desiredNumber:
description: The number of nodes that are running static pods which
need to be upgraded.
format: int32
type: integer
observedGeneration:
description: The most recent generation observed by the static pod
controller.
format: int64
type: integer
totalNumber:
description: The total number of nodes that are running the static
pod.
format: int32
type: integer
upgradedNumber:
description: The number of nodes that are running updated static pod.
format: int32
type: integer
required:
- desiredNumber
- totalNumber
- upgradedNumber
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
Expand Down Expand Up @@ -553,6 +708,32 @@ rules:
- get
- patch
- update
- apiGroups:
- apps.openyurt.io
resources:
- staticpods
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps.openyurt.io
resources:
- staticpods/finalizers
verbs:
- update
- apiGroups:
- apps.openyurt.io
resources:
- staticpods/status
verbs:
- get
- patch
- update
- apiGroups:
- certificates.k8s.io
resources:
Expand Down Expand Up @@ -588,6 +769,18 @@ rules:
- patch
- update
- watch
- apiGroups:
- ""
resources:
- configmaps
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
Expand Down Expand Up @@ -736,6 +929,27 @@ webhooks:
resources:
- nodepools
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: webhook-service
namespace: kube-system
path: /mutate-apps-openyurt-io-v1alpha1-staticpod
failurePolicy: Fail
name: mutate.apps.v1alpha1.staticpod.openyurt.io
rules:
- apiGroups:
- apps.openyurt.io
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- staticpods
sideEffects: None
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
Expand Down Expand Up @@ -785,3 +999,24 @@ webhooks:
resources:
- nodepools
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: webhook-service
namespace: kube-system
path: /validate-apps-openyurt-io-v1alpha1-staticpod
failurePolicy: Fail
name: validate.apps.v1alpha1.staticpod.openyurt.io
rules:
- apiGroups:
- apps.openyurt.io
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- staticpods
sideEffects: None
25 changes: 13 additions & 12 deletions pkg/apis/apps/v1alpha1/staticpod_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,18 @@ const (

// StaticPodSpec defines the desired state of StaticPod
type StaticPodSpec struct {
// StaticPodName indicates the static pod desired to be upgraded.
StaticPodName string `json:"staticPodName"`

// StaticPodManifest indicates the Static Pod desired to be upgraded. The corresponding
// manifest file name is `StaticPodManifest.yaml`.
// +optional
StaticPodManifest string `json:"staticPodManifest,omitempty"`

// Namespace indicates the namespace of target static pod
// +optional
StaticPodNamespace string `json:"staticPodNamespace,omitempty"`

// An upgrade strategy to replace existing static pods with new ones.
UpgradeStrategy StaticPodUpgradeStrategy `json:"upgradeStrategy,omitempty"`

// The number of old history to retain to allow rollback.
// Defaults to 10.
// +optional
RevisionHistoryLimit *int32 `json:"revisionHistoryLimit,omitempty"`

// An object that describes the desired upgrade static pod.
// +optional
// +kubebuilder:pruning:PreserveUnknownFields
Expand Down Expand Up @@ -97,15 +94,19 @@ type StaticPodCondition struct {

// StaticPodStatus defines the observed state of StaticPod
type StaticPodStatus struct {
// The total number of static pods
// The total number of nodes that are running the static pod.
TotalNumber int32 `json:"totalNumber"`

// The number of static pods that should be upgraded.
// The number of nodes that are running static pods which need to be upgraded.
DesiredNumber int32 `json:"desiredNumber"`

// The number of static pods that have been upgraded.
// The number of nodes that are running updated static pod.
UpgradedNumber int32 `json:"upgradedNumber"`

// The most recent generation observed by the static pod controller.
// +optional
ObservedGeneration int64 `json:"observedGeneration"`

// Represents the latest available observations of StaticPod's current state.
// +optional
Conditions []StaticPodCondition `json:"conditions"`
Expand All @@ -115,7 +116,7 @@ type StaticPodStatus struct {
// +k8s:openapi-gen=true
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster,path=staticpods,shortName=sp,categories=all
// +kubebuilder:resource:shortName=sp
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp",description="CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC."
//+kubebuilder:printcolumn:name="TotalNumber",type="integer",JSONPath=".status.totalNumber",description="The total number of static pods"
//+kubebuilder:printcolumn:name="DesiredNumber",type="integer",JSONPath=".status.desiredNumber",description="The number of static pods that desired to be upgraded"
Expand Down
Loading

0 comments on commit 8bf25d0

Please sign in to comment.