sigs.k8s.io/cluster-api@v1.6.3/api/v1alpha4/clusterclass_types.go (about) 1 /* 2 Copyright 2021 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package v1alpha4 18 19 import ( 20 corev1 "k8s.io/api/core/v1" 21 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 ) 23 24 // +kubebuilder:object:root=true 25 // +kubebuilder:unservedversion 26 // +kubebuilder:deprecatedversion 27 // +kubebuilder:resource:path=clusterclasses,shortName=cc,scope=Namespaced,categories=cluster-api 28 // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of ClusterClass" 29 30 // ClusterClass is a template which can be used to create managed topologies. 31 // 32 // Deprecated: This type will be removed in one of the next releases. 33 type ClusterClass struct { 34 metav1.TypeMeta `json:",inline"` 35 metav1.ObjectMeta `json:"metadata,omitempty"` 36 37 Spec ClusterClassSpec `json:"spec,omitempty"` 38 } 39 40 // ClusterClassSpec describes the desired state of the ClusterClass. 41 type ClusterClassSpec struct { 42 // Infrastructure is a reference to a provider-specific template that holds 43 // the details for provisioning infrastructure specific cluster 44 // for the underlying provider. 45 // The underlying provider is responsible for the implementation 46 // of the template to an infrastructure cluster. 47 Infrastructure LocalObjectTemplate `json:"infrastructure,omitempty"` 48 49 // ControlPlane is a reference to a local struct that holds the details 50 // for provisioning the Control Plane for the Cluster. 51 ControlPlane ControlPlaneClass `json:"controlPlane,omitempty"` 52 53 // Workers describes the worker nodes for the cluster. 54 // It is a collection of node types which can be used to create 55 // the worker nodes of the cluster. 56 // +optional 57 Workers WorkersClass `json:"workers,omitempty"` 58 } 59 60 // ControlPlaneClass defines the class for the control plane. 61 type ControlPlaneClass struct { 62 // Metadata is the metadata applied to the machines of the ControlPlane. 63 // At runtime this metadata is merged with the corresponding metadata from the topology. 64 // 65 // This field is supported if and only if the control plane provider template 66 // referenced is Machine based. 67 Metadata ObjectMeta `json:"metadata,omitempty"` 68 69 // LocalObjectTemplate contains the reference to the control plane provider. 70 LocalObjectTemplate `json:",inline"` 71 72 // MachineTemplate defines the metadata and infrastructure information 73 // for control plane machines. 74 // 75 // This field is supported if and only if the control plane provider template 76 // referenced above is Machine based and supports setting replicas. 77 // 78 // +optional 79 MachineInfrastructure *LocalObjectTemplate `json:"machineInfrastructure,omitempty"` 80 } 81 82 // WorkersClass is a collection of deployment classes. 83 type WorkersClass struct { 84 // MachineDeployments is a list of machine deployment classes that can be used to create 85 // a set of worker nodes. 86 MachineDeployments []MachineDeploymentClass `json:"machineDeployments,omitempty"` 87 } 88 89 // MachineDeploymentClass serves as a template to define a set of worker nodes of the cluster 90 // provisioned using the `ClusterClass`. 91 type MachineDeploymentClass struct { 92 // Class denotes a type of worker node present in the cluster, 93 // this name MUST be unique within a ClusterClass and can be referenced 94 // in the Cluster to create a managed MachineDeployment. 95 Class string `json:"class"` 96 97 // Template is a local struct containing a collection of templates for creation of 98 // MachineDeployment objects representing a set of worker nodes. 99 Template MachineDeploymentClassTemplate `json:"template"` 100 } 101 102 // MachineDeploymentClassTemplate defines how a MachineDeployment generated from a MachineDeploymentClass 103 // should look like. 104 type MachineDeploymentClassTemplate struct { 105 // Metadata is the metadata applied to the machines of the MachineDeployment. 106 // At runtime this metadata is merged with the corresponding metadata from the topology. 107 Metadata ObjectMeta `json:"metadata,omitempty"` 108 109 // Bootstrap contains the bootstrap template reference to be used 110 // for the creation of worker Machines. 111 Bootstrap LocalObjectTemplate `json:"bootstrap"` 112 113 // Infrastructure contains the infrastructure template reference to be used 114 // for the creation of worker Machines. 115 Infrastructure LocalObjectTemplate `json:"infrastructure"` 116 } 117 118 // LocalObjectTemplate defines a template for a topology Class. 119 type LocalObjectTemplate struct { 120 // Ref is a required reference to a custom resource 121 // offered by a provider. 122 Ref *corev1.ObjectReference `json:"ref"` 123 } 124 125 // +kubebuilder:object:root=true 126 127 // ClusterClassList contains a list of Cluster. 128 // 129 // Deprecated: This type will be removed in one of the next releases. 130 type ClusterClassList struct { 131 metav1.TypeMeta `json:",inline"` 132 metav1.ListMeta `json:"metadata,omitempty"` 133 Items []ClusterClass `json:"items"` 134 } 135 136 func init() { 137 objectTypes = append(objectTypes, &ClusterClass{}, &ClusterClassList{}) 138 }