Kubernetes之pod的属性

属性名称 取值类型                   是否必选 取值说明
version String Required(必) 版本号,例如v1
kind String Required pod
metadata Object Required 元数据
metadata.name String Required pod的名称,命名规范须符合RFC 1035规范
metadata.namespace String Required pod的所属命名空间,默认值为default
metadata.labels[] List   自定义便签列表
metadata.annotation[] List   自定义注解列表
Spec Object Required pod中容器的详细定义
spec.containers[] List Required Pod容器列表
spec.containers[].name String Required 容器名称
spec.containers[].image String Required 容器镜像名称
spec.containers[].imagePullPolicy String  

获取镜像策略,可选值包括:Always、Never、IfNOtPresent,默认值为Always 

Always:表示每次都尝试重新下载镜像

IfNotPresent:表示如果本地有镜像,使用本地镜像,本地镜像不存在时下载镜像

Never:表示仅使用本地镜像

spec.containers[].command[] List   容器启动命令列表,如果不指定,则使用镜像打包是的启动命令
spec.containers[].args[] List   容器启动命令参数列表
spec.containers[].workingDir String   容器工作目录
spec.containers[].volumeMounts[] List   挂载到容器内部的存储卷配置
spec.containers[].volumeMounts[].name String  

引用Pod定义的共享存储名称,需要使用volumes[]部分定义的共享存储名称

spec.containers[].volumeMounts[].mountPath String   存储卷在容器内Mount的绝对路径,应少于512字符

spec.containers[].volumeMounts[].readOnly

string   是否为只读模式,默认读写模式
spec.containers[].ports[] list   容器需要暴露端口号列表
spec.containers[].ports[].name String   端口名称

spec.containers[].ports[].containerPort

lnt   容器需要监听的端口号
spec.containers[].ports[].hostPort Int   容器所在主机需要监听的端口号,默认与containerPort相同。设置hostPost时,同一台主机无法启动该容器的第二个副本
spec.containers[].ports[].protocol String   端口协议,支持TCP和UDP,默认TCP
spec.containers[].env[] list   容器运行前需要设置的环境变量列表
spec.containers[].env[].name String   环境变量的名称
spec.containers[].env[].value String   环境变量值
spec.containers[].resources Object   资源限制和资源请求的请求设置
spec.containers[].resources.limits Object   资源限定的设置
spec.containers[].resources.limits.cpu String   CPU限制,单位为core数,将用于 docker run  --cpu-shares参数
spec.containers[].resources.limits.memory String   内存限制,单位为MIB/GiB等,将用于docker run --memory参数
spec.containers[].resources.requests Object   容器初始化的资源限制设置
spec.containers[].resources.requests.cpu String   CPU请求,单位为core数,容器启动时初始化可用数量
spec.containers[].resources.requests.memory String   内存请求,单位为MIB、GiB容器启动的初始化可用数量
spec.volumes[] list   在该Pod定义共享存储列表
spec.volumes[].name String  

共享存储卷的名称;在同一个Pod中每个存储卷定义一个名称,应符合RFC 1035规范。容器定义部分的containers[].

volumeMount[].name将引用该存储卷法人名称

spec.volumes[].emptyDir Object   类型为emptyDir的存储卷,表示与pod同生命周期的一个临时目录,其值为一个空对象:emptyDir
spec.volumes[].hostPath.path String   类型为hostpash的存储卷,表示挂着pod所在宿主机的目录
spec.volumes[].secret Object   类型为secret的存储卷,表示挂载集群预定义的secret对象到容器内部

spec.volumes[].configMap

Object   类型为configMap的存储卷,表示挂载集群预定义的configMap对象到容器内部
spec.volumes[].livenessProbe Object  

对pod内容器设置健康状态检查的设置,当探测几次无响应后,系统自动重启该容器。可以设置的方法包括:exec、httpGet、

和tcpSocket。对一个容器仅设置一种健康检查方法

spec.volumes[].livenessProbe.exec Object   对pod内部健康状态检查设置exec方式
spec.volumes[].livenessProbe.exec.command[] String   exec 需要指定的命令或者脚本
spec.volumes[].livenessProbe.httpGet Object   对Pod内个容器健康状态检查,设置HTTPGet方式。需要指定Path、pod
spec.volumes[].livenessProbe.tcpSocket Object   对pod内各个容器健康检查的设置,tcpSocket方式
spec.volumes[].livenessProbe.initialDelaySeconds Number   容器启动完成后进行首次探测的时间,单位为s
spec.volumes[].livenessProbe.timeoutSeconds Number   对容器健康状态检查的等待响应的超时时间。单位为s,默认为1s,超过该超时时间设置,将认为该容器不健康,将重启容器
spec.volumes[].livenessProbe.periodSeconds Number   对容器健康检查的定期时间设置,单位为s默认为10s探测一次
spec.restartPolicy String  

pod的重启策略,可选值为Always、OnFailure、默认值Always

Always:pod一旦停止运行,则无论容器是如何终止的。kubelet都将它重启

OnFailure:只有pod以非零吗终止时,kubelet才会重启容器,如果正常退出则不会重启

Never:pod终止后将该pod退出吗;报告给Master,不会再重启pod

spec.nodeSelector Object   设置NodeSelector表示将该pod调度到包含这些label的Node上。以key:value格式指定
spec.imagePullSecret  Object    pull镜像时使用secret名称,以name:secretkey.格式指定
 spec.hostNetwork  Boolean  

是否使用主机网络模式,默认值为false.。如果设置为true,则表示容器使用宿主机网络,使用Docker网桥,该pod将无法在同一

台主机启动第二个副本

猜你喜欢

转载自www.cnblogs.com/rdchenxi/p/10986013.html