apiVersion: apps/v1
kind: Deployment
metadata:
  name: fusiion-gestion-clients
  namespace: fusiion
  labels:
    app: fusiion
    name: fusiion-gestion-clients
spec:
  replicas: 1
  selector:
    matchLabels:
      app: fusiion
      name: fusiion-gestion-clients
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
  minReadySeconds: 1
  revisionHistoryLimit: 2
  template:
    metadata:
      labels:
        app: fusiion
        name: fusiion-gestion-clients
    spec:
      containers:
      - name: fusiion-gestion-clients
        image: fusiion/sii-codelab-chaos-gestion-clients:latest
        imagePullPolicy: IfNotPresent
        env:
          - name: SPRING_DATA_NEO4J_PASSWORD
            valueFrom:
              secretKeyRef:
                name: neo4j-secret
                key: neo4j-password
          - name: SPRING_DATA_NEO4J_USERNAME
            valueFrom:
              secretKeyRef:
                name: neo4j-secret
                key: neo4j-username
          - name: SPRING_RABBITMQ_PASSWORD
            valueFrom:
              secretKeyRef:
                name: rabbitmq-secret
                key: rabbitmq-password
          - name: SPRING_RABBITMQ_USERNAME
            valueFrom:
              secretKeyRef:
                name: rabbitmq-secret
                key: rabbitmq-username
        args: ["--server.port=8080"
                ,"--spring.data.neo4j.uri=bolt://neo4j-core-0.neo4j-service"
                ,"--spring.rabbitmq.host=rabbitmq-0.rabbitmq-service"
                ,"--spring.rabbitmq.port=5672"
                ]
        ports:
         - containerPort: 8080
        readinessProbe:
          httpGet:
            path: /actuator/health
            port: 8080
          initialDelaySeconds: 10
          timeoutSeconds: 2
          periodSeconds: 5
          failureThreshold: 1
      initContainers:
        - name: init
          image: busybox:1.28
          command: ["sh", "-c", "until (nslookup neo4j-service && nslookup rabbitmq-service); do echo waiting; sleep 1; done;"]
      imagePullSecrets:
        - name: regcred
