apiVersion : apps/v1 版本号,例如v1
kind:pod
metadata 元数据
- name: string pod名称
namespace: string 命名空间,默认default
labels 自定标签列表
- name: string
annotation 自定义注解列表
- name: string
spec: pod中容器的详细定义
containers pod容器列表
- name: string 容器名字
image: string 容器镜像名称
imagePullPolicy: Always<默认>, Never,<永不拉取> ifNotPresen<本地拉取镜像> 拉取策略
command: string 容器启动命令,如不指定,使用镜像打包时启动命令
args: string 容器启动命令参数列表
workingDir: string 容器工作目录
volumeMounts 挂载到容器内部的存储卷配置
- name: string 引用pod定义共享卷名称,需使用volumes部分定义的名称
mountPath: string 存储卷在容器内挂载的绝对路径
readOnly:boolean 是否读写模式,默认读写
ports 容器需要暴露的端口号
- name: string 端口名称
containerPort: int 容器需要监听的端口号
hostPort: int 宿主机需要监听端口号,默认与containerPort相同
protocol: string 端口协议,tcp udp 默认 tcp
env
- name: string 环境变量名称
value: string 环境变量值
resources 容器资源限制和资源请求设置
limits 资源限制设置
cpu: string
memory: string
requests 资源请求设置
cpu: string
memory: string
livenessProbe
exec 指定命令或脚本
command: [string]
httpGet 一种方式检查
path: string
port: string
host: string
httpHeaders
- name: string
value: string
tcpSocket
port: string
initialDelaySeconds:0 容器启动玩首次探测时间
timeoutSeconds:1 探测响应超出时间,认为不健康
periodSeconds:10 定期探测时间
restartPolicy:[Always Never OnFailure(非零退出码时重启)]
nodeSelector: object 设置Node的Label,pod调度到具有Label的Node上
imagePullSecrets pull镜像时使用Secret名称,以name:secretkey格式指定
- name: string
hostNetwork: false 是否使用主机网络,默认false,设置true,docker不使用网桥了
vloumes 共享卷列表
- name: string 共享卷名称需要volumeMounts定义名称相同
emptyDir: {} 临时目录
hostPath pod容器挂载宿主机目录
path: string
secret 挂载集群预定义的secret对象到容器内部
secretName: string
items
- key: string
path: string
configMap 挂载集群预定义的secret对象到容器内部
- name: string
items
- key: : string
path: string