Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
camilamacedo86 opened this issue Oct 27, 2022 · 1 comment
Open

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

camilamacedo86 opened this issue Oct 27, 2022 · 1 comment

Comments

@camilamacedo86
Copy link
Contributor

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
@camilamacedo86 camilamacedo86 changed the title Allows kots work on with kind by replacing replacing RequiredDuringSchedulingIgnoredDuringExecution with preferredDuringSchedulingIgnoredDuringExecution Allows kots work on with kind by changing Node affinity criteria Oct 27, 2022
@camilamacedo86 camilamacedo86 changed the title Allows kots work on with kind by changing Node affinity criteria Allows kots work on Kind by changing Node affinity criteria Oct 27, 2022
@adamancini
Copy link
Member

Looks like the original master label is being deprecated https://kubernetes.io/docs/reference/labels-annotations-taints/#node-role-kubernetes-io-master-taint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants