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