Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: push test images to Harbor instead of GHCR #197

Merged
merged 5 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ jobs:
runs-on: ubuntu-22.04
env:
VERSION: ${{ github.run_id }}
GHCR_REGISTRY: "ghcr.io"
HARBOR_URL: "harbor.enix.io"
HARBOR_REPO: "kube-image-keeper/kube-image-keeper"
GHCR_IMAGE: "ghcr.io/enix/kube-image-keeper"
QUAY_IMAGE: "quay.io/enix/kube-image-keeper"
steps:
- name: Checkout Repository
Expand All @@ -132,9 +134,9 @@ jobs:
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.GHCR_REGISTRY }}
username: ${{ env.COMMIT_NAME }}
password: ${{ secrets.RELEASE_GITHUB_TOKEN }}
registry: ${{ env.HARBOR_URL }}
username: ${{ secrets.HARBOR_USERNAME }}
password: ${{ secrets.HARBOR_PASSWORD }}

- name: Generate image metadata
id: meta
Expand All @@ -156,7 +158,7 @@ jobs:
push: true
labels: ${{ steps.meta.outputs.labels }}
tags: |
${{ env.GHCR_REGISTRY }}/${{ github.repository }}:${{ env.VERSION }}
${{ env.HARBOR_URL }}/${{ env.HARBOR_REPO }}:${{ env.VERSION }}

- name: Build alpine container images
uses: docker/build-push-action@v5
Expand All @@ -170,16 +172,18 @@ jobs:
push: true
labels: ${{ steps.meta.outputs.labels }}
tags: |
${{ env.GHCR_REGISTRY }}/${{ github.repository }}:${{ env.VERSION }}-alpine
${{ env.HARBOR_URL }}/${{ env.HARBOR_REPO }}:${{ env.VERSION }}-alpine
e2e:
name: Tests End-to-End on K8s
needs:
- build
runs-on: ubuntu-22.04
env:
VERSION: ${{ github.run_id }}
GHCR_IMAGE_NAME: "ghcr.io/enix/kube-image-keeper"
GHCR_REGISTRY: "ghcr.io"
HARBOR_IMAGE: "harbor.enix.io/kube-image-keeper/kube-image-keeper"
HARBOR_REGISTRY: "harbor.enix.io"
HARBOR_USERNAME: ${{ secrets.HARBOR_USERNAME }}
HARBOR_PASSWORD: ${{ secrets.HARBOR_PASSWORD }}
strategy:
max-parallel: 6
matrix:
Expand Down Expand Up @@ -226,13 +230,12 @@ jobs:
run : |
set -euo pipefail
kubectl create namespace kuik-system
kubectl create secret docker-registry ghcr-secret -n kuik-system --docker-server=https://ghcr.io \
--docker-username=monkeynator --docker-password=${{ secrets.RELEASE_GITHUB_TOKEN }} \
--docker-email=${{ env.COMMIT_EMAIL }}
kubectl create secret docker-registry harbor-secret -n kuik-system --docker-server=${{ env.HARBOR_REGISTRY }} \
--docker-username="$HARBOR_USERNAME" --docker-password="$HARBOR_PASSWORD"
helm upgrade --install kube-image-keeper -n kuik-system --create-namespace ./helm/kube-image-keeper \
--set controllers.image.tag=${{ env.VERSION }} --set proxy.image.tag=${{ env.VERSION }} \
--set controllers.image.repository=${{ env.GHCR_IMAGE_NAME }} --set proxy.image.repository=${{ env.GHCR_IMAGE_NAME }} \
--set controllers.imagePullSecrets[0].name=ghcr-secret --set proxy.image.imagePullSecrets[0].name=ghcr-secret --debug
--set controllers.image.tag=$VERSION --set proxy.image.tag=$VERSION \
--set controllers.image.repository=$HARBOR_IMAGE --set proxy.image.repository=$HARBOR_IMAGE \
--set controllers.imagePullSecrets[0].name=harbor-secret --set proxy.image.imagePullSecrets[0].name=harbor-secret --debug
kubectl wait pods -n kuik-system -l app.kubernetes.io/instance=kube-image-keeper --for condition=Ready --timeout=30s

- name: Run end-to-end tests
Expand Down Expand Up @@ -416,7 +419,6 @@ jobs:
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}


- name: Generate image metadata
id: meta
uses: docker/metadata-action@v5
Expand Down
45 changes: 25 additions & 20 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ jobs:
runs-on: ubuntu-22.04
env:
VERSION: ${{ github.run_id }}
GHCR_REGISTRY: "ghcr.io"
HARBOR_URL: "harbor.enix.io"
HARBOR_REPO: "kube-image-keeper/kube-image-keeper"
GHCR_IMAGE: "ghcr.io/enix/kube-image-keeper"
QUAY_IMAGE: "quay.io/enix/kube-image-keeper"
steps:
- name: Checkout Repository
Expand All @@ -31,16 +33,16 @@ jobs:
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.GHCR_REGISTRY }}
username: ${{ env.COMMIT_NAME }}
password: ${{ secrets.RELEASE_GITHUB_TOKEN }}
registry: ${{ env.HARBOR_URL }}
username: ${{ secrets.HARBOR_USERNAME }}
password: ${{ secrets.HARBOR_PASSWORD }}

