Standardize all scripts to English without emojis

This commit is contained in:
2025-10-04 10:25:53 -03:00
parent 5e9ffa1f4b
commit 14900fc27f
4 changed files with 135 additions and 125 deletions

View File

@@ -1,81 +1,81 @@
#!/bin/bash
# Script de build e push para OpenShift Resource Governance Tool usando Podman
# Build and push script for OpenShift Resource Governance Tool using Podman
set -e
# Cores para output
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Configurações
# Configuration
IMAGE_NAME="resource-governance"
TAG="${1:-latest}"
REGISTRY="${2:-quay.io/rh_ee_anobre}"
FULL_IMAGE_NAME="${REGISTRY}/${IMAGE_NAME}:${TAG}"
echo -e "${BLUE}🚀 Building and Pushing OpenShift Resource Governance Tool${NC}"
echo -e "${BLUE}Building and Pushing OpenShift Resource Governance Tool${NC}"
echo -e "${BLUE}Image: ${FULL_IMAGE_NAME}${NC}"
# Verificar se Podman está instalado
# Check if Podman is installed
if ! command -v podman &> /dev/null; then
echo -e "${RED} Podman não está instalado. Instale o Podman e tente novamente.${NC}"
echo -e "${RED}ERROR: Podman is not installed. Please install Podman and try again.${NC}"
exit 1
fi
# Buildah é opcional, Podman pode fazer o build
# Buildah is optional, Podman can do the build
# Build da imagem
echo -e "${YELLOW}📦 Building container image with Podman...${NC}"
# Build image
echo -e "${YELLOW}Building container image with Podman...${NC}"
podman build -t "${FULL_IMAGE_NAME}" .
if [ $? -eq 0 ]; then
echo -e "${GREEN} Image built successfully!${NC}"
echo -e "${GREEN}SUCCESS: Image built successfully!${NC}"
else
echo -e "${RED} Build failed!${NC}"
echo -e "${RED}ERROR: Build failed!${NC}"
exit 1
fi
# Testar a imagem
echo -e "${YELLOW}🧪 Testing image...${NC}"
podman run --rm "${FULL_IMAGE_NAME}" python -c "import app.main; print(' App imports successfully')"
# Test image
echo -e "${YELLOW}Testing image...${NC}"
podman run --rm "${FULL_IMAGE_NAME}" python -c "import app.main; print('SUCCESS: App imports successfully')"
if [ $? -eq 0 ]; then
echo -e "${GREEN} Image test passed!${NC}"
echo -e "${GREEN}SUCCESS: Image test passed!${NC}"
else
echo -e "${RED} Image test failed!${NC}"
echo -e "${RED}ERROR: Image test failed!${NC}"
exit 1
fi
# Login no Quay.io
echo -e "${YELLOW}🔐 Logging into Quay.io...${NC}"
# Login to Quay.io
echo -e "${YELLOW}Logging into Quay.io...${NC}"
podman login -u="rh_ee_anobre+oru" -p="EJNIJD7FPO5IN33ZGQZ4OM8BIB3LICASBVRGOJCX4WP84Y0ZG5SMQLTZ0S6DOZEC" quay.io
if [ $? -eq 0 ]; then
echo -e "${GREEN} Login successful!${NC}"
echo -e "${GREEN}SUCCESS: Login successful!${NC}"
else
echo -e "${RED} Login failed!${NC}"
echo -e "${RED}ERROR: Login failed!${NC}"
exit 1
fi
# Push da imagem
echo -e "${YELLOW}📤 Pushing image to Quay.io...${NC}"
# Push image
echo -e "${YELLOW}Pushing image to Quay.io...${NC}"
podman push "${FULL_IMAGE_NAME}"
if [ $? -eq 0 ]; then
echo -e "${GREEN} Image pushed successfully!${NC}"
echo -e "${GREEN}SUCCESS: Image pushed successfully!${NC}"
else
echo -e "${RED} Push failed!${NC}"
echo -e "${RED}ERROR: Push failed!${NC}"
exit 1
fi
# Mostrar informações da imagem
echo -e "${BLUE}📊 Image information:${NC}"
# Show image information
echo -e "${BLUE}Image information:${NC}"
podman images "${FULL_IMAGE_NAME}"
echo -e "${GREEN}🎉 Build and push completed successfully!${NC}"
echo -e "${BLUE}🌐 Image available at: https://quay.io/repository/${REGISTRY#quay.io/}/${IMAGE_NAME}${NC}"
echo -e "${BLUE}🚀 Ready for deployment!${NC}"
echo -e "${BLUE}📋 Registry: Quay.io (public repository)${NC}"
echo -e "${GREEN}SUCCESS: Build and push completed successfully!${NC}"
echo -e "${BLUE}Image available at: https://quay.io/repository/${REGISTRY#quay.io/}/${IMAGE_NAME}${NC}"
echo -e "${BLUE}Ready for deployment!${NC}"
echo -e "${BLUE}Registry: Quay.io (public repository)${NC}"

