apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: eureka
spec:
  serviceName: "eureka"
  selector:
    matchLabels:
      app: eureka-pod
  replicas: 3
  template:
    metadata:
      labels:
        app: eureka-pod
    spec:
      containers:
      - env:
        name: eureka
        image: 192.168.1.232:5000/k8s/eureka:statefull
        imagePullPolicy: Always
        env:
          - name: APP_NAME
            value: "eureka" # statefulSet name
          - name: POD_NAME
            valueFrom:
              fieldRef:
                fieldPath: metadata.name
          - name: POD_HOST_NAME
            value: "$(POD_NAME).$(APP_NAME).default.svc.cluster.local"
          - name: EUREKA_INSTANCE_LIST
            value: "http://eureka-0.$(APP_NAME).default.svc.cluster.local:8761/eureka/,http://eureka-1.$(APP_NAME).default.svc.cluster.local:8761/eureka/,http://eureka-2.$(APP_NAME).default.svc.cluster.local:8761/eureka/"
        ports:
        - containerPort: 8761
        livenessProbe:
          failureThreshold: 10
          httpGet:
            path: /health
            port: 8761
            scheme: HTTP
          initialDelaySeconds: 30
          periodSeconds: 60
          successThreshold: 1
          timeoutSeconds: 2
        readinessProbe:
          failureThreshold: 1
          httpGet:
            path: /health
            port: 8761
            scheme: HTTP
          initialDelaySeconds: 10
          periodSeconds: 3
          successThreshold: 1
          timeoutSeconds: 2