apiVersion: apps/v1
kind: Deployment
metadata:
  name: admission-controller
  namespace: federatorai
  labels:
    app: alameda
    component: admission-controller
  annotations:
    description: Defines how to deploy the admission-controller
    template.alpha.openshift.io/wait-for-ready: 'true'
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      component: admission-controller
  template:
    metadata:
      name: admission-controller
      labels:
        app: alameda
        component: admission-controller
    spec:
      containers:
      - name: admission-controller
        image: quay.io/prophetstor/alameda-admission-ubi:v0.3.8
        imagePullPolicy: IfNotPresent
        resources:
          requests:
            cpu: 45m
            memory: 75Mi
        env:
        - name: NAMESPACE_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: ALAMEDA_ADMCTL_DEPLOYED_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: ALAMEDA_ADMCTL_DATAHUB_ADDRESS
          value: "alameda-datahub.federatorai.svc:50050"
        - name: ALAMEDA_ADMCTL_ENABLE
          value: 'true'
        - name: ALAMEDA_ADMCTL_TLS_CERT_FILE
          value: /etc/tls-certs/tls.crt
        - name: ALAMEDA_ADMCTL_TLS_PRIVATE_KEY_FILE
          value: /etc/tls-certs/tls.key
        - name: ALAMEDA_ADMCTL_CA_CERT_FILE
          value: /etc/tls-certs/ca.crt
        volumeMounts:
        - mountPath: /etc/tls-certs
          name: tls-certs
          readOnly: false
        readinessProbe:
          exec:
            command:
            - /usr/local/bin/admission-controller
            - probe
            - --type=readiness
          failureThreshold: 20
          initialDelaySeconds: 5
          periodSeconds: 5
        livenessProbe:
          exec:
            command:
            - /usr/local/bin/admission-controller
            - probe
            - --type=liveness
          failureThreshold: 20
          initialDelaySeconds: 5
          periodSeconds: 5
      volumes:
      - name:  admission-controller-data-storage
      - name:  admission-controller-log-storage
      - name: tls-certs
        secret:
          secretName: admission-controller-tls
      serviceAccount: admission-controller
      serviceAccountName: admission-controller
