Skip to content

Latest commit

 

History

History
71 lines (60 loc) · 1.58 KB

File metadata and controls

71 lines (60 loc) · 1.58 KB

Node selector

Node Selector
Tips and Tricks

For simulated Practice problems visit KillerCoda.
  1. Add label name=master to node01 node.

    Solution

    k label node node01 name=master

  2. create a pod named p1 with nginx image. Schedule it on the node01 node using node selector.

    Solution

    apiVersion: v1
    kind: Pod
    metadata:
      creationTimestamp: null
      labels:
        run: p1
      name: p1
    spec:
      nodeSelector:
        name: master
      containers:
      - image: nginx
        name: p1
        resources: {}
      dnsPolicy: ClusterFirst
      restartPolicy: Always
    status: {}

  3. Create a pod named p2 with image nginx. Schedule it on the node01 node using nodeName.

    Solution

    apiVersion: v1
    kind: Pod
    metadata:
      creationTimestamp: null
      labels:
        run: p2
      name: p2
    spec:
      nodeName: node01
      containers:
      - image: nginx
        name: p2
        resources: {}
      dnsPolicy: ClusterFirst
      restartPolicy: Always
    status: {}