apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    docker-registry: default
  name: docker-registry
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      docker-registry: default
  template:
    metadata:
      labels:
        docker-registry: default
    spec:
      containers:
      - env:
        - name: REGISTRY_HTTP_ADDR
          value: :5000
        - name: REGISTRY_HTTP_NET
          value: tcp
        - name: REGISTRY_HTTP_SECRET
          value: '*** GENERATED ***'
        - name: REGISTRY_MIDDLEWARE_REPOSITORY_OPENSHIFT_ENFORCEQUOTA
          value: "false"
        - name: REGISTRY_HTTP_TLS_KEY
          value: /etc/secrets/registry.key
        - name: REGISTRY_OPENSHIFT_SERVER_ADDR
          value: docker-registry.default.svc:5000
        - name: REGISTRY_CONFIGURATION_PATH
          value: /etc/registry/config.yml
        - name: REGISTRY_HTTP_TLS_CERTIFICATE
          value: /etc/secrets/registry.crt
        image: '*** GENERATED ***'
        livenessProbe:
          httpGet:
            path: /healthz
            port: 5000
            scheme: HTTPS
          initialDelaySeconds: 10
          timeoutSeconds: 5
        name: registry
        ports:
        - containerPort: 5000
        readinessProbe:
          httpGet:
            path: /healthz
            port: 5000
            scheme: HTTPS
          timeoutSeconds: 5
        resources:
          requests:
            cpu: 100m
            memory: 256Mi
        volumeMounts:
        - mountPath: /registry
          name: registry-storage
        - mountPath: /etc/secrets
          name: registry-certificates
        - mountPath: /etc/registry
          name: shared-config
      initContainers:
      - args:
        - |
          set -o errexit
          set -o nounset
          set -o pipefail

          . <(sed -e 's/: */=/' /etc/origin/cloudprovider/azure.conf)
          az login --service-principal -u "$aadClientId" -p "$aadClientSecret" --tenant "$aadTenantId" &>/dev/null
          REGISTRY_STORAGE_ACCOUNT_KEY=$(az storage account keys list -g "$resourceGroup" -n "$REGISTRY_STORAGE_ACCOUNT_NAME" --query "[?keyName == 'key1'].value" -o tsv)
          az logout

          cp /etc/registry/config.yml /tmp/registry/config.yml
          sed -i -e "s#REGISTRY_STORAGE_ACCOUNT_KEY#$REGISTRY_STORAGE_ACCOUNT_KEY#" /tmp/registry/config.yml
        command:
        - /bin/bash
        - -c
        env:
        - name: REGISTRY_STORAGE_ACCOUNT_NAME
          value: '*** GENERATED ***'
        image: '*** GENERATED ***'
        name: storage-setup
        volumeMounts:
        - mountPath: /etc/origin/cloudprovider
          name: azure-config
        - mountPath: /etc/registry
          name: docker-config
        - mountPath: /tmp/registry
          name: shared-config
        - mountPath: /.azure
          name: empty-dir
      nodeSelector:
        region: infra
      serviceAccountName: registry
      volumes:
      - emptyDir: {}
        name: registry-storage
      - emptyDir: {}
        name: shared-config
      - emptyDir: {}
        name: empty-dir
      - name: registry-certificates
        secret:
          secretName: registry-certificates
      - name: azure-config
        secret:
          secretName: etc-origin-cloudprovider
      - name: docker-config
        secret:
          secretName: registry-config