View File

@@ -1,112 +1,112 @@
#!/bin/bash
# Script completo de deploy do OpenShift Resource Governance Tool
# Inclui criação de namespace, RBAC, ConfigMap, Secret e Deployment
# Complete deployment script for OpenShift Resource Governance Tool
# Includes namespace creation, RBAC, ConfigMap, Secret and Deployment
set -e
# Cores para output
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Configurações
# Configuration
NAMESPACE="resource-governance"
SERVICE_ACCOUNT="resource-governance-sa"
SECRET_NAME="resource-governance-sa-token"
echo -e "${BLUE}🚀 Deploying OpenShift Resource Governance Tool${NC}"
echo -e "${BLUE}Deploying OpenShift Resource Governance Tool${NC}"
# Verificar se está conectado ao cluster
# Check if connected to cluster
if ! oc whoami > /dev/null 2>&1; then
echo -e "${RED} Not connected to OpenShift cluster. Please run 'oc login' first.${NC}"
echo -e "${RED}ERROR: Not connected to OpenShift cluster. Please run 'oc login' first.${NC}"
exit 1
fi
echo -e "${GREEN} Connected to OpenShift cluster as $(oc whoami)${NC}"
echo -e "${GREEN}SUCCESS: Connected to OpenShift cluster as $(oc whoami)${NC}"
# Criar namespace se não existir
echo -e "${YELLOW}📦 Creating namespace...${NC}"
# Create namespace if it doesn't exist
echo -e "${YELLOW}Creating namespace...${NC}"
oc create namespace $NAMESPACE --dry-run=client -o yaml | oc apply -f -
# Aplicar RBAC
echo -e "${YELLOW}🔐 Applying RBAC...${NC}"
# Apply RBAC
echo -e "${YELLOW}Applying RBAC...${NC}"
oc apply -f k8s/rbac.yaml
# Aplicar ConfigMap
echo -e "${YELLOW}⚙️ Applying ConfigMap...${NC}"
# Apply ConfigMap
echo -e "${YELLOW}Applying ConfigMap...${NC}"
oc apply -f k8s/configmap.yaml
# Criar secret do token do ServiceAccount
echo -e "${YELLOW}🔑 Creating ServiceAccount token...${NC}"
# Create ServiceAccount token secret
echo -e "${YELLOW}Creating ServiceAccount token...${NC}"
# Verificar se o secret existe
# Check if secret already exists
if oc get secret $SECRET_NAME -n $NAMESPACE > /dev/null 2>&1; then
echo -e "${YELLOW}⚠️ Secret $SECRET_NAME already exists, skipping creation${NC}"
echo -e "${YELLOW}WARNING: Secret $SECRET_NAME already exists, skipping creation${NC}"
else
# Criar token do ServiceAccount
# Create ServiceAccount token
TOKEN=$(oc create token $SERVICE_ACCOUNT -n $NAMESPACE --duration=8760h)
# Criar secret com o token
# Create secret with token
oc create secret generic $SECRET_NAME -n $NAMESPACE \
--from-literal=token="$TOKEN" \
--from-literal=ca.crt="$(oc get secret -n $NAMESPACE -o jsonpath='{.items[0].data.ca\.crt}' | base64 -d)" \
--from-literal=namespace="$NAMESPACE"
echo -e "${GREEN} ServiceAccount token created${NC}"
echo -e "${GREEN}SUCCESS: ServiceAccount token created${NC}"
fi
# Aplicar Deployment
echo -e "${YELLOW}🚀 Applying Deployment...${NC}"
# Apply Deployment
echo -e "${YELLOW}Applying Deployment...${NC}"
oc apply -f k8s/deployment.yaml
# Aplicar Service
echo -e "${YELLOW}🌐 Applying Service...${NC}"
# Apply Service
echo -e "${YELLOW}Applying Service...${NC}"
oc apply -f k8s/service.yaml
# Aplicar Route
echo -e "${YELLOW}🛣️ Applying Route...${NC}"
# Apply Route
echo -e "${YELLOW}Applying Route...${NC}"
oc apply -f k8s/route.yaml
# Aguardar deployment estar pronto
echo -e "${YELLOW}Waiting for deployment to be ready...${NC}"
# Wait for deployment to be ready
echo -e "${YELLOW}Waiting for deployment to be ready...${NC}"
oc rollout status deployment/resource-governance -n $NAMESPACE --timeout=300s
# Verificar status dos pods
echo -e "${YELLOW}📊 Checking pod status...${NC}"
# Check pod status
echo -e "${YELLOW}Checking pod status...${NC}"
oc get pods -n $NAMESPACE -l app.kubernetes.io/name=resource-governance
# Verificar logs para erros
echo -e "${YELLOW}📋 Checking application logs...${NC}"
# Check logs for errors
echo -e "${YELLOW}Checking application logs...${NC}"
POD_NAME=$(oc get pods -n $NAMESPACE -l app.kubernetes.io/name=resource-governance -o jsonpath='{.items[0].metadata.name}')
if [ -n "$POD_NAME" ]; then
echo -e "${BLUE}Recent logs from $POD_NAME:${NC}"
oc logs $POD_NAME -n $NAMESPACE --tail=10
fi
# Obter URL da aplicação
echo -e "${YELLOW}🌍 Getting application URL...${NC}"
# Get application URL
echo -e "${YELLOW}Getting application URL...${NC}"
# Aguardar um pouco para garantir que a rota esteja pronta
# Wait a bit to ensure route is ready
sleep 5
# Verificar se a rota existe
# Check if route exists
if oc get route resource-governance-route -n $NAMESPACE > /dev/null 2>&1; then
ROUTE_URL=$(oc get route resource-governance-route -n $NAMESPACE -o jsonpath='{.spec.host}')
else
echo -e "${YELLOW}⚠️ Route not found, checking available routes...${NC}"
echo -e "${YELLOW}WARNING: Route not found, checking available routes...${NC}"
oc get routes -n $NAMESPACE
ROUTE_URL=""
fi
if [ -n "$ROUTE_URL" ]; then
echo -e "${GREEN} Application deployed successfully!${NC}"
echo -e "${GREEN}🌐 URL: https://$ROUTE_URL${NC}"
echo -e "${GREEN}📊 Health check: https://$ROUTE_URL/health${NC}"
echo -e "${GREEN}SUCCESS: Application deployed successfully!${NC}"
echo -e "${GREEN}URL: https://$ROUTE_URL${NC}"
echo -e "${GREEN}Health check: https://$ROUTE_URL/health${NC}"
else
echo -e "${YELLOW}⚠️ Route not found, checking service...${NC}"
echo -e "${YELLOW}WARNING: Route not found, checking service...${NC}"
oc get svc -n $NAMESPACE
fi
echo -e "${GREEN}🎉 Deployment completed successfully!${NC}"
echo -e "${GREEN}SUCCESS: Deployment completed successfully!${NC}"

