Skip to content

Allows kots work on Kind by changing Node affinity criteria #3361

@camilamacedo86

Description

@camilamacedo86

Description

Kots has some NodeAffinity criteria implementations which require the label node-role.kubernetes.io/masterwhich does not necessarily exist for all K8s vendors. Therefore, this issue is to propose a suggestion for replacing RequiredDuringSchedulingIgnoredDuringExecution with preferredDuringSchedulingIgnoredDuringExecution so that it still be able to be scheduled with/when is not possible to match but ensure its preference which would allow work on more vendors by default. You can check the k8s doc for further info: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity.

See the code spot:

kots/pkg/kurl/join_cert.go

Lines 208 to 229 in c597a4a

Spec: corev1.PodSpec{
SecurityContext: &securityContext,
Affinity: &corev1.Affinity{
NodeAffinity: &corev1.NodeAffinity{
RequiredDuringSchedulingIgnoredDuringExecution: &corev1.NodeSelector{
NodeSelectorTerms: []corev1.NodeSelectorTerm{
{
MatchExpressions: []corev1.NodeSelectorRequirement{
{
Key: "node-role.kubernetes.io/control-plane",
Operator: corev1.NodeSelectorOpExists,
},
{
Key: "node-role.kubernetes.io/master",
Operator: corev1.NodeSelectorOpExists,
},
},
},
},
},
},
},

Motivation

Note that Kind for example will not have this label: (Following an example with a default basic config)

(i.e.) Kind cluster with 3 nodes created with the following config (kind v0.16.0 / k8s 1.25.2)

$ cat kind-example-config.yaml 
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
kind create cluster --config=kind-example-config.yaml

See that we have not node-role.kubernetes.io/master label

$ kind get nodes 
kind-worker2
kind-control-plane
kind-worker
 $ kubectl label node kind-control-plane --list
kubernetes.io/hostname=kind-control-plane
kubernetes.io/os=linux
node-role.kubernetes.io/control-plane=
node.kubernetes.io/exclude-from-external-load-balancers=
beta.kubernetes.io/arch=arm64
beta.kubernetes.io/os=linux
kubernetes.io/arch=arm64

$ kubectl label node kind-worker2 --list
beta.kubernetes.io/arch=arm64
beta.kubernetes.io/os=linux
kubernetes.io/arch=arm64
kubernetes.io/hostname=kind-worker2
kubernetes.io/os=linux

$ kubectl label node kind-worker --list
kubernetes.io/arch=arm64
kubernetes.io/hostname=kind-worker
kubernetes.io/os=linux
beta.kubernetes.io/arch=arm64
beta.kubernetes.io/os=linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions