Skip to content
This repository was archived by the owner on Jul 30, 2021. It is now read-only.

Commit 0bae6ec

Browse files
authored
Merge pull request #296 from fabriziopandini/mark-defaulted-fields-as-optional
Mark defaulted fields as optional
2 parents 38af74d + d09473c commit 0bae6ec

File tree

3 files changed

+59
-38
lines changed

3 files changed

+59
-38
lines changed

config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ spec:
105105
info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
106106
type: string
107107
certificatesDir:
108-
description: CertificatesDir specifies where to store or look for
109-
all required certificates.
108+
description: 'CertificatesDir specifies where to store or look for
109+
all required certificates. NB: if not provided, this will default
110+
to `/etc/kubernetes/pki`'
110111
type: string
111112
clusterName:
112113
description: The cluster name
@@ -186,11 +187,10 @@ spec:
186187
type:
187188
description: Type defines the DNS add-on to be used
188189
type: string
189-
required:
190-
- type
191190
type: object
192191
etcd:
193-
description: Etcd holds configuration for etcd.
192+
description: 'Etcd holds configuration for etcd. NB: This value
193+
defaults to a Local (stacked) etcd'
194194
properties:
195195
external:
196196
description: External describes how to connect to an external
@@ -257,8 +257,6 @@ spec:
257257
items:
258258
type: string
259259
type: array
260-
required:
261-
- dataDir
262260
type: object
263261
type: object
264262
featureGates:
@@ -294,14 +292,16 @@ spec:
294292
Defaults to "cluster.local".
295293
type: string
296294
podSubnet:
297-
description: PodSubnet is the subnet used by pods.
295+
description: PodSubnet is the subnet used by pods. If unset,
296+
the API server will not allocate CIDR ranges for every node.
297+
Defaults to the first element of the Cluster object's spec.clusterNetwork.services.cidrBlocks
298+
if that is set
298299
type: string
299300
serviceSubnet:
300301
description: ServiceSubnet is the subnet used by k8s services.
301-
Defaults to "10.96.0.0/12".
302+
Defaults to the first element of the Cluster object's spec.clusterNetwork.pods.cidrBlocks
303+
field, or to "10.96.0.0/12" if that's unset.
302304
type: string
303-
required:
304-
- podSubnet
305305
type: object
306306
scheduler:
307307
description: Scheduler contains extra settings for the scheduler
@@ -715,8 +715,6 @@ spec:
715715
type: object
716716
type: array
717717
type: object
718-
required:
719-
- nodeRegistration
720718
type: object
721719
ntp:
722720
description: NTP specifies NTP configuration

config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigtemplates.yaml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,9 @@ spec:
112112
reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
113113
type: string
114114
certificatesDir:
115-
description: CertificatesDir specifies where to store or
116-
look for all required certificates.
115+
description: 'CertificatesDir specifies where to store or
116+
look for all required certificates. NB: if not provided,
117+
this will default to `/etc/kubernetes/pki`'
117118
type: string
118119
clusterName:
119120
description: The cluster name
@@ -197,11 +198,10 @@ spec:
197198
type:
198199
description: Type defines the DNS add-on to be used
199200
type: string
200-
required:
201-
- type
202201
type: object
203202
etcd:
204-
description: Etcd holds configuration for etcd.
203+
description: 'Etcd holds configuration for etcd. NB: This
204+
value defaults to a Local (stacked) etcd'
205205
properties:
206206
external:
207207
description: External describes how to connect to an
@@ -274,8 +274,6 @@ spec:
274274
items:
275275
type: string
276276
type: array
277-
required:
278-
- dataDir
279277
type: object
280278
type: object
281279
featureGates:
@@ -313,14 +311,18 @@ spec:
313311
services. Defaults to "cluster.local".
314312
type: string
315313
podSubnet:
316-
description: PodSubnet is the subnet used by pods.
314+
description: PodSubnet is the subnet used by pods. If
315+
unset, the API server will not allocate CIDR ranges
316+
for every node. Defaults to the first element of the
317+
Cluster object's spec.clusterNetwork.services.cidrBlocks
318+
if that is set
317319
type: string
318320
serviceSubnet:
319321
description: ServiceSubnet is the subnet used by k8s
320-
services. Defaults to "10.96.0.0/12".
322+
services. Defaults to the first element of the Cluster
323+
object's spec.clusterNetwork.pods.cidrBlocks field,
324+
or to "10.96.0.0/12" if that's unset.
321325
type: string
322-
required:
323-
- podSubnet
324326
type: object
325327
scheduler:
326328
description: Scheduler contains extra settings for the scheduler
@@ -762,8 +764,6 @@ spec:
762764
type: object
763765
type: array
764766
type: object
765-
required:
766-
- nodeRegistration
767767
type: object
768768
ntp:
769769
description: NTP specifies NTP configuration

