diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 03e0b3f8..e35a2e8a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 @@ -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 @@ -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 @@ -170,7 +172,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 needs: @@ -178,8 +180,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: @@ -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 @@ -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 diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 9c9683b7..7adfaa7c 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -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 @@ -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 }} @@ -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 @@ -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 @@ -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: @@ -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 @@ -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