How to edit the command line argument to sleep for 2000 edit? "kubectl edit pod . . .

Nav:
How to edit the command line argument to sleep for 2000 edit? “kubectl edit pod” not working.

root@controlplane:~# kubectl describe pod ubuntu-sleeper-3 
Name:         ubuntu-sleeper-3
Namespace:    default
Priority:     0
Node:         controlplane/10.1.234.3
Start Time:   Wed, 18 Aug 2021 02:46:56 +0000
Labels:       <none>
Annotations:  <none>
Status:       Running
IP:           10.244.0.7
IPs:
  IP:  10.244.0.7
Containers:
  ubuntu:
    Container ID:  <docker://ab1e1666a2a51d0e319a4b2a667edff913d0d56e0f293fa9b5c4f5c57404b59>4
    Image:         ubuntu
    Image ID:      <docker-pullable://ubuntu@sha256:82>becede498899ec668628e7cb0ad87b6e1c371cb8a1e597d83a47fac21d6af3
    Port:          &lt;none&gt;
    Host Port:     &lt;none&gt;
    Command:
      sleep
      1200
    State:          Running
      Started:      Wed, 18 Aug 2021 02:46:59 +0000
    Ready:          True
    Restart Count:  0
    Environment:    &lt;none&gt;
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-cq9qg (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  default-token-cq9qg:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-cq9qg
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  &lt;none&gt;
Tolerations:     <http://node.kubernetes.io/not-ready:NoExecute|node.kubernetes.io/not-ready:NoExecute> op=Exists for 300s
                 <http://node.kubernetes.io/unreachable:NoExecute|node.kubernetes.io/unreachable:NoExecute> op=Exists for 300s
Events:
  Type    Reason     Age    From               Message
  ----    ------     ----   ----               -------
  Normal  Scheduled  6m43s  default-scheduler  Successfully assigned default/ubuntu-sleeper-3 to controlplane
  Normal  Pulling    6m41s  kubelet            Pulling image "ubuntu"
  Normal  Pulled     6m41s  kubelet            Successfully pulled image "ubuntu" in 255.729128ms
  Normal  Created    6m41s  kubelet            Created container ubuntu
  Normal  Started    6m40s  kubelet            Started container ubuntu
root@controlplane:~# kubectl edit pods ubuntu-sleeper-3
error: pods "ubuntu-sleeper-3" is invalid
A copy of your changes has been stored to "/tmp/kubectl-edit-zgx6p.yaml"
error: Edit cancelled, no valid changes were saved.
root@controlplane:~# 

Tej_Singh_Rana:
Hello, @Nav
As you can see in the last line.
> A copy of your changes has been stored to “/tmp/kubectl-edit-zgx6p.yaml”
Simply run the kubectl replace command. It will delete existing one and recreate new one with changes.

kubectl replace -f /tmp/kubectl-edit-zgx6p.yaml --force
1 Like

Tej_Singh_Rana:
We can’t change values for immutable fields.

Nav:
@Tej_Singh_Rana thanks. IT works