Hi all When I do: `kubectl get pod my-pod -o yaml > pod-definition.yaml` I . . .

Hinodeya:
@Dave McLean no Only hard way Exists Go practice :wink:

Dave McLean:
Or is the intention that we just write the yaml out by hand?

Hinodeya:
During the exam you’re really know in two hours you have a time to manage the manifest really no man

Hinodeya:
depend what do you need in the netpol pv pvc pod binding pvc you refer to the doc and copy past

Hinodeya:
It always the question of the time to win

Hinodeya:
Just focus of the structure of manifest take a exemple with deploy

Hinodeya:
https://kubernetes.io/docs/reference/kubectl/cheatsheet/

Madhan Kumar:
practice and you will get used to it …

Ashok Kumar:
If you are not interested in seeing those f: you can use

kubectl get po my-pod -o yaml | grep -v 'f:' > pod-definition.yaml

This will omit all unwanted fields and easy to understand

Dave McLean:
thanks @Ashok Kumar useful answer.

I still feel like I’m missing something. For example in lesson2 topic 4 the question is:

Edit the pod 'ubuntu-sleeper' to run the sleep process with user ID 1010.

What’s the intended way to complete this task?
I can see that I could dump the yaml and grep not-matching f but what’s the intended way to do it?

kubectl edit pod … etc.

gives me permission errors because you cannot edit the security context of a running pod I believe.

Madhan Kumar:
kubectl edit pod ubuntu-sleeper -> this will open the spec in vi editor , make your changes , then save the file :wq , it will not save , then use :q! , you will get a tmp file … then use the temp file with the replace command . kubectl replace -f temp.yaml --force

Dave McLean:
thank you very much @Madhan Kumar

Dave McLean:
last question if I may….

I can set extra capabilities at the container level like this:

containers:
- command: 
  securityContext:
      capabilities:
        add: ["SYS_TIME"]

but if I try to do the same at the pod level capabilities isn’t valid.

spec:
  securityContext:
    capabilities:
      add: ["SYS_TIME"]

is there a way to add capabilities at the pod level?

madhusmita:
Even I face the same issue.

Dave McLean:
good to know it’s not just me!

That is changed with kubectl v1.21
https://github.com/kubernetes/kubernetes/pull/96878