Less than 1 minute
apiVersion: v1
kind: Service
metadata:
name: nginx
labels:
app: nginx
spec:
ports:
- port: 80
name: web-sts-svc
clusterIP: None
selector:
app: nginx
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: stateful-nginx
spec:
serviceName: "nginx"
replicas: 2
podManagementPolicy: Parallel # 控制Pod扩缩行为。Parallel表示Pod扩缩时同时启停多个Pod,而不是一个一个进行(即默认的OrderedReady)
updateStrategy:
rollingUpdate:
partition: 0
type: RollingUpdate
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
name: web