- name: Generate image metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.GHCR_REGISTRY }}/${{ github.repository }}
${{ env.GHCR_IMAGE }}
${{ github.repository }}
${{ env.QUAY_IMAGE }}

Expand All @@ -55,7 +57,7 @@ jobs:
push: true
labels: ${{ steps.meta.outputs.labels }}
tags: |
${{ env.GHCR_REGISTRY }}/${{ github.repository }}:${{ env.VERSION }}
${{ env.HARBOR_URL }}/${{ env.HARBOR_REPO }}:${{ env.VERSION }}

- name: Build alpine container images
uses: docker/build-push-action@v5
Expand All @@ -69,7 +71,7 @@ jobs:
push: true
labels: ${{ steps.meta.outputs.labels }}
tags: |
${{ env.GHCR_REGISTRY }}/${{ github.repository }}:${{ env.VERSION }}-alpine
${{ env.HARBOR_URL }}/${{ env.HARBOR_REPO }}:${{ env.VERSION }}-alpine

e2e:
name: Tests End-to-End on K8s
Expand All @@ -78,8 +80,10 @@ jobs:
runs-on: ubuntu-22.04
env:
VERSION: ${{ github.run_id }}
GHCR_IMAGE_NAME: "ghcr.io/enix/kube-image-keeper"
GHCR_REGISTRY: "ghcr.io"
HARBOR_IMAGE: "harbor.enix.io/kube-image-keeper/kube-image-keeper"
HARBOR_REGISTRY: "harbor.enix.io"
HARBOR_USERNAME: ${{ secrets.HARBOR_USERNAME }}
HARBOR_PASSWORD: ${{ secrets.HARBOR_PASSWORD }}
strategy:
max-parallel: 6
matrix:
Expand Down Expand Up @@ -126,13 +130,12 @@ jobs:
run : |
set -euo pipefail
kubectl create namespace kuik-system
kubectl create secret docker-registry ghcr-secret -n kuik-system --docker-server=https://ghcr.io \
--docker-username=monkeynator --docker-password=${{ secrets.RELEASE_GITHUB_TOKEN }} \
--docker-email=${{ env.COMMIT_EMAIL }}
kubectl create secret docker-registry harbor-secret -n kuik-system --docker-server=${{ env.HARBOR_REGISTRY }} \
--docker-username="$HARBOR_USERNAME" --docker-password="$HARBOR_PASSWORD"
helm upgrade --install kube-image-keeper -n kuik-system --create-namespace ./helm/kube-image-keeper \
--set controllers.image.tag=${{ env.VERSION }} --set proxy.image.tag=${{ env.VERSION }} \
--set controllers.image.repository=${{ env.GHCR_IMAGE_NAME }} --set proxy.image.repository=${{ env.GHCR_IMAGE_NAME }} \
--set controllers.imagePullSecrets[0].name=ghcr-secret --set proxy.image.imagePullSecrets[0].name=ghcr-secret --debug
--set controllers.image.tag=$VERSION --set proxy.image.tag=$VERSION \
--set controllers.image.repository=$HARBOR_IMAGE --set proxy.image.repository=$HARBOR_IMAGE \
--set controllers.imagePullSecrets[0].name=harbor-secret --set proxy.image.imagePullSecrets[0].name=harbor-secret --debug
kubectl wait pods -n kuik-system -l app.kubernetes.io/instance=kube-image-keeper --for condition=Ready --timeout=30s

- name: Run end-to-end tests
Expand Down Expand Up @@ -165,18 +168,20 @@ jobs:
while [[ $attempts -lt 3 && $success == false ]]
do
response=$(kubectl run curl-pod --image=curlimages/curl --rm -ti --quiet --restart=Never -- curl -s -o /dev/null -w "%{http_code}\n" http://$ip:8080/metrics)
if [[ $response -ge 200 && $response -lt 300 ]]; then
if [[ -z "$response" ]]; then
echo "No HTTP response received from $ip"
elif [[ $response -ge 200 && $response -lt 300 ]]; then
echo "HTTP status code $response is valid for $ip"
success=true
else
echo "HTTP status code $response is not valid for $ip"
((attempts++))
sleep 5
fi
attempts=$(( $attempts + 1 ))
sleep 3
done
if [[ $success == false ]]; then
echo "Failed after 3 attempts for $ip"
exit 1
echo "Failed after 3 attempts for $ip"
exit 1
fi
done
done