apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: consul-server-gd
  namespace: consul
spec:
  serviceName: consul-server-gd
  selector:
    matchLabels:
      app: consul-server-gd
  replicas: 3
  template:
    metadata:
      labels:
        app: consul-server-gd
    spec:
      terminationGracePeriodSeconds: 10
      containers:
        - name: consul-server
          image: harbor.freedom.org/docker.io/consul:1.9.1
          args:
               - "agent"
               - "-server"
               - "-bootstrap-expect=3"
               - "-ui"
               #- "-data-dir=/consul/data"     # 就算是在虚拟机中使用consul-server集群，也没有使用-data-dir及-config-dir目录，先在yaml中保留。
               #- "-config-dir=/consul/conf"
               - "-log-level=info"
               - "-log-rotate-duration=86400s"
               - "-log-rotate-max-files=7"
               - "-bind=0.0.0.0"
               - "-client=0.0.0.0"
               - "-datacenter=guangdong"
               - "-advertise=$(PODIP)"
               - "-retry-join=consul-server-gd-0.consul-server-gd.$(NAMESPACE).svc.cluster.local"
               - "-retry-join=consul-server-gd-1.consul-server-gd.$(NAMESPACE).svc.cluster.local"
               - "-retry-join=consul-server-gd-2.consul-server-gd.$(NAMESPACE).svc.cluster.local"
               - "-domain=cluster.local"
               - "-disable-host-node-id"
          env:
            - name: TZ
              value: Asia/Shanghai
            - name: HOSTIP
              valueFrom:
                fieldRef:
                  fieldPath: status.hostIP
            - name: PODIP
              valueFrom:
                fieldRef:
                  fieldPath: status.podIP
            - name: NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          ports:
            - containerPort: 8500
              name: ui-port
            - containerPort: 8443
              name: https-port
            - containerPort: 8400
              name: rpc-port
            - containerPort: 8301
              name: serflan
            - containerPort: 8302
              name: serfwan
            - containerPort: 8600
              name: consuldns
            - containerPort: 8300
              name: server
          imagePullPolicy: IfNotPresent
          resources:
            limits:
              cpu: 200m
              memory: 128Mi
            requests:
              cpu: 100m
              memory: 64Mi