StatefulSet详解
kubectl explain sts.spec :主要字段解释
replicas :副本数
selector:那个pod是由自己管理的
serviceName:必须关联到一个无头服务商
template:定义pod模板(其中定义关联那个存储卷)
volumeClaimTemplates :生成PVC
cat << EOF > nginx-ss.yaml apiVersion: apps/v1 kind: StatefulSet metadata: name: web namespace: nginx-ss spec: selector: matchLabels: app: nginx #必须匹配 .spec.template.metadata.labels serviceName: "nginx" #声明它属于哪个Headless Service. replicas: 3 #副本数 template: metadata: labels: app: nginx # 必须配置 .spec.selector.matchLabels spec: terminationGracePeriodSeconds: 10 containers: - name: nginx image: www.my.com/web/nginx:v1 ports: - containerPort: 80 name: web volumeMounts: - name: nginx-pvc mountPath: /usr/share/nginx/html volumeClaimTemplates: #可看作pvc的模板 - metadata: name: nginx-pvc spec: accessModes: [ "ReadWriteOnce" ] storageClassName: "nginx-nfs-storage" #存储类名,改为集群中已存在的 resources: requests: storage: 1Gi EOF
标签:statefulset,name,nginx,pvc,template,K8S,spec,metadata From: https://www.cnblogs.com/libruce/p/16806080.html