sigs.k8s.io/cluster-api@v1.6.3/api/v1alpha4/common_types.go (about) 1 /* 2 Copyright 2020 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 const ( 25 // ClusterLabelName is the label set on machines linked to a cluster and 26 // external objects(bootstrap and infrastructure providers). 27 ClusterLabelName = "cluster.x-k8s.io/cluster-name" 28 29 // ClusterTopologyLabelName is the label set on all the object which are managed as part of a ClusterTopology. 30 // 31 // Deprecated: use ClusterTopologyOwnedLabel instead. 32 ClusterTopologyLabelName = "cluster.x-k8s.io/topology" 33 34 // ClusterTopologyOwnedLabel is the label set on all the object which are managed as part of a ClusterTopology. 35 ClusterTopologyOwnedLabel = "topology.cluster.x-k8s.io/owned" 36 37 // ClusterTopologyMachineDeploymentLabelName is the label set on the generated MachineDeployment objects 38 // to track the name of the MachineDeployment topology it represents. 39 ClusterTopologyMachineDeploymentLabelName = "topology.cluster.x-k8s.io/deployment-name" 40 41 // ProviderLabelName is the label set on components in the provider manifest. 42 // This label allows to easily identify all the components belonging to a provider; the clusterctl 43 // tool uses this label for implementing provider's lifecycle operations. 44 ProviderLabelName = "cluster.x-k8s.io/provider" 45 46 // ClusterNameAnnotation is the annotation set on nodes identifying the name of the cluster the node belongs to. 47 ClusterNameAnnotation = "cluster.x-k8s.io/cluster-name" 48 49 // ClusterNamespaceAnnotation is the annotation set on nodes identifying the namespace of the cluster the node belongs to. 50 ClusterNamespaceAnnotation = "cluster.x-k8s.io/cluster-namespace" 51 52 // MachineAnnotation is the annotation set on nodes identifying the machine the node belongs to. 53 MachineAnnotation = "cluster.x-k8s.io/machine" 54 55 // OwnerKindAnnotation is the annotation set on nodes identifying the owner kind. 56 OwnerKindAnnotation = "cluster.x-k8s.io/owner-kind" 57 58 // OwnerNameAnnotation is the annotation set on nodes identifying the owner name. 59 OwnerNameAnnotation = "cluster.x-k8s.io/owner-name" 60 61 // PausedAnnotation is an annotation that can be applied to any Cluster API 62 // object to prevent a controller from processing a resource. 63 // 64 // Controllers working with Cluster API objects must check the existence of this annotation 65 // on the reconciled object. 66 PausedAnnotation = "cluster.x-k8s.io/paused" 67 68 // DisableMachineCreate is an annotation that can be used to signal a MachineSet to stop creating new machines. 69 // It is utilized in the OnDelete MachineDeploymentStrategy to allow the MachineDeployment controller to scale down 70 // older MachineSets when Machines are deleted and add the new replicas to the latest MachineSet. 71 DisableMachineCreate = "cluster.x-k8s.io/disable-machine-create" 72 73 // WatchLabel is a label othat can be applied to any Cluster API object. 74 // 75 // Controllers which allow for selective reconciliation may check this label and proceed 76 // with reconciliation of the object only if this label and a configured value is present. 77 WatchLabel = "cluster.x-k8s.io/watch-filter" 78 79 // DeleteMachineAnnotation marks control plane and worker nodes that will be given priority for deletion 80 // when KCP or a machineset scales down. This annotation is given top priority on all delete policies. 81 DeleteMachineAnnotation = "cluster.x-k8s.io/delete-machine" 82 83 // TemplateClonedFromNameAnnotation is the infrastructure machine annotation that stores the name of the infrastructure template resource 84 // that was cloned for the machine. This annotation is set only during cloning a template. Older/adopted machines will not have this annotation. 85 TemplateClonedFromNameAnnotation = "cluster.x-k8s.io/cloned-from-name" 86 87 // TemplateClonedFromGroupKindAnnotation is the infrastructure machine annotation that stores the group-kind of the infrastructure template resource 88 // that was cloned for the machine. This annotation is set only during cloning a template. Older/adopted machines will not have this annotation. 89 TemplateClonedFromGroupKindAnnotation = "cluster.x-k8s.io/cloned-from-groupkind" 90 91 // MachineSkipRemediationAnnotation is the annotation used to mark the machines that should not be considered for remediation by MachineHealthCheck reconciler. 92 MachineSkipRemediationAnnotation = "cluster.x-k8s.io/skip-remediation" 93 94 // ClusterSecretType defines the type of secret created by core components. 95 ClusterSecretType corev1.SecretType = "cluster.x-k8s.io/secret" //nolint:gosec 96 97 // InterruptibleLabel is the label used to mark the nodes that run on interruptible instances. 98 InterruptibleLabel = "cluster.x-k8s.io/interruptible" 99 100 // ManagedByAnnotation is an annotation that can be applied to InfraCluster resources to signify that 101 // some external system is managing the cluster infrastructure. 102 // 103 // Provider InfraCluster controllers will ignore resources with this annotation. 104 // An external controller must fulfill the contract of the InfraCluster resource. 105 // External infrastructure providers should ensure that the annotation, once set, cannot be removed. 106 ManagedByAnnotation = "cluster.x-k8s.io/managed-by" 107 ) 108 109 const ( 110 // TemplateSuffix is the object kind suffix used by template types. 111 TemplateSuffix = "Template" 112 ) 113 114 var ( 115 // ZeroDuration is a zero value of the metav1.Duration type. 116 ZeroDuration = metav1.Duration{} 117 ) 118 119 const ( 120 // MachineNodeNameIndex is used by the Machine Controller to index Machines by Node name, and add a watch on Nodes. 121 // 122 // Deprecated: Use api/v1alpha4/index.MachineNodeNameField instead. 123 MachineNodeNameIndex = "status.nodeRef.name" 124 125 // MachineProviderIDIndex is used to index Machines by ProviderID. It's useful to find Machines 126 // in a management cluster from Nodes in a workload cluster. 127 // 128 // Deprecated: Use api/v1alpha4/index.MachineProviderIDField instead. 129 MachineProviderIDIndex = "spec.providerID" 130 ) 131 132 // MachineAddressType describes a valid MachineAddress type. 133 type MachineAddressType string 134 135 // Define the MachineAddressType constants. 136 const ( 137 MachineHostName MachineAddressType = "Hostname" 138 MachineExternalIP MachineAddressType = "ExternalIP" 139 MachineInternalIP MachineAddressType = "InternalIP" 140 MachineExternalDNS MachineAddressType = "ExternalDNS" 141 MachineInternalDNS MachineAddressType = "InternalDNS" 142 ) 143 144 // MachineAddress contains information for the node's address. 145 type MachineAddress struct { 146 // Machine address type, one of Hostname, ExternalIP or InternalIP. 147 Type MachineAddressType `json:"type"` 148 149 // The machine address. 150 Address string `json:"address"` 151 } 152 153 // MachineAddresses is a slice of MachineAddress items to be used by infrastructure providers. 154 type MachineAddresses []MachineAddress 155 156 // ObjectMeta is metadata that all persisted resources must have, which includes all objects 157 // users must create. This is a copy of customizable fields from metav1.ObjectMeta. 158 // 159 // ObjectMeta is embedded in `Machine.Spec`, `MachineDeployment.Template` and `MachineSet.Template`, 160 // which are not top-level Kubernetes objects. Given that metav1.ObjectMeta has lots of special cases 161 // and read-only fields which end up in the generated CRD validation, having it as a subset simplifies 162 // the API and some issues that can impact user experience. 163 // 164 // During the [upgrade to controller-tools@v2](https://github.com/kubernetes-sigs/cluster-api/pull/1054) 165 // for v1alpha2, we noticed a failure would occur running Cluster API test suite against the new CRDs, 166 // specifically `spec.metadata.creationTimestamp in body must be of type string: "null"`. 167 // The investigation showed that `controller-tools@v2` behaves differently than its previous version 168 // when handling types from [metav1](k8s.io/apimachinery/pkg/apis/meta/v1) package. 169 // 170 // In more details, we found that embedded (non-top level) types that embedded `metav1.ObjectMeta` 171 // had validation properties, including for `creationTimestamp` (metav1.Time). 172 // The `metav1.Time` type specifies a custom json marshaller that, when IsZero() is true, returns `null` 173 // which breaks validation because the field isn't marked as nullable. 174 // 175 // In future versions, controller-tools@v2 might allow overriding the type and validation for embedded 176 // types. When that happens, this hack should be revisited. 177 type ObjectMeta struct { 178 // Map of string keys and values that can be used to organize and categorize 179 // (scope and select) objects. May match selectors of replication controllers 180 // and services. 181 // More info: http://kubernetes.io/docs/user-guide/labels 182 // +optional 183 Labels map[string]string `json:"labels,omitempty"` 184 185 // Annotations is an unstructured key value map stored with a resource that may be 186 // set by external tools to store and retrieve arbitrary metadata. They are not 187 // queryable and should be preserved when modifying objects. 188 // More info: http://kubernetes.io/docs/user-guide/annotations 189 // +optional 190 Annotations map[string]string `json:"annotations,omitempty"` 191 }