Simplify S2I deployment - remove unnecessary template complexity

- Replace complex template with simple oc new-app command
- Remove dependency on openshift-s2i.yaml template
- Add ultra-simple deploy-s2i-simple.sh script (one command)
- Keep resource configuration via oc patch
- Maintain same functionality with much simpler approach
- Follow OpenShift best practices for S2I deployment
- Reduce maintenance overhead and complexity
This commit is contained in:
2025-10-04 09:10:02 -03:00
parent 04aca2f56e
commit 4eec703cba
2 changed files with 101 additions and 16 deletions

65
scripts/deploy-s2i-simple.sh Executable file
View File

@@ -0,0 +1,65 @@
#!/bin/bash
# Ultra-simple S2I deployment - just run this one command!
set -e
echo "🚀 Ultra-Simple ORU Analyzer S2I Deployment"
echo "============================================="
# Check if logged in
if ! oc whoami >/dev/null 2>&1; then
echo "❌ Not logged in to OpenShift. Please run 'oc login' first"
exit 1
fi
# Create namespace
echo "📦 Creating namespace..."
oc new-project resource-governance 2>/dev/null || echo "Namespace already exists"
# Deploy with oc new-app (super simple!)
echo "🚀 Deploying with oc new-app..."
oc new-app python:3.11~https://github.com/andersonid/openshift-resource-governance.git \
--name=oru-analyzer \
--env=PYTHON_VERSION=3.11 \
--env=APP_ROOT=/app
# Configure resources
echo "⚙️ Configuring resources..."
oc patch deploymentconfig/oru-analyzer -p '{
"spec": {
"template": {
"spec": {
"containers": [{
"name": "oru-analyzer",
"resources": {
"requests": {"cpu": "50m", "memory": "64Mi"},
"limits": {"cpu": "200m", "memory": "256Mi"}
}
}]
}
}
}
}'
# Wait for build and deployment
echo "⏳ Waiting for build and deployment..."
oc logs -f buildconfig/oru-analyzer &
BUILD_PID=$!
# Wait for build to complete
oc wait --for=condition=Complete buildconfig/oru-analyzer --timeout=600s
kill $BUILD_PID 2>/dev/null || true
# Wait for deployment
oc rollout status deploymentconfig/oru-analyzer --timeout=300s
# Get URL
ROUTE_URL=$(oc get route oru-analyzer -o jsonpath='{.spec.host}' 2>/dev/null || echo "")
echo ""
echo "✅ Deployment Complete!"
echo "🌐 Application URL: https://$ROUTE_URL"
echo ""
echo "📊 Check status:"
echo " oc get pods -n resource-governance"
echo " oc logs -f deploymentconfig/oru-analyzer -n resource-governance"

View File

@@ -73,25 +73,44 @@ create_namespace() {
fi
}
# Deploy using S2I template
# Deploy using oc new-app (simpler S2I)
deploy_s2i() {
print_status "Deploying using S2I template..."
print_status "Deploying using oc new-app S2I..."
# Process template with parameters
oc process -f openshift-s2i.yaml \
-p NAME="$APP_NAME" \
-p NAMESPACE="$NAMESPACE" \
-p GIT_REPOSITORY="$GIT_REPO" \
-p GIT_REF="$GIT_REF" \
-p PYTHON_VERSION="$PYTHON_VERSION" \
-p CPU_REQUEST="50m" \
-p CPU_LIMIT="200m" \
-p MEMORY_REQUEST="64Mi" \
-p MEMORY_LIMIT="256Mi" \
-p REPLICAS="1" \
| oc apply -f -
# Use oc new-app for simple S2I deployment
oc new-app python:3.11~"$GIT_REPO" \
--name="$APP_NAME" \
--env=PYTHON_VERSION=3.11 \
--env=APP_ROOT=/app \
--namespace="$NAMESPACE"
print_success "S2I template applied successfully"
print_success "S2I application created successfully"
# Configure resource requests and limits
print_status "Configuring resource requests and limits..."
oc patch deploymentconfig/"$APP_NAME" -p '{
"spec": {
"template": {
"spec": {
"containers": [{
"name": "'"$APP_NAME"'",
"resources": {
"requests": {
"cpu": "50m",
"memory": "64Mi"
},
"limits": {
"cpu": "200m",
"memory": "256Mi"
}
}
}]
}
}
}
}'
print_success "Resource configuration applied"
}
# Wait for build to complete
@@ -176,6 +195,7 @@ main() {
echo "Git Repository: $GIT_REPO"
echo "Git Reference: $GIT_REF"
echo "Python Version: $PYTHON_VERSION"
echo "Method: oc new-app (simplified S2I)"
echo "=========================================="
echo ""