Skip to content

Commit

Permalink
NODE-5583 add docker registry secret to kubernetes test environment
Browse files Browse the repository at this point in the history
  • Loading branch information
braek-neck committed Aug 7, 2024
1 parent 20ea64c commit 1b2ab24
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 6 deletions.
47 changes: 46 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ jobs:
env:
SKIP_CLUSTER_CREATION: true
SKIP_IMAGE_CREATION: true
DOCKERHUB_USER: ${{ steps.secrets.outputs.user }}
DOCKERHUB_PASSWORD: ${{ steps.secrets.outputs.password }}
WALLARM_API_TOKEN: ${{ steps.secrets.outputs.api_token }}
WALLARM_API_HOST: ${{ steps.secrets.outputs.api_host }}
WALLARM_API_PRESET: ${{ steps.secrets.outputs.api_preset }}
Expand Down Expand Up @@ -216,7 +218,10 @@ jobs:
role: ${{ secrets.VAULT_ROLE }}
method: kubernetes
path: kubernetes-ci
secrets: kv-gitlab-ci/data/github/ingress api_token
secrets: |
kv-gitlab-ci/data/github/ingress api_token ;
kv-gitlab-ci/data/github/shared/dockerhub-creds user ;
kv-gitlab-ci/data/github/shared/dockerhub-creds password ;
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
Expand All @@ -231,6 +236,9 @@ jobs:
- name: Load images
run: docker load -i controller-${{ env.ARCH }}.tar

- name: Login to DockerHub
run: echo ${{ steps.secrets.outputs.password }} | docker login -u ${{ steps.secrets.outputs.user }} --password-stdin

- name: Create cluster
run: kind create cluster --image=kindest/node:v1.25.8 --config test/e2e/kind.yaml

Expand Down Expand Up @@ -267,6 +275,22 @@ jobs:
- name: Load controller images
run: docker load -i controller-${{ env.ARCH }}.tar

- name: Import secrets
uses: hashicorp/vault-action@d1720f055e0635fd932a1d2a48f87a666a57906c # v3.0.0
id: secrets
with:
exportEnv: false
url: ${{ secrets.VAULT_URL }}
role: ${{ secrets.VAULT_ROLE }}
method: kubernetes
path: kubernetes-ci
secrets: |
kv-gitlab-ci/data/github/shared/dockerhub-creds user ;
kv-gitlab-ci/data/github/shared/dockerhub-creds password ;
- name: Login to DockerHub
run: echo ${{ steps.secrets.outputs.password }} | docker login -u ${{ steps.secrets.outputs.user }} --password-stdin

- name: Create cluster
run: kind create cluster --image=kindest/node:v1.25.8 --config test/e2e/kind.yaml

Expand Down Expand Up @@ -309,6 +333,8 @@ jobs:
secrets: |
kv-gitlab-ci/data/github/ingress api_token ;
kv-gitlab-ci/data/github/ingress api_host ;
kv-gitlab-ci/data/github/shared/dockerhub-creds user ;
kv-gitlab-ci/data/github/shared/dockerhub-creds password ;
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
Expand All @@ -321,6 +347,9 @@ jobs:
- name: Load controller images
run: docker load -i controller-${{ env.ARCH }}.tar

- name: Login to DockerHub
run: echo ${{ steps.secrets.outputs.password }} | docker login -u ${{ steps.secrets.outputs.user }} --password-stdin

- name: Create cluster ${{ matrix.k8s }}
run: kind create cluster --image=kindest/node:${{ matrix.k8s }} --config test/e2e/kind.yaml

Expand Down Expand Up @@ -357,6 +386,22 @@ jobs:
- name: Load controller images
run: docker load -i controller-${{ env.ARCH }}.tar

- name: Import secrets
uses: hashicorp/vault-action@d1720f055e0635fd932a1d2a48f87a666a57906c # v3.0.0
id: secrets
with:
exportEnv: false
url: ${{ secrets.VAULT_URL }}
role: ${{ secrets.VAULT_ROLE }}
method: kubernetes
path: kubernetes-ci
secrets: |
kv-gitlab-ci/data/github/shared/dockerhub-creds user ;
kv-gitlab-ci/data/github/shared/dockerhub-creds password ;
- name: Login to DockerHub
run: echo ${{ steps.secrets.outputs.password }} | docker login -u ${{ steps.secrets.outputs.user }} --password-stdin

