0

I Created a deployment named blue with the nginx image and 6 replicas using imperative commands

I created using the following commands

kubectl create deployment blue --image=nginx
kubectl scale deployment blue --replicas=6

Now I want to update the deployment using the declarative way by using the following yaml file

apiVersion: apps/v1
kind: Deployment
metadata:
  name: blue
spec:
  replicas: 6
  selector:
    matchLabels:
      run: nginx
  template:
    metadata:
      labels:
        run: nginx
    spec:
      containers:
      - image: nginx
        imagePullPolicy: Always
        name: nginx
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: color
                operator: In
                values:
                - blue

Please help me how to solve it

  • please be more specific. what is the problem? are you getting an error? Solve what? – Opri Nov 04 '20 at 09:53
  • I created Kubernetes deployment using imperatives commands and I want to update Kubernetes deployment using YAML file I tried using kubectl apply .......command but I am unable to update – Harsha Kumar Nov 04 '20 at 16:18

1 Answers1

0

try the command

kubectl edit deployment <deployment name>

and then add the fields with proper indentation, save and exit file.

FYI. some specs can't be changed and applied. you need to delete it first and then apply it.