From a124a98d441c935a655ff506ca3ebceb2f8d2de8 Mon Sep 17 00:00:00 2001 From: Richard Chen Date: Fri, 16 Dec 2022 08:42:44 -0800 Subject: [PATCH] Update API and proposal --- ...e.cluster.x-k8s.io_gcpmanagedclusters.yaml | 9 +-- ...ster.x-k8s.io_gcpmanagedcontrolplanes.yaml | 62 +++++++++++++-- ...uster.x-k8s.io_gcpmanagedmachinepools.yaml | 77 +++++++++++++++---- .../20221123-managed-kubernetes-in-capg.md | 15 +++- exp/api/v1beta1/gcpmanagedcluster_types.go | 3 +- .../v1beta1/gcpmanagedcontrolplane_types.go | 3 + .../v1beta1/gcpmanagedmachinepool_types.go | 11 ++- exp/api/v1beta1/types.go | 10 --- exp/api/v1beta1/zz_generated.deepcopy.go | 23 +++++- 9 files changed, 167 insertions(+), 46 deletions(-) diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmanagedclusters.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmanagedclusters.yaml index a824f16cff..4270430654 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmanagedclusters.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmanagedclusters.yaml @@ -40,7 +40,7 @@ spec: name: v1beta1 schema: openAPIV3Schema: - description: GCPManagedCluster is the Schema for the gcpmanagedclusters API + description: GCPManagedCluster is the Schema for the gcpmanagedclusters API. properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation @@ -55,7 +55,7 @@ spec: metadata: type: object spec: - description: GCPManagedClusterSpec defines the desired state of GCPManagedCluster + description: GCPManagedClusterSpec defines the desired state of GCPManagedCluster. properties: additionalLabels: additionalProperties: @@ -64,7 +64,7 @@ spec: GCP resources managed by the GCP provider, in addition to the ones added by default. type: object - controlplaneEndpoint: + controlPlaneEndpoint: description: ControlPlaneEndpoint represents the endpoint used to communicate with the control plane. properties: @@ -173,12 +173,11 @@ spec: description: The GCP Region the cluster lives in. type: string required: - - controlplaneEndpoint - project - region type: object status: - description: GCPManagedClusterStatus defines the observed state of GCPManagedCluster + description: GCPManagedClusterStatus defines the observed state of GCPManagedCluster. properties: conditions: description: Conditions specifies the conditions for the managed control diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmanagedcontrolplanes.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmanagedcontrolplanes.yaml index 22f6fad881..3764d75e0c 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmanagedcontrolplanes.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmanagedcontrolplanes.yaml @@ -23,7 +23,7 @@ spec: schema: openAPIV3Schema: description: GCPManagedControlPlane is the Schema for the gcpmanagedcontrolplanes - API + API. properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation @@ -38,16 +38,16 @@ spec: metadata: type: object spec: - description: GCPManagedControlPlaneSpec defines the desired state of GCPManagedControlPlane + description: GCPManagedControlPlaneSpec defines the desired state of GCPManagedControlPlane. properties: controlPlaneVersion: description: ControlPlaneVersion represents the control plane version - of the GKE cluster If not specified, the default version currently - supported by GKE will be used + of the GKE cluster. If not specified, the default version currently + supported by GKE will be used. type: string enableAutopilot: description: EnableAutopilot indicates whether to enable autopilot - for this GKE cluster + for this GKE cluster. type: boolean endpoint: description: Endpoint represents the endpoint used to communicate @@ -66,11 +66,11 @@ spec: type: object location: description: Location represents the location (region or zone) in - which the GKE cluster will be created + which the GKE cluster will be created. type: string releaseChannel: description: ReleaseChannel represents the release channel of the - GKE cluster + GKE cluster. type: string required: - enableAutopilot @@ -79,8 +79,54 @@ spec: type: object status: description: GCPManagedControlPlaneStatus defines the observed state of - GCPManagedControlPlane + GCPManagedControlPlane. properties: + conditions: + description: Conditions specifies the cpnditions for the managed control + plane + items: + description: Condition defines an observation of a Cluster API resource + operational state. + properties: + lastTransitionTime: + description: Last time the condition transitioned from one status + to another. This should be when the underlying condition changed. + If that is not known, then using the time when the API field + changed is acceptable. + format: date-time + type: string + message: + description: A human readable message indicating details about + the transition. This field may be empty. + type: string + reason: + description: The reason for the condition's last transition + in CamelCase. The specific API may choose whether or not this + field is considered a guaranteed API. This field may not be + empty. + type: string + severity: + description: Severity provides an explicit classification of + Reason code, so the users or machines can immediately understand + the current situation and act accordingly. The Severity field + MUST be set only when Status=False. + type: string + status: + description: Status of the condition, one of True, False, Unknown. + type: string + type: + description: Type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources + like Available, but because arbitrary conditions can be useful + (see .node.status.conditions), the ability to deconflict is + important. + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array ready: type: boolean required: diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmanagedmachinepools.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmanagedmachinepools.yaml index db02ae72c7..5556a903bd 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmanagedmachinepools.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmanagedmachinepools.yaml @@ -27,7 +27,7 @@ spec: schema: openAPIV3Schema: description: GCPManagedMachinePool is the Schema for the gcpmanagedmachinepools - API + API. properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation @@ -42,7 +42,7 @@ spec: metadata: type: object spec: - description: GCPManagedMachinePoolSpec defines the desired state of GCPManagedMachinePool + description: GCPManagedMachinePoolSpec defines the desired state of GCPManagedMachinePool. properties: additionalLabels: additionalProperties: @@ -61,16 +61,16 @@ spec: additionalProperties: type: string description: KubernetesLabels specifies the labels to apply to the - nodes of the node pool + nodes of the node pool. type: object kubernetesTaints: description: KubernetesTaints specifies the taints to apply to the - nodes of the node pool + nodes of the node pool. items: description: Taint represents a Kubernetes taint. properties: effect: - description: Effect specifies the effect for the taint + description: Effect specifies the effect for the taint. enum: - NoSchedule - NoExecute @@ -88,26 +88,71 @@ spec: - value type: object type: array - mode: - description: Mode represents mode of an machine pool. A cluster always - requires 1 system pool - enum: - - system - - user - type: string nodeVersion: - description: NodeVersion represents the node version of the node pool + description: NodeVersion represents the node version of the node pool. If not specified, the GKE cluster control plane version will be - used + used. type: string + providerIDList: + description: ProviderIDList are the provider IDs of instances in the + managed instance group corresponding to the nodegroup represented + by this machine pool + items: + type: string + type: array required: - initialNodeCount - - mode type: object status: description: GCPManagedMachinePoolStatus defines the observed state of - GCPManagedMachinePool + GCPManagedMachinePool. properties: + conditions: + description: Conditions specifies the cpnditions for the managed machine + pool + items: + description: Condition defines an observation of a Cluster API resource + operational state. + properties: + lastTransitionTime: + description: Last time the condition transitioned from one status + to another. This should be when the underlying condition changed. + If that is not known, then using the time when the API field + changed is acceptable. + format: date-time + type: string + message: + description: A human readable message indicating details about + the transition. This field may be empty. + type: string + reason: + description: The reason for the condition's last transition + in CamelCase. The specific API may choose whether or not this + field is considered a guaranteed API. This field may not be + empty. + type: string + severity: + description: Severity provides an explicit classification of + Reason code, so the users or machines can immediately understand + the current situation and act accordingly. The Severity field + MUST be set only when Status=False. + type: string + status: + description: Status of the condition, one of True, False, Unknown. + type: string + type: + description: Type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources + like Available, but because arbitrary conditions can be useful + (see .node.status.conditions), the ability to deconflict is + important. + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array ready: type: boolean replicas: diff --git a/docs/proposals/20221123-managed-kubernetes-in-capg.md b/docs/proposals/20221123-managed-kubernetes-in-capg.md index abbb937a8b..e6728e9570 100644 --- a/docs/proposals/20221123-managed-kubernetes-in-capg.md +++ b/docs/proposals/20221123-managed-kubernetes-in-capg.md @@ -132,7 +132,8 @@ type GCPManagedClusterSpec struct { Region string `json:"region"` // ControlPlaneEndpoint represents the endpoint used to communicate with the control plane. - ControlPlaneEndpoint clusterv1.APIEndpoint `json:”controlplaneEndpoint”` + // +optional + ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"` // NetworkSpec encapsulates all things related to the GCP network. // +optional @@ -178,6 +179,9 @@ type GCPManagedControlPlaneSpec struct { type GCPManagedControlPlaneStatus struct { Ready bool `json:"ready"` + + // Conditions specifies the cpnditions for the managed control plane + Conditions clusterv1.Conditions `json:"conditions,omitempty"` } type GCPManagedMachinePoolSpec struct { @@ -202,6 +206,12 @@ type GCPManagedMachinePoolSpec struct { // ones added by default. // +optional AdditionalLabels Labels `json:"additionalLabels,omitempty"` + + // ProviderIDList are the provider IDs of instances in the + // managed instance group corresponding to the nodegroup represented by this + // machine pool + // +optional + ProviderIDList []string `json:"providerIDList,omitempty"` } type GCPManagedMachinePoolStatus struct { @@ -210,6 +220,9 @@ type GCPManagedMachinePoolStatus struct { // Replicas is the most recently observed number of replicas. // +optional Replicas int32 `json:"replicas"` + + // Conditions specifies the cpnditions for the managed machine pool + Conditions clusterv1.Conditions `json:"conditions,omitempty"` } ``` diff --git a/exp/api/v1beta1/gcpmanagedcluster_types.go b/exp/api/v1beta1/gcpmanagedcluster_types.go index 0b229ba834..6564b701da 100644 --- a/exp/api/v1beta1/gcpmanagedcluster_types.go +++ b/exp/api/v1beta1/gcpmanagedcluster_types.go @@ -35,7 +35,8 @@ type GCPManagedClusterSpec struct { // The GCP Region the cluster lives in. Region string `json:"region"` // ControlPlaneEndpoint represents the endpoint used to communicate with the control plane. - ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlplaneEndpoint"` + // +optional + ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"` // NetworkSpec encapsulates all things related to the GCP network. // +optional Network infrav1.NetworkSpec `json:"network"` diff --git a/exp/api/v1beta1/gcpmanagedcontrolplane_types.go b/exp/api/v1beta1/gcpmanagedcontrolplane_types.go index dec7093661..a592bb195d 100644 --- a/exp/api/v1beta1/gcpmanagedcontrolplane_types.go +++ b/exp/api/v1beta1/gcpmanagedcontrolplane_types.go @@ -49,6 +49,9 @@ type GCPManagedControlPlaneSpec struct { // GCPManagedControlPlaneStatus defines the observed state of GCPManagedControlPlane. type GCPManagedControlPlaneStatus struct { Ready bool `json:"ready"` + + // Conditions specifies the cpnditions for the managed control plane + Conditions clusterv1.Conditions `json:"conditions,omitempty"` } // +kubebuilder:object:root=true diff --git a/exp/api/v1beta1/gcpmanagedmachinepool_types.go b/exp/api/v1beta1/gcpmanagedmachinepool_types.go index e98948ea23..9f2c785f87 100644 --- a/exp/api/v1beta1/gcpmanagedmachinepool_types.go +++ b/exp/api/v1beta1/gcpmanagedmachinepool_types.go @@ -19,6 +19,7 @@ package v1beta1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" infrav1 "sigs.k8s.io/cluster-api-provider-gcp/api/v1beta1" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ) const ( @@ -46,9 +47,11 @@ type GCPManagedMachinePoolSpec struct { // ones added by default. // +optional AdditionalLabels infrav1.Labels `json:"additionalLabels,omitempty"` - // Mode represents mode of an machine pool. A cluster always requires 1 system pool. - // +kubebuilder:validation:Enum=system;user - Mode string `json:"mode"` + // ProviderIDList are the provider IDs of instances in the + // managed instance group corresponding to the nodegroup represented by this + // machine pool + // +optional + ProviderIDList []string `json:"providerIDList,omitempty"` } // GCPManagedMachinePoolStatus defines the observed state of GCPManagedMachinePool. @@ -57,6 +60,8 @@ type GCPManagedMachinePoolStatus struct { // Replicas is the most recently observed number of replicas. // +optional Replicas int32 `json:"replicas"` + // Conditions specifies the cpnditions for the managed machine pool + Conditions clusterv1.Conditions `json:"conditions,omitempty"` } // +kubebuilder:object:root=true diff --git a/exp/api/v1beta1/types.go b/exp/api/v1beta1/types.go index ba23bd599f..c3ad109876 100644 --- a/exp/api/v1beta1/types.go +++ b/exp/api/v1beta1/types.go @@ -32,13 +32,3 @@ type Taint struct { // Taints is an array of Taints. type Taints []Taint - -// MachinePoolMode represents the mode of operation for the machine pool. -type MachinePoolMode string - -const ( - // MachinePoolModeSystem represents a system machine pool. - MachinePoolModeSystem MachinePoolMode = "system" - // MachinePoolModeUser represenyts a user machine pool. - MachinePoolModeUser MachinePoolMode = "user" -) diff --git a/exp/api/v1beta1/zz_generated.deepcopy.go b/exp/api/v1beta1/zz_generated.deepcopy.go index 3b6926b336..cd997f930f 100644 --- a/exp/api/v1beta1/zz_generated.deepcopy.go +++ b/exp/api/v1beta1/zz_generated.deepcopy.go @@ -146,7 +146,7 @@ func (in *GCPManagedControlPlane) DeepCopyInto(out *GCPManagedControlPlane) { out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status + in.Status.DeepCopyInto(&out.Status) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GCPManagedControlPlane. @@ -228,6 +228,13 @@ func (in *GCPManagedControlPlaneSpec) DeepCopy() *GCPManagedControlPlaneSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GCPManagedControlPlaneStatus) DeepCopyInto(out *GCPManagedControlPlaneStatus) { *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(cluster_apiapiv1beta1.Conditions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GCPManagedControlPlaneStatus. @@ -246,7 +253,7 @@ func (in *GCPManagedMachinePool) DeepCopyInto(out *GCPManagedMachinePool) { out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status + in.Status.DeepCopyInto(&out.Status) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GCPManagedMachinePool. @@ -326,6 +333,11 @@ func (in *GCPManagedMachinePoolSpec) DeepCopyInto(out *GCPManagedMachinePoolSpec (*out)[key] = val } } + if in.ProviderIDList != nil { + in, out := &in.ProviderIDList, &out.ProviderIDList + *out = make([]string, len(*in)) + copy(*out, *in) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GCPManagedMachinePoolSpec. @@ -341,6 +353,13 @@ func (in *GCPManagedMachinePoolSpec) DeepCopy() *GCPManagedMachinePoolSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GCPManagedMachinePoolStatus) DeepCopyInto(out *GCPManagedMachinePoolStatus) { *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(cluster_apiapiv1beta1.Conditions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GCPManagedMachinePoolStatus.