Kubernetes: Update pod liveness probe timeoutSeconds

3.4k views Asked by At

i'm working with Kubernetes and Jenkins-x, i need to create a devpod with customized property. In particular i need a timeoutSeconds for the livenessProbe differebt from the default one. I dont know how to customize this attribute before the pod is created so i'm trying to update it once it's running. I tried with

kubectl edit pod/<pod_name>

but it told me i cant update that property.

Do you have suggestions on how i can do this?

Thank you.

2

There are 2 answers

5
Arghya Sadhu On

Although this may not be something you really want to do in production but you can follow these steps.

  1. Get the yaml from the cluster kubectl get pod podname -o yaml --export > pod.yaml

  2. Delete the running pod kubectl deplete pod podname

  3. Edit the pod.yaml and apply it to the cluster.

0
hariK On

You can use kubectl --overrides flag. Something similar to this,

kubectl run busybox --image=busybox --restart=Never --overrides='
      {
         "apiVersion": "v1",
         "kind": "Pod",
         "metadata": {
            "labels": {
               "test": "liveness"
            },
            "name": "liveness-exec"
         },
         "spec": {
            "containers": [
               {
                  "name": "liveness",
                  "image": "k8s.gcr.io/busybox",
                  "livenessProbe": {
                     "exec": {
                        "command": [
                           "cat",
                           "/tmp/healthy"
                        ]
                     },
                     "initialDelaySeconds": 5,
                     "periodSeconds": 5
                  }
               }
            ]
         }
      }
      '