Here, we show as shortly as possible how we can place a POD on the controlplane node on killerkoda CKA playground:

Task: place a POD on the controlplane POD using Affinity

# create POD YAML:
k run mypod--image nginx -o yaml --dry-run=client > pod.yaml

# edit pod.yaml (in killerkoda you can use the editor that helps with the syntax. Also look in the documentation above):
apiVersion: v1
kind: Pod
metadata:
  labels:
    run: mypod
  name: mypod
spec:
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
          - matchExpressions:
              - key: myKey
                operator: In
                values:
                  - "label1"
                  - "label2"

# create pod
k apply -f pod.yaml

# check pod location
k get pod -o wide

# check, why the pod is in Pending state:
k describe pod mypod | grep -A 100 Events:

# add a matching label to the controlplane node
k label nodes controlplane myKey=label1

# the pod is still not scheduled because of a taint. View taints:
k describe nodes controlplane | grep -i taint

# remove taint
k taint node controlplane node-role.kubernetes.io/control-plane:NoSchedule-

# now the pod is scheduled
k get pod -o wide

Reference

Comments

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.