sigs.k8s.io/cluster-api/bootstrap/kubeadm@v0.0.0-20191016155141-23a891785b60/api/v1alpha2/kubeadmbootstrapconfig_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 v1alpha2 18 19 import ( 20 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 kubeadmv1beta1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/kubeadm/v1beta1" 22 ) 23 24 // Format specifies the output format of the bootstrap data 25 // +kubebuilder:validation:Enum=cloud-config 26 type Format string 27 28 const ( 29 // CloudConfig make the bootstrap data to be of cloud-config format 30 CloudConfig Format = "cloud-config" 31 ) 32 33 // KubeadmConfigSpec defines the desired state of KubeadmConfig. 34 // Either ClusterConfiguration and InitConfiguration should be defined or the JoinConfiguration should be defined. 35 type KubeadmConfigSpec struct { 36 // ClusterConfiguration along with InitConfiguration are the configurations necessary for the init command 37 // +optional 38 ClusterConfiguration *kubeadmv1beta1.ClusterConfiguration `json:"clusterConfiguration,omitempty"` 39 // InitConfiguration along with ClusterConfiguration are the configurations necessary for the init command 40 // +optional 41 InitConfiguration *kubeadmv1beta1.InitConfiguration `json:"initConfiguration,omitempty"` 42 // JoinConfiguration is the kubeadm configuration for the join command 43 // +optional 44 JoinConfiguration *kubeadmv1beta1.JoinConfiguration `json:"joinConfiguration,omitempty"` 45 // Files specifies extra files to be passed to user_data upon creation. 46 // +optional 47 Files []File `json:"files,omitempty"` 48 // PreKubeadmCommands specifies extra commands to run before kubeadm runs 49 // +optional 50 PreKubeadmCommands []string `json:"preKubeadmCommands,omitempty"` 51 // PostKubeadmCommands specifies extra commands to run after kubeadm runs 52 // +optional 53 PostKubeadmCommands []string `json:"postKubeadmCommands,omitempty"` 54 // Users specifies extra users to add 55 // +optional 56 Users []User `json:"users,omitempty"` 57 // NTP specifies NTP configuration 58 // +optional 59 NTP *NTP `json:"ntp,omitempty"` 60 // Format specifies the output format of the bootstrap data 61 // +optional 62 Format Format `json:"format,omitempty"` 63 } 64 65 // KubeadmConfigStatus defines the observed state of KubeadmConfig 66 type KubeadmConfigStatus struct { 67 // Ready indicates the BootstrapData field is ready to be consumed 68 Ready bool `json:"ready,omitempty"` 69 70 // BootstrapData will be a cloud-init script for now 71 // +optional 72 BootstrapData []byte `json:"bootstrapData,omitempty"` 73 74 // ErrorReason will be set on non-retryable errors 75 // +optional 76 ErrorReason string `json:"errorReason,omitempty"` 77 78 // ErrorMessage will be set on non-retryable errors 79 // +optional 80 ErrorMessage string `json:"errorMessage,omitempty"` 81 } 82 83 // +kubebuilder:object:root=true 84 // +kubebuilder:resource:path=kubeadmconfigs,scope=Namespaced,categories=cluster-api 85 // +kubebuilder:storageversion 86 // +kubebuilder:subresource:status 87 88 // KubeadmConfig is the Schema for the kubeadmconfigs API 89 type KubeadmConfig struct { 90 metav1.TypeMeta `json:",inline"` 91 metav1.ObjectMeta `json:"metadata,omitempty"` 92 93 Spec KubeadmConfigSpec `json:"spec,omitempty"` 94 Status KubeadmConfigStatus `json:"status,omitempty"` 95 } 96 97 // +kubebuilder:object:root=true 98 99 // KubeadmConfigList contains a list of KubeadmConfig 100 type KubeadmConfigList struct { 101 metav1.TypeMeta `json:",inline"` 102 metav1.ListMeta `json:"metadata,omitempty"` 103 Items []KubeadmConfig `json:"items"` 104 } 105 106 func init() { 107 SchemeBuilder.Register(&KubeadmConfig{}, &KubeadmConfigList{}) 108 } 109 110 // Encoding specifies the cloud-init file encoding. 111 // +kubebuilder:validation:Enum=base64;gzip;gzip+base64 112 type Encoding string 113 114 const ( 115 // Base64 implies the contents of the file are encoded as base64. 116 Base64 Encoding = "base64" 117 // Gzip implies the contents of the file are encoded with gzip. 118 Gzip Encoding = "gzip" 119 // GzipBase64 implies the contents of the file are first base64 encoded and then gzip encoded. 120 GzipBase64 Encoding = "gzip+base64" 121 ) 122 123 // File defines the input for generating write_files in cloud-init. 124 type File struct { 125 // Path specifies the full path on disk where to store the file. 126 Path string `json:"path"` 127 128 // Owner specifies the ownership of the file, e.g. "root:root". 129 // +optional 130 Owner string `json:"owner,omitempty"` 131 132 // Permissions specifies the permissions to assign to the file, e.g. "0640". 133 // +optional 134 Permissions string `json:"permissions,omitempty"` 135 136 // Encoding specifies the encoding of the file contents. 137 // +optional 138 Encoding Encoding `json:"encoding,omitempty"` 139 140 // Content is the actual content of the file. 141 Content string `json:"content"` 142 } 143 144 // User defines the input for a generated user in cloud-init. 145 type User struct { 146 // Name specifies the user name 147 Name string `json:"name"` 148 149 // Gecos specifies the gecos to use for the user 150 // +optional 151 Gecos *string `json:"gecos,omitempty"` 152 153 // Groups specifies the additional groups for the user 154 // +optional 155 Groups *string `json:"groups,omitempty"` 156 157 // HomeDir specifies the home directory to use for the user 158 // +optional 159 HomeDir *string `json:"homeDir,omitempty"` 160 161 // Inactive specifies whether to mark the user as inactive 162 // +optional 163 Inactive *bool `json:"inactive,omitempty"` 164 165 // Shell specifies the user's shell 166 // +optional 167 Shell *string `json:"shell,omitempty"` 168 169 // Passwd specifies a hashed password for the user 170 // +optional 171 Passwd *string `json:"passwd"` 172 173 // PrimaryGroup specifies the primary group for the user 174 // +optional 175 PrimaryGroup *string `json:"primaryGroup,omitempty"` 176 177 // LockPassword specifies if password login should be disabled 178 // +optional 179 LockPassword *bool `json:"lockPassword,omitempty"` 180 181 // Sudo specifies a sudo role for the user 182 // +optional 183 Sudo *string `json:"sudo,omitempty"` 184 185 // SSHAuthorizedKeys specifies a list of ssh authorized keys for the user 186 // +optional 187 SSHAuthorizedKeys []string `json:"sshAuthorizedKeys,omitempty"` 188 } 189 190 // NTP defines input for generated ntp in cloud-init 191 type NTP struct { 192 // Servers specifies which NTP servers to use 193 // +optional 194 Servers []string `json:"servers,omitempty"` 195 196 // Enabled specifies whether NTP should be enabled 197 // +optional 198 Enabled *bool `json:"enabled,omitempty"` 199 }