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

Dave McLean:
Hi all

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

I get a very verbose output which makes it hard to see the important stuff and hard to compare my answer and the correct answer.
What am I doing wrong?

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: "2021-07-05T16:39:31Z"
  managedFields:
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:spec:
        f:containers:
          k:{"name":"ubuntu"}:
            .: {}
            f:command: {}
            f:image: {}
            f:imagePullPolicy: {}
            f:name: {}
            f:resources: {}
            f:terminationMessagePath: {}
            f:terminationMessagePolicy: {}
        f:dnsPolicy: {}
        f:enableServiceLinks: {}
        f:restartPolicy: {}
        f:schedulerName: {}
        f:securityContext: {}
        f:terminationGracePeriodSeconds: {}
    manager: python-requests
    operation: Update
    time: "2021-07-05T16:39:31Z"
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:status:
        f:conditions:
          k:{"type":"ContainersReady"}:
            .: {}
            f:lastProbeTime: {}
            f:lastTransitionTime: {}
            f:status: {}
            f:type: {}
          k:{"type":"Initialized"}:
            .: {}
            f:lastProbeTime: {}
            f:lastTransitionTime: {}
            f:status: {}
            f:type: {}
          k:{"type":"Ready"}:
            .: {}
            f:lastProbeTime: {}
            f:lastTransitionTime: {}
            f:status: {}
            f:type: {}
        f:containerStatuses: {}
        f:hostIP: {}
        f:phase: {}
        f:podIP: {}
        f:podIPs:
          .: {}
          k:{"ip":"10.244.1.4"}:
            .: {}
            f:ip: {}
        f:startTime: {}
    manager: kubelet
    operation: Update
    time: "2021-07-05T16:39:40Z"
  name: ubuntu-sleeper
  namespace: default
  resourceVersion: "911"
  selfLink: /api/v1/namespaces/default/pods/ubuntu-sleeper
  uid: c0ebcc54-1125-4356-99c6-c14edb997e85
spec:
  securityContext:
    runAsUser: 1010
  containers:
  - command:
    - sleep
    - "4800"
    image: ubuntu
    imagePullPolicy: Always
    name: ubuntu
    resources: {}
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    volumeMounts:
    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      name: default-token-m6v69
      readOnly: true
  dnsPolicy: ClusterFirst
  enableServiceLinks: true
  nodeName: node01
  preemptionPolicy: PreemptLowerPriority
  priority: 0
  restartPolicy: Always
  schedulerName: default-scheduler
  securityContext: {}
  serviceAccount: default
  serviceAccountName: default
  terminationGracePeriodSeconds: 30
  tolerations:
  - effect: NoExecute
    key: <http://node.kubernetes.io/not-ready|node.kubernetes.io/not-ready>
    operator: Exists
    tolerationSeconds: 300
  - effect: NoExecute
    key: <http://node.kubernetes.io/unreachable|node.kubernetes.io/unreachable>
    operator: Exists
    tolerationSeconds: 300
  volumes:
  - name: default-token-m6v69
    secret:
      defaultMode: 420
      secretName: default-token-m6v69
status:
  conditions:
  - lastProbeTime: null
    lastTransitionTime: "2021-07-05T16:39:30Z"
    status: "True"
    type: Initialized
  - lastProbeTime: null
    lastTransitionTime: "2021-07-05T16:39:39Z"
    status: "True"
    type: Ready
  - lastProbeTime: null
    lastTransitionTime: "2021-07-05T16:39:39Z"
    status: "True"
    type: ContainersReady
  - lastProbeTime: null
    lastTransitionTime: "2021-07-05T16:39:31Z"
    status: "True"
    type: PodScheduled
  containerStatuses:
  - containerID: <docker://6eeae445be2c52a4dfa4af63b953a192acd3ce24c0935cd00384868c522bf57>7
    image: ubuntu:latest
    imageID: <docker-pullable://ubuntu@sha256>:aba80b77e27148d99c034a987e7da3a287ed455390352663418c0f2ed40417fe
    lastState: {}
    name: ubuntu
    ready: true
    restartCount: 0
    started: true
    state:
      running:
        startedAt: "2021-07-05T16:39:39Z"
  hostIP: 172.17.0.25
  phase: Running
  podIP: 10.244.1.4
  podIPs:
  - ip: 10.244.1.4
  qosClass: BestEffort
  startTime: "2021-07-05T16:39:30Z"

Hinodeya:
hey @Dave McLean try this kubectl get po my-pod --dry-run=client -o yaml > pod.yaml

Hinodeya:
if you would like to add args kubectl get po my-pod --dry-run=client -o yaml – sleep “3600” > mypod.yaml

Dave McLean:
I don’t think that’s a valid command - you can’t do a --dry-run of a get

Hinodeya:
Oh sorry I cannot see the get lol

Hinodeya:
Your command is correct it’s normally that you have a lot of items let me check a old post to manage them

Dave McLean:
what’s the intended way to edit a pod if a definition yaml file isn’t provided?

Hinodeya:
why it would be not provided :wink:

Hinodeya:
you can edit the pod and it would generated file in tmp

Hinodeya:
or generated a dump as mentionned above

Dave McLean:
> why it would be not provided
It is often not provided.

Dave McLean:
for example in CKAD lecture 52 - security contexts

Hinodeya:
You’have always a manifest binding to your pod so it provided or not

Dave McLean:
ah. what’s a manifest binding? and how do I access it?

Hinodeya:
The question is mostly how can you generated

Hinodeya:
On the node man

Madhan Kumar:
its not that tough you, can just skip everything under managedFields: and status: and look into the spec: section only…

Hinodeya:
for you @Madhan Kumar but @Dave McLean discover K8S I think :wink:

Hinodeya:
But yes when you manage well the manifest you’are really don’t care about verbose items :wink:

Dave McLean:
> its not that tough you,
I’m finding it quite hard to compare what I’ve written to the “answer” or to any k8s docs. It seems like I’m not doing things the intended way, is there a better way?