feat: add make crc-* targets for OpenShift Local deployment#1174
feat: add make crc-* targets for OpenShift Local deployment#1174Gkrumbach07 wants to merge 2 commits into
Conversation
Add new `make crc-*` targets to provide a clear way to deploy and manage local OpenShift (CRC) environments. New targets: - crc-up: Start CRC cluster and deploy the platform - crc-down: Stop CRC deployments (keep cluster running) - crc-clean: Full cleanup including CRC cluster - crc-status: Show CRC cluster and deployment status - crc-test: Run CRC environment tests - crc-rebuild: Rebuild and redeploy all components - crc-logs: Show logs from all components - crc-logs-backend: Backend logs only - crc-logs-frontend: Frontend logs only - crc-logs-operator: Operator logs only These targets use existing CRC scripts in components/scripts/local-dev/ and mirror the functionality of the kind-* targets for consistency. Configuration variables: - CRC_CPUS (default: 4) - CRC_MEMORY (default: 11264 MB) - CRC_DISK (default: 50 GB) - CRC_PROJECT_NAME (default: vteam-dev) Resolves #1116 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthroughAdds new Makefile targets for OpenShift Local (CRC) lifecycle, testing, rebuilding, and logs, and introduces CRC configuration variables ( Changes
🚥 Pre-merge checks | ✅ 8✅ Passed checks (8 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@Makefile`:
- Around line 1050-1053: The crc-clean Makefile target calls
components/scripts/local-dev/crc-stop.sh with CLI flags but the script reads
STOP_CLUSTER and DELETE_PROJECT environment variables; update the crc-clean
recipe (target "crc-clean") to export or prefix the call with STOP_CLUSTER=true
and DELETE_PROJECT=true (and keep PROJECT_NAME=$(CRC_PROJECT_NAME)) so the
script sees these env vars (e.g., PROJECT_NAME=$(CRC_PROJECT_NAME)
STOP_CLUSTER=true DELETE_PROJECT=true bash
components/scripts/local-dev/crc-stop.sh --stop-cluster --delete-project should
be replaced with PROJECT_NAME=$(CRC_PROJECT_NAME) STOP_CLUSTER=true
DELETE_PROJECT=true bash components/scripts/local-dev/crc-stop.sh).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
…rc-clean The crc-stop.sh script reads STOP_CLUSTER and DELETE_PROJECT as environment variables. Use env var prefixes instead of CLI flags for consistency and clarity. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@Makefile`:
- Around line 1077-1096: The crc-rebuild target currently only checks oc
authentication and swallows failures, so it may run against the wrong OpenShift
cluster and still print success; update the crc-rebuild recipe to (1) verify the
active server is the local CRC cluster (e.g. use oc whoami --show-server or
inspect oc config current-context/server and compare against the expected CRC
host) before proceeding and fail early if it doesn't match, and (2) stop
suppressing errors from oc start-build and oc rollout restart (remove the "||
echo …" and "|| true" fallbacks) so the Make target exits non-zero on build or
restart failures and does not print the final success message unless all steps
succeed (adjust the final echo to only run on success).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
| crc-rebuild: ## Rebuild and redeploy all components in CRC | ||
| @echo "$(COLOR_BLUE)▶$(COLOR_RESET) Rebuilding all components..." | ||
| @if ! oc whoami >/dev/null 2>&1; then \ | ||
| echo "$(COLOR_RED)✗$(COLOR_RESET) Not logged into OpenShift. Run 'make crc-up' first."; \ | ||
| exit 1; \ | ||
| fi | ||
| @echo "$(COLOR_BLUE)▶$(COLOR_RESET) Rebuilding backend..." | ||
| @oc start-build vteam-backend --from-dir=components/backend --wait -n $(CRC_PROJECT_NAME) || \ | ||
| echo "$(COLOR_YELLOW)Backend build failed (may need to create BuildConfig first)$(COLOR_RESET)" | ||
| @echo "$(COLOR_BLUE)▶$(COLOR_RESET) Rebuilding frontend..." | ||
| @oc start-build vteam-frontend --from-dir=components/frontend --wait -n $(CRC_PROJECT_NAME) || \ | ||
| echo "$(COLOR_YELLOW)Frontend build failed (may need to create BuildConfig first)$(COLOR_RESET)" | ||
| @echo "$(COLOR_BLUE)▶$(COLOR_RESET) Rebuilding operator..." | ||
| @oc start-build vteam-operator --from-dir=components/operator --wait -n $(CRC_PROJECT_NAME) || \ | ||
| echo "$(COLOR_YELLOW)Operator build failed (may need to create BuildConfig first)$(COLOR_RESET)" | ||
| @echo "$(COLOR_BLUE)▶$(COLOR_RESET) Restarting deployments..." | ||
| @oc rollout restart deployment/vteam-backend -n $(CRC_PROJECT_NAME) 2>/dev/null || true | ||
| @oc rollout restart deployment/vteam-frontend -n $(CRC_PROJECT_NAME) 2>/dev/null || true | ||
| @oc rollout restart deployment/vteam-operator -n $(CRC_PROJECT_NAME) 2>/dev/null || true | ||
| @echo "$(COLOR_GREEN)✓$(COLOR_RESET) All components rebuilt and restarted" |
There was a problem hiding this comment.
crc-rebuild can hit the wrong cluster and still report success.
This target only checks that oc is authenticated, not that the active server is the local CRC cluster, so the build/restart calls can run against any logged-in OpenShift environment. On top of that, Lines 1084-1095 swallow failures with || echo / || true, so the recipe can print a green success message even when rebuilds or rollouts failed.
Suggested fix
crc-rebuild: ## Rebuild and redeploy all components in CRC
`@echo` "$(COLOR_BLUE)▶$(COLOR_RESET) Rebuilding all components..."
`@if` ! oc whoami >/dev/null 2>&1; then \
echo "$(COLOR_RED)✗$(COLOR_RESET) Not logged into OpenShift. Run 'make crc-up' first."; \
exit 1; \
fi
- `@echo` "$(COLOR_BLUE)▶$(COLOR_RESET) Rebuilding backend..."
- `@oc` start-build vteam-backend --from-dir=components/backend --wait -n $(CRC_PROJECT_NAME) || \
- echo "$(COLOR_YELLOW)Backend build failed (may need to create BuildConfig first)$(COLOR_RESET)"
- `@echo` "$(COLOR_BLUE)▶$(COLOR_RESET) Rebuilding frontend..."
- `@oc` start-build vteam-frontend --from-dir=components/frontend --wait -n $(CRC_PROJECT_NAME) || \
- echo "$(COLOR_YELLOW)Frontend build failed (may need to create BuildConfig first)$(COLOR_RESET)"
- `@echo` "$(COLOR_BLUE)▶$(COLOR_RESET) Rebuilding operator..."
- `@oc` start-build vteam-operator --from-dir=components/operator --wait -n $(CRC_PROJECT_NAME) || \
- echo "$(COLOR_YELLOW)Operator build failed (may need to create BuildConfig first)$(COLOR_RESET)"
- `@echo` "$(COLOR_BLUE)▶$(COLOR_RESET) Restarting deployments..."
- `@oc` rollout restart deployment/vteam-backend -n $(CRC_PROJECT_NAME) 2>/dev/null || true
- `@oc` rollout restart deployment/vteam-frontend -n $(CRC_PROJECT_NAME) 2>/dev/null || true
- `@oc` rollout restart deployment/vteam-operator -n $(CRC_PROJECT_NAME) 2>/dev/null || true
+ `@SERVER`=$$(oc whoami --show-server 2>/dev/null || true); \
+ case "$$SERVER" in \
+ *crc*) ;; \
+ *) echo "$(COLOR_RED)✗$(COLOR_RESET) Current oc target is not the local CRC cluster: $$SERVER"; exit 1 ;; \
+ esac
+ `@set` -e; \
+ echo "$(COLOR_BLUE)▶$(COLOR_RESET) Rebuilding backend..."; \
+ oc start-build vteam-backend --from-dir=components/backend --wait -n $(CRC_PROJECT_NAME); \
+ echo "$(COLOR_BLUE)▶$(COLOR_RESET) Rebuilding frontend..."; \
+ oc start-build vteam-frontend --from-dir=components/frontend --wait -n $(CRC_PROJECT_NAME); \
+ echo "$(COLOR_BLUE)▶$(COLOR_RESET) Rebuilding operator..."; \
+ oc start-build vteam-operator --from-dir=components/operator --wait -n $(CRC_PROJECT_NAME); \
+ echo "$(COLOR_BLUE)▶$(COLOR_RESET) Restarting deployments..."; \
+ oc rollout restart deployment/vteam-backend -n $(CRC_PROJECT_NAME); \
+ oc rollout restart deployment/vteam-frontend -n $(CRC_PROJECT_NAME); \
+ oc rollout restart deployment/vteam-operator -n $(CRC_PROJECT_NAME)
`@echo` "$(COLOR_GREEN)✓$(COLOR_RESET) All components rebuilt and restarted"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@Makefile` around lines 1077 - 1096, The crc-rebuild target currently only
checks oc authentication and swallows failures, so it may run against the wrong
OpenShift cluster and still print success; update the crc-rebuild recipe to (1)
verify the active server is the local CRC cluster (e.g. use oc whoami
--show-server or inspect oc config current-context/server and compare against
the expected CRC host) before proceeding and fail early if it doesn't match, and
(2) stop suppressing errors from oc start-build and oc rollout restart (remove
the "|| echo …" and "|| true" fallbacks) so the Make target exits non-zero on
build or restart failures and does not print the final success message unless
all steps succeed (adjust the final echo to only run on success).
Summary
Adds new
make crc-*targets to provide a clear way to deploy and manage local OpenShift (CRC) environments. This addresses the retirement ofmake local-*targets by providing explicit CRC deployment commands.Changes
New Makefile Targets
make crc-up: Start CRC cluster and deploy the platformCRC_CPUS,CRC_MEMORY,CRC_DISK,CRC_PROJECT_NAMEcomponents/scripts/local-dev/crc-start.shmake crc-down: Stop CRC deployments (keep cluster running)make crc-clean: Full cleanup including CRC clustermake crc-status: Show CRC cluster and deployment statusmake crc-test: Run CRC environment testscomponents/scripts/local-dev/crc-test.shmake crc-rebuild: Rebuild and redeploy all componentsmake crc-logs: Show logs from all CRC components (follow mode)make crc-logs-backend: Backend logs onlymake crc-logs-frontend: Frontend logs onlymake crc-logs-operator: Operator logs onlyConfiguration Variables
Design Decisions
kind-*pattern: The new targets follow the same naming and structure as existingkind-*targets for consistencycomponents/scripts/local-dev/local-*targetsTesting
Verified with:
Related Issues
make local-*targets)Checklist
.PHONYdeclarationsNote: This PR introduces the Makefile targets only. The underlying CRC scripts (
crc-start.sh,crc-stop.sh,crc-test.sh) already exist incomponents/scripts/local-dev/.Summary by CodeRabbit