apiVersion: v1
kind: Service
metadata:
  name: kra-uat-etcd-service
  namespace: kra-uat
spec:
  selector:
    app: etcd
  ports:
    - protocol: TCP
      port: 2379
      targetPort: 2379
  type: ClusterIP

---

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: kra-uat-etcd
  namespace: kra-uat
  labels:
    app: etcd
spec:
  replicas: 1
  selector:
    matchLabels:
      app: etcd
  serviceName: etcd-headless
  podManagementPolicy: Parallel
  updateStrategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: etcd
      #annotations:
       # checksum/token-secret: 3177ccf4f760e12a075e633a0baa5bb000ad55ab74d6320877644a5a5b887def
    spec:
      containers:
        - name: etcd
          image: quay.io/coreos/etcd:v3.4.13
          imagePullPolicy: "IfNotPresent"
          securityContext:
            allowPrivilegeEscalation: false
            runAsUser: 0
          env:
            - name: ETCD_DATA_DIR
              value: "/default.etcd"
            - name: ALLOW_NONE_AUTHENTICATION
              value: "yes"
            - name: ETCD_ADVERTISE_CLIENT_URLS
              value: "http://etcd:2379"
            - name: ETCD_LISTEN_CLIENT_URLS
              value: "http://0.0.0.0:2379"
          ports:
            - name: client
              containerPort: 2379
              protocol: TCP
            - name: peer
              containerPort: 2380
              protocol: TCP
          volumeMounts:
            - name: data
              mountPath: /default.etcd
  volumeClaimTemplates:
    - metadata:
        name: data
      spec:
        storageClassName: standard
        accessModes:
          - "ReadWriteOnce"
        resources:
          requests:
            storage: "1Gi"

---

apiVersion: v1
kind: PersistentVolume
metadata:
  name: kra-uat-etcd-pv
  labels:
    vol: etcd
spec:
  storageClassName: standard
  volumeMode: Filesystem
  capacity:
    storage: "1Gi"
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  local:
    path: /kra-data/data/uat/rigel
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
            - master
