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