Monday 20 July 2020

Kubernetes: See the pod definition as yaml

Using ‘-o yaml’ option, you can see the pod definition as yaml.

 

Step 1: Let’s create a pod definition file and create the pod using the below definition file.

 

employeeServicePod.yml
apiVersion: v1
kind: Pod
metadata:
  name: employee-service
  labels:
    app: employee-service
    author: krishna
    serviceType: webservice
spec:
  containers:
    - name: employee-service-container
      image: jboss/wildfly

Create the pod by executing the below command.

kubectl create -f employeeServicePod.yml

$kubectl create -f employeeServicePod.yml
pod/employee-service created

You can query pods by executing ‘get pods’ command.

$kubectl get pods
NAME               READY   STATUS    RESTARTS   AGE
employee-service   1/1     Running   0          7s

Step 2: Let’s extract the pod definition using the option ‘-o yaml’

kubectl get pods {podName} -o yaml

$kubectl get pods employee-service -o yaml
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: "2020-06-11T04:48:53Z"
  labels:
    app: employee-service
    author: krishna
    serviceType: webservice
  managedFields:
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:metadata:
        f:labels:
          .: {}
          f:app: {}
          f:author: {}
          f:serviceType: {}
      f:spec:
        f:containers:
          k:{"name":"employee-service-container"}:
            .: {}
            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: kubectl
    operation: Update
    time: "2020-06-11T04:48:53Z"
  - 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":"172.17.0.7"}:
            .: {}
            f:ip: {}
        f:startTime: {}
    manager: kubelet
    operation: Update
    time: "2020-06-11T04:48:59Z"
  name: employee-service
  namespace: default
  resourceVersion: "399974"
  selfLink: /api/v1/namespaces/default/pods/employee-service
  uid: 04bfa9aa-70cd-4f61-9562-9235a5dbc4ea
spec:
  containers:
  - image: jboss/wildfly
    imagePullPolicy: Always
    name: employee-service-container
    resources: {}
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    volumeMounts:
    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      name: default-token-w7rp7
      readOnly: true
  dnsPolicy: ClusterFirst
  enableServiceLinks: true
  nodeName: minikube
  priority: 0
  restartPolicy: Always
  schedulerName: default-scheduler
  securityContext: {}
  serviceAccount: default
  serviceAccountName: default
  terminationGracePeriodSeconds: 30
  tolerations:
  - effect: NoExecute
    key: node.kubernetes.io/not-ready
    operator: Exists
    tolerationSeconds: 300
  - effect: NoExecute
    key: node.kubernetes.io/unreachable
    operator: Exists
    tolerationSeconds: 300
  volumes:
  - name: default-token-w7rp7
    secret:
      defaultMode: 420
      secretName: default-token-w7rp7
status:
  conditions:
  - lastProbeTime: null
    lastTransitionTime: "2020-06-11T04:48:53Z"
    status: "True"
    type: Initialized
  - lastProbeTime: null
    lastTransitionTime: "2020-06-11T04:48:59Z"
    status: "True"
    type: Ready
  - lastProbeTime: null
    lastTransitionTime: "2020-06-11T04:48:59Z"
    status: "True"
    type: ContainersReady
  - lastProbeTime: null
    lastTransitionTime: "2020-06-11T04:48:53Z"
    status: "True"
    type: PodScheduled
  containerStatuses:
  - containerID: docker://1650217eb9aa7e24990fd0e83d2435a085d8efa34da5253936700e6227c356a1
    image: jboss/wildfly:latest
    imageID: docker-pullable://jboss/wildfly@sha256:67a4f90b213bc2600d08d90e82df58be83813d118d163fbcc8765b6eeaade7e6
    lastState: {}
    name: employee-service-container
    ready: true
    restartCount: 0
    started: true
    state:
      running:
        startedAt: "2020-06-11T04:48:58Z"
  hostIP: 192.168.99.100
  phase: Running
  podIP: 172.17.0.7
  podIPs:
  - ip: 172.17.0.7
  qosClass: BestEffort
  startTime: "2020-06-11T04:48:53Z"



Previous                                                    Next                                                    Home

No comments:

Post a Comment