apiVersion: v1
kind: Pod
metadata:
spec:
activeDeadlineSeconds: >
automountServiceAccountToken: >
dnsPolicy: > # 'ClusterFirst', 'Default' or 'None'
enableServiceLinks: >
hostIPC: >
hostNetwork: > # 是否使用宿主机网路,类似于--network=host
hostPID: >
hostname: > # 设置主机名称,类似于--hostname
nodeName: > #
nodeSelector:
spec:
affinity:
spec:
affinity: >
podAffinity: >
requiredDuringSchedulingIgnoredDuringExecution: <[]Object>
namespaces: <[]string>
topologyKey: > -required-
labelSelector: >
matchLabels:
spec:
affinity: >
podAntiAffinity: >
requiredDuringSchedulingIgnoredDuringExecution: <[]Object>
namespaces: <[]string>
topologyKey: > -required-
labelSelector: >
matchLabels: [string]string>
key1: value1
key2: value2
matchExpressions:
key: > -required-
operator: > -required- # 设置键值关系(In, NotIn, Exists, DoesNotExist)
values: <[]string>
- value1
- value2
preferredDuringSchedulingIgnoredDuringExecution: <[]Object>
- weight: > -required-
podAffinityTerm: > -required-
namespaces: <[]string>
topologyKey: > -required-
labelSelector: >
matchLabels: [string]string>
key1: value1
key2: value2
matchExpressions:
key: > -required-
operator: > -required- # 设置键值关系(In, NotIn, Exists, DoesNotExist)
values: <[]string>
- value1
- value2
spec:
containers: <[]Object> # 容器配置
- name: > -required- # 容器名、DNS_LABEL
image: > # 镜像名称
imagePullPolicy: > # 镜像拉取策略,Always、Never、IfNotPresent
command: ["/bin/sh"] # 类似于dockerfile中的entrypiont
args: ["-c", "while true; do echo hello; sleep 10;done"] # 类似于dockerfile中的cmd
stdin: >
stdinOnce: >
terminationMessagePath: >
terminationMessagePolicy: >
tty: >
workingDir: >
spec:
containers: <[]Object>
ports: <[]Object> # 端口配置
- name: > # 定义端口名
containerPort: > -required- # 容器暴露的端口
protocol: > # 端口协议,UDP, TCP, or SCTP
hostIP: > # 指定要绑定的主机IP
hostPort: > # 指定主机开放的端口
spec:
containers: <[]Object>
env: <[]Object> #环境变量配置
- name: > -required- # 环境变量名称,如:MYSQL_ROOT_PASSWORD
value: > # 设置环境变量的值
valueFrom: >
configMapKeyRef: > # 指定从configmap的键名获取
name: > # configmap名称
key: > -required- # configmap资源清单下data字段下的键名
optional: >
fieldRef: >
apiVersion: >
fieldPath: > -required-
resourceFieldRef: >
containerName: >
divisor: >
resource: > -required-
secretKeyRef: > # 指定从Secret的键名获取
name: > # Secret名称
key: > -required- # Secret资源清单下data字段下的键名
optional: >
envFrom: <[]Object>
- configMapRef: > # 指定从configmap资源获取
name: > # 指定configmap名称
optional: >
secretRef: > # 指定从Secret资源获取
name: > # 指定Secret名称
optional: >
prefix: >
spec:
containers: <[]Object>
volumeMounts: <[]Object> # 容器挂载卷配置
- name: > -required- # 设置挂载卷名称
mountPath: > -required- # 设置挂载存储卷的路径
readOnly: > # 是否只读,默认为false
mountPropagation: >
subPath: >
subPathExpr: >
spec:
containers: <[]Object>
livenessProbe: > # 存活探针
exec: >
command: <[]string>
httpGet: >
port: > -required-
path: >
host: >
httpHeaders: <[]Object>
name: > -required-
value: > -required-
scheme: >
tcpSocket: > # TCPSocket指定涉及TCP端口的操作
port: > -required- # 容器暴露的端口
host: > # 默认pod的IP
initialDelaySeconds: > # 设置多少秒后开始探测
failureThreshold: > # 设置连续探测多少次失败后,标记为失败,默认三次
successThreshold: > # 设置失败后探测的最小连续成功次数,默认为1
timeoutSeconds: > # 设置探测超时的秒数,默认1s
periodSeconds: > # 设置执行探测的频率(以秒为单位),默认1s
spec:
containers: <[]Object>
readinessProbe: > # 就绪探针
exec: >
command: <[]string>
httpGet: >
port: > -required-
path: >
host: >
httpHeaders: <[]Object>
name: > -required-
value: > -required-
scheme: >
tcpSocket: > # TCPSocket指定涉及TCP端口的操作
port: > -required- # 容器暴露的端口
host: > # 默认pod的IP
initialDelaySeconds: > # 设置多少秒后开始探测
failureThreshold: > # 设置连续探测多少次失败后,标记为失败,默认三次
successThreshold: > # 设置失败后探测的最小连续成功次数,默认为1
timeoutSeconds: > # 设置探测超时的秒数,默认1s
periodSeconds: > # 设置执行探测的频率(以秒为单位),默认1s
spec:
containers: <[]Object>
resources: > # 资源配置
requests: [string]string> # 要求分配的最小资源
memory: "1024Mi" # Mi,Gi
cpu: "500m" # 500m代表0.5CPU
limits: [string]string> # 能够分配的最大资源
memory:
cpu:
spec:
containers: <[]Object>
lifecycle: >
postStart: >
exec: >
command: <[]string>
httpGet: >
port: > -required-
path: >
host: >
httpHeaders: <[]Object>
name: > -required-
value: > -required-
scheme: >
tcpSocket: >
port: > -required- # 容器暴露的端口
host: > # 默认pod的IP
preStop: >
exec: >
command: <[]string>
httpGet: >
port: > -required-
path: >
host: >
httpHeaders: <[]Object>
name: > -required-
value: > -required-
scheme: >
tcpSocket: >
port: > -required- # 容器暴露的端口
host: > # 默认pod的IP
spec:
containers: <[]Object>
volumeDevices: <[]Object>
- name: > -required-
devicePath: > -required-
spec:
volumes: <[]Object> #数据卷配置
- name: > -required- #设置卷名称,与volumeMounts名称对应
emptyDir: >
medium: >
sizeLimit: >
spec:
volumes: <[]Object> #数据卷配置
- name: > -required- #设置卷名称,与volumeMounts名称对应
hostPath: > #设置挂载宿主机路径
path: > -required-
type: > #类型:DirectoryOrCreate、Directory、FileOrCreate、File、Socket、CharDevice、BlockDevice
spec:
volumes: <[]Object> #数据卷配置
- name: > -required- #设置卷名称,与volumeMounts名称对应
nfs: > #设置NFS服务器
server: > -required- #设置NFS服务器地址
path: > -required- #设置NFS服务器路径(该路径必须存在)
readOnly: > #设置是否只读
spec:
volumes: <[]Object> #数据卷配置
- name: > -required- #设置卷名称,与volumeMounts名称对应
configMap: >
name: > #configmap名称
defaultMode: > #权限设置0~0777,默认0664
optional: > #指定是否必须定义configmap或其keys
items: <[]Object>
- key: > -required-
path: > -required-
mode: >
spec:
volumes: <[]Object> #数据卷配置
- name: > -required- #设置卷名称,与volumeMounts名称对应
secret: >
secretName: >
defaultMode: > #权限设置0~0777,默认0664
optional: > #指定是否必须定义configmap或其keys
spec:
volumes: <[]Object> #数据卷配置
- name: > -required- #设置卷名称,与volumeMounts名称对应
persistentVolumeClaim: >
claimName: > -required- #pvc名称
readOnly: >
spec:
volumes: <[]Object> #数据卷配置
- name: > -required- #设置卷名称,与volumeMounts名称对应
storageos: >
volumeName: >liangzhuyicong
volumeNamespace: >
fsType: >
secretRef: >
name: >
spec:
tolerations: <[]Object>
effect: > # NoSchedule, PreferNoSchedule, NoExecute
key: >
value: >
operator: > # Exists, Equal
tolerationSeconds: >
spec:
securityContext: >
fsGroup: >
runAsGroup: >
runAsNonRoot: >
runAsUser: >
supplementalGroups: <[]integer>
seLinuxOptions: >
level: >
role: >
type: >
user: >
sysctls: <[]Object>
name: > -required-
value: > -required-
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
spec:
minReadySeconds: > # 设置pod准备就绪的最小秒数
paused: > # 表示部署已暂停并且deploy控制器不会处理该部署
progressDeadlineSeconds: >
replicas: > # pod的副本数量
revisionHistoryLimit: > # 设置保留的历史版本个数,默认是10
rollbackTo: >
revision: > # 设置回滚的版本,设置为0则回滚到上一个版本
selector: > # pod标签选择器,匹配pod标签,默认使用pods的标签
matchLabels: [string]string>
key1: value1
key2: value2
matchExpressions: <[]Object>
operator: > -required- #设定标签键与一组值的关系,In, NotIn, Exists and DoesNotExist
key: > -required-
values: <[]string>
strategy: > # 将现有pod替换为新pod的部署策略
rollingUpdate: > # 滚动更新配置参数,仅当类型为RollingUpdate
maxSurge: > # 滚动更新过程产生的最大pod数量,可以是个数,也可以是百分比
maxUnavailable: > #
type: > #部署类型,Recreate,RollingUpdate
template: > -required- # 同pod配置
apiVersion: apps/v1
kind: StatefulSet
metadata:
spec:
podManagementPolicy: > # pod更新替换策略,OrderedReady(默认)、Parallel
replicas: > # 副本数
revisionHistoryLimit: > # 历史版本
serviceName: > -required- # 设置headless服务名
selector: > -required- # 标签选择器
matchLabels: [string]string>
key1: value1
key2: value2
matchExpressions: <[]Object>
operator: > -required- #设定标签键与一组值的关系,In, NotIn, Exists and DoesNotExist
key: > -required-
values: <[]string>
template: > -required- # 同pod配置
updateStrategy: >
rollingUpdate: >
partition: > # 默认为0
type: > # 默认RollingUpdate
volumeClaimTemplates: <[]Object>
- apiVersion: >
kind: >
metadata: >
spec: >
accessModes: <[]string>
resources: > # 参考链接:https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/
limits: [string]string>
requests: [string]string>
storage: 5Gi
dataSource: >
apiGroup: >
kind: > -required-
name: > -required-
selector: >
matchLabels: [string]string>
key1: value1
key2: value2
matchExpressions: <[]Object>
operator: > -required- #设定标签键与一组值的关系,In, NotIn, Exists and DoesNotExist
key: > -required-
values: <[]string>
storageClassName: >
volumeMode: >
volumeName: >
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
spec:
minReadySeconds: >
revisionHistoryLimit: >
selector: >
template: > -required-
templateGeneration: > #已过时
updateStrategy: >
apiVersion: v1
kind: PersistentVolume
metadata:
spec:
accessModes: <[]string>
persistentVolumeReclaimPolicy: >
storageClassName: >
capacity: [string]string>
storage: 5Gi #容量设置
spec:
nfs: >
server: > -required- # nfs服务器地址
path: > -required- # nfs服务器存储路径设置
readOnly: > # 是否只读
spec:
hostPath: >
path: > -required-
type: > # 参考链接:https://kubernetes.io/docs/concepts/storage/volumes/#hostpath
spec:
storageos: >
fsType: > # "ext4", "xfs", "ntfs",未指定默认为ext4
readOnly: >
volumeName: >
volumeNamespace: >
secretRef: >
apiVersion: >
kind: >
name: >
namespace: >
fieldPath: >
resourceVersion: >
uid: >
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
spec:
accessModes: <[]string>
storageClassName: >
volumeMode: >
volumeName: >
resources: > # 参考链接:https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/
limits: [string]string>
requests: [string]string>
storage: 5Gi
dataSource: >
apiGroup: >
kind: > -required-
name: > -required-
selector: >
matchLabels: [string]string>
key1: value1
key2: value2
matchExpressions: <[]Object>
operator: > -required- #设定标签键与一组值的关系,In, NotIn, Exists and DoesNotExist
key: > -required-
values: <[]string>
apiVersion: v1
kind: Service
metadata:
spec:
clusterIP: >
externalIPs: <[]string>
externalName: >
externalTrafficPolicy: >
healthCheckNodePort: >
loadBalancerIP: >
loadBalancerSourceRanges: <[]string>
ports: <[]Object>
publishNotReadyAddresses: >
selector: [string]string>
key: value
sessionAffinity: >
sessionAffinityConfig: >
clientIP: >
timeoutSeconds: >
type: > # ExternalName, ClusterIP, NodePort, LoadBalancer
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
spec:
backend: >
serviceName: > -required-
servicePort: > -required-
rules: <[]Object>
host: >
http: >
paths: <[]Object> -required-
backend: > -required-
serviceName: > -required-
servicePort: > -required-
path: >
tls: <[]Object>
hosts: <[]string>
secretName: >
apiVersion: v1
kind: ConfigMap
metadata:
binaryData: [string]string>
data: [string]string>
apiVersion: v1
kind: Secret
metadata:
data: [string]string>
stringData: [string]string>
type: >
kubectl autoscale (-f FILENAME | TYPE NAME | TYPE/NAME) [--min=MINPODS] --max=MAXPODS [--cpu-percent=CPU] [options]
spec:
maxReplicas: > -required- # 最大副本数
minReplicas: > # 最小副本数,默认为1
targetCPUUtilizationPercentage: > #
scaleTargetRef: > -required- #设置指定资源类型
apiVersion: >
kind: > -required-
name: > -required-