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:
ArgoCD Setup
2026-03-14 01:44:30 -03:00
parent ff7af56c30
commit d380cd8585
35 changed files with 3374 additions and 1202 deletions

View File

@@ -0,0 +1,188 @@
#!/bin/bash
# =============================================================================
# Benchmark LIMPO: eStargz vs Traditional Image Pull
# =============================================================================
#
# Este benchmark força execução em um node SEM cache das imagens
# para medir tempo REAL de pull.
#
# =============================================================================
set -e
NAMESPACE="benchmark-clean"
ESTARGZ_IMAGE="registry.kube.quest/factory/postgresql:17"
TRADITIONAL_IMAGE="postgres:17-alpine"
TARGET_NODE="talos-msadg4-worker-0" # Node sem cache
echo "========================================================================"
echo "Benchmark LIMPO: eStargz vs Traditional Image Pull"
echo "========================================================================"
echo ""
echo "Target node: $TARGET_NODE (sem cache de imagens)"
echo ""
echo "Comparando:"
echo " Tradicional: $TRADITIONAL_IMAGE"
echo " eStargz: $ESTARGZ_IMAGE"
echo ""
# Verificar cluster
echo "[1/6] Verificando cluster..."
kubectl cluster-info >/dev/null || { echo "ERRO: Cluster inacessível"; exit 1; }
echo " Cluster OK"
# Limpar ambiente anterior
echo "[2/6] Limpando ambiente anterior..."
kubectl delete namespace $NAMESPACE --ignore-not-found=true --wait=true 2>/dev/null || true
echo " Ambiente limpo"
# Criar namespace
echo "[3/6] Criando namespace de teste..."
kubectl create namespace $NAMESPACE
kubectl create secret docker-registry gitlab-registry \
--docker-server=registry.kube.quest \
--docker-username=root \
--docker-password="${GITLAB_TOKEN:-glpat-dummy}" \
-n $NAMESPACE 2>/dev/null || true
echo " Namespace criado"
# Teste 1: Imagem tradicional
echo ""
echo "========================================================================"
echo "[4/6] TESTE 1: Imagem Tradicional (gzip) - PULL REAL"
echo "========================================================================"
echo "Iniciando em $(date)"
T1_START=$(date +%s)
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
name: pg-traditional
namespace: $NAMESPACE
spec:
nodeName: $TARGET_NODE
restartPolicy: Never
containers:
- name: postgres
image: $TRADITIONAL_IMAGE
imagePullPolicy: Always
env:
- name: POSTGRES_PASSWORD
value: benchmarktest
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
seccompProfile:
type: RuntimeDefault
EOF
kubectl wait --for=condition=Ready pod/pg-traditional -n $NAMESPACE --timeout=300s
T1_END=$(date +%s)
TIME1=$((T1_END - T1_START))
echo "Finalizado em $(date)"
echo ">>> Tempo total: ${TIME1}s <<<"
# Teste 2: Imagem eStargz
echo ""
echo "========================================================================"
echo "[5/6] TESTE 2: Imagem eStargz (lazy pulling) - PULL REAL"
echo "========================================================================"
echo "Iniciando em $(date)"
T2_START=$(date +%s)
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
name: pg-estargz
namespace: $NAMESPACE
spec:
nodeName: $TARGET_NODE
restartPolicy: Never
imagePullSecrets:
- name: gitlab-registry
containers:
- name: postgres
image: $ESTARGZ_IMAGE
imagePullPolicy: Always
env:
- name: POSTGRES_PASSWORD
value: benchmarktest
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
seccompProfile:
type: RuntimeDefault
EOF
kubectl wait --for=condition=Ready pod/pg-estargz -n $NAMESPACE --timeout=300s
T2_END=$(date +%s)
TIME2=$((T2_END - T2_START))
echo "Finalizado em $(date)"
echo ">>> Tempo total: ${TIME2}s <<<"
# Resultados
echo ""
echo "========================================================================"
echo "[6/6] RESULTADOS"
echo "========================================================================"
echo ""
# Status dos pods
echo "Status dos Pods:"
kubectl get pods -n $NAMESPACE -o wide
echo ""
# Eventos completos
echo "Todos os Eventos (ordenados por tempo):"
kubectl get events -n $NAMESPACE --sort-by='.lastTimestamp' \
-o custom-columns='TIMESTAMP:.lastTimestamp,REASON:.reason,POD:.involvedObject.name,MESSAGE:.message'
echo ""
# Verificar se houve pull real
echo "Análise de Pull:"
TRAD_PULL=$(kubectl get events -n $NAMESPACE --field-selector involvedObject.name=pg-traditional,reason=Pulled -o jsonpath='{.items[0].message}' 2>/dev/null)
ESTARGZ_PULL=$(kubectl get events -n $NAMESPACE --field-selector involvedObject.name=pg-estargz,reason=Pulled -o jsonpath='{.items[0].message}' 2>/dev/null)
echo " Tradicional: $TRAD_PULL"
echo " eStargz: $ESTARGZ_PULL"
echo ""
# Tabela de resultados
echo "┌─────────────────────────────────────────────────────────────────┐"
echo "│ RESULTADOS DO BENCHMARK (PULL REAL) │"
echo "├───────────────────┬─────────────────┬─────────────────────────────┤"
echo "│ Métrica │ Tradicional │ eStargz │"
echo "├───────────────────┼─────────────────┼─────────────────────────────┤"
printf "│ Tempo até Ready │ %12ss │ %12ss │\n" "$TIME1" "$TIME2"
echo "├───────────────────┼─────────────────┼─────────────────────────────┤"
if [ "$TIME1" -gt "$TIME2" ]; then
DIFF=$((TIME1 - TIME2))
PERCENT=$(( (DIFF * 100) / TIME1 ))
echo "│ Diferença │ baseline │ -${DIFF}s (${PERCENT}% mais rápido) │"
elif [ "$TIME2" -gt "$TIME1" ]; then
DIFF=$((TIME2 - TIME1))
PERCENT=$(( (DIFF * 100) / TIME2 ))
echo "│ Diferença │ +${DIFF}s mais rápido │ baseline │"
else
echo "│ Diferença │ igual │ igual │"
fi
echo "└───────────────────┴─────────────────┴─────────────────────────────┘"
echo ""
echo "Nota: Este benchmark usou imagePullPolicy: Always no node '$TARGET_NODE'"
echo " que não tinha as imagens em cache, forçando pull real."
echo ""
echo "O benefício do eStargz (lazy pulling) é mais significativo em:"
echo " - Imagens maiores (1GB+)"
echo " - Scale-out events (novos nodes)"
echo " - Cold starts"
echo ""
echo "Para limpar: kubectl delete namespace $NAMESPACE"

