Statefulset
一个Statefulset可以通过配置template的方式批量管理创建多个配置相同的pod,通常用于配置有状态的pod
与Deployment的不同
- 可以每个节点可以拥有固定的并且可以被同Namespase 的pod解析的主机全域名
- 可给每个pod分配各自的挂载Volume
- pod名字是有序的 {statefulset name}-{index} index由0开始递增,并且pod被删除重启pod名不会发生变化
格式
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
app: hes
name: nginx
spec:
podManagementPolicy: OrderedReady
replicas: 1
selector:
matchLabels:
component: fep
serviceName: hes-hs
template:
metadata:
labels:
component: fep
web: ami
spec:
containers:
- image: 10.32.233.112/library/nginx:1.12
name: hes-fep
volumeMounts:
- mountPath: /home/application/bin/Logs
name: log
- mountPath: /etc/local
name: hes-fep-configmap
volumes:
- configMap:
defaultMode: 420
name: hes-fep-configmap
name: hes-fep-configmap
volumeClaimTempl