@Mohamed Ayman or anyone here who can help for below discussion - Is there any . . .

Rahul:
@Mohamed Ayman or anyone here who can help for below discussion -

Is there any issue in setting nodeName: master. This is question 4 lightning lab 2
This does not work for me

apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: my-busybox
name: my-busybox
namespace: dev2406
spec:
nodeName: master
volumes:
- name: secret-volume
secret:
secretName: dotfile-secret
containers:

  • args:
    • /bin/sh
    • -c
    • sleep 3600
      image: busybox
      name: secret
      volumeMounts:
    • name: secret-volume
      mountPath: /etc/secret-volume
      resources: {}
      dnsPolicy: ClusterFirst
      restartPolicy: Always

MAyman [10:52 PM]
Yes if you delete the line of setting nodename:master the pod will be running normally

MAyman [11:36 PM]
If you want to be able to schedule pods on the Kubernetes control-plane node, you need to remove a taint on the master nodes.
kubectl taint nodes --all http://node-role.kubernetes.io/master-|node-role.kubernetes.io/master-

Rahul [1:06 PM]
@Mohamed Ayman How can I ensure the pod to run on master . Do we need to check for the taint always in exam ? Like if they say it to schedule on master, what should I use in YAML ?

Rahul [9:07 AM]
controlplane $ k taint nodes --all http://node-role.kubernetes.io/master-|node-role.kubernetes.io/master-
node/controlplane untainted
error: taint “http://node-role.kubernetes.io/master|node-role.kubernetes.io/master” not found
@Mohamed Ayman How to ensure it running on master (edited)

Madhan Kumar:
Use kubectl get nodes to get the actual nodename , sometimes its called “controlplane” sometimes its called “master”

Madhan Kumar:
Use kunectl get pods -o wide. To check the node where pod is running …

Mohamed Ayman:
Yes, It’s controlplane not master so check the node name using kubectl get nodes -o wide

Mohamed Ayman:
You need to add nodeSelector to schedule It into the controlplane node, check the following:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: my-busybox
  name: my-busybox
  namespace: dev2406
spec:
  volumes:
  - name: secret-volume
    secret:
      secretName: dotfile-secret
  nodeSelector:
    <http://kubernetes.io/hostname|kubernetes.io/hostname>: controlplane
  tolerations:
  - key: "<http://node-role.kubernetes.io/master|node-role.kubernetes.io/master>"
    operator: "Exists"
    effect: "NoSchedule"
  containers:
  - command:
    - sleep
    args:
    - "3600"
    image: busybox
    name: secret
    volumeMounts:
    - name: secret-volume
      readOnly: true
      mountPath: "/etc/secret-volume"