Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interface: improve ClusterStagedUpdateRun APIs #1008

Merged
merged 4 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion apis/placement/v1alpha1/stagedupdate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ import (
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster,categories={fleet,fleet-placement},shortName=crsur
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:printcolumn:JSONPath=`.spec.placementName`,name="Placement",type=string
// +kubebuilder:printcolumn:JSONPath=`.spec.resourceSnapshotIndex`,name="Resource-Snapshot",type=string
// +kubebuilder:printcolumn:JSONPath=`.status.policySnapshotIndexUsed`,name="Policy-Snapshot",type=string
// +kubebuilder:printcolumn:JSONPath=`.status.conditions[?(@.type=="Initialized")].status`,name="Initialized",type=string
jwtty marked this conversation as resolved.
Show resolved Hide resolved
// +kubebuilder:printcolumn:JSONPath=`.status.conditions[?(@.type=="Succeeded")].status`,name="Succeeded",type=string
// +kubebuilder:printcolumn:JSONPath=`.metadata.creationTimestamp`,name="Age",type=date
// +kubebuilder:printcolumn:JSONPath=`.spec.stagedRolloutStrategyName`,name="Strategy",priority=1,type=string
// +kubebuilder:validation:XValidation:rule="size(self.metadata.name) < 128",message="metadata.name max length is 127"
jwtty marked this conversation as resolved.
Show resolved Hide resolved

// ClusterStagedUpdateRun represents a stage by stage update process that applies ClusterResourcePlacement
// selected resources to specified clusters.
Expand Down Expand Up @@ -102,7 +110,7 @@ type ClusterStagedUpdateStrategyList struct {
type StageConfig struct {
// The name of the stage. This MUST be unique within the same StagedUpdateStrategy.
// +kubebuilder:validation:MaxLength=63
// +kubebuilder:validation:Pattern="[A-Za-z0-9]+$"
// +kubebuilder:validation:Pattern="^[a-z0-9]+$"
ryanzhang-oss marked this conversation as resolved.
Show resolved Hide resolved
// +kubebuilder:validation:Required
Name string `json:"name"`

Expand Down Expand Up @@ -397,6 +405,10 @@ type ClusterStagedUpdateRunList struct {
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster,categories={fleet,fleet-placement},shortName=careq
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:printcolumn:JSONPath=`.spec.parentStageRollout`,name="Update-Run",type=string
// +kubebuilder:printcolumn:JSONPath=`.spec.targetStage`,name="Stage",type=string
// +kubebuilder:printcolumn:JSONPath=`.status.conditions[?(@.type=="Approved")].status`,name="Approved",type=string
jwtty marked this conversation as resolved.
Show resolved Hide resolved
// +kubebuilder:printcolumn:JSONPath=`.metadata.creationTimestamp`,name="Age",type=date

// ClusterApprovalRequest defines a request for user approval for cluster staged update run.
// The request object MUST have the following labels:
Expand Down
14 changes: 13 additions & 1 deletion apis/placement/v1beta1/stageupdate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ import (
// +kubebuilder:resource:scope=Cluster,categories={fleet,fleet-placement},shortName=crsur
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:storageversion
// +kubebuilder:printcolumn:JSONPath=`.spec.placementName`,name="Placement",type=string
// +kubebuilder:printcolumn:JSONPath=`.spec.resourceSnapshotIndex`,name="Resource-Snapshot",type=string
// +kubebuilder:printcolumn:JSONPath=`.status.policySnapshotIndexUsed`,name="Policy-Snapshot",type=string
// +kubebuilder:printcolumn:JSONPath=`.status.conditions[?(@.type=="Initialized")].status`,name="Initialized",type=string
// +kubebuilder:printcolumn:JSONPath=`.status.conditions[?(@.type=="Succeeded")].status`,name="Succeeded",type=string
// +kubebuilder:printcolumn:JSONPath=`.metadata.creationTimestamp`,name="Age",type=date
// +kubebuilder:printcolumn:JSONPath=`.spec.stagedRolloutStrategyName`,name="Strategy",priority=1,type=string
// +kubebuilder:validation:XValidation:rule="size(self.metadata.name) < 128",message="metadata.name max length is 127"

// ClusterStagedUpdateRun represents a stage by stage update process that applies ClusterResourcePlacement
// selected resources to specified clusters.
Expand Down Expand Up @@ -102,7 +110,7 @@ type ClusterStagedUpdateStrategyList struct {
type StageConfig struct {
// The name of the stage. This MUST be unique within the same StagedUpdateStrategy.
// +kubebuilder:validation:MaxLength=63
// +kubebuilder:validation:Pattern="[A-Za-z0-9]+$"
// +kubebuilder:validation:Pattern="^[a-z0-9]+$"
// +kubebuilder:validation:Required
Name string `json:"name"`

Expand Down Expand Up @@ -398,6 +406,10 @@ type ClusterStagedUpdateRunList struct {
// +kubebuilder:resource:scope=Cluster,categories={fleet,fleet-placement},shortName=careq
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:storageversion
// +kubebuilder:printcolumn:JSONPath=`.spec.parentStageRollout`,name="Update-Run",type=string
// +kubebuilder:printcolumn:JSONPath=`.spec.targetStage`,name="Stage",type=string
// +kubebuilder:printcolumn:JSONPath=`.status.conditions[?(@.type=="Approved")].status`,name="Approved",type=string
// +kubebuilder:printcolumn:JSONPath=`.metadata.creationTimestamp`,name="Age",type=date

// ClusterApprovalRequest defines a request for user approval for cluster staged update run.
// The request object MUST have the following labels:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,20 @@ spec:
singular: clusterapprovalrequest
scope: Cluster
versions:
- name: v1alpha1
- additionalPrinterColumns:
- jsonPath: .spec.parentStageRollout
name: Update-Run
type: string
- jsonPath: .spec.targetStage
name: Stage
type: string
- jsonPath: .status.conditions[?(@.type=="Approved")].status
name: Approved
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha1
schema:
openAPIV3Schema:
description: |-
Expand Down Expand Up @@ -150,7 +163,20 @@ spec:
storage: false
subresources:
status: {}
- name: v1beta1
- additionalPrinterColumns:
- jsonPath: .spec.parentStageRollout
name: Update-Run
type: string
- jsonPath: .spec.targetStage
name: Stage
type: string
- jsonPath: .status.conditions[?(@.type=="Approved")].status
name: Approved
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1beta1
schema:
openAPIV3Schema:
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,30 @@ spec:
singular: clusterstagedupdaterun
scope: Cluster
versions:
- name: v1alpha1
- additionalPrinterColumns:
- jsonPath: .spec.placementName
name: Placement
type: string
- jsonPath: .spec.resourceSnapshotIndex
name: Resource-Snapshot
type: string
- jsonPath: .status.policySnapshotIndexUsed
name: Policy-Snapshot
type: string
- jsonPath: .status.conditions[?(@.type=="Initialized")].status
name: Initialized
type: string
- jsonPath: .status.conditions[?(@.type=="Succeeded")].status
name: Succeeded
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
- jsonPath: .spec.stagedRolloutStrategyName
name: Strategy
priority: 1
type: string
name: v1alpha1
schema:
openAPIV3Schema:
description: |-
Expand Down Expand Up @@ -861,7 +884,7 @@ spec:
description: The name of the stage. This MUST be unique
within the same StagedUpdateStrategy.
maxLength: 63
pattern: '[A-Za-z0-9]+$'
pattern: ^[a-z0-9]+$
type: string
sortingLabelKey:
description: |-
Expand Down Expand Up @@ -1209,11 +1232,37 @@ spec:
required:
- spec
type: object
x-kubernetes-validations:
- message: metadata.name max length is 127
rule: size(self.metadata.name) < 128
served: true
storage: false
subresources:
status: {}
- name: v1beta1
- additionalPrinterColumns:
- jsonPath: .spec.placementName
name: Placement
type: string
- jsonPath: .spec.resourceSnapshotIndex
name: Resource-Snapshot
type: string
- jsonPath: .status.policySnapshotIndexUsed
name: Policy-Snapshot
type: string
- jsonPath: .status.conditions[?(@.type=="Initialized")].status
name: Initialized
type: string
- jsonPath: .status.conditions[?(@.type=="Succeeded")].status
name: Succeeded
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
- jsonPath: .spec.stagedRolloutStrategyName
name: Strategy
priority: 1
type: string
name: v1beta1
schema:
openAPIV3Schema:
description: |-
Expand Down Expand Up @@ -2055,7 +2104,7 @@ spec:
description: The name of the stage. This MUST be unique
within the same StagedUpdateStrategy.
maxLength: 63
pattern: '[A-Za-z0-9]+$'
pattern: ^[a-z0-9]+$
type: string
sortingLabelKey:
description: |-
Expand Down Expand Up @@ -2403,6 +2452,9 @@ spec:
required:
- spec
type: object
x-kubernetes-validations:
- message: metadata.name max length is 127
rule: size(self.metadata.name) < 128
served: true
storage: true
subresources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ spec:
description: The name of the stage. This MUST be unique within
the same StagedUpdateStrategy.
maxLength: 63
pattern: '[A-Za-z0-9]+$'
pattern: ^[a-z0-9]+$
type: string
sortingLabelKey:
description: |-
Expand Down Expand Up @@ -273,7 +273,7 @@ spec:
description: The name of the stage. This MUST be unique within
the same StagedUpdateStrategy.
maxLength: 63
pattern: '[A-Za-z0-9]+$'
pattern: ^[a-z0-9]+$
type: string
sortingLabelKey:
description: |-
Expand Down
4 changes: 2 additions & 2 deletions examples/stagedupdaterun/approvalRequest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ spec:
targetStage: canary
status:
conditions:
- type: Approved
status: "True"
- type: Approved
status: "True"
Loading
Loading