################################
# Istio-CA cluster-wide
################################
# Service account CA
apiVersion: v1
kind: ServiceAccount
metadata:
  name: istio-ca-service-account
  namespace: {ISTIO_NAMESPACE}
---
apiVersion: v1
kind: Service
metadata:
  name: istio-ca
  namespace: istio-system
  labels:
    istio: istio-ca
spec:
  ports:
    - port: 8060
  selector:
    istio: istio-ca
---
# Istio CA watching all namespaces
apiVersion: v1
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  name: istio-ca
  namespace: {ISTIO_NAMESPACE}
spec:
  replicas: 1
  template:
    metadata:
      labels:
        istio: istio-ca
      annotations:
        sidecar.istio.io/inject: "false"
    spec:
      serviceAccountName: istio-ca-service-account
      containers:
      - name: istio-ca
        image: {CA_HUB}/istio-ca:{CA_TAG}
        imagePullPolicy: IfNotPresent
        command: ["/usr/local/bin/istio_ca"]
        args:
          - --istio-ca-storage-namespace={ISTIO_NAMESPACE}
          - --grpc-port=8060
          - --grpc-hostname=istio-ca
          - --self-signed-ca=true
          - --liveness-probe-path=/tmp/ca.liveness # path to the liveness health check status file
          - --liveness-probe-interval=60s # interval for health check file update
          - --probe-check-interval=15s    # interval for health status check
        livenessProbe:
          exec:
            command:
            - /usr/local/bin/istio_ca
            - probe
            - --probe-path=/tmp/ca.liveness # path to the liveness health check status file
            - --interval=125s               # the maximum time gap allowed between the file mtime and the current sys clock.
          initialDelaySeconds: 60
          periodSeconds: 60
---
