Could not update containr args in Pods - kuberneties -got 'pod updates may not change fields'

6/21/2021

I am trying to update entrypoint in specific container

the struture is : statefulset -> list of pods -> specificPod -> specific contianer

I tried to do that using the javascript client and got the following:

    body: {
      kind: 'Status',
      apiVersion: 'v1',
      metadata: {},
      status: 'Failure',
      message: 'Pod "name-0" is invalid: spec: Forbidden: pod updates may not change fields other than `spec.containers[*].image`, `spec.initContainers[*].image`, `spec.activeDeadlineSeconds` or `spec.tolerations` (only additions to existing tolerations)\n' +
        '  core.PodSpec{\n' +

I did the following:

  for(let c of pod.spec.containers){
        if(c.name === 'name'){
            console.log('in name contianer');
            c.args = ['test;sleep 3600'];
        }
    }
    
await coreV1Api.replaceNamespacedPod(podName,namespace, pod);

this is works if I will update the stateful set args but I need only for specific pod

is it possible?

-- Tuz
javascript
kubectl
kubernetes

1 Answer

6/21/2021

This is not possible. The whole point of using a StatefulSet is to have a bunch of Pods that are basically identical. It is the precise goal of the Controller Manager to reconcile the StatefulSet resource and ensure there are replicas number of Pods that match the StatefulSet spec.

If you want to have different pods you need to have different StatefulSets.

-- whites11
Source: StackOverflow