Changing value of running deployment

10/29/2020

I have a problem that I don't understand.

When I edit my wordpress deployment ( kubectl edit deployment wordpress ) and try to add my livenessProbe or readinessProbe .

I got the message below and I don't understand why

Edit cancelled, no changes made.

if I rerun ( kubectl edit deployment wordpress ) no modification has been saved :(

  template:
    metadata:
      creationTimestamp: null
      labels:
        app: wordpress
        tier: frontend
    spec:
      containers:
      - env:
        - name: WORDPRESS_DB_HOST
          value: wordpress-mysql
        - name: WORDPRESS_DB_PASSWORD
          valueFrom:
            secretKeyRef:
              key: password.txt
              name: mysql-pass-h4hhdb94mg
        image: wordpress:latest
        imagePullPolicy: Always
        readinessProbe:
          tcpSocket:
            port: 8080
          initialDelaySeconds: 5
          periodSeconds: 10
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /healthz
            port: 8080
            scheme: HTTP
          initialDelaySeconds: 5
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
-- zyriuse
kubernetes
kubernetes-pod

1 Answer

10/29/2020

First make sure that after editing you have saved changes.

Your error is likely caused by opening an editor that forks off instead of staying.

That means you'll want to set $EDITOR to an editor that does wait. E.g. nano, vim or emacs should work, and e.g. if you use sublime text you'll have to use subl -w to explicitly tell it to wait.

You didn't say which shell you're running at the moment. If it's bash, run export EDITOR="subl -w", in fish run set -gx EDITOR subl -w (or "subl -w" if you use fish < 3.0).

Take a look: deployment-edits-cancelled.

You can also edit deployment by:

1. kubectl patch. The following command disable a deployment livenessProbe:

# Disable a deployment livenessProbe using a json patch with positional arrays
$ kubectl patch deployment valid-deployment  --type json   -p='[{"op": "remove", "path": "/spec/template/spec/containers/0/livenessProbe"}]'

2. Manually editing deployment yaml file and apply changes:

$ kubectl apply -f your-deployment.yaml

-- Malgorzata
Source: StackOverflow