- name: Scan controller image
uses: anchore/scan-action@3343887d815d7b07465f6fdcd395bd66508d486a
with:
Expand Down
4 changes: 2 additions & 2 deletions charts/ingress-nginx/templates/tarantool-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- if .Values.controller.wallarm.imagePullSecrets }}
imagePullSecrets: {{ toYaml .Values.controller.wallarm.imagePullSecrets | nindent 8 }}
{{- if .Values.imagePullSecrets }}
imagePullSecrets: {{ toYaml .Values.imagePullSecrets | nindent 8 }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.controller.wallarm.tarantool.terminationGracePeriodSeconds }}
initContainers:
Expand Down
6 changes: 3 additions & 3 deletions charts/ingress-nginx/templates/tarantool-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- if .Values.controller.wallarm.imagePullSecrets }}
imagePullSecrets: {{ toYaml .Values.controller.wallarm.imagePullSecrets | nindent 8 }}
{{- if .Values.imagePullSecrets }}
imagePullSecrets: {{ toYaml .Values.imagePullSecrets | nindent 8 }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.controller.wallarm.tarantool.terminationGracePeriodSeconds }}
initContainers:
Expand Down Expand Up @@ -145,4 +145,4 @@ spec:
name: {{ template "ingress-nginx.wallarmTarantoolCronConfig" . }}
{{- include "ingress-nginx.wallarmTokenVolume" . | nindent 8 }}
{{- end }}
{{- end }}
{{- end }}
23 changes: 23 additions & 0 deletions test/smoke/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ export SMOKE_IMAGE_TAG="${SMOKE_IMAGE_TAG:-latest}"

K8S_VERSION=${K8S_VERSION:-v1.25.8}


DOCKERHUB_REGISTRY_SERVER="https://index.docker.io/v1/"

# This will prevent the secret for index.docker.io from being used if the DOCKERHUB_USER is not set.
if [ "${DOCKERHUB_USER:-false}" = "false" ]; then
DOCKERHUB_REGISTRY_SERVER="fake_docker_registry_server"
fi

DOCKERHUB_SECRET_NAME="dockerhub-secret"
DOCKERHUB_USER="${DOCKERHUB_USER:-fake_user}"
DOCKERHUB_PASSWORD="${DOCKERHUB_PASSWORD:-fake_password}"

set -o errexit
set -o nounset
set -o pipefail
Expand Down Expand Up @@ -97,6 +109,15 @@ EOF
fi
fi

# create docker-registry secret
echo "[test-env] creating secret docker-registry ..."
kubectl create secret docker-registry ${DOCKERHUB_SECRET_NAME} \
--docker-server=${DOCKERHUB_REGISTRY_SERVER} \
--docker-username="${DOCKERHUB_USER}" \
--docker-password="${DOCKERHUB_PASSWORD}" \
--docker-email=docker-pull@unexists.unexists


if [ "${SKIP_IMAGE_CREATION:-false}" = "false" ]; then
echo "[test-env] building controller image..."
make -C "${DIR}"/../../ clean-image build image
Expand Down Expand Up @@ -129,6 +150,8 @@ trap describe_pods_on_exit EXIT
echo "[test-env] installing Helm chart using TAG=${TAG} ..."
cat << EOF | helm upgrade --install ingress-nginx "${DIR}/../../charts/ingress-nginx" --wait --values -
fullnameOverride: wallarm-ingress
imagePullSecrets:
- name: ${DOCKERHUB_SECRET_NAME}
controller:
wallarm:
enabled: true
Expand Down
2 changes: 2 additions & 0 deletions test/smoke/workload.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ spec:
labels:
app: workload
spec:
imagePullSecrets:
- name: dockerhub-secret
containers:
- name: nginx
image: nginx:stable-alpine
Expand Down

0 comments on commit 1b2ab24

Please sign in to comment.