diff --git a/.github/workflows/integration_test.yaml b/.github/workflows/integration_test.yaml index eab25070f..10e3b8177 100644 --- a/.github/workflows/integration_test.yaml +++ b/.github/workflows/integration_test.yaml @@ -151,6 +151,10 @@ on: If this parameter is not specified, the default behavior is to use 'artifact' for pull requests originating from forked repositories, and 'registry' for all other cases. default: "" + use-canonical-k8s: + type: boolean + description: (Experimental) Whether to use canonical k8s instead of microk8s + default: false working-directory: type: string description: The working directory for jobs @@ -331,6 +335,7 @@ jobs: plan: ${{ needs.plan.outputs.plan }} pre-run-script: ${{ inputs.pre-run-script }} provider: ${{ inputs.provider }} + use-canonical-k8s: ${{ inputs.use-canonical-k8s }} registry: ghcr.io self-hosted-runner-arch: ${{ inputs.self-hosted-runner-arch }} self-hosted-runner-label: ${{ inputs.self-hosted-runner-label }} diff --git a/.github/workflows/integration_test_run.yaml b/.github/workflows/integration_test_run.yaml index 267ef33ba..16b884370 100644 --- a/.github/workflows/integration_test_run.yaml +++ b/.github/workflows/integration_test_run.yaml @@ -116,6 +116,10 @@ on: type: string description: Target directory to do the Trivy testing default: "." + use-canonical-k8s: + type: boolean + description: (Experimental) Whether to use canonical k8s instead of microk8s + default: false working-directory: type: string description: The working directory for jobs @@ -171,10 +175,26 @@ jobs: )) || inputs.runs-on }} steps: + - name: Setup Canonical k8s + if: ${{ inputs.use-canonical-k8s }} == true + id: canonical-k8s + run: | + sudo snap install k8s --channel=1.30-classic/beta --classic + sudo k8s bootstrap + mkdir -p ~/.kube + sudo k8s config > ~/.kube/config + echo "kubeconfig=$(sudo k8s config | base64 -w 0)" >> $GITHUB_OUTPUT + + IPADDR=$(ip -4 -j route get 2.2.2.2 | jq -r '.[] | .prefsrc') + LB_FIRST_ADDR="$(echo "${IPADDR}" | awk -F'.' '{print $1,$2,$3,100}' OFS='.')" + LB_LAST_ADDR="$(echo "${IPADDR}" | awk -F'.' '{print $1,$2,$3,255}' OFS='.')" + LB_ADDR_RANGE="${LB_FIRST_ADDR}-${LB_LAST_ADDR}" + sudo k8s set load-balancer.cidrs=$LB_ADDR_RANGE load-balancer.enabled=true load-balancer.l2-mode=true - name: Setup operator environment uses: charmed-kubernetes/actions-operator@main with: provider: ${{ inputs.provider }} + credentials-yaml: ${{ steps.canonical-k8s.outputs.kubeconfig }} microk8s-addons: >- ${{ ( @@ -296,7 +316,7 @@ jobs: echo "MODULE=$module" >> $GITHUB_ENV - name: Run k8s integration tests working-directory: ${{ inputs.working-directory }} - if: ${{ inputs.provider == 'microk8s' }} + if: ${{ inputs.provider == 'microk8s' }} || ${ inputs.provider == 'k8s' } run: | tox -e ${{ inputs.test-tox-env }} -- --model testing --keep-models ${{ env.SERIES }} ${{ env.MODULE }} ${{ env.ARGS }} ${{ inputs.extra-arguments }} ${{ secrets.INTEGRATION_TEST_ARGS }} - name: Run lxd integration tests