---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: consul-client-base
  labels:
    app: consul-client-base
spec:
  replicas: 1
  selector:
    matchLabels:
      app: consul-client-base
  template:
    metadata:
      labels:
        app: consul-client-base
    spec:
      containers:
      - name: consul-client-base
        image: consul_client_base:1.0.0
        env:
          - name: POD_IP
            valueFrom:
              fieldRef:
                fieldPath: status.podIP
          - name: NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace
        args:
          - "agent"
          - "-bind=0.0.0.0"
          - "-retry-join=consul-0.consul.$(NAMESPACE).svc.cluster.local"
          - "-domain=cluster.local"
          - "-data-dir=/consul/data"
          - "-config-dir=/consul/config"
        lifecycle:
          preStop:
            exec:
              command:
              - /bin/sh
              - -c
              - consul leave
        volumeMounts:
          - name: client-base-configmap
            mountPath: /consul/config
      volumes:
        - name: client-base-configmap
          configMap:
            name: client-base-configmap