Apply RBAC manifest in CI before pre-flight check
Make the E2E workflow self-sufficient by applying the polaris-rbac.yaml manifest before the pre-flight check, instead of requiring manual cluster pre-configuration. Before: workflow checked for RBAC and failed fast, but had no mechanism to apply it — it was purely a detection step. After: workflow applies the RBAC manifest (idempotent kubectl apply), then verifies the resources exist as a correctness check. Also collapses MISSING_ROLE and MISSING_ROLEBINDING into a single boolean flag and drops the non-standard --quiet flag on kubectl get. Fixes: PRI-324 Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -45,31 +45,20 @@ jobs:
|
|||||||
- name: Setup kubectl
|
- name: Setup kubectl
|
||||||
uses: azure/setup-kubectl@v4
|
uses: azure/setup-kubectl@v4
|
||||||
|
|
||||||
|
- name: Apply RBAC for Polaris dashboard proxy
|
||||||
|
run: kubectl apply -f deployment/polaris-rbac.yaml
|
||||||
|
|
||||||
- name: RBAC pre-flight check
|
- name: RBAC pre-flight check
|
||||||
run: |
|
run: |
|
||||||
echo "Checking RBAC resources in polaris namespace..."
|
echo "Checking RBAC resources in polaris namespace..."
|
||||||
MISSING_ROLE=false
|
if kubectl get role polaris-dashboard-proxy-reader -n polaris -o name >/dev/null 2>&1 && \
|
||||||
MISSING_ROLEBINDING=false
|
kubectl get rolebinding polaris-dashboard-proxy-reader -n polaris -o name >/dev/null 2>&1; then
|
||||||
|
echo "RBAC pre-flight check passed."
|
||||||
if ! kubectl get role polaris-dashboard-proxy-reader -n polaris --quiet 2>/dev/null; then
|
else
|
||||||
echo "::error::Role polaris-dashboard-proxy-reader not found in polaris namespace."
|
echo "::error::Role or RoleBinding not found in polaris namespace after apply."
|
||||||
MISSING_ROLE=true
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! kubectl get rolebinding polaris-dashboard-proxy-reader -n polaris --quiet 2>/dev/null; then
|
|
||||||
echo "::error::RoleBinding polaris-dashboard-proxy-reader not found in polaris namespace."
|
|
||||||
MISSING_ROLEBINDING=true
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$MISSING_ROLE" = true ] || [ "$MISSING_ROLEBINDING" = true ]; then
|
|
||||||
echo ""
|
|
||||||
echo "::error::RBAC not applied. Apply the RBAC manifests before running E2E tests:"
|
|
||||||
echo "::error:: kubectl apply -f deployment/polaris-rbac.yaml"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "RBAC pre-flight check passed."
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user