Pod 相关标签

Pod相关标签

Pod的Yaml

{
    "metadata": {
        "name": "",//Pod名称
        "generateName": "",
        "namespace": , //名称空间
        "selfLink": "",
        "uid": "",
        "resourceVersion": "",
        "creationTimestamp": "2021-07-31T02:52:12Z", //创建时间
        "labels": {//标签
            "app": "nginx",
            "k8s.kuboard.cn/layer": "web",
        },
        "annotations": {//注释
            "cni.projectcalico.org/podIP": "1.1.7.192/32",
            "cni.projectcalico.org/podIPs": "1.1.7.194/32"
        },
        "ownerReferences": [
            {
                "apiVersion": "apps/v1",
                "kind": "ReplicaSet",
                "name": "",
                "uid": "",
                "controller": true,
                "blockOwnerDeletion": true
            }
        ]
    },
    "spec": {
        "volumes": [//存储卷
            {
                "name": "configmap", -- 数据卷名称
                "configMap": { -- 数据卷ConfigMap类型
                    "name": "cmtest", -- 数据卷名称
                    "items": [
                        {
                            "key": "mycm",
                            "path": "map"
                        }
                    ],
                    "defaultMode": 420// configmap类型
                }
            },
            {
                "name": "secret",  -- 数据卷名称
                "secret": {-- 数据卷secret类型
                    "secretName": "wordpress-secret",-- secret名称
                    "items": [
                        {
                            "key": "WORDPRESS_DB_PASSWORD",
                            "path": "sc"
                        }
                    ],
                    "defaultMode": 420// secret类型   
                }
            },
            {
                "name": "pvc",  -- 数据卷名称
                "persistentVolumeClaim": { -- 存储卷声明类型
                    "claimName": "wordpress-pvc"
                }
            },
            {
                "name": "default-token-tt5tt",
                "secret": {
                    "secretName": "default-token-tt5tt",
                    "defaultMode": 420
                }
            }
        ],
        "containers": [ //containers为工作容器
            {
                "name": "nginx", //容器名称
                "image": "nginx:1.12", //镜像名称
                "resources": {
                    "limits": {
                        "cpu": "600m",//cpu最大值
                        "memory": "300M"//内存最大值
                    },
                    "requests": {
                        "cpu": "500m",//cpu最小值
                        "memory": "200M" //内存小值
                    }
                },
                "volumeMounts": [//挂载点
                    {
                        "name": "configmap",
                        "mountPath": "/opt/cm"//容器内目标路径
                    },
                    {
                        "name": "secret",
                        "mountPath": ""
                    },
                    {
                        "name": "pvc",
                        "mountPath": "/opt/pvc"
                    },
                    {
                        "name": "",
                        "readOnly": true,
                        "mountPath": ""
                    }
                ],
                "terminationMessagePath": "",
                "terminationMessagePolicy": "File",
                "imagePullPolicy": "Always"
            }
        ],
        "restartPolicy": "Always", //重启策略
        "terminationGracePeriodSeconds": 30,         //终止等待时间
        "dnsPolicy": "ClusterFirst",    //DNS Policy  ClusterFirstWithHostNet、ClusterFirst、Default、None
        "serviceAccountName": "default",    //serviceAccountName
        "serviceAccount": "default",     //serviceAccount
        "nodeName": "", //所在节点
        "securityContext": {},
        "schedulerName": "default-scheduler",
        "tolerations": [
            {
                "key": "node.kubernetes.io/not-ready",  //容忍名称
                "operator": "Exists",    //操作 Exists,Equal
                "effect": "NoExecute",   //NoSchedule、PreferNoSchedule、NoExecute 、默认所有
                "tolerationSeconds": 300    //操作时间
            },
            {
                "key": "node.kubernetes.io/unreachable",
                "operator": "Exists",
                "effect": "NoExecute",
                "tolerationSeconds": 300
            }
        ],
        "priority": 0,
        "dnsConfig": {},
        "enableServiceLinks": true,
        "preemptionPolicy": "PreemptLowerPriority"
    },
    "status": {
        "phase": "Running",
        "conditions": [
            {
                "type": "Initialized",
                "status": "True",
                "lastProbeTime": null,
                "lastTransitionTime": ""
            },
            {
                "type": "Ready",
                "status": "True",
                "lastProbeTime": null,
                "lastTransitionTime": ""
            },
            {
                "type": "ContainersReady",
                "status": "True",
                "lastProbeTime": null,
                "lastTransitionTime": ""
            },
            {
                "type": "PodScheduled",
                "status": "True",
                "lastProbeTime": null,
                "lastTransitionTime": ""
            }
        ],
        "hostIP": "",       //主机IP
        "podIP": "",        //容器组IP
        "podIPs": [
            {
                "ip": ""
            }
        ],
        "startTime": "",         //开始时间
        "containerStatuses": [        //容器
            {
                "name": "nginx",
                "state": {        //容器状态 分为["running","waiting","terminated"],
                    "running": {
                        "startedAt": ""
                    }
                },
                "lastState": {},
                "ready": true, //就绪状态
                "restartCount": 0,
                "image": "docker.io/library/nginx:1.12",
                "imageID": "",
                "containerID": "",
                "started": true
            }
        ],
        "qosClass": "Burstable"
    }
}

