Hi Team, Does anyone know if we export yamls in CKAD exam , do we get metadata.m . . .

HITESH RATHOD:
Hi Team,
Does anyone know if we export yamls in CKAD exam , do we get metadata.managedFields as well ? if yes how can we get the neat and clean k8’s object yamls exported , please advise

Mohamed Ayman:
Yes, you will need to use imperative commands and export YAML to save time in the exam. These additional fields in the new version of kubernetes.

Mohamed Ayman:
You can only exclude using grep command to decrease the file:
kubectl get pod nginx -o yaml | grep -v "f:" > pod.yaml

Basavraj Nilkanthe:
@Mohamed Ayman I dont see much difference between this approach and i have get YAML file without using grep -v “f:” and with using grep -v “f:”

Basavraj Nilkanthe:

kubectl get pod nginx -o yaml > definitation.yaml

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: "2021-01-22T03:47:31Z"
  labels:
    run: nginx
  name: nginx
  namespace: default
  resourceVersion: "1038909"
  selfLink: /api/v1/namespaces/default/pods/nginx
  uid: bcbe9204-4db0-4600-b2a0-71f225f90b01
spec:
  containers:
  - image: nginx
    imagePullPolicy: Always
    name: nginx
    resources: {}
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    volumeMounts:
    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      name: default-token-n747h
      readOnly: true
  dnsPolicy: ClusterFirst
    enableServiceLinks: true
  nodeName: gke-ckad-sunday-default-pool-76c7fedf-r6c4
  priority: 0
  restartPolicy: Never
  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-n747h
    secret:
      defaultMode: 420
      secretName: default-token-n747h
status:
  conditions:
  - lastProbeTime: null
    lastTransitionTime: "2021-01-22T03:47:31Z"
    status: "True"
        type: Initialized
  - lastProbeTime: null
    lastTransitionTime: "2021-01-22T03:47:33Z"
    status: "True"
    type: Ready
  - lastProbeTime: null
    lastTransitionTime: "2021-01-22T03:47:33Z"
    status: "True"
    type: ContainersReady
  - lastProbeTime: null
    lastTransitionTime: "2021-01-22T03:47:31Z"
    status: "True"
    type: PodScheduled
  containerStatuses:
  - containerID: <docker://4e2ef7d7176dade0ae7aa1b5b545b8b8e37348bda259fccd3b98b62391d72ffa>
    image: nginx:latest
    imageID: <docker-pullable://nginx@sha256:10b8cc432d56da8b61b070f4c7d2543a9ed17c2b23010b43af434fd40e2ca4aa>
    lastState: {}
    name: nginx
    ready: true
    restartCount: 0
    started: true
    state:
      running:
        startedAt: "2021-01-22T03:47:32Z"
  hostIP: 10.128.0.32
  phase: Running
    podIP: 10.112.2.14
  podIPs:
  - ip: 10.112.2.14
  qosClass: BestEffort
  startTime: "2021-01-22T03:47:31Z"

---

kubectl get pod nginx -o yaml | grep -v "f:" &gt; pod55.yaml

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: "2021-01-22T03:47:31Z"
  labels:
    run: nginx
  name: nginx
  namespace: default
  resourceVersion: "1038909"
  selfLink: /api/v1/namespaces/default/pods/nginx
  uid: bcbe9204-4db0-4600-b2a0-71f225f90b01
spec:
  containers:
  - image: nginx
    imagePullPolicy: Always
    name: nginx
    resources: {}
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    volumeMounts:
    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      name: default-token-n747h
      readOnly: true
  dnsPolicy: ClusterFirst
  enableServiceLinks: true
  nodeName: gke-ckad-sunday-default-pool-76c7fedf-r6c4
  priority: 0
  restartPolicy: Never
  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-n747h
    secret:
      defaultMode: 420
      secretName: default-token-n747h
status:
  conditions:
  - lastProbeTime: null
    lastTransitionTime: "2021-01-22T03:47:31Z"
    status: "True"
      type: Initialized
  - lastProbeTime: null
    lastTransitionTime: "2021-01-22T03:47:33Z"
    status: "True"
    type: Ready
  - lastProbeTime: null
    lastTransitionTime: "2021-01-22T03:47:33Z"
    status: "True"
    type: ContainersReady
  - lastProbeTime: null
    lastTransitionTime: "2021-01-22T03:47:31Z"
    status: "True"
    type: PodScheduled
  containerStatuses:
  - containerID: <docker://4e2ef7d7176dade0ae7aa1b5b545b8b8e37348bda259fccd3b98b62391d72ffa>
    image: nginx:latest
    imageID: <docker-pullable://nginx@sha256:10b8cc432d56da8b61b070f4c7d2543a9ed17c2b23010b43af434fd40e2ca4aa>
    lastState: {}
    name: nginx
    ready: true
    restartCount: 0
    started: true
    state:
      running:
        startedAt: "2021-01-22T03:47:32Z"
  hostIP: 10.128.0.32
  phase: Running
    podIP: 10.112.2.14
  podIPs:
  - ip: 10.112.2.14
  qosClass: BestEffort
  startTime: "2021-01-22T03:47:31Z"

HITESH RATHOD:
Thanks for the response @Mohamed Ayman ill try to use as much as possible imperative commands but in some cases we may need to export yaml and this addtional metadata makes yaml too long