mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 08:17:26 +00:00
kubeadm: apply the new "control-plane" taint on CP nodes
- Apply "control-plane" taint during init/join by adding the taint in SetNodeRegistrationDynamicDefaults(). The old taint "master" is still applied. - Clarify API docs (v1beta2 and v1beta3) for nodeRegistration.Taint to not mention "master" taint and be more generic. Remove example for taints that includes the word "master". - Update unit tests.
This commit is contained in:
parent
a3d5e55982
commit
370031cada
@ -212,9 +212,9 @@ type NodeRegistrationOptions struct {
|
||||
// CRISocket is used to retrieve container runtime info. This information will be annotated to the Node API object, for later re-use
|
||||
CRISocket string
|
||||
|
||||
// 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.
|
||||
// Taints specifies the taints the Node API object should be registered with. If this field is unset, i.e. nil,
|
||||
// it will be defaulted with a control-plane taint for control-plane nodes. 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.
|
||||
Taints []v1.Taint
|
||||
|
||||
// KubeletExtraArgs passes through extra arguments to the kubelet. The arguments here are passed to the kubelet command line via the environment file
|
||||
|
@ -172,7 +172,7 @@ limitations under the License.
|
||||
// criSocket: "unix:///var/run/dockershim.sock"
|
||||
// taints:
|
||||
// - key: "kubeadmNode"
|
||||
// value: "master"
|
||||
// value: "someValue"
|
||||
// effect: "NoSchedule"
|
||||
// kubeletExtraArgs:
|
||||
// v: 4
|
||||
|
@ -201,9 +201,9 @@ type NodeRegistrationOptions struct {
|
||||
// CRISocket is used to retrieve container runtime info. This information will be annotated to the Node API object, for later re-use
|
||||
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.
|
||||
// Taints specifies the taints the Node API object should be registered with. If this field is unset, i.e. nil,
|
||||
// it will be defaulted with a control-plane taint for control-plane nodes. 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.
|
||||
Taints []v1.Taint `json:"taints"`
|
||||
|
||||
// KubeletExtraArgs passes through extra arguments to the kubelet. The arguments here are passed to the kubelet command line via the environment file
|
||||
|
@ -176,7 +176,7 @@ limitations under the License.
|
||||
// criSocket: "unix:///var/run/dockershim.sock"
|
||||
// taints:
|
||||
// - key: "kubeadmNode"
|
||||
// value: "master"
|
||||
// value: "someValue"
|
||||
// effect: "NoSchedule"
|
||||
// kubeletExtraArgs:
|
||||
// v: 4
|
||||
|
@ -215,9 +215,9 @@ type NodeRegistrationOptions struct {
|
||||
// +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.
|
||||
// Taints specifies the taints the Node API object should be registered with. If this field is unset, i.e. nil,
|
||||
// it will be defaulted with a control-plane taint for control-plane nodes. 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.
|
||||
Taints []corev1.Taint `json:"taints"`
|
||||
|
||||
// KubeletExtraArgs passes through extra arguments to the kubelet. The arguments here are passed to the kubelet command line via the environment file
|
||||
|
@ -106,7 +106,7 @@ func SetNodeRegistrationDynamicDefaults(cfg *kubeadmapi.NodeRegistrationOptions,
|
||||
// Only if the slice is nil, we should append the control-plane taint. This allows the user to specify an empty slice for no default control-plane taint
|
||||
if controlPlaneTaint && cfg.Taints == nil {
|
||||
// TODO: https://github.com/kubernetes/kubeadm/issues/2200
|
||||
cfg.Taints = []v1.Taint{kubeadmconstants.OldControlPlaneTaint}
|
||||
cfg.Taints = []v1.Taint{kubeadmconstants.OldControlPlaneTaint, kubeadmconstants.ControlPlaneTaint}
|
||||
}
|
||||
|
||||
if cfg.CRISocket == "" {
|
||||
|
@ -116,17 +116,17 @@ func TestDefaultTaintsMarshaling(t *testing.T) {
|
||||
expectedTaintCnt int
|
||||
}{
|
||||
{
|
||||
desc: "Uninitialized nodeRegistration field produces a single taint (the master one)",
|
||||
desc: "Uninitialized nodeRegistration field produces expected taints",
|
||||
cfg: kubeadmapiv1.InitConfiguration{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: kubeadmapiv1.SchemeGroupVersion.String(),
|
||||
Kind: constants.InitConfigurationKind,
|
||||
},
|
||||
},
|
||||
expectedTaintCnt: 1,
|
||||
expectedTaintCnt: 2,
|
||||
},
|
||||
{
|
||||
desc: "Uninitialized taints field produces a single taint (the master one)",
|
||||
desc: "Uninitialized taints field produces expected taints",
|
||||
cfg: kubeadmapiv1.InitConfiguration{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: kubeadmapiv1.SchemeGroupVersion.String(),
|
||||
@ -134,7 +134,7 @@ func TestDefaultTaintsMarshaling(t *testing.T) {
|
||||
},
|
||||
NodeRegistration: kubeadmapiv1.NodeRegistrationOptions{},
|
||||
},
|
||||
expectedTaintCnt: 1,
|
||||
expectedTaintCnt: 2,
|
||||
},
|
||||
{
|
||||
desc: "Forsing taints to an empty slice produces no taints",
|
||||
|
Loading…
Reference in New Issue
Block a user