diff --git a/Makefile b/Makefile index 0a6fa4b..9f037fa 100755 --- a/Makefile +++ b/Makefile @@ -1,11 +1,20 @@ BUILD_TARGET?=workload-app NAMESPACE?=workload-web-app -CONTAINER_ENGINE?=docker + +# Auto-detect container engine if not specified +CONTAINER_ENGINE?=$(shell command -v podman >/dev/null 2>&1 && echo podman || echo docker) + CONTAINER_PLATFORM?=linux/amd64 TOOLS_IMAGE?=quay.io/integreatly/workload-web-app-tools WORKLOAD_WEB_APP_IMAGE?= # Alternative image KUBECONFIG?=${HOME}/.kube/config -ADDITIONAL_CONTAINER_ENGINE_PARAMS?= + +# Podman-specific parameters for better compatibility +ifeq ($(CONTAINER_ENGINE),podman) + ADDITIONAL_CONTAINER_ENGINE_PARAMS?=--userns=keep-id +else + ADDITIONAL_CONTAINER_ENGINE_PARAMS?= +endif in_container = ${CONTAINER_ENGINE} run --rm -it ${ADDITIONAL_CONTAINER_ENGINE_PARAMS} \ -e KUBECONFIG=/kube.config \ @@ -23,8 +32,20 @@ in_container = ${CONTAINER_ENGINE} run --rm -it ${ADDITIONAL_CONTAINER_ENGINE_PA test: @echo "SUCCESS" +.PHONY: container-engine +container-engine: + @echo "Container Engine: $(CONTAINER_ENGINE)" + @echo "Platform: $(CONTAINER_PLATFORM)" + @echo "Additional Parameters: $(ADDITIONAL_CONTAINER_ENGINE_PARAMS)" + @$(CONTAINER_ENGINE) --version + +.PHONY: validate-engine +validate-engine: + @command -v $(CONTAINER_ENGINE) >/dev/null 2>&1 || { echo "$(CONTAINER_ENGINE) not found. Please install $(CONTAINER_ENGINE) or use CONTAINER_ENGINE= to specify another."; exit 1; } + @echo "✓ $(CONTAINER_ENGINE) is available" + .PHONY: image/build/tools -image/build/tools: +image/build/tools: validate-engine ${CONTAINER_ENGINE} build --platform=$(CONTAINER_PLATFORM) -t ${TOOLS_IMAGE} -f Dockerfile.tools . local/deploy: image/build/tools @@ -33,7 +54,7 @@ local/deploy: image/build/tools local/undeploy: image/build/tools $(call in_container,undeploy) -local/build-deploy: +local/build-deploy: validate-engine ${CONTAINER_ENGINE} build --platform=$(CONTAINER_PLATFORM) -t ${WORKLOAD_WEB_APP_IMAGE} . ${CONTAINER_ENGINE} push ${WORKLOAD_WEB_APP_IMAGE} $(call in_container,deploy) diff --git a/README.md b/README.md index d96a67e..e55ac50 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,26 @@ # workload-web-app A test app for simulating the workload on the openshift cluster based on end-user use cases in order to monitor the downtime of component products in integreatly during an upgrade. +## Container Engine Support + +This application supports both **Docker** and **Podman**. The Makefile automatically detects which container engine is available: + +- If Podman is available, it uses Podman +- If only Docker is available, it uses Docker +- You can override the detection by setting `CONTAINER_ENGINE=docker` or `CONTAINER_ENGINE=podman` + +### Check your container engine + +You can check which container engines are available and get setup guidance: + +```bash +# Quick environment check with helpful tips +./check-container-engine.sh + +# Or use the Makefile target for basic info +make container-engine +``` + ## Deploying the Application on the RHOAM cluster To deploy the app to a RHOAM cluster, you will need to: @@ -15,7 +35,21 @@ To deploy the app to a RHOAM cluster, you will need to: export RHOAMI=true ``` 4. Then run this command to deploy the app: - ```make local/deploy``` + ```bash + make local/deploy + ``` + +### Using a specific container engine + +If you want to use a specific container engine, set the `CONTAINER_ENGINE` variable: + +```bash +# Using Docker +CONTAINER_ENGINE=docker make local/deploy + +# Using Podman +CONTAINER_ENGINE=podman make local/deploy +``` ## Delete the app @@ -28,9 +62,34 @@ Note: It might take up to 15 minutes for 3scale to fully remove the service (Pro ## Troubleshooting -In case of `make: stat: Makefile: Permission denied` error try to use privileged: +### Container Engine Issues -``` -ADDITIONAL_CONTAINER_ENGINE_PARAMS="--privileged" CONTAINER_ENGINE=podman make local/deploy -``` +1. **Check if your container engine is working:** + ```bash + make validate-engine + ``` + +2. **Permission denied errors with Podman:** + ```bash + ADDITIONAL_CONTAINER_ENGINE_PARAMS="--privileged" make local/deploy + ``` + +3. **SELinux issues with volume mounts:** + The Makefile automatically adds `:z` labels for SELinux compatibility. If you still have issues: + ```bash + ADDITIONAL_CONTAINER_ENGINE_PARAMS="--privileged --security-opt label=disable" make local/deploy + ``` + +4. **Force a specific container engine:** + ```bash + # Force Docker even if Podman is available + CONTAINER_ENGINE=docker make local/deploy + + # Force Podman even if Docker is available + CONTAINER_ENGINE=podman make local/deploy + ``` + +### 3scale Service Issues + +Note: It might take up to 15 minutes for 3scale to fully remove the service (Product) hence you need to wait this long after undeploy if you want to deploy the workload-web-app again. In case the service is not fully removed yet the deployment fails with `System name has already been taken` error. diff --git a/check-container-engine.sh b/check-container-engine.sh new file mode 100755 index 0000000..312f9cd --- /dev/null +++ b/check-container-engine.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +# Container Engine Detection and Validation Script +# This script helps users understand which container engine will be used + +set -e + +echo "🔍 Container Engine Detection Report" +echo "==================================" + +# Check for Podman +if command -v podman >/dev/null 2>&1; then + echo "✅ Podman found: $(podman --version)" + PODMAN_AVAILABLE=true +else + echo "❌ Podman not found" + PODMAN_AVAILABLE=false +fi + +# Check for Docker +if command -v docker >/dev/null 2>&1; then + echo "✅ Docker found: $(docker --version)" + DOCKER_AVAILABLE=true +else + echo "❌ Docker not found" + DOCKER_AVAILABLE=false +fi + +echo "" + +# Determine which engine would be used +if [ "$DOCKER_AVAILABLE" = true ] && [ "$PODMAN_AVAILABLE" = true ]; then + echo "🎯 Both container engines are available!" + echo " The Makefile will automatically use: Podman (preferred)" + echo " To use Docker instead: CONTAINER_ENGINE=docker make " +elif [ "$PODMAN_AVAILABLE" = true ]; then + echo "🎯 Only Podman is available - it will be used automatically" +elif [ "$DOCKER_AVAILABLE" = true ]; then + echo "🎯 Only Docker is available - it will be used automatically" +else + echo "❌ No container engine found!" + echo " Please install either Docker or Podman to continue" + exit 1 +fi + +echo "" +echo "📋 Quick Commands:" +echo " Check current detection: make container-engine" +echo " Validate your engine: make validate-engine" +echo " Deploy with auto-detect: make local/deploy" +echo " Deploy with Docker: CONTAINER_ENGINE=docker make local/deploy" +echo " Deploy with Podman: CONTAINER_ENGINE=podman make local/deploy" + +if [ "$PODMAN_AVAILABLE" = true ]; then + echo "" + echo "💡 Podman Tips:" + echo " - If you encounter permission issues, try:" + echo " ADDITIONAL_CONTAINER_ENGINE_PARAMS=\"--privileged\" make local/deploy" + echo " - For SELinux systems, volume mounts include :z labels automatically" +fi + +echo "" +echo "✅ Environment check complete!"