apiVersion: apps/v1
kind: StatefulSet
metadata:
  namespace: default
  name: eureka
  labels:
    app: eureka
spec:
  serviceName: "eureka"
  replicas: 3
  selector:
    matchLabels:
      app: eureka
  template:
    metadata:
      labels:
        app: eureka
    spec:
      terminationGracePeriodSeconds: 10
      imagePullSecrets:
        - name: my-registry-key
      containers:
        - name: eureka
          image: eureka-server:v1
          ports:
            - name: http
              containerPort: 8761
              protocol: TCP
            - name: actuator
              containerPort: 7761
              protocol: TCP
          env:
            - name: SPRING_PROFILES_ACTIVE
              value: k8s
            - name: EUREKA_INSTANCE_HOSTNAME
              value: ${HOSTNAME}.eureka
            - name: EUREKA_INSTANCE_LIST
              value: "http://eureka-0.eureka.default.svc.cluster.local:8761/eureka/,http://eureka-1.eureka.default.svc.cluster.local:8761/eureka/,http://eureka-2.eureka.default.svc.cluster.local:8761/eureka/"

          # 健康检查
          livenessProbe:
            httpGet:
              path: /actuator/health
              port: 7761
              scheme: HTTP
            initialDelaySeconds: 20
            timeoutSeconds: 5
