diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 7ee92ce..e8864f2 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -45,6 +45,35 @@ jobs: - name: Setup kubectl uses: azure/setup-kubectl@v4 + - name: Apply RBAC for E2E pipeline + run: | + set -x + kubectl apply -f deployment/e2e-ci-runner-rbac.yaml --dry-run=server 2>&1 || true + kubectl apply -f deployment/e2e-ci-runner-rbac.yaml 2>&1 + echo "exit code: $?" + echo "Waiting for RBAC propagation (Kubernetes subject access review caching)..." + sleep 5 + echo "Verifying CI runner permissions..." + kubectl auth can-i create roles -n headlamp-dev --as="system:serviceaccount:arc-runners:runners-privilegedescalation-gha-rs-no-permission" 2>&1 || { echo "::error::CI runner still lacks roles permission after propagation wait"; exit 1; } + set +x + + - name: Apply Polaris dashboard RBAC + run: kubectl apply -f deployment/polaris-rbac.yaml + + - name: RBAC pre-flight check + run: | + echo "Checking RBAC resources..." + MISSING=0 + kubectl get role polaris-dashboard-proxy-reader -n polaris -o name >/dev/null 2>&1 || MISSING=1 + kubectl get rolebinding polaris-dashboard-proxy-reader -n polaris -o name >/dev/null 2>&1 || MISSING=1 + kubectl auth can-i delete configmaps -n "$E2E_NAMESPACE" --quiet 2>/dev/null || MISSING=1 + if [ "$MISSING" -eq 0 ]; then + echo "RBAC pre-flight check passed." + else + echo "::error::RBAC pre-flight check failed. Missing required permissions." + exit 1 + fi + - name: Install dependencies run: npm ci diff --git a/deployment/e2e-ci-runner-rbac.yaml b/deployment/e2e-ci-runner-rbac.yaml index e6bf4ff..069c5ee 100644 --- a/deployment/e2e-ci-runner-rbac.yaml +++ b/deployment/e2e-ci-runner-rbac.yaml @@ -30,6 +30,34 @@ rules: - apiGroups: [""] resources: ["serviceaccounts/token"] verbs: ["create"] + # Apply Polaris dashboard RBAC in the polaris namespace + - apiGroups: ["rbac.authorization.k8s.io"] + resources: ["roles", "rolebindings"] + verbs: ["get", "list", "create", "update", "patch", "delete"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: e2e-ci-runner-polaris + namespace: polaris +rules: + - apiGroups: ["rbac.authorization.k8s.io"] + resources: ["roles", "rolebindings"] + verbs: ["get", "list", "create", "update", "patch", "delete"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: e2e-ci-runner-polaris + namespace: polaris +subjects: + - kind: ServiceAccount + name: runners-privilegedescalation-gha-rs-no-permission + namespace: arc-runners +roleRef: + kind: Role + name: e2e-ci-runner-polaris + apiGroup: rbac.authorization.k8s.io --- apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding