Fix E2E kubeconfig: locate kubeconfig before RBAC step

The 'kubectl auth can-i --as' impersonation check was falling back to
localhost:8080 because KUBECONFIG was not set and the ARC runner's
kubeconfig was not in the default location. azure/setup-kubectl@v4
does not set KUBECONFIG — it installs kubectl and relies on the runner's
existing kubeconfig in /runner/.kube/config (ARC runner home).

Add a 'Locate kubeconfig for ARC runner' step that searches the known
runner kubeconfig paths before the RBAC step runs, exports KUBECONFIG
to GITHUB_ENV, and verifies cluster connectivity before proceeding.

Fixes: PRI-785
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
2026-05-05 19:47:08 +00:00
committed by Hugh Hackman [agent]
parent c79a4bdfa9
commit fcb0018216
+17
View File
@@ -45,6 +45,23 @@ jobs:
- name: Setup kubectl
uses: azure/setup-kubectl@v4
- name: Locate kubeconfig for ARC runner
run: |
set -euo pipefail
for dir in /runner /home/runner/.kube /home/github/.kube; do
if [ -f "${dir}/config" ]; then
echo "Found kubeconfig at ${dir}/config"
echo "KUBECONFIG=${dir}/config" >> "$GITHUB_ENV"
break
fi
done
if [ -z "${KUBECONFIG:-}" ]; then
echo "::error::No kubeconfig found for ARC runner. Checked: /runner, ~/.kube, ~/kube"
exit 1
fi
echo "Using kubeconfig: ${KUBECONFIG}"
kubectl cluster-info --request-timeout=5s
- name: Apply RBAC for E2E pipeline
run: |
set -x