K8S部署etcd




---
apiVersion: v1
kind: Secret
metadata:
  namespace: arts-system
  name: etcd-auth
type: Opaque
stringData:
  ETCD_ROOT_PASSWORD: "123456"

---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  namespace: arts-system
  name: etcd
spec:
  serviceName: "etcd"
  replicas: 1
  selector:
    matchLabels:
      app: etcd
  template:
    metadata:
      labels:
        app: etcd
    spec:
      containers:
      - name: etcd
        image: quay.io/coreos/etcd:v3.4.15
        env:
        - name: ETCD_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: etcd-auth
              key: ETCD_ROOT_PASSWORD
        command:
        - /usr/local/bin/etcd
        - --name
        - etcd
        - --data-dir
        - /var/lib/etcd
        - --advertise-client-urls
        - http://etcd:2379
        - --listen-client-urls
        - http://0.0.0.0:2379
        - --auth-token
        - simple
        - --enable-pprof
        volumeMounts:
        - name: etcd-data
          mountPath: /var/lib/etcd
          subPath: artsdata/etcd
      volumes:
      - name: data
        persistentVolumeClaim:
          claimName: etcd-data
      volumes:
      - name: etcd-data
        persistentVolumeClaim:
          #claimName: artspvc
          claimName: arts-pvc

---
apiVersion: v1
kind: Service
metadata:
  namespace: arts-system
  name: etcd
spec:
  selector:
    app: etcd
  ports:
    - protocol: TCP
      port: 2379
      targetPort: 2379
  #type: LoadBalancer
  type: ClusterIP














你可能感兴趣的:(k8s,kubernetes,etcd,容器)