refactor: migrar GitLab → Gitea (aulas 10, 11, 13)
- Aula 10: Gitea + Registry + Actions + Runner (substituiu GitLab) - gitea-values.yaml: PostgreSQL standalone, Valkey standalone, ~800Mi RAM - setup.sh/cleanup.sh: namespace gitea, Helm gitea-charts/gitea + actions - README.md: documentação completa com de→para (GitLab/Harbor/Tekton vs Gitea) - Aula 11: ArgoCD (GitOps) — removido GitLab Runner (runner vive na aula-10) - setup.sh: só ArgoCD, integração SSH com Gitea - node-bugado/.gitea/workflows/ci.yml: pipeline convertida - Aula 13: Container Factory — atualizado para Gitea - setup.sh/cleanup.sh: referências GitLab → Gitea - pipelines/postgresql/ci.yml: Gitea Actions workflow - README.md: conexão com act_runner explicada - CLAUDE.md: tabela de aulas atualizada
This commit is contained in:
138
aula-13/benchmarks/benchmark-toolbox.sh
Executable file
138
aula-13/benchmarks/benchmark-toolbox.sh
Executable file
@@ -0,0 +1,138 @@
|
||||
#!/bin/bash
|
||||
# =============================================================================
|
||||
# Benchmark: DevOps Toolbox - eStargz vs GZIP
|
||||
# =============================================================================
|
||||
# Compara tempo de startup usando apenas UMA ferramenta (terraform version)
|
||||
# para demonstrar o benefício do lazy pulling em imagens grandes.
|
||||
# =============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
NAMESPACE="benchmark-toolbox"
|
||||
REGISTRY="registry.kube.quest"
|
||||
IMAGE_NAME="factory/devops-toolbox"
|
||||
|
||||
# Cores
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
||||
log_ok() { echo -e "${GREEN}[OK]${NC} $1"; }
|
||||
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
|
||||
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||
|
||||
cleanup() {
|
||||
log_info "Limpando recursos..."
|
||||
kubectl delete namespace $NAMESPACE --ignore-not-found --wait=false 2>/dev/null || true
|
||||
}
|
||||
|
||||
measure_startup() {
|
||||
local name=$1
|
||||
local image=$2
|
||||
local tag=$3
|
||||
|
||||
log_info "Testando $name ($tag)..."
|
||||
|
||||
# Criar pod
|
||||
cat <<EOF | kubectl apply -f - -n $NAMESPACE
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: $name
|
||||
spec:
|
||||
containers:
|
||||
- name: toolbox
|
||||
image: ${REGISTRY}/${IMAGE_NAME}:${tag}
|
||||
command: ["terraform", "version"]
|
||||
imagePullPolicy: Always
|
||||
restartPolicy: Never
|
||||
imagePullSecrets:
|
||||
- name: gitlab-registry
|
||||
EOF
|
||||
|
||||
# Medir tempo até completar
|
||||
local start_time=$(date +%s.%N)
|
||||
|
||||
# Aguardar pod completar ou falhar
|
||||
kubectl wait --for=condition=Ready pod/$name -n $NAMESPACE --timeout=300s 2>/dev/null || true
|
||||
kubectl wait --for=jsonpath='{.status.phase}'=Succeeded pod/$name -n $NAMESPACE --timeout=300s 2>/dev/null || true
|
||||
|
||||
local end_time=$(date +%s.%N)
|
||||
local duration=$(echo "$end_time - $start_time" | bc)
|
||||
|
||||
echo "$duration"
|
||||
}
|
||||
|
||||
main() {
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo " Benchmark: DevOps Toolbox"
|
||||
echo " eStargz vs GZIP"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
# Verificar se imagens existem
|
||||
log_info "Verificando imagens no registry..."
|
||||
|
||||
# Limpar namespace anterior
|
||||
cleanup
|
||||
sleep 5
|
||||
|
||||
# Criar namespace
|
||||
kubectl create namespace $NAMESPACE 2>/dev/null || true
|
||||
|
||||
# Copiar secret do registry
|
||||
if kubectl get secret gitlab-registry -n gitlab &>/dev/null; then
|
||||
kubectl get secret gitlab-registry -n gitlab -o yaml | \
|
||||
sed "s/namespace: gitlab/namespace: $NAMESPACE/" | \
|
||||
kubectl apply -f - 2>/dev/null || true
|
||||
else
|
||||
log_warn "Secret gitlab-registry não encontrado. Usando imagens públicas."
|
||||
fi
|
||||
|
||||
echo ""
|
||||
log_info "Iniciando benchmarks..."
|
||||
echo ""
|
||||
|
||||
# Teste 1: eStargz
|
||||
log_info "=== Teste 1: eStargz (lazy pulling) ==="
|
||||
time_estargz=$(measure_startup "toolbox-estargz" "$IMAGE_NAME" "latest")
|
||||
log_ok "eStargz: ${time_estargz}s"
|
||||
|
||||
# Limpar para teste justo
|
||||
kubectl delete pod toolbox-estargz -n $NAMESPACE --wait=true 2>/dev/null || true
|
||||
sleep 5
|
||||
|
||||
# Teste 2: GZIP
|
||||
log_info "=== Teste 2: GZIP (tradicional) ==="
|
||||
time_gzip=$(measure_startup "toolbox-gzip" "$IMAGE_NAME" "gzip")
|
||||
log_ok "GZIP: ${time_gzip}s"
|
||||
|
||||
# Resultados
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo " RESULTADOS"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
echo "| Formato | Tempo |"
|
||||
echo "|----------|----------|"
|
||||
printf "| eStargz | %6.1fs |\n" "$time_estargz"
|
||||
printf "| GZIP | %6.1fs |\n" "$time_gzip"
|
||||
echo ""
|
||||
|
||||
# Calcular diferença
|
||||
if command -v bc &>/dev/null; then
|
||||
speedup=$(echo "scale=1; $time_gzip / $time_estargz" | bc)
|
||||
echo "Speedup eStargz: ${speedup}x mais rápido"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
log_info "Para ver logs: kubectl logs -n $NAMESPACE toolbox-estargz"
|
||||
log_info "Para limpar: kubectl delete namespace $NAMESPACE"
|
||||
}
|
||||
|
||||
# Executar
|
||||
main "$@"
|
||||
Reference in New Issue
Block a user