View File

@@ -0,0 +1,170 @@
#!/bin/bash
# =============================================================================
# Benchmark: eStargz vs Traditional Image Pull
# =============================================================================
#
# Compara tempo de startup entre:
# - postgres:17-alpine (gzip tradicional)
# - registry.kube.quest/factory/postgresql:17 (eStargz)
#
# Este script usa timestamps dos eventos do Kubernetes para medir:
# - Tempo de pull (Pulling -> Pulled)
# - Tempo total (Scheduled -> Started)
#
# =============================================================================
set -e
NAMESPACE="benchmark-test"
ESTARGZ_IMAGE="registry.kube.quest/factory/postgresql:17"
TRADITIONAL_IMAGE="postgres:17-alpine"
echo "========================================================================"
echo "Benchmark: eStargz vs Traditional Image Pull"
echo "========================================================================"
echo ""
echo "Comparando:"
echo " Tradicional: $TRADITIONAL_IMAGE"
echo " eStargz: $ESTARGZ_IMAGE"
echo ""
# Verificar cluster
echo "[1/6] Verificando cluster..."
kubectl cluster-info >/dev/null || { echo "ERRO: Cluster inacessível"; exit 1; }
echo " Cluster OK"
# Limpar ambiente anterior
echo "[2/6] Limpando ambiente anterior..."
kubectl delete namespace $NAMESPACE --ignore-not-found=true --wait=true 2>/dev/null || true
echo " Ambiente limpo"
# Criar namespace
echo "[3/6] Criando namespace de teste..."
kubectl create namespace $NAMESPACE
kubectl create secret docker-registry gitlab-registry \
--docker-server=registry.kube.quest \
--docker-username=root \
--docker-password="${GITLAB_TOKEN:-glpat-dummy}" \
-n $NAMESPACE 2>/dev/null || true
echo " Namespace criado"
# Teste 1: Imagem tradicional
echo ""
echo "========================================================================"
echo "[4/6] TESTE 1: Imagem Tradicional (gzip)"
echo "========================================================================"
T1_START=$(date +%s)
kubectl run pg-traditional --image=$TRADITIONAL_IMAGE --restart=Never \
--env=POSTGRES_PASSWORD=benchmarktest \
-n $NAMESPACE 2>&1 | grep -v "Warning:"
kubectl wait --for=condition=Ready pod/pg-traditional -n $NAMESPACE --timeout=180s
T1_END=$(date +%s)
TIME1=$((T1_END - T1_START))
echo "Tempo total: ${TIME1}s"
# Teste 2: Imagem eStargz
echo ""
echo "========================================================================"
echo "[5/6] TESTE 2: Imagem eStargz (lazy pulling)"
echo "========================================================================"
T2_START=$(date +%s)
kubectl run pg-estargz --image=$ESTARGZ_IMAGE --restart=Never \
--env=POSTGRES_PASSWORD=benchmarktest \
--overrides='{"spec":{"imagePullSecrets":[{"name":"gitlab-registry"}]}}' \
-n $NAMESPACE 2>&1 | grep -v "Warning:"
kubectl wait --for=condition=Ready pod/pg-estargz -n $NAMESPACE --timeout=180s
T2_END=$(date +%s)
TIME2=$((T2_END - T2_START))
echo "Tempo total: ${TIME2}s"
# Resultados
echo ""
echo "========================================================================"
echo "[6/6] RESULTADOS"
echo "========================================================================"
echo ""
# Status dos pods
echo "Status dos Pods:"
kubectl get pods -n $NAMESPACE -o wide
echo ""
# Eventos completos
echo "Todos os Eventos (ordenados por tempo):"
kubectl get events -n $NAMESPACE --sort-by='.lastTimestamp' \
-o custom-columns='TIMESTAMP:.lastTimestamp,REASON:.reason,POD:.involvedObject.name,MESSAGE:.message'
echo ""
# Verificar se houve pull real ou cache hit
echo "Análise de Pull:"
TRAD_PULL=$(kubectl get events -n $NAMESPACE --field-selector involvedObject.name=pg-traditional,reason=Pulled -o jsonpath='{.items[0].message}' 2>/dev/null)
ESTARGZ_PULL=$(kubectl get events -n $NAMESPACE --field-selector involvedObject.name=pg-estargz,reason=Pulled -o jsonpath='{.items[0].message}' 2>/dev/null)
echo " Tradicional: $TRAD_PULL"
echo " eStargz: $ESTARGZ_PULL"
echo ""
# Tabela de resultados
echo "┌─────────────────────────────────────────────────────────────────┐"
echo "│ RESULTADOS DO BENCHMARK │"
echo "├───────────────────┬─────────────────┬─────────────────────────────┤"
echo "│ Métrica │ Tradicional │ eStargz │"
echo "├───────────────────┼─────────────────┼─────────────────────────────┤"
printf "│ Tempo até Ready │ %12ss │ %12ss │\n" "$TIME1" "$TIME2"
echo "├───────────────────┼─────────────────┼─────────────────────────────┤"
if [ "$TIME1" -gt 0 ] && [ "$TIME2" -gt 0 ]; then
if [ "$TIME1" -gt "$TIME2" ]; then
DIFF=$((TIME1 - TIME2))
echo "│ Diferença │ baseline │ -${DIFF}s mais rápido │"
elif [ "$TIME2" -gt "$TIME1" ]; then
DIFF=$((TIME2 - TIME1))
echo "│ Diferença │ -${DIFF}s mais rápido │ baseline │"
else
echo "│ Diferença │ igual │ igual │"
fi
fi
echo "└───────────────────┴─────────────────┴─────────────────────────────┘"
# Verificar cache hit
if echo "$TRAD_PULL" | grep -q "already present"; then
TRAD_CACHED="SIM"
else
TRAD_CACHED="NAO"
fi
if echo "$ESTARGZ_PULL" | grep -q "already present"; then
ESTARGZ_CACHED="SIM"
else
ESTARGZ_CACHED="NAO"
fi
echo ""
echo "Cache Status:"
echo " Tradicional em cache: $TRAD_CACHED"
echo " eStargz em cache: $ESTARGZ_CACHED"
if [ "$TRAD_CACHED" = "SIM" ] || [ "$ESTARGZ_CACHED" = "SIM" ]; then
echo ""
echo "AVISO: Imagens em cache - benchmark não reflete tempo real de pull!"
echo ""
echo "Para benchmark preciso, limpe o cache dos worker nodes com:"
echo ""
echo " # Via talosctl (para cada worker node):"
echo " export TALOSCONFIG=/private/data/app/workshop/aula-08/talosconfig"
echo " WORKER_IP=46.224.192.153 # IP do worker"
echo " talosctl -n \$WORKER_IP service restart containerd"
echo ""
echo " # OU escale um novo worker sem cache"
fi
echo ""
echo "Namespace de teste mantido. Para limpar:"
echo " kubectl delete namespace $NAMESPACE"