环境变量不同类型详情

关于容器组信息

  • metadata.name类型
{
  "env":[
  {
    "name": "aviliage",
    "valueFrom": {
      "fieldRef": {
        "apiVersion": "v1",
        "fieldPath": "metadata.name"
      }
    }
  }]
}
  • spec.nodeName类型
{
  "env":[
  {
    "name": "aviliage",
    "valueFrom": {
      "fieldRef": {
        "apiVersion": "v1",
        "fieldPath": "spec.nodeName"
      }
    }
  }]
}
  • status.hostIP类型
{
  "env":[
  {
    "name": "aviliage",
    "valueFrom": {
      "fieldRef": {
        "apiVersion": "v1",
        "fieldPath": "status.podIP"
      }
    }
  }]
}

关于资源信息

{
  "env":[
  {
    "name": "aviliage",
    "valueFrom": {
      "resourceFieldRef": {
        "resource": "requests.cpu",
        "divisor": "",
      }
    }
  }]
}

关于ComfigMap

{
  "env":[
  {
    "name": "aviliage",
    "valueFrom": {
      "configMapKeyRef": {
        "name": "special-config",  //configmap名称
        "key": "special.how"   
      }
    }
  }]
}

关于Secret

{
  "env":[
  {
    "name": "aviliage",
    "valueFrom": {
      "secretKeyRef": {
        "name": "special-config",  //secret名称
        "key": "special.how"   
      }
    }
  }]
}

关于环境变量配置的请求

{
  "env":[
  {
    "name": "aviliage",
    "valueFrom": {
      "secretKeyRef": {
        "name": "special-config",  //secret名称
        "key": "special.how"   
      }
    }
  }]
}

关于环境变量配置的请求

{
  "envFrom": [
    {
      "configMapRef":{
        "name":"envfrom-config" \\configmap名称
      }
    }
  ]
}

Pod Volume不同类型详情描述

  • emptyDir类型
{
  "volumes": [ //存储卷
    {
      "emptyDir": {},   -- 数据卷EmptyDir类型
      "name": "volume1"  -- 数据卷名称
    },
  ],
}
  • Secret类型
{
  "volumes": [
     {
      "name": "volume4", // 数据卷名称
      "secret": { //数据卷secret类型
        "items": [
          {
            "key": "admin",
            "path": "usr/local"
          }
        ],
        "secretName": "test-secret" //secret名称
        "defaultMode": 420
      }
    }
  ]
}
  • HostPath类型
{"volumes": [ 
        {
          "hostPath": {   -- 数据卷HostPath类型
            "path": "/usr/local",
            "type": ""
          },
          "name": "volume2"  -- 数据卷名称
        },
      ],
}
  • ConfigMap类型
{
  "volumes": [ //存储卷
    {
      "configMap": {  -- 数据卷ConfigMap类型
        "items": [
          {
            "key": "user",
            "path": "usr/log"
          }
        ],
        "name": "testconfigmap"  -- 数据卷名称
      },
      "name": "volume3"
    },
  ],
}
  • Nfs类型
{
  "volumes": [ //存储卷
    {
      "name": "volume0",  -- 数据卷名称
      "nfs": {  -- 数据卷NFS类型
        "path": "/usr/local",
        "server": "http://localhost:8080/"
      }
    }
  ]
}
  • PersistentVolumeClaim类型
{
  "volumes": [ //存储卷
    {
      "name": "volume5",  -- 数据卷名称
      "persistentVolumeClaim": {   -- 存储卷声明类型
        "claimName": "test-volume"
      }
    }
  ]
}

