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

Commit

Permalink
Merge pull request #296 from fabriziopandini/mark-defaulted-fields-as…
Browse files Browse the repository at this point in the history
…-optional

Mark defaulted fields as optional
  • Loading branch information
k8s-ci-robot authored Jul 2, 2020
2 parents 38af74d + d09473c commit 0bae6ec
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 38 deletions.
24 changes: 11 additions & 13 deletions config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ spec:
info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
type: string
certificatesDir:
description: CertificatesDir specifies where to store or look for
all required certificates.
description: 'CertificatesDir specifies where to store or look for
all required certificates. NB: if not provided, this will default
to `/etc/kubernetes/pki`'
type: string
clusterName:
description: The cluster name
Expand Down Expand Up @@ -186,11 +187,10 @@ spec:
type:
description: Type defines the DNS add-on to be used
type: string
required:
- type
type: object
etcd:
description: Etcd holds configuration for etcd.
description: 'Etcd holds configuration for etcd. NB: This value
defaults to a Local (stacked) etcd'
properties:
external:
description: External describes how to connect to an external
Expand Down Expand Up @@ -257,8 +257,6 @@ spec:
items:
type: string
type: array
required:
- dataDir
type: object
type: object
featureGates:
Expand Down Expand Up @@ -294,14 +292,16 @@ spec:
Defaults to "cluster.local".
type: string
podSubnet:
description: PodSubnet is the subnet used by pods.
description: PodSubnet is the subnet used by pods. If unset,
the API server will not allocate CIDR ranges for every node.
Defaults to the first element of the Cluster object's spec.clusterNetwork.services.cidrBlocks
if that is set
type: string
serviceSubnet:
description: ServiceSubnet is the subnet used by k8s services.
Defaults to "10.96.0.0/12".
Defaults to the first element of the Cluster object's spec.clusterNetwork.pods.cidrBlocks
field, or to "10.96.0.0/12" if that's unset.
type: string
required:
- podSubnet
type: object
scheduler:
description: Scheduler contains extra settings for the scheduler
Expand Down Expand Up @@ -715,8 +715,6 @@ spec:
type: object
type: array
type: object
required:
- nodeRegistration
type: object
ntp:
description: NTP specifies NTP configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@ spec:
reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
type: string
certificatesDir:
description: CertificatesDir specifies where to store or
look for all required certificates.
description: 'CertificatesDir specifies where to store or
look for all required certificates. NB: if not provided,
this will default to `/etc/kubernetes/pki`'
type: string
clusterName:
description: The cluster name
Expand Down Expand Up @@ -197,11 +198,10 @@ spec:
type:
description: Type defines the DNS add-on to be used
type: string
required:
- type
type: object
etcd:
description: Etcd holds configuration for etcd.
description: 'Etcd holds configuration for etcd. NB: This
value defaults to a Local (stacked) etcd'
properties:
external:
description: External describes how to connect to an
Expand Down Expand Up @@ -274,8 +274,6 @@ spec:
items:
type: string
type: array
required:
- dataDir
type: object
type: object
featureGates:
Expand Down Expand Up @@ -313,14 +311,18 @@ spec:
services. Defaults to "cluster.local".
type: string
podSubnet:
description: PodSubnet is the subnet used by pods.
description: PodSubnet is the subnet used by pods. If
unset, the API server will not allocate CIDR ranges
for every node. Defaults to the first element of the
Cluster object's spec.clusterNetwork.services.cidrBlocks
if that is set
type: string
serviceSubnet:
description: ServiceSubnet is the subnet used by k8s
services. Defaults to "10.96.0.0/12".
services. Defaults to the first element of the Cluster
object's spec.clusterNetwork.pods.cidrBlocks field,
or to "10.96.0.0/12" if that's unset.
type: string
required:
- podSubnet
type: object
scheduler:
description: Scheduler contains extra settings for the scheduler
Expand Down Expand Up @@ -762,8 +764,6 @@ spec:
type: object
type: array
type: object
required:
- nodeRegistration
type: object
ntp:
description: NTP specifies NTP configuration
Expand Down
47 changes: 35 additions & 12 deletions kubeadm/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ type InitConfiguration struct {

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

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

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

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

// Etcd holds configuration for etcd.
// NB: This value defaults to a Local (stacked) etcd
// +optional
Etcd Etcd `json:"etcd"`
Etcd Etcd `json:"etcd,omitempty"`

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

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

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

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

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

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

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

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

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

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

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

// The cluster name
Expand Down Expand Up @@ -160,7 +170,8 @@ const (
// DNS defines the DNS addon that should be used in the cluster
type DNS struct {
// Type defines the DNS add-on to be used
Type DNSAddOnType `json:"type"`
// +optional
Type DNSAddOnType `json:"type,omitempty"`

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

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

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

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

// Networking contains elements describing cluster's networking configuration
type Networking struct {
// ServiceSubnet is the subnet used by k8s services. Defaults to "10.96.0.0/12".
// ServiceSubnet is the subnet used by k8s services.
// Defaults to the first element of the Cluster object's spec.clusterNetwork.pods.cidrBlocks field, or
// to "10.96.0.0/12" if that's unset.
// +optional
ServiceSubnet string `json:"serviceSubnet,omitempty"`
// PodSubnet is the subnet used by pods.
PodSubnet string `json:"podSubnet"`
// If unset, the API server will not allocate CIDR ranges for every node.
// Defaults to the first element of the Cluster object's spec.clusterNetwork.services.cidrBlocks if that is set
// +optional
PodSubnet string `json:"podSubnet,omitempty"`
// DNSDomain is the dns domain used by k8s services. Defaults to "cluster.local".
// +optional
DNSDomain string `json:"dnsDomain,omitempty"`
Expand Down Expand Up @@ -277,7 +297,8 @@ type LocalEtcd struct {

// DataDir is the directory etcd will place its data.
// Defaults to "/var/lib/etcd".
DataDir string `json:"dataDir"`
// +optional
DataDir string `json:"dataDir,omitempty"`

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

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

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

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

Expand Down

0 comments on commit 0bae6ec

Please sign in to comment.