YAML文件配置模板
apiVersionv1 #必选,版本号,例如v1
kindPod #必选,Pod
metadata#必选,元数据
namestring #必选,Pod名称
namespacestring #必选,Pod所属的命名空间
labels#自定义标签
namestring #自定义标签名字
annotations#自定义注释列表
namestring
spec#必选,Pod中容器的详细定义
containers#必选,Pod中容器列表
namestring #必选,容器名称
imagestring #必选,容器的镜像名称
imagePullPolicyAlways | Never | IfNotPresent #获取镜像的策略 Alawys表示下载镜像 IfnotPresent表示优先使用本地镜像,否则下载镜像,Nerver表示仅使用本地镜像
commandstring #容器的启动命令列表,如不指定,使用打包时使用的启动命令
argsstring #容器的启动命令参数列表
workingDirstring #容器的工作目录
volumeMounts#挂载到容器内部的存储卷配置
namestring #引用pod定义的共享存储卷的名称,需用volumes[]部分定义的的卷名
mountPathstring #存储卷在容器内mount的绝对路径,应少于512字符
readOnlyboolean #是否为只读模式
ports#需要暴露的端口库号列表
namestring #端口号名称
containerPortint #容器需要监听的端口号
hostPortint #容器所在主机需要监听的端口号,默认与Container相同
protocolstring #端口协议,支持TCP和UDP,默认TCP
env#容器运行前需设置的环境变量列表
namestring #环境变量名称
valuestring #环境变量的值
resources#资源限制和请求的设置
limits#资源限制的设置
cpustring #Cpu的限制,单位为core数,将用于docker run --cpu-shares参数
memorystring #内存限制,单位可以为Mib/Gib,将用于docker run --memory参数
requests#资源请求的设置
cpustring #Cpu请求,容器启动的初始可用数量
memorystring #内存清楚,容器启动的初始可用数量
livenessProbe#对Pod内个容器健康检查的设置,当探测无响应几次后将自动重启该容器,检查方法有exec、httpGet和tcpSocket,对一个容器只需设置其中一种方法即可
exec#对Pod容器内检查方式设置为exec方式
commandstring #exec方式需要制定的命令或脚本
httpGet#对Pod内个容器健康检查方法设置为HttpGet,需要制定Path、port
pathstring
portnumber
hoststring
schemestring
HttpHeaders
namestring
valuestring
tcpSocket#对Pod内个容器健康检查方式设置为tcpSocket方式
portnumber
initialDelaySeconds0 #容器启动完成后首次探测的时间,单位为秒
timeoutSeconds0 #对容器健康检查探测等待响应的超时时间,单位秒,默认1秒
periodSeconds0 #对容器监控检查的定期探测时间设置,单位秒,默认10秒一次
successThreshold0
failureThreshold0
securityContext
privileged:false
restartPolicyAlways | Never | OnFailure#Pod的重启策略,Always表示一旦不管以何种方式终止运行,kubelet都将重启,OnFailure表示只有Pod以非0退出码退出才重启,Nerver表示不再重启该Pod
nodeSelectorobeject #设置NodeSelector表示将该Pod调度到包含这个label的node上,以key:value的格式指定
imagePullSecrets#Pull镜像时使用的secret名称,以key:secretkey格式指定
namestring
hostNetwork:false #是否使用主机网络模式,默认为false,如果设置为true,表示使用宿主机网络
volumes#在该pod上定义共享存储卷列表
namestring #共享存储卷名称 (volumes类型有很多种)
emptyDir #类型为emtyDir的存储卷,与Pod同生命周期的一个临时目录。为空值
hostPathstring #类型为hostPath的存储卷,表示挂载Pod所在宿主机的目录
pathstring #Pod所在宿主机的目录,将被用于同期中mount的目录
secret#类型为secret的存储卷,挂载集群与定义的secre对象到容器内部
scretnamestring
items
keystring
pathstring
configMap#类型为configMap的存储卷,挂载预定义的configMap对象到容器内部
namestring
items
keystring
pathstring