View File

@@ -6,9 +6,9 @@
set -e
echo "🚀 ORU Analyzer S2I Deployment"
echo "==============================="
echo "📦 This will deploy the application with ALL required resources"
echo "ORU Analyzer S2I Deployment"
echo "============================"
echo "This will deploy the application with ALL required resources"
echo " - RBAC (ServiceAccount, ClusterRole, ClusterRoleBinding)"
echo " - ConfigMap with all configurations"
echo " - S2I Build and Deployment"
@@ -18,28 +18,28 @@ echo ""
# Check for GitHub Actions option
if [ "$1" = "--github" ] || [ "$1" = "-g" ]; then
echo "🔄 Deploying via GitHub Actions (S2I Webhook)..."
echo "📦 Repository: andersonid/openshift-resource-governance"
echo "🌿 Branch: $(git branch --show-current)"
echo "🔗 Commit: $(git rev-parse HEAD)"
echo "Deploying via GitHub Actions (S2I Webhook)..."
echo "Repository: andersonid/openshift-resource-governance"
echo "Branch: $(git branch --show-current)"
echo "Commit: $(git rev-parse HEAD)"
echo ""
# Trigger GitHub Actions workflow
if command -v gh &> /dev/null; then
echo "🚀 Triggering S2I deployment via GitHub Actions..."
echo "Triggering S2I deployment via GitHub Actions..."
gh workflow run s2i-deploy.yml
echo " GitHub Actions workflow triggered!"
echo "📱 Monitor progress: https://github.com/andersonid/openshift-resource-governance/actions"
echo "SUCCESS: GitHub Actions workflow triggered!"
echo "Monitor progress: https://github.com/andersonid/openshift-resource-governance/actions"
else
echo " GitHub CLI (gh) not found. Please install it or use manual deployment."
echo "💡 Manual webhook URL:"
echo "ERROR: GitHub CLI (gh) not found. Please install it or use manual deployment."
echo "Manual webhook URL:"
echo " curl -X POST 'https://oru.apps.shrocp4upi419ovn.lab.upshift.rdu2.redhat.com/apis/build.openshift.io/v1/namespaces/resource-governance/buildconfigs/resource-governance/webhooks/pqWLANKULBy1p6aTbPFa/generic'"
exit 1
fi
exit 0
fi
echo "💡 Usage options:"
echo "Usage options:"
echo " ./scripts/deploy-s2i.sh # Manual S2I deployment"
echo " ./scripts/deploy-s2i.sh --github # Deploy via GitHub Actions"
echo ""
@@ -237,9 +237,9 @@ oc get route -n "$NAMESPACE"
# Final status
echo ""
echo "🎉 DEPLOYMENT COMPLETED SUCCESSFULLY!"
echo "====================================="
echo " All resources deployed:"
echo "DEPLOYMENT COMPLETED SUCCESSFULLY!"
echo "=================================="
echo "SUCCESS: All resources deployed:"
echo " - Namespace: $NAMESPACE"
echo " - RBAC: ServiceAccount, ClusterRole, ClusterRoleBinding"
echo " - ConfigMap: resource-governance-config"
@@ -248,7 +248,7 @@ echo " - Deployment: $APP_NAME"
echo " - Service: resource-governance-service"
echo " - Route: resource-governance-route"
echo ""
echo "🌐 Application Access:"
echo "Application Access:"
if [ -n "$ROUTE_URL" ]; then
echo " URL: https://$ROUTE_URL"
echo " Health: https://$ROUTE_URL/health"
@@ -257,10 +257,10 @@ else
echo " Get URL: oc get route -n $NAMESPACE"
fi
echo ""
echo "🔧 Management Commands:"
echo "Management Commands:"
echo " View logs: oc logs -f deployment/$APP_NAME -n $NAMESPACE"
echo " Check status: oc get all -n $NAMESPACE"
echo " Restart: oc rollout restart deployment/$APP_NAME -n $NAMESPACE"
echo ""
echo "📚 The application is now fully functional and self-service!"
echo "The application is now fully functional and self-service!"
echo " No additional configuration needed."

