查看pod创建时使用yaml文件内容

除了 kubectl describe pod 以外,另一种获取 Pod 额外信息(除了 kubectl get pod)的方法 是给 kubectl get pod 增加 -o yaml 输出格式参数。 该命令将以 YAML 格式为你提供比 kubectl describe pod 更多的信息 —— 实际上是系统拥有的关于 Pod 的所有信息。 在这里,你将看到注解(没有标签限制的键值元数据,由 Kubernetes 系统组件在内部使用)、 重启策略、端口和卷等。

# kubectl get pods my-mysql-556b66ff97-nt7c7 -n jeecg -o yaml        
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: "2021-04-28T03:31:12Z"
  generateName: my-mysql-556b66ff97-
  labels:
    app: my-mysql
    pod-template-hash: 556b66ff97
  managedFields:
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:metadata:
        f:generateName: {}
        f:labels:
          .: {}
          f:app: {}
          f:pod-template-hash: {}
        f:ownerReferences:
          .: {}
          k:{"uid":"f86e55f8-a7bb-4688-8157-c88d173e73ad"}:
            .: {}
            f:apiVersion: {}
            f:blockOwnerDeletion: {}
            f:controller: {}
            f:kind: {}
            f:name: {}
            f:uid: {}
      f:spec:
        f:containers:
          k:{"name":"my-mysql"}:
            .: {}
            f:env:
              .: {}
              k:{"name":"MYSQL_PASSWORD"}:
                .: {}
                f:name: {}
                f:value: {}
              k:{"name":"MYSQL_ROOT_PASSWORD"}:
                .: {}
                f:name: {}
                f:value: {}
              k:{"name":"MYSQL_USER"}:
                .: {}
                f:name: {}
                f:value: {}
            f:image: {}
            f:imagePullPolicy: {}
            f:name: {}
            f:ports:
              .: {}
              k:{"containerPort":3306,"protocol":"TCP"}:
                .: {}
                f:containerPort: {}
                f:name: {}
                f:protocol: {}
            f:resources:
              .: {}
              f:limits:
                .: {}
                f:cpu: {}
                f:memory: {}
              f:requests:
                .: {}
                f:cpu: {}
                f:memory: {}
            f:terminationMessagePath: {}
            f:terminationMessagePolicy: {}
            f:volumeMounts:
              .: {}
              k:{"mountPath":"/etc/mysql/mysql.conf.d"}:
                .: {}
                f:mountPath: {}
                f:name: {}
              k:{"mountPath":"/var/lib/mysql"}:
                .: {}
                f:mountPath: {}
                f:name: {}
        f:dnsPolicy: {}
        f:enableServiceLinks: {}
        f:restartPolicy: {}
        f:schedulerName: {}
        f:securityContext: {}
        f:terminationGracePeriodSeconds: {}
        f:volumes:
          .: {}
          k:{"name":"my-mysql-data"}:
            .: {}
            f:name: {}
            f:persistentVolumeClaim:
              .: {}
              f:claimName: {}
          k:{"name":"mysql-conf"}:
            .: {}
            f:configMap:
              .: {}
              f:defaultMode: {}
              f:name: {}
            f:name: {}
    manager: kube-controller-manager
    operation: Update
    time: "2021-04-28T03:31:12Z"
  - 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.0.1.129"}:
            .: {}
            f:ip: {}
        f:startTime: {}
    manager: kubelet
    operation: Update
    time: "2021-04-28T03:32:47Z"
  name: my-mysql-556b66ff97-nt7c7
  namespace: jeecg
  ownerReferences:
  - apiVersion: apps/v1
    blockOwnerDeletion: true
    controller: true
    kind: ReplicaSet
    name: my-mysql-556b66ff97
    uid: f86e55f8-a7bb-4688-8157-c88d173e73ad
  resourceVersion: "3966539"
  selfLink: /api/v1/namespaces/jeecg/pods/my-mysql-556b66ff97-nt7c7
  uid: a98940c0-208f-4e93-86fe-ba8439977ff7
spec:
  containers:
  - env:
    - name: MYSQL_ROOT_PASSWORD
      value: root
    - name: MYSQL_USER
      value: test
    - name: MYSQL_PASSWORD
      value: test
    image: mysql:8.0.23
    imagePullPolicy: IfNotPresent
    name: my-mysql
    ports:
    - containerPort: 3306
      name: http
      protocol: TCP
    resources:
      limits:
        cpu: 800m
        memory: 800Mi
      requests:
        cpu: 400m
        memory: 600Mi
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    volumeMounts:
    - mountPath: /var/lib/mysql
      name: my-mysql-data
    - mountPath: /etc/mysql/mysql.conf.d
      name: mysql-conf
    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      name: default-token-zp4x5
      readOnly: true
  dnsPolicy: ClusterFirst
  enableServiceLinks: true
  nodeName: develop-worker-1
  preemptionPolicy: PreemptLowerPriority
  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: my-mysql-data
    persistentVolumeClaim:
      claimName: my-mysql-data
  - configMap:
      defaultMode: 420
      name: mysql-conf
    name: mysql-conf
  - name: default-token-zp4x5
    secret:
      defaultMode: 420
      secretName: default-token-zp4x5
status:
  conditions:
  - lastProbeTime: null
    lastTransitionTime: "2021-04-28T03:31:12Z"
    status: "True"
    type: Initialized
  - lastProbeTime: null
    lastTransitionTime: "2021-04-28T03:32:47Z"
    status: "True"
    type: Ready
  - lastProbeTime: null
    lastTransitionTime: "2021-04-28T03:32:47Z"
    status: "True"
    type: ContainersReady
  - lastProbeTime: null
    lastTransitionTime: "2021-04-28T03:31:12Z"
    status: "True"
    type: PodScheduled
  containerStatuses:
  - containerID: docker://1e99303f3e6f1ead49da3d14e7a60456c655a038d79ba45d260ffb67d65b687b
    image: mysql:8.0.23
    imageID: docker-pullable://mysql@sha256:6e0014cdd88092545557dee5e9eb7e1a3c84c9a14ad2418d5f2231e930967a38
    lastState: {}
    name: my-mysql
    ready: true
    restartCount: 0
    started: true
    state:
      running:
        startedAt: "2021-04-28T03:32:46Z"
  hostIP: 192.168.2.165
  phase: Running
  podIP: 10.0.1.129
  podIPs:
  - ip: 10.0.1.129
  qosClass: Burstable
  startTime: "2021-04-28T03:31:12Z"
posted @ 2021-05-17 13:59  哈喽哈喽111111  阅读(1869)  评论(0编辑  收藏  举报