sigs.k8s.io/cluster-api@v1.7.1/bootstrap/kubeadm/types/upstreamv1beta1/types.go (about) 1 /* 2 Copyright 2018 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 upstreamv1beta1 18 19 import ( 20 corev1 "k8s.io/api/core/v1" 21 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 ) 23 24 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 25 26 // InitConfiguration contains a list of elements that is specific "kubeadm init"-only runtime 27 // information. 28 type InitConfiguration struct { 29 metav1.TypeMeta `json:",inline"` 30 31 // BootstrapTokens is respected at `kubeadm init` time and describes a set of Bootstrap Tokens to create. 32 // This information IS NOT uploaded to the kubeadm cluster configmap, partly because of its sensitive nature 33 // +optional 34 BootstrapTokens []BootstrapToken `json:"bootstrapTokens,omitempty"` 35 36 // NodeRegistration holds fields that relate to registering the new control-plane node to the cluster. 37 // When used in the context of control plane nodes, NodeRegistration should remain consistent 38 // across both InitConfiguration and JoinConfiguration 39 // +optional 40 NodeRegistration NodeRegistrationOptions `json:"nodeRegistration,omitempty"` 41 42 // LocalAPIEndpoint represents the endpoint of the API server instance that's deployed on this control plane node 43 // In HA setups, this differs from ClusterConfiguration.ControlPlaneEndpoint in the sense that ControlPlaneEndpoint 44 // is the global endpoint for the cluster, which then loadbalances the requests to each individual API server. This 45 // configuration object lets you customize what IP/DNS name and port the local API server advertises it's accessible 46 // on. By default, kubeadm tries to auto-detect the IP of the default interface and use that, but in case that process 47 // fails you may set the desired value here. 48 // +optional 49 LocalAPIEndpoint APIEndpoint `json:"localAPIEndpoint,omitempty"` 50 } 51 52 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 53 54 // ClusterConfiguration contains cluster-wide configuration for a kubeadm cluster. 55 type ClusterConfiguration struct { 56 metav1.TypeMeta `json:",inline"` 57 58 // Etcd holds configuration for etcd. 59 // NB: This value defaults to a Local (stacked) etcd 60 // +optional 61 Etcd Etcd `json:"etcd,omitempty"` 62 63 // Networking holds configuration for the networking topology of the cluster. 64 // NB: This value defaults to the Cluster object spec.clusterNetwork. 65 // +optional 66 Networking Networking `json:"networking,omitempty"` 67 68 // KubernetesVersion is the target version of the control plane. 69 // NB: This value defaults to the Machine object spec.version 70 // +optional 71 KubernetesVersion string `json:"kubernetesVersion,omitempty"` 72 73 // ControlPlaneEndpoint sets a stable IP address or DNS name for the control plane; it 74 // can be a valid IP address or a RFC-1123 DNS subdomain, both with optional TCP port. 75 // In case the ControlPlaneEndpoint is not specified, the AdvertiseAddress + BindPort 76 // are used; in case the ControlPlaneEndpoint is specified but without a TCP port, 77 // the BindPort is used. 78 // Possible usages are: 79 // e.g. In a cluster with more than one control plane instances, this field should be 80 // assigned the address of the external load balancer in front of the 81 // control plane instances. 82 // e.g. in environments with enforced node recycling, the ControlPlaneEndpoint 83 // could be used for assigning a stable DNS to the control plane. 84 // NB: This value defaults to the first value in the Cluster object status.apiEndpoints array. 85 // +optional 86 ControlPlaneEndpoint string `json:"controlPlaneEndpoint,omitempty"` 87 88 // APIServer contains extra settings for the API server control plane component 89 // +optional 90 APIServer APIServer `json:"apiServer,omitempty"` 91 92 // ControllerManager contains extra settings for the controller manager control plane component 93 // +optional 94 ControllerManager ControlPlaneComponent `json:"controllerManager,omitempty"` 95 96 // Scheduler contains extra settings for the scheduler control plane component 97 // +optional 98 Scheduler ControlPlaneComponent `json:"scheduler,omitempty"` 99 100 // DNS defines the options for the DNS add-on installed in the cluster. 101 // +optional 102 DNS DNS `json:"dns,omitempty"` 103 104 // CertificatesDir specifies where to store or look for all required certificates. 105 // NB: if not provided, this will default to `/etc/kubernetes/pki` 106 // +optional 107 CertificatesDir string `json:"certificatesDir,omitempty"` 108 109 // ImageRepository sets the container registry to pull images from. 110 // If empty, `k8s.gcr.io` will be used by default; in case of kubernetes version is a CI build (kubernetes version starts with `ci/` or `ci-cross/`) 111 // `gcr.io/k8s-staging-ci-images` will be used as a default for control plane components and for kube-proxy, while `k8s.gcr.io` 112 // will be used for all the other images. 113 // +optional 114 ImageRepository string `json:"imageRepository,omitempty"` 115 116 // UseHyperKubeImage controls if hyperkube should be used for Kubernetes components instead of their respective separate images 117 // +optional 118 UseHyperKubeImage bool `json:"useHyperKubeImage,omitempty"` 119 120 // FeatureGates enabled by the user. 121 // +optional 122 FeatureGates map[string]bool `json:"featureGates,omitempty"` 123 124 // The cluster name 125 // +optional 126 ClusterName string `json:"clusterName,omitempty"` 127 } 128 129 // ControlPlaneComponent holds settings common to control plane component of the cluster. 130 type ControlPlaneComponent struct { 131 // ExtraArgs is an extra set of flags to pass to the control plane component. 132 // TODO: This is temporary and ideally we would like to switch all components to 133 // use ComponentConfig + ConfigMaps. 134 ExtraArgs map[string]string `json:"extraArgs,omitempty"` 135 136 // ExtraVolumes is an extra set of host volumes, mounted to the control plane component. 137 ExtraVolumes []HostPathMount `json:"extraVolumes,omitempty"` 138 } 139 140 // APIServer holds settings necessary for API server deployments in the cluster. 141 type APIServer struct { 142 ControlPlaneComponent `json:",inline"` 143 144 // CertSANs sets extra Subject Alternative Names for the API Server signing cert. 145 CertSANs []string `json:"certSANs,omitempty"` 146 147 // TimeoutForControlPlane controls the timeout that we use for API server to appear 148 TimeoutForControlPlane *metav1.Duration `json:"timeoutForControlPlane,omitempty"` 149 } 150 151 // DNSAddOnType defines string identifying DNS add-on types. 152 type DNSAddOnType string 153 154 const ( 155 // CoreDNS add-on type. 156 CoreDNS DNSAddOnType = "CoreDNS" 157 158 // KubeDNS add-on type. 159 KubeDNS DNSAddOnType = "kube-dns" 160 ) 161 162 // DNS defines the DNS addon that should be used in the cluster. 163 type DNS struct { 164 // Type defines the DNS add-on to be used 165 // +optional 166 Type DNSAddOnType `json:"type,omitempty"` 167 168 // ImageMeta allows to customize the image used for the DNS component 169 ImageMeta `json:",inline"` 170 } 171 172 // ImageMeta allows to customize the image used for components that are not 173 // originated from the Kubernetes/Kubernetes release process. 174 type ImageMeta struct { 175 // ImageRepository sets the container registry to pull images from. 176 // if not set, the ImageRepository defined in ClusterConfiguration will be used instead. 177 ImageRepository string `json:"imageRepository,omitempty"` 178 179 // ImageTag allows to specify a tag for the image. 180 // In case this value is set, kubeadm does not change automatically the version of the above components during upgrades. 181 ImageTag string `json:"imageTag,omitempty"` 182 183 //TODO: evaluate if we need also a ImageName based on user feedbacks 184 } 185 186 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 187 188 // ClusterStatus contains the cluster status. The ClusterStatus will be stored in the kubeadm-config 189 // ConfigMap in the cluster, and then updated by kubeadm when additional control plane instance joins or leaves the cluster. 190 type ClusterStatus struct { 191 metav1.TypeMeta `json:",inline"` 192 193 // APIEndpoints currently available in the cluster, one for each control plane/api server instance. 194 // The key of the map is the IP of the host's default interface 195 APIEndpoints map[string]APIEndpoint `json:"apiEndpoints"` 196 } 197 198 // APIEndpoint struct contains elements of API server instance deployed on a node. 199 type APIEndpoint struct { 200 // AdvertiseAddress sets the IP address for the API server to advertise. 201 AdvertiseAddress string `json:"advertiseAddress"` 202 203 // BindPort sets the secure port for the API Server to bind to. 204 // Defaults to 6443. 205 BindPort int32 `json:"bindPort"` 206 } 207 208 // NodeRegistrationOptions holds fields that relate to registering a new control-plane or node to the cluster, either via "kubeadm init" or "kubeadm join". 209 type NodeRegistrationOptions struct { 210 211 // Name is the `.Metadata.Name` field of the Node API object that will be created in this `kubeadm init` or `kubeadm join` operation. 212 // This field is also used in the CommonName field of the kubelet's client certificate to the API server. 213 // Defaults to the hostname of the node if not provided. 214 // +optional 215 Name string `json:"name,omitempty"` 216 217 // CRISocket is used to retrieve container runtime info. This information will be annotated to the Node API object, for later re-use 218 // +optional 219 CRISocket string `json:"criSocket,omitempty"` 220 221 // Taints specifies the taints the Node API object should be registered with. If this field is unset, i.e. nil, in the `kubeadm init` process 222 // it will be defaulted to []v1.Taint{'node-role.kubernetes.io/master=""'}. If you don't want to taint your control-plane node, set this field to an 223 // empty slice, i.e. `taints: {}` in the YAML file. This field is solely used for Node registration. 224 // +optional 225 Taints []corev1.Taint `json:"taints,omitempty"` 226 227 // KubeletExtraArgs passes through extra arguments to the kubelet. The arguments here are passed to the kubelet command line via the environment file 228 // kubeadm writes at runtime for the kubelet to source. This overrides the generic base-level configuration in the kubelet-config-1.X ConfigMap 229 // Flags have higher priority when parsing. These values are local and specific to the node kubeadm is executing on. 230 // +optional 231 KubeletExtraArgs map[string]string `json:"kubeletExtraArgs,omitempty"` 232 } 233 234 // Networking contains elements describing cluster's networking configuration. 235 type Networking struct { 236 // ServiceSubnet is the subnet used by k8s services. 237 // Defaults to a comma-delimited string of the Cluster object's spec.clusterNetwork.pods.cidrBlocks, or 238 // to "10.96.0.0/12" if that's unset. 239 // +optional 240 ServiceSubnet string `json:"serviceSubnet,omitempty"` 241 // PodSubnet is the subnet used by pods. 242 // If unset, the API server will not allocate CIDR ranges for every node. 243 // Defaults to a comma-delimited string of the Cluster object's spec.clusterNetwork.services.cidrBlocks if that is set 244 // +optional 245 PodSubnet string `json:"podSubnet,omitempty"` 246 // DNSDomain is the dns domain used by k8s services. Defaults to "cluster.local". 247 // +optional 248 DNSDomain string `json:"dnsDomain,omitempty"` 249 } 250 251 // BootstrapToken describes one bootstrap token, stored as a Secret in the cluster. 252 type BootstrapToken struct { 253 // Token is used for establishing bidirectional trust between nodes and control-planes. 254 // Used for joining nodes in the cluster. 255 Token *BootstrapTokenString `json:"token"` 256 // Description sets a human-friendly message why this token exists and what it's used 257 // for, so other administrators can know its purpose. 258 Description string `json:"description,omitempty"` 259 // TTL defines the time to live for this token. Defaults to 24h. 260 // Expires and TTL are mutually exclusive. 261 TTL *metav1.Duration `json:"ttl,omitempty"` 262 // Expires specifies the timestamp when this token expires. Defaults to being set 263 // dynamically at runtime based on the TTL. Expires and TTL are mutually exclusive. 264 Expires *metav1.Time `json:"expires,omitempty"` 265 // Usages describes the ways in which this token can be used. Can by default be used 266 // for establishing bidirectional trust, but that can be changed here. 267 Usages []string `json:"usages,omitempty"` 268 // Groups specifies the extra groups that this token will authenticate as when/if 269 // used for authentication 270 Groups []string `json:"groups,omitempty"` 271 } 272 273 // Etcd contains elements describing Etcd configuration. 274 type Etcd struct { 275 276 // Local provides configuration knobs for configuring the local etcd instance 277 // Local and External are mutually exclusive 278 Local *LocalEtcd `json:"local,omitempty"` 279 280 // External describes how to connect to an external etcd cluster 281 // Local and External are mutually exclusive 282 External *ExternalEtcd `json:"external,omitempty"` 283 } 284 285 // LocalEtcd describes that kubeadm should run an etcd cluster locally. 286 type LocalEtcd struct { 287 // ImageMeta allows to customize the container used for etcd 288 ImageMeta `json:",inline"` 289 290 // DataDir is the directory etcd will place its data. 291 // Defaults to "/var/lib/etcd". 292 // +optional 293 DataDir string `json:"dataDir,omitempty"` 294 295 // ExtraArgs are extra arguments provided to the etcd binary 296 // when run inside a static pod. 297 ExtraArgs map[string]string `json:"extraArgs,omitempty"` 298 299 // ServerCertSANs sets extra Subject Alternative Names for the etcd server signing cert. 300 ServerCertSANs []string `json:"serverCertSANs,omitempty"` 301 // PeerCertSANs sets extra Subject Alternative Names for the etcd peer signing cert. 302 PeerCertSANs []string `json:"peerCertSANs,omitempty"` 303 } 304 305 // ExternalEtcd describes an external etcd cluster. 306 // Kubeadm has no knowledge of where certificate files live and they must be supplied. 307 type ExternalEtcd struct { 308 // Endpoints of etcd members. Required for ExternalEtcd. 309 Endpoints []string `json:"endpoints"` 310 311 // CAFile is an SSL Certificate Authority file used to secure etcd communication. 312 // Required if using a TLS connection. 313 CAFile string `json:"caFile"` 314 315 // CertFile is an SSL certification file used to secure etcd communication. 316 // Required if using a TLS connection. 317 CertFile string `json:"certFile"` 318 319 // KeyFile is an SSL key file used to secure etcd communication. 320 // Required if using a TLS connection. 321 KeyFile string `json:"keyFile"` 322 } 323 324 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 325 326 // JoinConfiguration contains elements describing a particular node. 327 type JoinConfiguration struct { 328 metav1.TypeMeta `json:",inline"` 329 330 // NodeRegistration holds fields that relate to registering the new control-plane node to the cluster. 331 // When used in the context of control plane nodes, NodeRegistration should remain consistent 332 // across both InitConfiguration and JoinConfiguration 333 // +optional 334 NodeRegistration NodeRegistrationOptions `json:"nodeRegistration,omitempty"` 335 336 // CACertPath is the path to the SSL certificate authority used to 337 // secure comunications between node and control-plane. 338 // Defaults to "/etc/kubernetes/pki/ca.crt". 339 // +optional 340 // TODO: revisit when there is defaulting from k/k 341 CACertPath string `json:"caCertPath,omitempty"` 342 343 // Discovery specifies the options for the kubelet to use during the TLS Bootstrap process 344 // +optional 345 // TODO: revisit when there is defaulting from k/k 346 Discovery Discovery `json:"discovery,omitempty"` 347 348 // ControlPlane defines the additional control plane instance to be deployed on the joining node. 349 // If nil, no additional control plane instance will be deployed. 350 // +optional 351 ControlPlane *JoinControlPlane `json:"controlPlane,omitempty"` 352 } 353 354 // JoinControlPlane contains elements describing an additional control plane instance to be deployed on the joining node. 355 type JoinControlPlane struct { 356 // LocalAPIEndpoint represents the endpoint of the API server instance to be deployed on this node. 357 LocalAPIEndpoint APIEndpoint `json:"localAPIEndpoint,omitempty"` 358 } 359 360 // Discovery specifies the options for the kubelet to use during the TLS Bootstrap process. 361 type Discovery struct { 362 // BootstrapToken is used to set the options for bootstrap token based discovery 363 // BootstrapToken and File are mutually exclusive 364 BootstrapToken *BootstrapTokenDiscovery `json:"bootstrapToken,omitempty"` 365 366 // File is used to specify a file or URL to a kubeconfig file from which to load cluster information 367 // BootstrapToken and File are mutually exclusive 368 File *FileDiscovery `json:"file,omitempty"` 369 370 // TLSBootstrapToken is a token used for TLS bootstrapping. 371 // If .BootstrapToken is set, this field is defaulted to .BootstrapToken.Token, but can be overridden. 372 // If .File is set, this field **must be set** in case the KubeConfigFile does not contain any other authentication information 373 // +optional 374 // TODO: revisit when there is defaulting from k/k 375 TLSBootstrapToken string `json:"tlsBootstrapToken,omitempty"` 376 377 // Timeout modifies the discovery timeout 378 Timeout *metav1.Duration `json:"timeout,omitempty"` 379 } 380 381 // BootstrapTokenDiscovery is used to set the options for bootstrap token based discovery. 382 type BootstrapTokenDiscovery struct { 383 // Token is a token used to validate cluster information 384 // fetched from the control-plane. 385 Token string `json:"token"` 386 387 // APIServerEndpoint is an IP or domain name to the API server from which info will be fetched. 388 APIServerEndpoint string `json:"apiServerEndpoint,omitempty"` 389 390 // CACertHashes specifies a set of public key pins to verify 391 // when token-based discovery is used. The root CA found during discovery 392 // must match one of these values. Specifying an empty set disables root CA 393 // pinning, which can be unsafe. Each hash is specified as "<type>:<value>", 394 // where the only currently supported type is "sha256". This is a hex-encoded 395 // SHA-256 hash of the Subject Public Key Info (SPKI) object in DER-encoded 396 // ASN.1. These hashes can be calculated using, for example, OpenSSL: 397 // openssl x509 -pubkey -in ca.crt openssl rsa -pubin -outform der 2>&/dev/null | openssl dgst -sha256 -hex 398 CACertHashes []string `json:"caCertHashes,omitempty"` 399 400 // UnsafeSkipCAVerification allows token-based discovery 401 // without CA verification via CACertHashes. This can weaken 402 // the security of kubeadm since other nodes can impersonate the control-plane. 403 UnsafeSkipCAVerification bool `json:"unsafeSkipCAVerification"` 404 } 405 406 // FileDiscovery is used to specify a file or URL to a kubeconfig file from which to load cluster information. 407 type FileDiscovery struct { 408 // KubeConfigPath is used to specify the actual file path or URL to the kubeconfig file from which to load cluster information 409 KubeConfigPath string `json:"kubeConfigPath"` 410 } 411 412 // HostPathMount contains elements describing volumes that are mounted from the 413 // host. 414 type HostPathMount struct { 415 // Name of the volume inside the pod template. 416 Name string `json:"name"` 417 // HostPath is the path in the host that will be mounted inside 418 // the pod. 419 HostPath string `json:"hostPath"` 420 // MountPath is the path inside the pod where hostPath will be mounted. 421 MountPath string `json:"mountPath"` 422 // ReadOnly controls write access to the volume 423 ReadOnly bool `json:"readOnly,omitempty"` 424 // PathType is the type of the HostPath. 425 PathType corev1.HostPathType `json:"pathType,omitempty"` 426 }