kubeadm/v1beta1/types.go

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ type InitConfiguration struct {
4040

4141
// BootstrapTokens is respected at `kubeadm init` time and describes a set of Bootstrap Tokens to create.
4242
// This information IS NOT uploaded to the kubeadm cluster configmap, partly because of its sensitive nature
43+
// +optional
4344
BootstrapTokens []BootstrapToken `json:"bootstrapTokens,omitempty"`
4445

4546
// NodeRegistration holds fields that relate to registering the new control-plane node to the cluster
47+
// +optional
4648
NodeRegistration NodeRegistrationOptions `json:"nodeRegistration,omitempty"`
4749

4850
// LocalAPIEndpoint represents the endpoint of the API server instance that's deployed on this control plane node
@@ -51,6 +53,7 @@ type InitConfiguration struct {
5153
// configuration object lets you customize what IP/DNS name and port the local API server advertises it's accessible
5254
// on. By default, kubeadm tries to auto-detect the IP of the default interface and use that, but in case that process
5355
// fails you may set the desired value here.
56+
// +optional
5457
LocalAPIEndpoint APIEndpoint `json:"localAPIEndpoint,omitempty"`
5558
}
5659

@@ -61,18 +64,19 @@ type ClusterConfiguration struct {
6164
metav1.TypeMeta `json:",inline"`
6265

6366
// Etcd holds configuration for etcd.
67+
// NB: This value defaults to a Local (stacked) etcd
6468
// +optional
65-
Etcd Etcd `json:"etcd"`
69+
Etcd Etcd `json:"etcd,omitempty"`
6670

6771
// Networking holds configuration for the networking topology of the cluster.
6872
// NB: This value defaults to the Cluster object spec.clusterNetwork.
6973
// +optional
70-
Networking Networking `json:"networking"`
74+
Networking Networking `json:"networking,omitempty"`
7175

7276
// KubernetesVersion is the target version of the control plane.
7377
// NB: This value defaults to the Machine object spec.kuberentesVersion
7478
// +optional
75-
KubernetesVersion string `json:"kubernetesVersion"`
79+
KubernetesVersion string `json:"kubernetesVersion,omitempty"`
7680

7781
// ControlPlaneEndpoint sets a stable IP address or DNS name for the control plane; it
7882
// can be a valid IP address or a RFC-1123 DNS subdomain, both with optional TCP port.
@@ -87,36 +91,42 @@ type ClusterConfiguration struct {
8791
// could be used for assigning a stable DNS to the control plane.
8892
// NB: This value defaults to the first value in the Cluster object status.apiEndpoints array.
8993
// +optional
90-
ControlPlaneEndpoint string `json:"controlPlaneEndpoint"`
94+
ControlPlaneEndpoint string `json:"controlPlaneEndpoint,omitempty"`
9195

9296
// APIServer contains extra settings for the API server control plane component
97+
// +optional
9398
APIServer APIServer `json:"apiServer,omitempty"`
9499

95100
// ControllerManager contains extra settings for the controller manager control plane component
101+
// +optional
96102
ControllerManager ControlPlaneComponent `json:"controllerManager,omitempty"`
97103

98104
// Scheduler contains extra settings for the scheduler control plane component
105+
// +optional
99106
Scheduler ControlPlaneComponent `json:"scheduler,omitempty"`
100107

101108
// DNS defines the options for the DNS add-on installed in the cluster.
102109
// +optional
103-
DNS DNS `json:"dns"`
110+
DNS DNS `json:"dns,omitempty"`
104111

105112
// CertificatesDir specifies where to store or look for all required certificates.
113+
// NB: if not provided, this will default to `/etc/kubernetes/pki`
106114
// +optional
107-
CertificatesDir string `json:"certificatesDir"`
115+
CertificatesDir string `json:"certificatesDir,omitempty"`
108116

109117
// ImageRepository sets the container registry to pull images from.
110118
// 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/`)
111119
// `gcr.io/kubernetes-ci-images` will be used as a default for control plane components and for kube-proxy, while `k8s.gcr.io`
112120
// will be used for all the other images.
113121
// +optional
114-
ImageRepository string `json:"imageRepository"`
122+
ImageRepository string `json:"imageRepository,omitempty"`
115123

116124
// UseHyperKubeImage controls if hyperkube should be used for Kubernetes components instead of their respective separate images
125+
// +optional
117126
UseHyperKubeImage bool `json:"useHyperKubeImage,omitempty"`
118127

119128
// FeatureGates enabled by the user.
129+
// +optional
120130
FeatureGates map[string]bool `json:"featureGates,omitempty"`
121131

122132
// The cluster name
@@ -160,7 +170,8 @@ const (
160170
// DNS defines the DNS addon that should be used in the cluster
161171
type DNS struct {
162172
// Type defines the DNS add-on to be used
163-
Type DNSAddOnType `json:"type"`
173+
// +optional
174+
Type DNSAddOnType `json:"type,omitempty"`
164175

165176
// ImageMeta allows to customize the image used for the DNS component
166177
ImageMeta `json:",inline"`
@@ -208,29 +219,38 @@ type NodeRegistrationOptions struct {
208219
// Name is the `.Metadata.Name` field of the Node API object that will be created in this `kubeadm init` or `kubeadm join` operation.
209220
// This field is also used in the CommonName field of the kubelet's client certificate to the API server.
210221
// Defaults to the hostname of the node if not provided.
222+
// +optional
211223
Name string `json:"name,omitempty"`
212224

213225
// CRISocket is used to retrieve container runtime info. This information will be annotated to the Node API object, for later re-use
226+
// +optional
214227
CRISocket string `json:"criSocket,omitempty"`
215228

216229
// 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
217230
// 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
218231
// empty slice, i.e. `taints: {}` in the YAML file. This field is solely used for Node registration.
232+
// +optional
219233
Taints []v1.Taint `json:"taints,omitempty"`
220234

221235
// KubeletExtraArgs passes through extra arguments to the kubelet. The arguments here are passed to the kubelet command line via the environment file
222236
// kubeadm writes at runtime for the kubelet to source. This overrides the generic base-level configuration in the kubelet-config-1.X ConfigMap
223237
// Flags have higher priority when parsing. These values are local and specific to the node kubeadm is executing on.
238+
// +optional
224239
KubeletExtraArgs map[string]string `json:"kubeletExtraArgs,omitempty"`
225240
}
226241

227242
// Networking contains elements describing cluster's networking configuration
228243
type Networking struct {
229-
// ServiceSubnet is the subnet used by k8s services. Defaults to "10.96.0.0/12".
244+
// ServiceSubnet is the subnet used by k8s services.
245+
// Defaults to the first element of the Cluster object's spec.clusterNetwork.pods.cidrBlocks field, or
246+
// to "10.96.0.0/12" if that's unset.
230247
// +optional
231248
ServiceSubnet string `json:"serviceSubnet,omitempty"`
232249
// PodSubnet is the subnet used by pods.
233-
PodSubnet string `json:"podSubnet"`
250+
// If unset, the API server will not allocate CIDR ranges for every node.
251+
// Defaults to the first element of the Cluster object's spec.clusterNetwork.services.cidrBlocks if that is set
252+
// +optional
253+
PodSubnet string `json:"podSubnet,omitempty"`
234254
// DNSDomain is the dns domain used by k8s services. Defaults to "cluster.local".
235255
// +optional
236256
DNSDomain string `json:"dnsDomain,omitempty"`
@@ -277,7 +297,8 @@ type LocalEtcd struct {
277297

278298
// DataDir is the directory etcd will place its data.
279299
// Defaults to "/var/lib/etcd".
280-
DataDir string `json:"dataDir"`
300+
// +optional
301+
DataDir string `json:"dataDir,omitempty"`
281302

282303
// ExtraArgs are extra arguments provided to the etcd binary
283304
// when run inside a static pod.
@@ -315,7 +336,8 @@ type JoinConfiguration struct {
315336
metav1.TypeMeta `json:",inline"`
316337

317338
// NodeRegistration holds fields that relate to registering the new control-plane node to the cluster
318-
NodeRegistration NodeRegistrationOptions `json:"nodeRegistration"`
339+
// +optional
340+
NodeRegistration NodeRegistrationOptions `json:"nodeRegistration,omitempty"`
319341

320342
// CACertPath is the path to the SSL certificate authority used to
321343
// secure comunications between node and control-plane.
@@ -331,6 +353,7 @@ type JoinConfiguration struct {
331353

332354
// ControlPlane defines the additional control plane instance to be deployed on the joining node.
333355
// If nil, no additional control plane instance will be deployed.
356+
// +optional
334357
ControlPlane *JoinControlPlane `json:"controlPlane,omitempty"`
335358
}
336359

0 commit comments

Comments
 (0)