插一嘴, 健康检查
cat << eof | k apply -f - -n csdn-test
apiVersion: v1
kind: Pod
metadata: {name: pod-with-tcp-socket-healthcheck}
spec:
containers:
- name: nginx
image: nginx
livenessProbe:
tcpSocket: {port: 80}
initialDelaySeconds: 30
timeoutSeconds: 1
ports: [ containerPort: 80]
eof
livenessProbe:
tcpSocket:
port: 80
httpGet:
path: /_status/healthz
port: 80
exec:
command:
- cat
- /tmp/health
initialDelaySeconds: 10
timeoutSeconds: 1
插一嘴 env
env:
- name: GET_HOST_FROM
value: env
- name: APPLOGLEVEL
valueFrom:
configMapKeyRef:
name: cm-appvars
key: apploglevel
插一嘴 matchExpressions
k explain deploy
selector:
matchLabels:
tier: frontend
matchExpressions:
- { key: tier, operator: In, values: [frontend] }
- {key: environment, operator: NotIn, values: [dev]}
cat << eof | k apply -f - -n csdn-test
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-lab
spec:
replicas: 3
selector:
matchLabels:
tier: backend
matchExpressions:
- { key: aa, operator: In, values: [frontend] }
- {key: environment, operator: NotIn, values: [dev]}
template:
metadata:
labels:
tier: backend
aa: frontend
environment: bac
spec:
containers:
- image: nginx
name: p1
livenessProbe:
tcpSocket:
port: 80
readinessProbe:
httpGet:
path: /
port: 80
eof
k get deployment.apps/deploy-lab