Skip to content

Commit

Permalink
Align ClusterClass ControlPlane with the rest of the fields
Browse files Browse the repository at this point in the history
This commits introduces ControlPlaneClass and allows users to set
metadata fields for all control plane objects. It also adds fields to
set infrastructure reference for Machine objects and clarifies what
contracts the field expects from the control plane provider.

Signed-off-by: Vince Prignano <[email protected]>
  • Loading branch information
vincepri committed Jul 22, 2021
1 parent ede33e3 commit 917e0b9
Show file tree
Hide file tree
Showing 5 changed files with 213 additions and 34 deletions.
16 changes: 15 additions & 1 deletion api/v1alpha4/clusterclass_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type ClusterClassSpec struct {

// ControlPlane is a reference to a local struct that holds the details
// for provisioning the Control Plane for the Cluster.
ControlPlane LocalObjectTemplate `json:"controlPlane,omitempty"`
ControlPlane ControlPlaneClass `json:"controlPlane,omitempty"`

// Workers describes the worker nodes for the cluster.
// It is a collection of node types which can be used to create
Expand All @@ -53,6 +53,20 @@ type ClusterClassSpec struct {
Workers WorkersClass `json:"workers,omitempty"`
}

type ControlPlaneClass struct {
Metadata ObjectMeta `json:"metadata,omitempty"`

// LocalObjectTemplate contains the reference to the control plane provider.
LocalObjectTemplate `json:",inline"`

// MachineTemplate defines the metadata and infrastructure information
// for control plane machines.
//
// This field is supported if and only if the control plane provider template
// referenced above is Machine based and supports setting replicas.
MachineInfrastructure LocalObjectTemplate `json:"machineInfrastructure"`
}

// WorkersClass is a collection of deployment classes.
type WorkersClass struct {
// MachineDeployments is a list of machine deployment classes that can be used to create
Expand Down
106 changes: 77 additions & 29 deletions api/v1alpha4/clusterclass_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ func TestClusterClassDefaultNamespaces(t *testing.T) {
},
Spec: ClusterClassSpec{
Infrastructure: LocalObjectTemplate{Ref: ref},
ControlPlane: LocalObjectTemplate{Ref: ref},
ControlPlane: ControlPlaneClass{
LocalObjectTemplate: LocalObjectTemplate{Ref: ref},
},
Workers: WorkersClass{
MachineDeployments: []MachineDeploymentClass{
{
Expand Down Expand Up @@ -96,7 +98,9 @@ func TestClusterClassValidationFeatureGated(t *testing.T) {
},
Spec: ClusterClassSpec{
Infrastructure: LocalObjectTemplate{Ref: ref},
ControlPlane: LocalObjectTemplate{Ref: ref},
ControlPlane: ControlPlaneClass{
LocalObjectTemplate: LocalObjectTemplate{Ref: ref},
},
Workers: WorkersClass{
MachineDeployments: []MachineDeploymentClass{
{
Expand All @@ -120,7 +124,9 @@ func TestClusterClassValidationFeatureGated(t *testing.T) {
},
Spec: ClusterClassSpec{
Infrastructure: LocalObjectTemplate{Ref: ref},
ControlPlane: LocalObjectTemplate{Ref: ref},
ControlPlane: ControlPlaneClass{
LocalObjectTemplate: LocalObjectTemplate{Ref: ref},
},
Workers: WorkersClass{
MachineDeployments: []MachineDeploymentClass{
{
Expand All @@ -140,7 +146,9 @@ func TestClusterClassValidationFeatureGated(t *testing.T) {
},
Spec: ClusterClassSpec{
Infrastructure: LocalObjectTemplate{Ref: ref},
ControlPlane: LocalObjectTemplate{Ref: ref},
ControlPlane: ControlPlaneClass{
LocalObjectTemplate: LocalObjectTemplate{Ref: ref},
},
Workers: WorkersClass{
MachineDeployments: []MachineDeploymentClass{
{
Expand Down Expand Up @@ -202,7 +210,9 @@ func TestClusterClassValidation(t *testing.T) {
},
Spec: ClusterClassSpec{
Infrastructure: LocalObjectTemplate{Ref: ref},
ControlPlane: LocalObjectTemplate{Ref: ref},
ControlPlane: ControlPlaneClass{
LocalObjectTemplate: LocalObjectTemplate{Ref: ref},
},
Workers: WorkersClass{
MachineDeployments: []MachineDeploymentClass{
{
Expand Down Expand Up @@ -233,7 +243,9 @@ func TestClusterClassValidation(t *testing.T) {
},
Spec: ClusterClassSpec{
Infrastructure: LocalObjectTemplate{Ref: refInAnotherNamespace},
ControlPlane: LocalObjectTemplate{Ref: ref},
ControlPlane: ControlPlaneClass{
LocalObjectTemplate: LocalObjectTemplate{Ref: ref},
},
Workers: WorkersClass{
MachineDeployments: []MachineDeploymentClass{
{
Expand All @@ -257,7 +269,9 @@ func TestClusterClassValidation(t *testing.T) {
},
Spec: ClusterClassSpec{
Infrastructure: LocalObjectTemplate{Ref: ref},
ControlPlane: LocalObjectTemplate{Ref: refInAnotherNamespace},
ControlPlane: ControlPlaneClass{
LocalObjectTemplate: LocalObjectTemplate{Ref: refInAnotherNamespace},
},
Workers: WorkersClass{
MachineDeployments: []MachineDeploymentClass{
{
Expand All @@ -281,7 +295,9 @@ func TestClusterClassValidation(t *testing.T) {
},
Spec: ClusterClassSpec{
Infrastructure: LocalObjectTemplate{Ref: ref},
ControlPlane: LocalObjectTemplate{Ref: ref},
ControlPlane: ControlPlaneClass{
LocalObjectTemplate: LocalObjectTemplate{Ref: ref},
},
Workers: WorkersClass{
MachineDeployments: []MachineDeploymentClass{
{
Expand All @@ -305,7 +321,9 @@ func TestClusterClassValidation(t *testing.T) {
},
Spec: ClusterClassSpec{
Infrastructure: LocalObjectTemplate{Ref: ref},
ControlPlane: LocalObjectTemplate{Ref: ref},
ControlPlane: ControlPlaneClass{
LocalObjectTemplate: LocalObjectTemplate{Ref: ref},
},
Workers: WorkersClass{
MachineDeployments: []MachineDeploymentClass{
{
Expand All @@ -329,7 +347,9 @@ func TestClusterClassValidation(t *testing.T) {
},
Spec: ClusterClassSpec{
Infrastructure: LocalObjectTemplate{Ref: ref},
ControlPlane: LocalObjectTemplate{Ref: ref},
ControlPlane: ControlPlaneClass{
LocalObjectTemplate: LocalObjectTemplate{Ref: ref},
},
Workers: WorkersClass{
MachineDeployments: []MachineDeploymentClass{
{
Expand Down Expand Up @@ -360,7 +380,9 @@ func TestClusterClassValidation(t *testing.T) {
},
Spec: ClusterClassSpec{
Infrastructure: LocalObjectTemplate{Ref: ref},
ControlPlane: LocalObjectTemplate{Ref: ref},
ControlPlane: ControlPlaneClass{
LocalObjectTemplate: LocalObjectTemplate{Ref: ref},
},
Workers: WorkersClass{
MachineDeployments: []MachineDeploymentClass{
{
Expand All @@ -380,7 +402,9 @@ func TestClusterClassValidation(t *testing.T) {
},
Spec: ClusterClassSpec{
Infrastructure: LocalObjectTemplate{Ref: ref},
ControlPlane: LocalObjectTemplate{Ref: ref},
ControlPlane: ControlPlaneClass{
LocalObjectTemplate: LocalObjectTemplate{Ref: ref},
},
Workers: WorkersClass{
MachineDeployments: []MachineDeploymentClass{
{
Expand All @@ -405,7 +429,9 @@ func TestClusterClassValidation(t *testing.T) {
},
Spec: ClusterClassSpec{
Infrastructure: LocalObjectTemplate{Ref: ref},
ControlPlane: LocalObjectTemplate{Ref: ref},
ControlPlane: ControlPlaneClass{
LocalObjectTemplate: LocalObjectTemplate{Ref: ref},
},
Workers: WorkersClass{
MachineDeployments: []MachineDeploymentClass{
{
Expand All @@ -431,7 +457,9 @@ func TestClusterClassValidation(t *testing.T) {
Name: "bazx",
Namespace: "default",
}},
ControlPlane: LocalObjectTemplate{Ref: ref},
ControlPlane: ControlPlaneClass{
LocalObjectTemplate: LocalObjectTemplate{Ref: ref},
},
Workers: WorkersClass{
MachineDeployments: []MachineDeploymentClass{
{
Expand All @@ -456,7 +484,9 @@ func TestClusterClassValidation(t *testing.T) {
},
Spec: ClusterClassSpec{
Infrastructure: LocalObjectTemplate{Ref: ref},
ControlPlane: LocalObjectTemplate{Ref: ref},
ControlPlane: ControlPlaneClass{
LocalObjectTemplate: LocalObjectTemplate{Ref: ref},
},
Workers: WorkersClass{
MachineDeployments: []MachineDeploymentClass{
{
Expand All @@ -477,12 +507,14 @@ func TestClusterClassValidation(t *testing.T) {
},
Spec: ClusterClassSpec{
Infrastructure: LocalObjectTemplate{Ref: ref},
ControlPlane: LocalObjectTemplate{Ref: &corev1.ObjectReference{
APIVersion: "foox",
Kind: "barx",
Name: "bazx",
Namespace: "default",
}},
ControlPlane: ControlPlaneClass{
LocalObjectTemplate: LocalObjectTemplate{Ref: &corev1.ObjectReference{
APIVersion: "foox",
Kind: "barx",
Name: "bazx",
Namespace: "default",
}},
},
Workers: WorkersClass{
MachineDeployments: []MachineDeploymentClass{
{
Expand All @@ -507,7 +539,9 @@ func TestClusterClassValidation(t *testing.T) {
},
Spec: ClusterClassSpec{
Infrastructure: LocalObjectTemplate{Ref: ref},
ControlPlane: LocalObjectTemplate{Ref: ref},
ControlPlane: ControlPlaneClass{
LocalObjectTemplate: LocalObjectTemplate{Ref: ref},
},
Workers: WorkersClass{
MachineDeployments: []MachineDeploymentClass{
{
Expand All @@ -528,7 +562,9 @@ func TestClusterClassValidation(t *testing.T) {
},
Spec: ClusterClassSpec{
Infrastructure: LocalObjectTemplate{Ref: ref},
ControlPlane: LocalObjectTemplate{Ref: ref},
ControlPlane: ControlPlaneClass{
LocalObjectTemplate: LocalObjectTemplate{Ref: ref},
},
Workers: WorkersClass{
MachineDeployments: []MachineDeploymentClass{
{
Expand Down Expand Up @@ -558,7 +594,9 @@ func TestClusterClassValidation(t *testing.T) {
},
Spec: ClusterClassSpec{
Infrastructure: LocalObjectTemplate{Ref: ref},
ControlPlane: LocalObjectTemplate{Ref: ref},
ControlPlane: ControlPlaneClass{
LocalObjectTemplate: LocalObjectTemplate{Ref: ref},
},
Workers: WorkersClass{
MachineDeployments: []MachineDeploymentClass{
{
Expand All @@ -578,7 +616,9 @@ func TestClusterClassValidation(t *testing.T) {
},
Spec: ClusterClassSpec{
Infrastructure: LocalObjectTemplate{Ref: ref},
ControlPlane: LocalObjectTemplate{Ref: ref},
ControlPlane: ControlPlaneClass{
LocalObjectTemplate: LocalObjectTemplate{Ref: ref},
},
Workers: WorkersClass{
MachineDeployments: []MachineDeploymentClass{
{
Expand Down Expand Up @@ -609,7 +649,9 @@ func TestClusterClassValidation(t *testing.T) {
},
Spec: ClusterClassSpec{
Infrastructure: LocalObjectTemplate{Ref: ref},
ControlPlane: LocalObjectTemplate{Ref: ref},
ControlPlane: ControlPlaneClass{
LocalObjectTemplate: LocalObjectTemplate{Ref: ref},
},
Workers: WorkersClass{
MachineDeployments: []MachineDeploymentClass{
{
Expand All @@ -629,7 +671,9 @@ func TestClusterClassValidation(t *testing.T) {
},
Spec: ClusterClassSpec{
Infrastructure: LocalObjectTemplate{Ref: ref},
ControlPlane: LocalObjectTemplate{Ref: ref},
ControlPlane: ControlPlaneClass{
LocalObjectTemplate: LocalObjectTemplate{Ref: ref},
},
Workers: WorkersClass{
MachineDeployments: []MachineDeploymentClass{
{
Expand Down Expand Up @@ -660,7 +704,9 @@ func TestClusterClassValidation(t *testing.T) {
},
Spec: ClusterClassSpec{
Infrastructure: LocalObjectTemplate{Ref: ref},
ControlPlane: LocalObjectTemplate{Ref: ref},
ControlPlane: ControlPlaneClass{
LocalObjectTemplate: LocalObjectTemplate{Ref: ref},
},
Workers: WorkersClass{
MachineDeployments: []MachineDeploymentClass{
{
Expand All @@ -687,7 +733,9 @@ func TestClusterClassValidation(t *testing.T) {
},
Spec: ClusterClassSpec{
Infrastructure: LocalObjectTemplate{Ref: ref},
ControlPlane: LocalObjectTemplate{Ref: ref},
ControlPlane: ControlPlaneClass{
LocalObjectTemplate: LocalObjectTemplate{Ref: ref},
},
Workers: WorkersClass{
MachineDeployments: []MachineDeploymentClass{
{
Expand Down
18 changes: 18 additions & 0 deletions api/v1alpha4/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 13 additions & 4 deletions cmd/clusterctl/config/manifest/clusterctl-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,33 @@ spec:
description: Provider defines an entry in the provider inventory.
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'
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'
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
providerName:
description: ProviderName indicates the name of the provider.
type: string
type:
description: Type indicates the type of the provider. See ProviderType for a list of supported values
description: Type indicates the type of the provider. See ProviderType
for a list of supported values
type: string
version:
description: Version indicates the component version.
type: string
watchedNamespace:
description: 'WatchedNamespace indicates the namespace where the provider controller is is watching. if empty the provider controller is watching for objects in all namespaces. Deprecated: in clusterctl v1alpha4 all the providers watch all the namespaces; this field will be removed in a future version of this API'
description: 'WatchedNamespace indicates the namespace where the provider
controller is is watching. if empty the provider controller is watching
for objects in all namespaces. Deprecated: in clusterctl v1alpha4 all
the providers watch all the namespaces; this field will be removed in
a future version of this API'
type: string
type: object
served: true
Expand Down
Loading

0 comments on commit 917e0b9

Please sign in to comment.