apiVersion: apps/v1
kind: Deployment
metadata:
name: wordpress-sre
labels:
app: wordpress-sre
spec:
selector:
matchLabels:
app: wordpress-sre
minReadySeconds: 5
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
template:
metadata:
labels:
app: wordpress-sre
spec:
initContainers:
- name: init-db
image: busybox
#判断mysql-sre这个服务有没有正常,否则本容器不初始化
command: ['sh', '-c', 'until nslookup mysql-sre; do echo waiting for mysql service; sleep 2; done;']
containers:
- name: wordpress
image: wordpress
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
name: wdport
...