apiVersion: v1
kind: Pod
metadata:
  name: kaniko
spec:
  restartPolicy: Never
  containers:
  - name: 'kaniko'
    image: 'gcr.io/kaniko-project/executor:latest'
    args:
    - --cache=true
    - --dockerfile=Dockerfile
    - --context=s3://{{AWS_S3_BUCKET}}/{{EXPERIMENT_NAME}}/dockerbuild.tar.gz
    - --destination={{DOCKER_IMAGE}}:latest
    env:
    - name: 'AWS_ACCESS_KEY_ID'
      valueFrom:
        secretKeyRef:
          name: '{{AWS_SECRET_NAME}}'
          key: 'aws_access_key'
    - name: 'AWS_SECRET_ACCESS_KEY'
      valueFrom:
        secretKeyRef:
          name: '{{AWS_SECRET_NAME}}'
          key: 'aws_secret_key'
    - name: 'AWS_DEFAULT_REGION'
      value: '{{AWS_DEFAULT_REGION}}'
    volumeMounts:
    - mountPath: '/kaniko/.docker'
      name: 'dockercreds'
  volumes:
  - name: 'dockercreds'
    projected:
      sources:
      - secret:
          name: '{{DOCKER_REGISTRY_SECRET}}'
          items:
            - key: '.dockerconfigjson'
              path: 'config.json'