容器 Volume Mount 不同类型详情

{
  "volumeMounts": [
    {
      "mountPath": "/root", //容器内目标路径
      "mountPropagation": "HostToContainer", //确定容器挂载方式 ["None","HostToContainer","Bidirectional"]
      "name": "test-volume", //选择的卷名称
      "readOnly": true,  //是否只读
      "subPath": "usr/log", //父路径
      "subPathExpr": "",
    }
  ]
}

就绪检查不同类型详情

就绪检查类型分为: ["httpGet","tcpSocket","exec"]

  • HttpGet类型详情
 {
  "readinessProbe": {
    "failureThreshold": 3,    // 不健康阈值
    "initialDelaySeconds": 5,     // 延迟探测时间
    "periodSeconds": 10,    // 执行探测频率
    "successThreshold": 1,     // 健康阈值
    "httpGet": {        // TCP 连接
      "host": "111.168.0.1", //检测地址
      "path": "/", //路径
      "port": ,   //端口
      "scheme": "HTTPS",  //协议
      "httpHeaders": [
        {
          "name": "", //headers 名称
          "value": "",  //headers value
        }
      ]
    },
    "timeoutSeconds": 1       //超时时间
  }
}
  • TcpSocket类型详情
 {
  "readinessProbe": {
    "failureThreshold": 3,    // 不健康阈值
    "initialDelaySeconds": 5,     // 延迟探测时间
    "periodSeconds": 10,    // 执行探测频率
    "successThreshold": 1,     // 健康阈值
    "tcpSocket": {        // TCP 连接
      "host": "111.168.0.1",  //地址
      "port": 8080        //端口
    },
    "timeoutSeconds": 1       //超时时间
  }
}
  • Exec类型详情
 {
  "readinessProbe": {
    "failureThreshold": 3,    // 不健康阈值
    "initialDelaySeconds": 5,     // 延迟探测时间
    "periodSeconds": 10,    // 执行探测频率
    "successThreshold": 1,     // 健康阈值
    "exec": {
      "command": [
        "/bin/bash",
        "/tmp/test.sh"
      ],
    },
    "timeoutSeconds": 1       //超时时间
  }
}

存活检查不同类型详情

存活检查类型分为: ["httpGet","tcpSocket","exec"]

  • HttpGet类型详情
{
  "livenessProbe": {
    "failureThreshold": 3,    // 不健康阈值
    "initialDelaySeconds": 5,     // 延迟探测时间
    "periodSeconds": 10,    // 执行探测频率
    "successThreshold": 1,     // 健康阈值
    "httpGet": {        // TCP 连接
      "host": "111.168.0.1", //检测地址
      "path": "/", //路径
      "port": ,   //端口
      "scheme": "HTTPS",  //协议
      "httpHeaders": [
        {
          "name": "", //headers 名称
          "value": "",  //headers value
        }
      ]
    },
    "timeoutSeconds": 1       //超时时间
  }
}
  • TcpSocket类型详情
 {
  "livenessProbe": {
    "failureThreshold": 3,    // 不健康阈值
    "initialDelaySeconds": 5,     // 延迟探测时间
    "periodSeconds": 10,    // 执行探测频率
    "successThreshold": 1,     // 健康阈值
    "tcpSocket": {        // TCP 连接
      "host": "111.168.0.1",  //地址
      "port": 8082        //端口
    },
    "timeoutSeconds": 1       //超时时间
  }
}

  • Exec类型详情
{
  "livenessProbe": {
    "failureThreshold": 3,    // 不健康阈值
    "initialDelaySeconds": 5,     // 延迟探测时间
    "periodSeconds": 10,    // 执行探测频率
    "successThreshold": 1,     // 健康阈值
    "exec": {
      "command": [
        "/bin/bash",
        "/tmp/test.sh"
      ],
    },
    "timeoutSeconds": 1       //超时时间
  }
}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容