View File

@@ -0,0 +1,129 @@
#!/bin/bash
# =============================================================================
# Benchmark de PULL: eStargz vs Traditional
# =============================================================================
#
# Mede apenas o tempo de PULL das imagens (não espera container ficar Ready)
# Executa em node limpo sem cache.
#
# =============================================================================
set -e
NAMESPACE="benchmark-pull"
ESTARGZ_IMAGE="registry.kube.quest/factory/postgresql:17"
TRADITIONAL_IMAGE="postgres:17-alpine"
TARGET_NODE="worker-pool-6bea48339a15ab6e" # Node 128.140.11.113 - sem cache
echo "========================================================================"
echo "Benchmark de PULL: eStargz vs Traditional"
echo "========================================================================"
echo ""
echo "Target node: $TARGET_NODE (sem cache)"
echo ""
# Setup
kubectl delete namespace $NAMESPACE --ignore-not-found=true --wait=true 2>/dev/null || true
kubectl create namespace $NAMESPACE
kubectl create secret docker-registry gitlab-registry \
--docker-server=registry.kube.quest \
--docker-username=root \
--docker-password="${GITLAB_TOKEN:-glpat-dummy}" \
-n $NAMESPACE 2>/dev/null || true
echo ""
echo "========================================================================"
echo "TESTE 1: Pull de Imagem Tradicional (gzip)"
echo "========================================================================"
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
name: test-traditional
namespace: $NAMESPACE
spec:
nodeName: $TARGET_NODE
restartPolicy: Never
containers:
- name: postgres
image: $TRADITIONAL_IMAGE
imagePullPolicy: Always
command: ["sleep", "infinity"]
env:
- name: POSTGRES_PASSWORD
value: test
EOF
echo "Aguardando pull..."
sleep 2
while true; do
PULLED=$(kubectl get events -n $NAMESPACE --field-selector involvedObject.name=test-traditional,reason=Pulled -o jsonpath='{.items[0].message}' 2>/dev/null)
if [ -n "$PULLED" ]; then
echo "RESULTADO: $PULLED"
break
fi
PULLING=$(kubectl get events -n $NAMESPACE --field-selector involvedObject.name=test-traditional,reason=Pulling -o jsonpath='{.items[0].message}' 2>/dev/null)
if [ -n "$PULLING" ]; then
echo -n "."
fi
sleep 1
done
echo ""
echo "========================================================================"
echo "TESTE 2: Pull de Imagem eStargz (lazy pulling)"
echo "========================================================================"
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
name: test-estargz
namespace: $NAMESPACE
spec:
nodeName: $TARGET_NODE
restartPolicy: Never
imagePullSecrets:
- name: gitlab-registry
containers:
- name: postgres
image: $ESTARGZ_IMAGE
imagePullPolicy: Always
command: ["sleep", "infinity"]
env:
- name: POSTGRES_PASSWORD
value: test
EOF
echo "Aguardando pull..."
sleep 2
while true; do
PULLED=$(kubectl get events -n $NAMESPACE --field-selector involvedObject.name=test-estargz,reason=Pulled -o jsonpath='{.items[0].message}' 2>/dev/null)
if [ -n "$PULLED" ]; then
echo "RESULTADO: $PULLED"
break
fi
PULLING=$(kubectl get events -n $NAMESPACE --field-selector involvedObject.name=test-estargz,reason=Pulling -o jsonpath='{.items[0].message}' 2>/dev/null)
if [ -n "$PULLING" ]; then
echo -n "."
fi
sleep 1
done
echo ""
echo "========================================================================"
echo "RESUMO"
echo "========================================================================"
echo ""
echo "Todos os eventos de pull:"
kubectl get events -n $NAMESPACE --sort-by='.lastTimestamp' \
-o custom-columns='TIME:.lastTimestamp,REASON:.reason,POD:.involvedObject.name,MESSAGE:.message' \
| grep -E "Pull|pull"
echo ""
echo "Status dos pods:"
kubectl get pods -n $NAMESPACE -o wide
echo ""
echo "Para limpar: kubectl delete namespace $NAMESPACE"

View 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 "$@"