apiVersion: v1
kind: Service
metadata:
  name: eureka
  namespace: imxc
  labels:
    app: eureka
spec:
  type: NodePort
  ports:
    - port: 8761
      targetPort: 8761
      nodePort: 30030
      name: eureka
  selector:
    app: eureka
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: eureka
  namespace: imxc
spec:
  serviceName: 'eureka'
  replicas: 3
  selector:
    matchLabels:
      app: eureka
  template:
    metadata:
      labels:
        app: eureka
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: cmoa
                operator: In
                values:
                - worker2
      containers:
        - name: eureka
          image: {{ .Values.global.IMXC_IN_REGISTRY }}/eureka-server:{{ .Values.global.EUREKA_SERVER_VERSION }}
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 8761
          #resources:
          #  requests:
          #    memory: "1Gi"
          #    cpu: "500m"
          #  limits:
          #    memory: "1200Mi"
          #    cpu: "500m"
          env:
            - name: SPRING_PROFILES_ACTIVE
              value: prd
            - name: EUREKA_CLIENT_SERVICE-URL_DEFAULTZONE
              value: http://eureka-0.eureka:8761/eureka/,http://eureka-1.eureka:8761/eureka/,http://eureka-2.eureka:8761/eureka/
            - name: JVM_OPTS
              value: "-Xms1g -Xmx1g"
            # log4j
            - name: LOG4J_FORMAT_MSG_NO_LOOKUPS
              value: "true"
          resources:
            requests:
              memory: "100Mi"
              cpu: "20m"
