apiVersion: apps/v1
kind: Deployment
metadata:
  name: registry-creds
  namespace: kube-system
  labels:
    addonmanager.kubernetes.io/mode: Reconcile
    kubernetes.io/minikube-addons: registry-creds
spec:
  replicas: 1
  selector:
    matchLabels:
        name: registry-creds
  template:
    metadata:
      labels:
        name: registry-creds
        addonmanager.kubernetes.io/mode: Reconcile
    spec:
      containers:
      - image: {{.CustomRegistries.RegistryCreds  | default .ImageRepository | default .Registries.RegistryCreds }}{{.Images.RegistryCreds}}
        name: registry-creds
        imagePullPolicy: IfNotPresent
        env:
          - name: AWS_ACCESS_KEY_ID
            valueFrom:
              secretKeyRef:
                name: registry-creds-ecr
                key: AWS_ACCESS_KEY_ID
          - name: AWS_SECRET_ACCESS_KEY
            valueFrom:
              secretKeyRef:
                name: registry-creds-ecr
                key: AWS_SECRET_ACCESS_KEY
          - name: AWS_SESSION_TOKEN
            valueFrom:
              secretKeyRef:
                name: registry-creds-ecr
                key: AWS_SESSION_TOKEN
          - name: awsregion
            valueFrom:
              secretKeyRef:
                name: registry-creds-ecr
                key: aws-region
          - name: awsaccount
            valueFrom:
              secretKeyRef:
                name: registry-creds-ecr
                key: aws-account
          - name: aws_assume_role
            valueFrom:
              secretKeyRef:
                name: registry-creds-ecr
                key: aws-assume-role
          - name: awsregion
            valueFrom:
              secretKeyRef:
                name: registry-creds-ecr
                key: aws-region
          - name: DOCKER_PRIVATE_REGISTRY_PASSWORD
            valueFrom:
              secretKeyRef:
                name: registry-creds-dpr
                key: DOCKER_PRIVATE_REGISTRY_PASSWORD
          - name: DOCKER_PRIVATE_REGISTRY_SERVER
            valueFrom:
              secretKeyRef:
                name: registry-creds-dpr
                key: DOCKER_PRIVATE_REGISTRY_SERVER
          - name: DOCKER_PRIVATE_REGISTRY_USER
            valueFrom:
              secretKeyRef:
                name: registry-creds-dpr
                key: DOCKER_PRIVATE_REGISTRY_USER
          - name: gcrurl
            valueFrom:
              secretKeyRef:
                name: registry-creds-gcr
                key: gcrurl
          - name: ACR_PASSWORD
            valueFrom:
              secretKeyRef:
                name: registry-creds-acr
                key: ACR_PASSWORD
          - name: ACR_URL
            valueFrom:
              secretKeyRef:
                name: registry-creds-acr
                key: ACR_URL
          - name: ACR_CLIENT_ID
            valueFrom:
              secretKeyRef:
                name: registry-creds-acr
                key: ACR_CLIENT_ID
        volumeMounts:
        - name: gcr-creds
          mountPath: "/root/.config/gcloud"
          readOnly: true
      volumes:
      - name: gcr-creds
        secret:
          secretName: registry-creds-gcr
          items:
            - key: "application_default_credentials.json"
              path: "application_default_credentials.json"

