O problema#
Você tem um cluster OKE rodando na OCI.
Quer Traefik como ingress, SSL automático via Let’s Encrypt,
e ArgoCD sincronizando tudo pelo Git sem kubectl apply manual.
Essa combinação não tem tutorial decente em português. Esse é ele.
Pré-requisitos#
- Cluster OKE provisionado (via Terraform ou console OCI)
kubectl configurado com kubeconfig do cluster
helm ≥ 3.12
- Domínio com DNS apontando para o Load Balancer da OCI
- ArgoCD CLI (
argocd) instalado localmente
1. Instalar Traefik via Helm#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
helm repo add traefik https://traefik.github.io/charts
helm repo update
helm upgrade --install traefik traefik/traefik \
--namespace traefik \
--create-namespace \
--set ingressClass.enabled=true \
--set ingressClass.isDefaultClass=true \
--set ports.web.redirectTo.port=websecure \
--set ports.websecure.tls.enabled=true \
--set certificatesResolvers.le.acme.email=contato@castroti.com.br \
--set certificatesResolvers.le.acme.storage=/data/acme.json \
--set certificatesResolvers.le.acme.httpChallenge.entryPoint=web \
--set persistence.enabled=true \
--set persistence.size=128Mi
|
Verifique se o Load Balancer da OCI foi criado:
1
2
|
kubectl get svc -n traefik traefik -w
# Aguarda EXTERNAL-IP aparecer (pode levar 2-3 min na OCI)
|
2. Instalar ArgoCD#
1
2
3
4
5
6
7
|
kubectl create namespace argocd
kubectl apply -n argocd \
-f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
# Aguarda todos os pods subirem
kubectl wait --for=condition=Ready pods --all -n argocd --timeout=300s
|
Expor o ArgoCD via IngressRoute do Traefik:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# argocd-ingressroute.yaml
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: argocd-server
namespace: argocd
spec:
entryPoints:
- websecure
routes:
- match: Host(`argocd.castroti.com.br`)
kind: Rule
services:
- name: argocd-server
port: 443
tls:
certResolver: le
|
1
2
3
4
5
6
|
kubectl apply -f argocd-ingressroute.yaml
# Pegar senha inicial
kubectl get secret argocd-initial-admin-secret \
-n argocd \
-o jsonpath="{.data.password}" | base64 -d
|
3. Estrutura de repositórios GitOps#
infra-gitops/
├── apps/
│ ├── app-namespace/
│ │ ├── deployment.yaml
│ │ ├── service.yaml
│ │ └── ingressroute.yaml
│ └── monitoring/
│ ├── prometheus/
│ └── grafana/
└── argocd/
└── applications/
├── app-namespace.yaml
└── monitoring.yaml
Cada Application no ArgoCD aponta para uma pasta desse repo:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# argocd/applications/app-namespace.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: app-namespace
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/r0b3rt0c4str0/infra-gitops
targetRevision: main
path: apps/app-namespace
destination:
server: https://kubernetes.default.svc
namespace: app-namespace
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
|
4. Armadilhas comuns na OCI#
Load Balancer travado em “Pending”:
1
2
3
4
5
6
7
8
9
|
# Verificar eventos do serviço
kubectl describe svc traefik -n traefik
# OCI exige annotation específico para LB shape
kubectl annotate svc traefik -n traefik \
oci.oraclecloud.com/load-balancer-type="lb" \
oci.oraclecloud.com/oci-load-balancer-shape="flexible" \
oci.oraclecloud.com/oci-load-balancer-shape-flex-min=10 \
oci.oraclecloud.com/oci-load-balancer-shape-flex-max=100
|
ACME rate limit (muitos certificados):
Use staging primeiro:
1
|
--set certificatesResolvers.le.acme.caServer=https://acme-staging-v02.api.letsencrypt.org/directory
|
Resultado#
git push origin main
↓
ArgoCD detecta mudança
↓
Sync automático no cluster
↓
Traefik atualiza rotas + renova certs
↓
Zero downtime
Infra como código. Git como fonte da verdade. Sem kubectl apply manual em produção.
Dúvidas? Abre uma issue no GitHub.