View File

@@ -1,71 +1,81 @@
#!/bin/bash
# Script completo de undeploy para OpenShift Resource Governance Tool
# Complete undeploy script for OpenShift Resource Governance Tool
set -e
# Cores para output
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Configurações
# Configuration
NAMESPACE="resource-governance"
echo -e "${BLUE}🗑️ Undeploy - OpenShift Resource Governance Tool${NC}"
echo -e "${BLUE}===============================================${NC}"
echo -e "${BLUE}Undeploy - OpenShift Resource Governance Tool${NC}"
echo -e "${BLUE}============================================${NC}"
# Verificar se está logado no OpenShift
# Check if logged into OpenShift
if ! oc whoami > /dev/null 2>&1; then
echo -e "${RED}❌ Não está logado no OpenShift. Faça login primeiro.${NC}"
echo -e "${RED}ERROR: Not logged into OpenShift. Please login first.${NC}"
exit 1
fi
echo -e "${GREEN}✅ Logado como: $(oc whoami)${NC}"
echo -e "${GREEN}SUCCESS: Logged in as: $(oc whoami)${NC}"
# Confirmar remoção
echo -e "${YELLOW}⚠️ Tem certeza que deseja remover a aplicação do namespace '$NAMESPACE'?${NC}"
read -p "Digite 'yes' para confirmar: " CONFIRM
# Confirm removal
echo -e "${YELLOW}WARNING: Are you sure you want to remove the application from namespace '$NAMESPACE'?${NC}"
read -p "Type 'yes' to confirm: " CONFIRM
if [ "$CONFIRM" != "yes" ]; then
echo -e "${YELLOW}Operação cancelada.${NC}"
echo -e "${YELLOW}Operation cancelled.${NC}"
exit 0
fi
# Remover recursos
echo -e "${YELLOW}🗑️ Removendo recursos...${NC}"
# Remove resources
echo -e "${YELLOW}Removing resources...${NC}"
# Remover Route
echo -e "${YELLOW} 🛣️ Removendo Route...${NC}"
# Remove Route
echo -e "${YELLOW} Removing Route...${NC}"
oc delete -f k8s/route.yaml --ignore-not-found=true
# Remover Service
echo -e "${YELLOW} 🌐 Removendo Service...${NC}"
# Remove Service
echo -e "${YELLOW} Removing Service...${NC}"
oc delete -f k8s/service.yaml --ignore-not-found=true
# Remover Deployment
echo -e "${YELLOW} 📦 Removendo Deployment...${NC}"
# Remove Deployment
echo -e "${YELLOW} Removing Deployment...${NC}"
oc delete -f k8s/deployment.yaml --ignore-not-found=true
# Aguardar pods serem removidos
echo -e "${YELLOW} ⏳ Aguardando pods serem removidos...${NC}"
# Wait for pods to be removed
echo -e "${YELLOW} Waiting for pods to be removed...${NC}"
oc wait --for=delete pod -l app.kubernetes.io/name=resource-governance -n $NAMESPACE --timeout=60s || true
# Remover ConfigMap
echo -e "${YELLOW} ⚙️ Removendo ConfigMap...${NC}"
# Remove ConfigMap
echo -e "${YELLOW} Removing ConfigMap...${NC}"
oc delete -f k8s/configmap.yaml --ignore-not-found=true
# Remover RBAC
echo -e "${YELLOW} 🔐 Removendo RBAC...${NC}"
# Remove RBAC (cluster resources)
echo -e "${YELLOW} Removing RBAC (ServiceAccount, ClusterRole, ClusterRoleBinding)...${NC}"
oc delete -f k8s/rbac.yaml --ignore-not-found=true
# Remover namespace (opcional)
echo -e "${YELLOW} 📁 Removendo namespace...${NC}"
# Remove cluster resources manually (in case namespace was already removed)
echo -e "${YELLOW} Removing ClusterRole and ClusterRoleBinding...${NC}"
oc delete clusterrole resource-governance-role --ignore-not-found=true
oc delete clusterrolebinding resource-governance-binding --ignore-not-found=true
oc delete clusterrolebinding resource-governance-monitoring --ignore-not-found=true
# Remove ServiceAccount (if still exists)
echo -e "${YELLOW} Removing ServiceAccount...${NC}"
oc delete serviceaccount resource-governance-sa -n $NAMESPACE --ignore-not-found=true
# Remove namespace (optional)
echo -e "${YELLOW} Removing namespace...${NC}"
oc delete -f k8s/namespace.yaml --ignore-not-found=true
echo -e "${GREEN} Undeploy concluído com sucesso!${NC}"
echo -e "${BLUE}===============================================${NC}"
echo -e "${GREEN}✅ Todos os recursos foram removidos${NC}"
echo -e "${GREEN} Namespace '$NAMESPACE' foi removido${NC}"
echo -e "${BLUE}===============================================${NC}"
echo -e "${GREEN}SUCCESS: Undeploy completed successfully!${NC}"
echo -e "${BLUE}============================================${NC}"
echo -e "${GREEN}SUCCESS: All resources have been removed${NC}"
echo -e "${GREEN}SUCCESS: Namespace '$NAMESPACE' has been removed${NC}"
echo -e "${BLUE}============================================${NC}"