yaml 中文化
前言
相信大家在学习 k8s 遇到一些问题,yaml 太多,记不全,甚至不知道什么意思,今天小编给你整备好了 中文解释 yaml
certificatesigningrequests (缩写 csr)
componentstatuses (缩写 cs)
configmaps (缩写 cm)
customresourcedefinition (缩写 crd)
daemonsets (缩写 ds)
deployments (缩写 deploy)
endpoints (缩写 ep)
events (缩写 ev)
horizontalpodautocordon, drain, uncordonrs (缩写 hpa)
ingresses (缩写 ing)
limitranges (缩写 limits)
namespaces (缩写 ns)
networkpolicies (缩写 netpol)
nodes (缩写 no)
persistentvolumeclaims (缩写 pvc)
persistentvolumes (缩写 pv)
poddisruptionbudgets (缩写 pdb)
pods (缩写 po)
podsecuritypolicies (缩写 psp)
replicasets (缩写 rs)
replicationcontrollers (缩写 rc)
resourcequotas (缩写 quota)
serviceaccounts (缩写 sa)
services (缩写 svc)
statefulsets (缩写 sts)
storageclasses (缩写 sc)
一、生产一条 yaml
kubectl create deploy --dry-run=client nginx \
--image=nginx -o yaml > deployment.yaml
cat deployment ↓ 获取中文文档QQ857676355
spec
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: nginx
name: nginx
namespace: demo
spec:
replicas: 2
selector:
matchLabels:
app: mysql
template:
metadata:
labels:
app: mysql
以下是容器pod
spec:
initContainers
- command:
- sh
- echo "hell qxh"
restartPolicy: Always
hostNetwork: true
nodeSelector:
node:node1
containers:
- name: nginx
image: nginx
imagePullPolicy: Never
args:
- "--character-set-server=utf8"
- "--collation-server=utf8_general_ci"
ports:
- containerPort: 80
protocol: udp
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: terminationMessagePolicy: File
restartPolicy: OnFailure
#Always
#OnFailure :
#Never :
dnsPolicy: ClusterFirst
None
Default
ClusterFirst
terminationGracePeriodSeconds: 30
资源管理 或者使用 LimitRange 默认配置
resources:
limits:
cpu: '2'
memory: 2000Mi
requests:
cpu: '0.1'
memory: 256Mi
健康检查
#和 ports 同级
(就绪检查):检查容器是否可以处理请求。
readinessProbe:
(存活检查):检查容器是否存活
livenessProbe:
(启动检查):检查容器是否启动成功,用于保护 慢启动容器 (TCP 端口方式)
startupProbe:
initialDelaySeconds: 5
timeoutSeconds: 1
periodSeconds: 5
successThreshold: 1
failureThreshold: 30
tcpSocket:
port: 123
............................. HTTP 请求格式
startupProbe:
..........
httpGet:
scheme: HTTP
path: /oss/actuator/health
port: 857676355
### 推荐
livenessProbe:
initialDelaySeconds: 30
periodSeconds: 10
failureThreshold: 2
httpGet:
scheme: HTTP
path: /oss/actuator/health
port: 857676355
readinessProbe:
initialDelaySeconds: 30
periodSeconds: 10
failureThreshold: 2
httpGet:
scheme: HTTP
path: /oss/actuator/health
port: 857676355
执行的命令
command: ['sh']
- /etc/init.d/mysql start
args: ["$(str)"]
workingDir: /etc/mysql
env:
- name: MYSQL_USER
valueFrom:
secretKeyRef:
name: myblog
key: MYSQL_USER
- name: MYSQL_USER
valueFrom:
secretKeyRef:
name: myblog
key: MYSQL_USER
- name: MYSQL_ROOT_PASSWORD
value: "123456"
- name: MYSQL_HOST
value: "192.168.0.191"
数据存储
volumeMounts:
- name: nginx-vmin
mountPath: /data/log
serviceAccount: default
initContainers: []
volumes:
- name: nginx-vmin
emptyDir: {}
#方案二
volumes:
- name: nginx-vmin
persistentVolumeClaim:
claimName: vol
#方案三
volumes:
- name: nginx-vmin
hostPath:
path: /opt/mysql/data
type: Directory
#方案四 nfs
volumeMounts:
- name: nginx-vmin
mountPath: /data/log
volumes:
- name: nginx-vmin
nfs:
server: 192.168.3.128
path: /data-nfs
#文件方式
volumes:
- name: nginx-vmin
configMap:
name: kube-root-ca.crt
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
progressDeadlineSeconds: 600