apiVersion: batch/v1
kind: Job
metadata:
  name: consul-join
spec:
  template:
    metadata:
      name: consul-join
    spec:
      nodeSelector:
        zone: sys
      containers:
        - name: consul
          image: 10.1.12.61:5000/consul:0.8.1
          command:
            - "/bin/consul"
            - "join"
          env:
            - name: NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          args:
            - "-http-addr=consul-0.consul.$(NAMESPACE).svc.cluster.local:8500"
            - "consul-1.consul.$(NAMESPACE).svc.cluster.local"
            - "consul-2.consul.$(NAMESPACE).svc.cluster.local"
      restartPolicy: Never
