Skip to content

Latest commit

 

History

History
84 lines (75 loc) · 1.5 KB

File metadata and controls

84 lines (75 loc) · 1.5 KB
kubectl config use-context cluster1-admin@cluster1
  1. Add a taint to controlplane and generate manifest for the pod
kubectl get no

kubectl label node ${put-controlplane-hostname} app_type=beta

kubectl create deployment beta-apps --image nginx --replicas 3 --dry-run=client -o yaml > 10.yaml
  1. Modify manifest file and add NodeAffinity
# vim 10.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: beta-apps
  name: beta-apps
spec:
  replicas: 3
  selector:
    matchLabels:
      app: beta-apps
  template:
    metadata:
      labels:
        app: beta-apps
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: app_type
                operator: In
                values:
                - beta
      tolerations:
      - key: node-role.kubernetes.io/control-plane
        effect: "NoSchedule"
      containers:
      - image: nginx
        name: nginx

or

# vim 10.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: beta-apps
  name: beta-apps
spec:
  replicas: 3
  selector:
    matchLabels:
      app: beta-apps
  template:
    metadata:
      labels:
        app: beta-apps
    spec:
      nodeSelector:
        app_type: beta
      tolerations:
      - key: node-role.kubernetes.io/control-plane
        effect: "NoSchedule"
      containers:
      - image: nginx
        name: nginx

k apply -f 10.yaml