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:
@@ -1,23 +1,23 @@
|
||||
# Aula 11 - ArgoCD + GitLab Runner (GitOps)
|
||||
# Aula 11 - ArgoCD (GitOps)
|
||||
|
||||
Deploy de ArgoCD e GitLab Runner para pipeline CI/CD completo com GitOps.
|
||||
Deploy do ArgoCD para CD declarativo com GitOps, integrado ao Gitea (aula-10).
|
||||
|
||||
## Arquitetura
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ GitLab (aula-10) │
|
||||
│ Gitea (aula-10) │
|
||||
│ ┌─────────────┐ ┌──────────────┐ ┌───────────────┐ │
|
||||
│ │ git push │───►│ GitLab CI │───►│ Registry │ │
|
||||
│ │ (código) │ │ (Runner K8s)│ │ (imagem:tag) │ │
|
||||
│ │ git push │───►│ Gitea Actions│───►│ Registry │ │
|
||||
│ │ (código) │ │ (act_runner) │ │ (imagem:tag) │ │
|
||||
│ └─────────────┘ └──────┬───────┘ └───────────────┘ │
|
||||
└────────────────────────────┼────────────────────────────────┘
|
||||
│ atualiza manifests
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ Repositório GitOps │
|
||||
│ Repositório GitOps │
|
||||
│ apps/node-bugado/ │
|
||||
│ ├── deployment.yaml (image: registry.../node-bugado:sha) │
|
||||
│ ├── deployment.yaml (image: gitea.../node-bugado:sha) │
|
||||
│ ├── service.yaml │
|
||||
│ └── configmap.yaml │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
@@ -25,7 +25,7 @@ Deploy de ArgoCD e GitLab Runner para pipeline CI/CD completo com GitOps.
|
||||
│ sync automático
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ ArgoCD │
|
||||
│ ArgoCD │
|
||||
│ ┌─────────────┐ ┌──────────────┐ ┌───────────────┐ │
|
||||
│ │ Application │───►│ Sync │───►│ Kubernetes │ │
|
||||
│ │ CRD │ │ Controller │ │ (deploy) │ │
|
||||
@@ -38,7 +38,7 @@ Deploy de ArgoCD e GitLab Runner para pipeline CI/CD completo com GitOps.
|
||||
1. **Cluster Talos na Hetzner** (aula-08) com:
|
||||
- NGINX Ingress Controller com LoadBalancer
|
||||
- Hetzner CSI Driver
|
||||
2. **GitLab instalado** (aula-10)
|
||||
2. **Gitea instalado** (aula-10)
|
||||
3. **kubectl** e **helm** instalados
|
||||
|
||||
## Contexto do Cluster
|
||||
@@ -60,9 +60,8 @@ chmod +x setup.sh
|
||||
```
|
||||
|
||||
O script instala:
|
||||
1. **GitLab Runner** - Executor Kubernetes para pipelines CI
|
||||
2. **ArgoCD** - GitOps CD para Kubernetes
|
||||
3. Configura integração SSH com GitLab
|
||||
1. **ArgoCD** - GitOps CD para Kubernetes
|
||||
2. Configura integração SSH com Gitea
|
||||
|
||||
## Componentes Instalados
|
||||
|
||||
@@ -72,8 +71,7 @@ O script instala:
|
||||
| ArgoCD Repo Server | argocd | 256Mi/512Mi | Git clone/sync |
|
||||
| ArgoCD Controller | argocd | 256Mi/512Mi | Reconciliation |
|
||||
| ArgoCD Redis | argocd | 64Mi/128Mi | Cache |
|
||||
| GitLab Runner | gitlab | 128Mi/256Mi | CI jobs como pods |
|
||||
| **Total** | | ~1.2Gi | |
|
||||
| **Total** | | **~832Mi** | |
|
||||
|
||||
## Acesso
|
||||
|
||||
@@ -86,21 +84,9 @@ Senha: kubectl get secret argocd-initial-admin-secret -n argocd \
|
||||
-o jsonpath='{.data.password}' | base64 -d
|
||||
```
|
||||
|
||||
### GitLab Runner
|
||||
|
||||
Verificar status em: `https://{gitlab-host}/admin/runners`
|
||||
|
||||
```bash
|
||||
# Ver pods do runner
|
||||
kubectl get pods -n gitlab -l app=gitlab-runner
|
||||
|
||||
# Ver logs
|
||||
kubectl logs -n gitlab -l app=gitlab-runner -f
|
||||
```
|
||||
|
||||
## Configurar Pipeline GitOps
|
||||
|
||||
### 1. Criar Repositório GitOps no GitLab
|
||||
### 1. Criar Repositório GitOps no Gitea
|
||||
|
||||
Crie um repositório `gitops-demo` com a estrutura:
|
||||
|
||||
@@ -122,9 +108,9 @@ Use os arquivos de exemplo em `node-bugado/k8s/`.
|
||||
# Gerar par de chaves
|
||||
ssh-keygen -t ed25519 -f argocd-deploy-key -N ''
|
||||
|
||||
# Adicionar chave pública no GitLab:
|
||||
# Settings → Repository → Deploy Keys
|
||||
# Marcar "Grant write permissions"
|
||||
# Adicionar chave pública no Gitea:
|
||||
# Repositório → Settings → Deploy Keys
|
||||
# Marcar "Enable Write Access" (se o CI precisa push)
|
||||
```
|
||||
|
||||
### 3. Conectar Repositório no ArgoCD
|
||||
@@ -133,12 +119,12 @@ Via UI:
|
||||
1. Acesse https://argocd.{domain}
|
||||
2. Settings → Repositories → Connect Repo
|
||||
3. Method: SSH
|
||||
4. URL: `git@git.{domain}:{usuario}/gitops-demo.git`
|
||||
4. URL: `git@gitea.{domain}:{usuario}/gitops-demo.git`
|
||||
5. SSH private key: (conteúdo de argocd-deploy-key)
|
||||
|
||||
Ou via CLI:
|
||||
```bash
|
||||
argocd repo add git@git.kube.quest:usuario/gitops-demo.git \
|
||||
argocd repo add git@gitea.kube.quest:usuario/gitops-demo.git \
|
||||
--ssh-private-key-path argocd-deploy-key
|
||||
```
|
||||
|
||||
@@ -154,7 +140,7 @@ metadata:
|
||||
spec:
|
||||
project: default
|
||||
source:
|
||||
repoURL: git@git.kube.quest:usuario/gitops-demo.git
|
||||
repoURL: git@gitea.kube.quest:usuario/gitops-demo.git
|
||||
targetRevision: HEAD
|
||||
path: apps/node-bugado
|
||||
destination:
|
||||
@@ -171,84 +157,49 @@ EOF
|
||||
|
||||
### 5. Configurar Pipeline no Repositório da App
|
||||
|
||||
No repositório `node-bugado`:
|
||||
No repositório `node-bugado`, crie `.gitea/workflows/ci.yml`:
|
||||
|
||||
1. Copie `.gitlab-ci.yml` de `node-bugado/.gitlab-ci.yml`
|
||||
2. Configure variáveis em Settings → CI/CD → Variables:
|
||||
- `GITOPS_REPO`: `git@git.kube.quest:usuario/gitops-demo.git`
|
||||
- `DEPLOY_KEY`: Chave SSH privada (com write access ao repo gitops)
|
||||
```yaml
|
||||
name: Build and Deploy
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
env:
|
||||
REGISTRY: gitea.kube.quest
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login ${{ env.REGISTRY }} -u ${{ gitea.actor }} --password-stdin
|
||||
- run: |
|
||||
docker build -t ${{ env.REGISTRY }}/${{ gitea.repository }}:${{ github.sha }} .
|
||||
docker push ${{ env.REGISTRY }}/${{ gitea.repository }}:${{ github.sha }}
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: |
|
||||
# Clone GitOps repo e atualizar tag
|
||||
# ArgoCD sincroniza automaticamente
|
||||
```
|
||||
|
||||
Configure secrets em: Repository → Settings → Actions → Secrets:
|
||||
- `REGISTRY_TOKEN`: Token com permissão de push no registry
|
||||
- `DEPLOY_KEY`: Chave SSH privada (com write access ao repo gitops)
|
||||
|
||||
## Fluxo de Deploy
|
||||
|
||||
1. **Desenvolvedor** faz push no repositório `node-bugado`
|
||||
2. **GitLab CI** dispara pipeline:
|
||||
2. **Gitea Actions** (act_runner) dispara pipeline:
|
||||
- Build: Constrói imagem Docker
|
||||
- Push: Envia para GitLab Registry
|
||||
- Push: Envia para Gitea Container Registry
|
||||
- Deploy: Atualiza `deployment.yaml` no repo GitOps
|
||||
3. **ArgoCD** detecta mudança no repo GitOps
|
||||
4. **ArgoCD** sincroniza com cluster Kubernetes
|
||||
5. **Kubernetes** faz rolling update dos pods
|
||||
|
||||
## GitLab Runner - Executor Kubernetes
|
||||
|
||||
O runner usa executor `kubernetes`, onde cada job CI:
|
||||
|
||||
- Roda como um **pod efêmero** no cluster
|
||||
- Tem acesso a **Docker-in-Docker** para builds
|
||||
- É automaticamente **limpo** após conclusão
|
||||
- **Escala** conforme demanda de jobs
|
||||
|
||||
```yaml
|
||||
# gitlab-runner-values.yaml
|
||||
runners:
|
||||
executor: kubernetes
|
||||
privileged: true # Necessário para Docker-in-Docker
|
||||
namespace: gitlab
|
||||
```
|
||||
|
||||
### Por que Docker-in-Docker?
|
||||
|
||||
Para construir imagens Docker dentro de um container (o job do CI), precisamos:
|
||||
1. **Privileged mode**: Acesso ao kernel para criar containers
|
||||
2. **Docker daemon**: Serviço Docker rodando no job
|
||||
|
||||
Alternativas (mais seguras, mas mais complexas):
|
||||
- **Kaniko**: Build sem Docker daemon
|
||||
- **Buildah**: Build rootless
|
||||
|
||||
### Requisitos para Docker-in-Docker
|
||||
|
||||
#### 1. Pod Security (Kubernetes 1.25+)
|
||||
|
||||
Kubernetes 1.25+ aplica Pod Security Admission por padrão. O namespace `gitlab`
|
||||
precisa permitir pods privilegiados:
|
||||
|
||||
```bash
|
||||
kubectl label namespace gitlab \
|
||||
pod-security.kubernetes.io/enforce=privileged \
|
||||
pod-security.kubernetes.io/warn=privileged \
|
||||
--overwrite
|
||||
```
|
||||
|
||||
> **Nota**: O `setup.sh` já configura isso automaticamente.
|
||||
|
||||
#### 2. Helper Image para ARM64
|
||||
|
||||
Em clusters com nodes ARM64 (como Hetzner CAX), o runner precisa usar
|
||||
o helper image correto. Configure em `gitlab-runner-values.yaml`:
|
||||
|
||||
```toml
|
||||
# Dentro de runners.config
|
||||
[[runners]]
|
||||
[runners.kubernetes]
|
||||
helper_image = "gitlab/gitlab-runner-helper:arm64-latest"
|
||||
```
|
||||
|
||||
Sem isso, você verá erros como:
|
||||
```
|
||||
no match for platform in manifest: not found
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### ArgoCD não sincroniza
|
||||
@@ -264,65 +215,6 @@ kubectl describe application node-bugado -n argocd
|
||||
kubectl logs -n argocd -l app.kubernetes.io/name=argocd-application-controller
|
||||
```
|
||||
|
||||
### Runner não aparece no GitLab
|
||||
|
||||
```bash
|
||||
# Verificar pod do runner
|
||||
kubectl get pods -n gitlab -l app=gitlab-runner
|
||||
|
||||
# Ver logs
|
||||
kubectl logs -n gitlab -l app=gitlab-runner
|
||||
|
||||
# Verificar registration token
|
||||
kubectl get secret gitlab-gitlab-runner-secret -n gitlab -o yaml
|
||||
```
|
||||
|
||||
### Jobs CI falham
|
||||
|
||||
```bash
|
||||
# Ver pods dos jobs
|
||||
kubectl get pods -n gitlab
|
||||
|
||||
# Ver logs de um job específico
|
||||
kubectl logs -n gitlab runner-xxxxx-project-xxx-concurrent-xxx
|
||||
```
|
||||
|
||||
### Erro "violates PodSecurity"
|
||||
|
||||
```
|
||||
violates PodSecurity "baseline:latest": privileged
|
||||
(containers must not set securityContext.privileged=true)
|
||||
```
|
||||
|
||||
**Solução**: Configure o namespace para permitir pods privilegiados:
|
||||
```bash
|
||||
kubectl label namespace gitlab \
|
||||
pod-security.kubernetes.io/enforce=privileged \
|
||||
--overwrite
|
||||
```
|
||||
|
||||
### Erro "no match for platform in manifest"
|
||||
|
||||
```
|
||||
image pull failed: no match for platform in manifest: not found
|
||||
```
|
||||
|
||||
**Causa**: O runner está tentando usar imagem x86_64 em node ARM64.
|
||||
|
||||
**Solução**: Configure o helper image ARM64 no `gitlab-runner-values.yaml`:
|
||||
```toml
|
||||
[[runners]]
|
||||
[runners.kubernetes]
|
||||
helper_image = "gitlab/gitlab-runner-helper:arm64-latest"
|
||||
```
|
||||
|
||||
Depois faça upgrade do runner:
|
||||
```bash
|
||||
helm upgrade gitlab-runner gitlab/gitlab-runner \
|
||||
-n gitlab --reuse-values \
|
||||
-f gitlab-runner-values.yaml
|
||||
```
|
||||
|
||||
### Erro SSH ao conectar repositório
|
||||
|
||||
```bash
|
||||
@@ -330,7 +222,7 @@ helm upgrade gitlab-runner gitlab/gitlab-runner \
|
||||
kubectl get configmap argocd-ssh-known-hosts-cm -n argocd -o yaml
|
||||
|
||||
# Adicionar manualmente
|
||||
ssh-keyscan git.kube.quest | kubectl create configmap argocd-ssh-known-hosts-cm \
|
||||
ssh-keyscan gitea.kube.quest | kubectl create configmap argocd-ssh-known-hosts-cm \
|
||||
--from-file=ssh_known_hosts=/dev/stdin -n argocd --dry-run=client -o yaml | kubectl apply -f -
|
||||
```
|
||||
|
||||
@@ -343,10 +235,6 @@ kubectl get pods -n argocd
|
||||
argocd app list
|
||||
argocd app sync node-bugado
|
||||
|
||||
# GitLab Runner
|
||||
kubectl get pods -n gitlab -l app=gitlab-runner
|
||||
kubectl logs -n gitlab -l app=gitlab-runner -f
|
||||
|
||||
# Ver todos os recursos do demo
|
||||
kubectl get all -n demo
|
||||
|
||||
@@ -360,12 +248,10 @@ argocd app diff node-bugado
|
||||
## Lições do Workshop
|
||||
|
||||
1. **GitOps**: Git como fonte única de verdade para estado do cluster
|
||||
2. **Separação CI/CD**: GitLab CI = build, ArgoCD = deploy
|
||||
3. **Runner Kubernetes**: Jobs como pods efêmeros e escaláveis
|
||||
4. **Docker-in-Docker**: Build de imagens em containers privilegiados
|
||||
5. **Auditoria**: Histórico de deploys = histórico Git
|
||||
6. **Self-Heal**: ArgoCD corrige drift automaticamente
|
||||
7. **Segurança**: Deploy Keys com permissão mínima
|
||||
2. **Separação CI/CD**: Gitea Actions = build, ArgoCD = deploy
|
||||
3. **Auditoria**: Histórico de deploys = histórico Git
|
||||
4. **Self-Heal**: ArgoCD corrige drift automaticamente
|
||||
5. **Segurança**: Deploy Keys com permissão mínima
|
||||
|
||||
## Cleanup
|
||||
|
||||
@@ -373,25 +259,17 @@ argocd app diff node-bugado
|
||||
./cleanup.sh
|
||||
```
|
||||
|
||||
Remove ArgoCD e GitLab Runner. Não remove GitLab ou infraestrutura base.
|
||||
Remove ArgoCD. Não remove Gitea ou infraestrutura base.
|
||||
|
||||
## Custos
|
||||
|
||||
| Recurso | Custo/mês |
|
||||
|---------|-----------|
|
||||
| ArgoCD + Runner (~1.2Gi) | Usa workers existentes |
|
||||
| ArgoCD (~832Mi) | Usa workers existentes |
|
||||
| **Total Adicional** | ~$0 |
|
||||
|
||||
## Próximos Passos
|
||||
|
||||
- **Aula 12**: eStargz + Lazy Pulling
|
||||
- Converter imagens para formato eStargz
|
||||
- Demonstrar startup mais rápido com lazy pulling
|
||||
- Medir diferença de performance
|
||||
|
||||
## Referências
|
||||
|
||||
- [ArgoCD Docs](https://argo-cd.readthedocs.io/en/stable/)
|
||||
- [ArgoCD Helm Chart](https://github.com/argoproj/argo-helm)
|
||||
- [GitLab Runner Kubernetes Executor](https://docs.gitlab.com/runner/executors/kubernetes.html)
|
||||
- [GitOps with GitLab + ArgoCD](https://medium.com/@andrew.kaczynski/gitops-in-kubernetes-argo-cd-and-gitlab-ci-cd-5828c8eb34d6)
|
||||
- [Gitea Actions](https://docs.gitea.com/usage/actions/overview)
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
# Aula 11 - Cleanup
|
||||
# =============================================================================
|
||||
#
|
||||
# Remove ArgoCD e GitLab Runner instalados pelo setup.sh.
|
||||
# NÃO remove a infraestrutura base (GitLab, NGINX Ingress, etc).
|
||||
# Remove ArgoCD instalado pelo setup.sh.
|
||||
# NÃO remove a infraestrutura base (Gitea, NGINX Ingress, etc).
|
||||
#
|
||||
# =============================================================================
|
||||
|
||||
@@ -23,7 +23,7 @@ log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo " Removendo ArgoCD e GitLab Runner"
|
||||
echo " Removendo ArgoCD"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
@@ -44,18 +44,9 @@ fi
|
||||
log_info "Removendo namespace argocd..."
|
||||
kubectl delete namespace argocd --timeout=60s 2>/dev/null || true
|
||||
|
||||
# Remover GitLab Runner
|
||||
log_info "Removendo GitLab Runner..."
|
||||
if helm status gitlab-runner -n gitlab &> /dev/null; then
|
||||
helm uninstall gitlab-runner -n gitlab --wait
|
||||
log_success "GitLab Runner removido"
|
||||
else
|
||||
log_warn "GitLab Runner não estava instalado"
|
||||
fi
|
||||
|
||||
# Limpar secrets residuais
|
||||
log_info "Limpando secrets residuais..."
|
||||
kubectl delete secret argocd-ssh-known-hosts-cm -n argocd 2>/dev/null || true
|
||||
kubectl delete configmap argocd-ssh-known-hosts-cm -n argocd 2>/dev/null || true
|
||||
|
||||
# Remover arquivo .env local
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
@@ -67,6 +58,6 @@ fi
|
||||
echo ""
|
||||
log_success "Cleanup concluído!"
|
||||
echo ""
|
||||
echo "Nota: GitLab, NGINX Ingress e infraestrutura base foram mantidos."
|
||||
echo "Para remover o GitLab, execute: ../aula-10/cleanup.sh"
|
||||
echo "Nota: Gitea, NGINX Ingress e infraestrutura base foram mantidos."
|
||||
echo "Para remover o Gitea, execute: ../aula-10/cleanup.sh"
|
||||
echo ""
|
||||
|
||||
@@ -61,10 +61,11 @@ runners:
|
||||
helper_image = "gitlab/gitlab-runner-helper:arm64-latest"
|
||||
|
||||
# Recursos para pods de job (aumentados para builds Docker)
|
||||
cpu_request = "100m"
|
||||
cpu_limit = "1000m"
|
||||
memory_request = "256Mi"
|
||||
memory_limit = "1Gi"
|
||||
# CAX31 tem 8 vCPU e 16GB - aproveitar para builds rápidos
|
||||
cpu_request = "500m"
|
||||
cpu_limit = "4000m"
|
||||
memory_request = "1Gi"
|
||||
memory_limit = "8Gi"
|
||||
|
||||
# Timeout para pods
|
||||
poll_timeout = 600
|
||||
@@ -72,6 +73,17 @@ runners:
|
||||
# Pull policy
|
||||
pull_policy = ["if-not-present"]
|
||||
|
||||
# Node selector para usar o build-pool (CAX31)
|
||||
[runners.kubernetes.node_selector]
|
||||
"node-pool" = "build"
|
||||
|
||||
# Toleration para o taint do build-pool
|
||||
[[runners.kubernetes.node_tolerations]]
|
||||
key = "dedicated"
|
||||
operator = "Equal"
|
||||
value = "builds"
|
||||
effect = "NoSchedule"
|
||||
|
||||
# Volume para Docker certs (DinD)
|
||||
[[runners.kubernetes.volumes.empty_dir]]
|
||||
name = "docker-certs"
|
||||
|
||||
77
aula-11/node-bugado/.gitea/workflows/ci.yml
Normal file
77
aula-11/node-bugado/.gitea/workflows/ci.yml
Normal file
@@ -0,0 +1,77 @@
|
||||
# =============================================================================
|
||||
# Gitea Actions Workflow - node-bugado
|
||||
# =============================================================================
|
||||
#
|
||||
# Pipeline GitOps:
|
||||
# 1. Build: Constrói imagem Docker e faz push para Gitea Registry
|
||||
# 2. Deploy: Atualiza manifests no repo GitOps (ArgoCD faz sync)
|
||||
#
|
||||
# Secrets necessários (Repository → Settings → Actions → Secrets):
|
||||
# - REGISTRY_TOKEN: Token para push no Gitea Container Registry
|
||||
# - DEPLOY_KEY: Chave SSH privada para push no repo GitOps
|
||||
# - GITOPS_REPO: URL SSH do repo GitOps (ex: git@gitea.kube.quest:user/gitops-demo.git)
|
||||
#
|
||||
# =============================================================================
|
||||
|
||||
name: Build and Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
env:
|
||||
REGISTRY: gitea.kube.quest
|
||||
IMAGE_NAME: ${{ gitea.repository }}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Login to Gitea Registry
|
||||
run: |
|
||||
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login ${{ env.REGISTRY }} \
|
||||
-u ${{ gitea.actor }} --password-stdin
|
||||
|
||||
- name: Build and push
|
||||
run: |
|
||||
echo "Building ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}"
|
||||
docker build \
|
||||
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} \
|
||||
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
|
||||
.
|
||||
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
|
||||
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
||||
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- name: Setup SSH
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_ed25519
|
||||
chmod 600 ~/.ssh/id_ed25519
|
||||
ssh-keyscan gitea.kube.quest >> ~/.ssh/known_hosts 2>/dev/null || true
|
||||
|
||||
- name: Update GitOps repo
|
||||
run: |
|
||||
git config --global user.email "ci@gitea.kube.quest"
|
||||
git config --global user.name "Gitea CI"
|
||||
|
||||
git clone ${{ secrets.GITOPS_REPO }} gitops
|
||||
cd gitops
|
||||
|
||||
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-8)
|
||||
|
||||
if [ -f apps/node-bugado/deployment.yaml ]; then
|
||||
sed -i "s|image:.*node-bugado.*|image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}|g" apps/node-bugado/deployment.yaml
|
||||
git add apps/node-bugado/deployment.yaml
|
||||
git commit -m "deploy: node-bugado ${SHORT_SHA} [skip ci]"
|
||||
git push
|
||||
echo "GitOps repo updated"
|
||||
else
|
||||
echo "WARNING: apps/node-bugado/deployment.yaml not found"
|
||||
exit 1
|
||||
fi
|
||||
256
aula-11/setup.sh
256
aula-11/setup.sh
@@ -1,16 +1,15 @@
|
||||
#!/bin/bash
|
||||
# =============================================================================
|
||||
# Aula 11 - ArgoCD + GitLab Runner (GitOps)
|
||||
# Aula 11 - ArgoCD (GitOps)
|
||||
# =============================================================================
|
||||
#
|
||||
# Este script instala:
|
||||
# 1. GitLab Runner (executor kubernetes) para CI
|
||||
# 2. ArgoCD para CD declarativo (GitOps)
|
||||
# 3. Integração com GitLab self-hosted (aula-10)
|
||||
# 1. ArgoCD para CD declarativo (GitOps)
|
||||
# 2. Integração SSH com Gitea (aula-10)
|
||||
#
|
||||
# Pré-requisitos:
|
||||
# - Cluster Kubernetes (aula-08)
|
||||
# - GitLab instalado (aula-10)
|
||||
# - Gitea instalado (aula-10)
|
||||
# - NGINX Ingress Controller
|
||||
# - kubectl e helm instalados
|
||||
#
|
||||
@@ -23,16 +22,13 @@ RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
CYAN='\033[0;36m'
|
||||
NC='\033[0m' # No Color
|
||||
NC='\033[0m'
|
||||
|
||||
# Funções de log
|
||||
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
||||
log_success() { echo -e "${GREEN}[OK]${NC} $1"; }
|
||||
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
|
||||
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||
|
||||
# Diretório do script
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
ENV_FILE="${SCRIPT_DIR}/.env"
|
||||
|
||||
@@ -42,80 +38,51 @@ ENV_FILE="${SCRIPT_DIR}/.env"
|
||||
|
||||
log_info "Verificando pré-requisitos..."
|
||||
|
||||
# Verificar kubectl
|
||||
if ! command -v kubectl &> /dev/null; then
|
||||
log_error "kubectl não encontrado. Instale com: brew install kubectl"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Verificar helm
|
||||
if ! command -v helm &> /dev/null; then
|
||||
log_error "helm não encontrado. Instale com: brew install helm"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Verificar conexão com cluster
|
||||
if ! kubectl cluster-info &> /dev/null; then
|
||||
log_error "Não foi possível conectar ao cluster Kubernetes"
|
||||
log_info "Verifique se KUBECONFIG está configurado corretamente"
|
||||
log_info "Exemplo: export KUBECONFIG=\$(pwd)/../aula-08/kubeconfig"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Verificar se GitLab está instalado
|
||||
if ! kubectl get namespace gitlab &> /dev/null; then
|
||||
log_error "Namespace 'gitlab' não encontrado"
|
||||
log_info "Execute primeiro a aula-10 para instalar o GitLab"
|
||||
# Verificar se Gitea está instalado
|
||||
if ! kubectl get namespace gitea &> /dev/null; then
|
||||
log_error "Namespace 'gitea' não encontrado"
|
||||
log_info "Execute primeiro a aula-10 para instalar o Gitea"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Verificar NGINX Ingress
|
||||
if ! kubectl get ingressclass nginx &> /dev/null; then
|
||||
log_error "NGINX Ingress Controller não encontrado"
|
||||
log_info "Execute o script de instalação do NGINX Ingress na aula-08"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_success "Pré-requisitos verificados"
|
||||
|
||||
# =============================================================================
|
||||
# CONFIGURAR POD SECURITY PARA DOCKER-IN-DOCKER
|
||||
# =============================================================================
|
||||
#
|
||||
# Docker-in-Docker requer pods privilegiados. Kubernetes 1.25+ aplica
|
||||
# Pod Security Admission por padrão, bloqueando containers privilegiados
|
||||
# no modo "baseline". Precisamos configurar o namespace gitlab para
|
||||
# permitir pods privilegiados.
|
||||
#
|
||||
log_info "Configurando PodSecurity para Docker-in-Docker..."
|
||||
kubectl label namespace gitlab \
|
||||
pod-security.kubernetes.io/enforce=privileged \
|
||||
pod-security.kubernetes.io/warn=privileged \
|
||||
pod-security.kubernetes.io/audit=privileged \
|
||||
--overwrite
|
||||
log_success "PodSecurity configurado para permitir Docker-in-Docker"
|
||||
|
||||
# =============================================================================
|
||||
# CARREGAR CONFIGURAÇÃO EXISTENTE
|
||||
# CARREGAR CONFIGURAÇÃO
|
||||
# =============================================================================
|
||||
|
||||
# Carregar configuração local PRIMEIRO (se existir)
|
||||
if [[ -f "$ENV_FILE" ]]; then
|
||||
log_info "Carregando configuração local..."
|
||||
source "$ENV_FILE"
|
||||
fi
|
||||
|
||||
# Se não tiver configuração local, tentar herdar da aula-10
|
||||
if [[ -z "$GITLAB_HOST" ]]; then
|
||||
# Herdar da aula-10
|
||||
if [[ -z "$GITEA_HOST" ]]; then
|
||||
AULA10_ENV="${SCRIPT_DIR}/../aula-10/.env"
|
||||
if [[ -f "$AULA10_ENV" ]]; then
|
||||
log_info "Herdando configuração da aula-10..."
|
||||
source "$AULA10_ENV"
|
||||
GITLAB_HOST="${GITLAB_HOST:-}"
|
||||
DOMAIN="${DOMAIN:-}"
|
||||
USE_CLOUDFLARE="${USE_CLOUDFLARE:-false}"
|
||||
USE_LETSENCRYPT="${USE_LETSENCRYPT:-false}"
|
||||
LETSENCRYPT_EMAIL="${LETSENCRYPT_EMAIL:-}"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -125,19 +92,19 @@ fi
|
||||
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo " Configuração do ArgoCD + GitLab CI"
|
||||
echo " Configuração do ArgoCD (GitOps)"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
# GitLab Host
|
||||
if [[ -z "$GITLAB_HOST" ]]; then
|
||||
read -p "Hostname do GitLab (ex: git.kube.quest): " GITLAB_HOST
|
||||
# Gitea Host
|
||||
if [[ -z "$GITEA_HOST" ]]; then
|
||||
read -p "Hostname do Gitea (ex: gitea.kube.quest): " GITEA_HOST
|
||||
fi
|
||||
log_info "GitLab: https://${GITLAB_HOST}"
|
||||
log_info "Gitea: https://${GITEA_HOST}"
|
||||
|
||||
# Extrair domínio base
|
||||
if [[ -z "$DOMAIN" ]]; then
|
||||
DOMAIN=$(echo "$GITLAB_HOST" | sed 's/^[^.]*\.//')
|
||||
DOMAIN=$(echo "$GITEA_HOST" | sed 's/^[^.]*\.//')
|
||||
fi
|
||||
|
||||
# ArgoCD Host
|
||||
@@ -148,7 +115,7 @@ if [[ -z "$ARGOCD_HOST" ]]; then
|
||||
fi
|
||||
log_info "ArgoCD: https://${ARGOCD_HOST}"
|
||||
|
||||
# TLS (herdar da aula-10 ou perguntar)
|
||||
# TLS
|
||||
if [[ "$USE_CLOUDFLARE" != "true" && "$USE_LETSENCRYPT" != "true" ]]; then
|
||||
echo ""
|
||||
echo "Configuração de TLS:"
|
||||
@@ -158,21 +125,14 @@ if [[ "$USE_CLOUDFLARE" != "true" && "$USE_LETSENCRYPT" != "true" ]]; then
|
||||
read -p "Escolha [1-3]: " TLS_CHOICE
|
||||
|
||||
case $TLS_CHOICE in
|
||||
1)
|
||||
USE_CLOUDFLARE=true
|
||||
USE_LETSENCRYPT=false
|
||||
;;
|
||||
1) USE_CLOUDFLARE=true; USE_LETSENCRYPT=false ;;
|
||||
2)
|
||||
USE_CLOUDFLARE=false
|
||||
USE_LETSENCRYPT=true
|
||||
USE_CLOUDFLARE=false; USE_LETSENCRYPT=true
|
||||
if [[ -z "$LETSENCRYPT_EMAIL" ]]; then
|
||||
read -p "Email para Let's Encrypt: " LETSENCRYPT_EMAIL
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
USE_CLOUDFLARE=false
|
||||
USE_LETSENCRYPT=false
|
||||
;;
|
||||
*) USE_CLOUDFLARE=false; USE_LETSENCRYPT=false ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
@@ -180,7 +140,7 @@ fi
|
||||
cat > "$ENV_FILE" << EOF
|
||||
# Configuração gerada pelo setup.sh
|
||||
# $(date)
|
||||
GITLAB_HOST=${GITLAB_HOST}
|
||||
GITEA_HOST=${GITEA_HOST}
|
||||
ARGOCD_HOST=${ARGOCD_HOST}
|
||||
DOMAIN=${DOMAIN}
|
||||
USE_CLOUDFLARE=${USE_CLOUDFLARE}
|
||||
@@ -190,65 +150,6 @@ EOF
|
||||
|
||||
log_success "Configuração salva em ${ENV_FILE}"
|
||||
|
||||
# =============================================================================
|
||||
# INSTALAR GITLAB RUNNER
|
||||
# =============================================================================
|
||||
|
||||
echo ""
|
||||
log_info "=== Instalando GitLab Runner ==="
|
||||
|
||||
# Adicionar repositório Helm
|
||||
helm repo add gitlab https://charts.gitlab.io 2>/dev/null || true
|
||||
helm repo update
|
||||
|
||||
# Verificar se já está instalado
|
||||
if helm status gitlab-runner -n gitlab &> /dev/null; then
|
||||
log_warn "GitLab Runner já instalado, fazendo upgrade..."
|
||||
HELM_CMD="upgrade"
|
||||
else
|
||||
HELM_CMD="install"
|
||||
fi
|
||||
|
||||
# Obter runner registration token
|
||||
log_info "Obtendo token de registro do GitLab Runner..."
|
||||
|
||||
# Tentar obter o token do secret
|
||||
RUNNER_TOKEN=""
|
||||
if kubectl get secret gitlab-gitlab-runner-secret -n gitlab &> /dev/null; then
|
||||
RUNNER_TOKEN=$(kubectl get secret gitlab-gitlab-runner-secret -n gitlab -o jsonpath='{.data.runner-registration-token}' 2>/dev/null | base64 -d 2>/dev/null || echo "")
|
||||
fi
|
||||
|
||||
if [[ -z "$RUNNER_TOKEN" ]]; then
|
||||
log_warn "Token de registro não encontrado automaticamente"
|
||||
echo ""
|
||||
echo "Para obter o token:"
|
||||
echo " 1. Acesse https://${GITLAB_HOST}/admin/runners"
|
||||
echo " 2. Clique em 'New instance runner'"
|
||||
echo " 3. Copie o registration token"
|
||||
echo ""
|
||||
read -p "Cole o registration token: " RUNNER_TOKEN
|
||||
fi
|
||||
|
||||
if [[ -z "$RUNNER_TOKEN" ]]; then
|
||||
log_error "Token de registro é obrigatório"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Instalar GitLab Runner
|
||||
log_info "Instalando GitLab Runner via Helm..."
|
||||
helm ${HELM_CMD} gitlab-runner gitlab/gitlab-runner \
|
||||
--namespace gitlab \
|
||||
-f "${SCRIPT_DIR}/gitlab-runner-values.yaml" \
|
||||
--set gitlabUrl="https://${GITLAB_HOST}" \
|
||||
--set runnerRegistrationToken="${RUNNER_TOKEN}" \
|
||||
--wait --timeout 5m
|
||||
|
||||
log_success "GitLab Runner instalado"
|
||||
|
||||
# Verificar pods
|
||||
log_info "Verificando pods do GitLab Runner..."
|
||||
kubectl get pods -n gitlab -l app=gitlab-runner
|
||||
|
||||
# =============================================================================
|
||||
# INSTALAR CERT-MANAGER (se Let's Encrypt)
|
||||
# =============================================================================
|
||||
@@ -273,7 +174,6 @@ if [[ "$USE_LETSENCRYPT" == "true" ]]; then
|
||||
log_success "cert-manager já instalado"
|
||||
fi
|
||||
|
||||
# Criar ClusterIssuer se não existir
|
||||
if ! kubectl get clusterissuer letsencrypt-prod &> /dev/null; then
|
||||
log_info "Criando ClusterIssuer letsencrypt-prod..."
|
||||
kubectl apply -f - << EOF
|
||||
@@ -303,14 +203,11 @@ fi
|
||||
echo ""
|
||||
log_info "=== Instalando ArgoCD ==="
|
||||
|
||||
# Adicionar repositório Helm
|
||||
helm repo add argo https://argoproj.github.io/argo-helm 2>/dev/null || true
|
||||
helm repo update
|
||||
|
||||
# Criar namespace
|
||||
kubectl create namespace argocd 2>/dev/null || true
|
||||
|
||||
# Verificar se já está instalado
|
||||
if helm status argocd -n argocd &> /dev/null; then
|
||||
log_warn "ArgoCD já instalado, fazendo upgrade..."
|
||||
HELM_CMD="upgrade"
|
||||
@@ -318,7 +215,7 @@ else
|
||||
HELM_CMD="install"
|
||||
fi
|
||||
|
||||
# Construir argumentos Helm
|
||||
# Argumentos Helm
|
||||
HELM_ARGS=""
|
||||
HELM_ARGS="$HELM_ARGS --set global.domain=${ARGOCD_HOST}"
|
||||
HELM_ARGS="$HELM_ARGS --set server.ingress.hosts[0]=${ARGOCD_HOST}"
|
||||
@@ -327,12 +224,8 @@ if [[ "$USE_LETSENCRYPT" == "true" ]]; then
|
||||
HELM_ARGS="$HELM_ARGS --set server.ingress.tls[0].secretName=argocd-server-tls"
|
||||
HELM_ARGS="$HELM_ARGS --set server.ingress.tls[0].hosts[0]=${ARGOCD_HOST}"
|
||||
HELM_ARGS="$HELM_ARGS --set 'server.ingress.annotations.cert-manager\.io/cluster-issuer=letsencrypt-prod'"
|
||||
elif [[ "$USE_CLOUDFLARE" == "true" ]]; then
|
||||
# CloudFlare faz TLS na borda
|
||||
HELM_ARGS="$HELM_ARGS --set server.ingress.tls="
|
||||
fi
|
||||
|
||||
# Instalar ArgoCD
|
||||
log_info "Instalando ArgoCD via Helm..."
|
||||
eval helm ${HELM_CMD} argocd argo/argo-cd \
|
||||
--namespace argocd \
|
||||
@@ -349,7 +242,6 @@ log_success "ArgoCD instalado"
|
||||
echo ""
|
||||
log_info "=== Credenciais do ArgoCD ==="
|
||||
|
||||
# Aguardar secret ser criado
|
||||
log_info "Aguardando secret de credenciais..."
|
||||
for i in {1..30}; do
|
||||
if kubectl get secret argocd-initial-admin-secret -n argocd &> /dev/null; then
|
||||
@@ -360,33 +252,17 @@ done
|
||||
|
||||
ARGOCD_PASSWORD=$(kubectl get secret argocd-initial-admin-secret -n argocd -o jsonpath='{.data.password}' 2>/dev/null | base64 -d 2>/dev/null || echo "")
|
||||
|
||||
if [[ -z "$ARGOCD_PASSWORD" ]]; then
|
||||
log_warn "Não foi possível obter a senha inicial"
|
||||
log_info "Tente: kubectl get secret argocd-initial-admin-secret -n argocd -o jsonpath='{.data.password}' | base64 -d"
|
||||
else
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo " ArgoCD Credenciais"
|
||||
echo "=========================================="
|
||||
echo " URL: https://${ARGOCD_HOST}"
|
||||
echo " Username: admin"
|
||||
echo " Password: ${ARGOCD_PASSWORD}"
|
||||
echo "=========================================="
|
||||
fi
|
||||
|
||||
# =============================================================================
|
||||
# CONFIGURAR INTEGRAÇÃO GITLAB
|
||||
# CONFIGURAR INTEGRAÇÃO GITEA
|
||||
# =============================================================================
|
||||
|
||||
echo ""
|
||||
log_info "=== Configurando Integração GitLab ==="
|
||||
log_info "=== Configurando Integração Gitea ==="
|
||||
|
||||
# Obter host key do GitLab
|
||||
log_info "Obtendo SSH host key do GitLab..."
|
||||
SSH_HOST_KEY=$(ssh-keyscan -t ed25519 ${GITLAB_HOST} 2>/dev/null || ssh-keyscan ${GITLAB_HOST} 2>/dev/null || echo "")
|
||||
log_info "Obtendo SSH host key do Gitea..."
|
||||
SSH_HOST_KEY=$(ssh-keyscan -t ed25519 ${GITEA_HOST} 2>/dev/null || ssh-keyscan ${GITEA_HOST} 2>/dev/null || echo "")
|
||||
|
||||
if [[ -n "$SSH_HOST_KEY" ]]; then
|
||||
# Criar ConfigMap com known hosts
|
||||
kubectl create configmap argocd-ssh-known-hosts-cm \
|
||||
--from-literal=ssh_known_hosts="${SSH_HOST_KEY}" \
|
||||
-n argocd \
|
||||
@@ -398,7 +274,7 @@ else
|
||||
fi
|
||||
|
||||
# =============================================================================
|
||||
# INSTRUÇÕES FINAIS
|
||||
# RESUMO FINAL
|
||||
# =============================================================================
|
||||
|
||||
echo ""
|
||||
@@ -415,47 +291,12 @@ else
|
||||
echo " Password: kubectl get secret argocd-initial-admin-secret -n argocd -o jsonpath='{.data.password}' | base64 -d"
|
||||
fi
|
||||
echo ""
|
||||
echo "GitLab Runner:"
|
||||
echo " Namespace: gitlab"
|
||||
echo " Verificar: kubectl get pods -n gitlab -l app=gitlab-runner"
|
||||
echo " Status no GitLab: https://${GITLAB_HOST}/admin/runners"
|
||||
echo ""
|
||||
echo "Próximos passos:"
|
||||
echo ""
|
||||
# Obter IP do LoadBalancer
|
||||
LB_IP=$(kubectl get svc -n ingress-nginx ingress-nginx-controller \
|
||||
-o jsonpath='{.status.loadBalancer.ingress[0].ip}' 2>/dev/null || echo "<pendente>")
|
||||
|
||||
# Extrair nome do host
|
||||
HOST_NAME=$(echo "$ARGOCD_HOST" | cut -d. -f1)
|
||||
|
||||
echo "1. Configure DNS:"
|
||||
echo " Adicione registro A para ${ARGOCD_HOST} apontando para o LoadBalancer"
|
||||
echo ""
|
||||
if [[ "$USE_CLOUDFLARE" == "true" ]]; then
|
||||
echo " No painel do CloudFlare (https://dash.cloudflare.com):"
|
||||
echo ""
|
||||
echo -e " ${YELLOW}Tipo:${NC} A"
|
||||
echo -e " ${YELLOW}Nome:${NC} ${HOST_NAME}"
|
||||
echo -e " ${YELLOW}Conteúdo:${NC} ${GREEN}${LB_IP}${NC}"
|
||||
echo -e " ${YELLOW}Proxy:${NC} ✓ (ícone laranja)"
|
||||
echo ""
|
||||
echo -e " ${GREEN}O CloudFlare cuida do TLS automaticamente!${NC}"
|
||||
else
|
||||
echo " No seu provedor DNS:"
|
||||
echo ""
|
||||
echo -e " ${YELLOW}Tipo:${NC} A"
|
||||
echo -e " ${YELLOW}Nome:${NC} ${HOST_NAME}"
|
||||
echo -e " ${YELLOW}Valor:${NC} ${GREEN}${LB_IP}${NC}"
|
||||
if [[ "$USE_LETSENCRYPT" == "true" ]]; then
|
||||
echo ""
|
||||
echo -e " ${GREEN}Let's Encrypt irá emitir certificados automaticamente!${NC}"
|
||||
echo -e " Aguarde ~2 minutos após configurar o DNS."
|
||||
echo ""
|
||||
read -rp " Pressione ENTER após configurar o DNS e aguardar a propagação... "
|
||||
fi
|
||||
fi
|
||||
echo ""
|
||||
echo "2. Crie um repositório GitOps no GitLab:"
|
||||
echo "2. Crie um repositório GitOps no Gitea:"
|
||||
echo " - Nome: gitops-demo"
|
||||
echo " - Estrutura: apps/node-bugado/{deployment,service,configmap}.yaml"
|
||||
echo ""
|
||||
@@ -463,42 +304,21 @@ echo "3. Configure repositório no ArgoCD:"
|
||||
echo " a) Gere uma deploy key:"
|
||||
echo " ssh-keygen -t ed25519 -f argocd-deploy-key -N ''"
|
||||
echo ""
|
||||
echo " b) Adicione a chave pública no GitLab:"
|
||||
echo " Settings → Repository → Deploy Keys"
|
||||
echo " b) Adicione a chave pública no Gitea:"
|
||||
echo " Repositório → Settings → Deploy Keys"
|
||||
echo ""
|
||||
echo " c) Conecte o repositório no ArgoCD:"
|
||||
echo " - Acesse https://${ARGOCD_HOST}"
|
||||
echo " - Settings → Repositories → Connect Repo"
|
||||
echo " - Method: SSH"
|
||||
echo " - URL: git@${GITLAB_HOST}:<usuario>/gitops-demo.git"
|
||||
echo " - URL: git@${GITEA_HOST}:<usuario>/gitops-demo.git"
|
||||
echo " - SSH private key: (conteúdo de argocd-deploy-key)"
|
||||
echo ""
|
||||
echo "4. Crie uma Application no ArgoCD:"
|
||||
echo " kubectl apply -f - << 'EOF'"
|
||||
echo " apiVersion: argoproj.io/v1alpha1"
|
||||
echo " kind: Application"
|
||||
echo " metadata:"
|
||||
echo " name: node-bugado"
|
||||
echo " namespace: argocd"
|
||||
echo " spec:"
|
||||
echo " project: default"
|
||||
echo " source:"
|
||||
echo " repoURL: git@${GITLAB_HOST}:<usuario>/gitops-demo.git"
|
||||
echo " targetRevision: HEAD"
|
||||
echo " path: apps/node-bugado"
|
||||
echo " destination:"
|
||||
echo " server: https://kubernetes.default.svc"
|
||||
echo " namespace: demo"
|
||||
echo " syncPolicy:"
|
||||
echo " automated:"
|
||||
echo " prune: true"
|
||||
echo " selfHeal: true"
|
||||
echo " syncOptions:"
|
||||
echo " - CreateNamespace=true"
|
||||
echo " EOF"
|
||||
echo ""
|
||||
echo "Comandos úteis:"
|
||||
echo " kubectl get pods -n argocd"
|
||||
echo " kubectl get applications -n argocd"
|
||||
echo " kubectl logs -n gitlab -l app=gitlab-runner -f"
|
||||
echo ""
|
||||
|
||||
# Status dos pods
|
||||
log_info "Status dos pods:"
|
||||
kubectl get pods -n argocd
|
||||
|
||||
Reference in New Issue
Block a user