How to pass my Docker credential before/while running e2e tests on Kubernetes

5/6/2021

I am trying to run e2e tests on Kubernetes cluster but while running Pods are pulled from docker and the docker is using default username present in the git-hub and the limit is exceeding.

I need to pass my docker user credential while running e2e test.

Any thing i can export / pass my user credential while running e2e test. I am using Ginkgo framework to trigger the e2e test

-- karthik B.N
docker
e2e
ginkgo
kubernetes

1 Answer

5/7/2021

Welcome to community!

From kubernetes perspective it's possible to pass environment variables to containers running in pods. You'll need to specify them in your yaml file for pods. Here is an example from kubernetes documentation:

apiVersion: v1
kind: Pod
metadata:
  name: envar-demo
  labels:
    purpose: demonstrate-envars
spec:
  containers:
  - name: envar-demo-container
    image: gcr.io/google-samples/node-hello:1.0
    env:
    - name: DEMO_GREETING
      value: "Hello from the environment"
    - name: DEMO_FAREWELL
      value: "Such a sweet sorrow"

Please find k8s documentation on how to set it up - define environment variable for containers

Once you manage with this part, you should consider doing it securely. For this matter it's advise to use kubernetes secrets.

In this kubernetes documentation (Distribute Credentials Securely Using Secrets) you will find all steps and examples on how you can do it.

Keeping this in mind, there might be other solutions build-in in e2e ginkgo solution.

-- moonkotte
Source: StackOverflow