# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: consul
spec:
  selector:
    matchLabels:
      app: consul
  replicas: 1
  template:
    metadata:
      labels:
        app: consul
    spec:
      volumes:
        - name: consul-pv
          persistentVolumeClaim:
            claimName: consul-pvc
      containers:
        - name: consul
          image: fogsyio/consul:{{ .Values.external.consulVersion }}
          imagePullPolicy: {{ .Values.pullPolicy }}
          command:
            - "/bin/sh"
            - "-ec"
            - |
              exec /bin/consul agent \
                -server \
                -bind=0.0.0.0 \
                -bootstrap-expect=1 \
                -data-dir=/consul/data \
                -node=consule-one \
                -client=0.0.0.0 \
                -enable-script-checks=true \
                -ui
          env:
            - name: CONSUL_BIND_INTERFACE
              value: "eth0"
            - name: CONSUL_HTTP_ADDR
              value: "0.0.0.0"
            - name: CONSUL_LOCAL_CONFIG
              value: "{\"disable_update_check\": true}"
          ports:
            - containerPort: 8500
            - containerPort: 8600
          volumeMounts:
            - mountPath: "/consul/data"
              name: consul-pv
