# This manifest deploys a Job which performs one time
# configuration of Canal.
apiVersion: batch/v1
kind: Job
metadata:
  name: configure-canal
  namespace: kube-system
  labels:
    k8s-app: canal
spec:
  template:
    metadata:
      name: configure-canal
    spec:
      nodeSelector:
        beta.kubernetes.io/os: linux
      hostNetwork: true
      restartPolicy: OnFailure
      containers:
        # Writes basic flannel configuration to etcd.
        - name: configure-flannel
          image: quay.io/coreos/etcd:v3.1.5
          command:
          - "etcdctl"
          # Uncomment the following lines if using TLS to etcd.
          # - "--cert-file=/calico-secrets/etcd-cert"
          # - "--key-file=/calico-secrets/etcd-key"
          # - "--ca-file=/calico-secrets/etcd-ca"
          - "--no-sync"
          - "set"
          - "/coreos.com/network/config"
          - '{ "Network": "10.244.0.0/16", "Backend": {"Type": "vxlan"} }'
          env:
            # The location of the etcd cluster.
            - name: ETCDCTL_PEERS
              valueFrom:
                configMapKeyRef:
                  name: canal-config
                  key: etcd_endpoints
            # The location of the Calico etcd cluster.
            - name: ETCDCTL_CACERT
              valueFrom:
                configMapKeyRef:
                  name: canal-config
                  key: etcd_ca
          volumeMounts:
            # Mount in the etcd TLS secrets.
            - mountPath: /calico-secrets
              name: etcd-certs
      volumes:
        # Mount in the etcd TLS secrets.
        - name: etcd-certs
          secret:
            secretName: calico-etcd-secrets
