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:
@@ -45,6 +45,23 @@ jobs:
|
|||||||
- name: Setup kubectl
|
- name: Setup kubectl
|
||||||
uses: azure/setup-kubectl@v4
|
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
|
- name: Apply RBAC for E2E pipeline
|
||||||
run: |
|
run: |
|
||||||
set -x
|
set -x
|
||||||
|
|||||||
Reference in New Issue
Block a user