On vous demande d’introduire GitOps sur un petit parc. Le démarrage rapide d’Argo CD lâche un manifeste dans un kubectl apply, vous faites un port-forward sur l’interface, vous vous connectez en admin avec le mot de passe auto-généré, et vous synchronisez votre première Application. Deux mois plus tard, le mot de passe admin est toujours celui auto-généré, tous les opérateurs partagent le compte admin parce que dex n’a jamais été câblé, le port-forward est la façon dont les gens atteignent l’interface (accès kubectl égale écriture sur le cluster), le certificat TLS est auto-signé, et l’etcd embarqué de k3s vit sur le système de fichiers racine à côté de logs qui s’emballent.
Ce qui se passe
Un déploiement Argo CD réellement prêt pour la production demande plus que kubectl apply -f install.yaml. La couche de base (k3s ici) a besoin d’un placement délibéré du datastore, de seuils d’éviction kubelet qui correspondent au disque, et du service load balancer embarqué désactivé au profit d’un vrai contrôleur d’ingress ; Argo CD est installé via Helm pour que les valeurs soient revues en Git ; ingress-nginx est devant argocd-server avec cert-manager + Let’s Encrypt ; le SSO OIDC remplace le compte admin pour le quotidien, avec admin tourné comme bris-de-glace uniquement ; le ConfigMap argocd-rbac-cm mappe les groupes SSO aux rôles ; et le dépôt source GitOps est verrouillé au niveau Git. Le cluster est le plan de contrôle de tout le reste — sa discipline opérationnelle est le premier arrêt de l’audit.
Comment vérifier
k3s doit être en santé et les pods Argo CD tous en Running :
kubectl -n argocd get pods
L’ingress doit répondre avec une vraie chaîne de certificats :
echo | openssl s_client -servername argocd.example.com -connect argocd.example.com:443 2>/dev/null \
| openssl x509 -noout -subject -issuer -dates
Et argocd login doit fonctionner sur le nom d’hôte public, pas par port-forward :
argocd login argocd.example.com --sso
S’il ne fonctionne qu’avec --port-forward-namespace argocd, l’ingress n’est pas câblé — corrigez-le avant d’exposer le cluster à des applications.
Le correctif
Enregistrez le script ci-dessous sous /root/setup-argocd-ubuntu22.sh, puis exécutez-le. Il tourne sur une VM Ubuntu 22.04 fraîche : apt update, unattended-upgrades, ajustement sysctl/descripteurs, durcissement SSH, k3s avec traefik et servicelb désactivés, Helm, ingress-nginx + cert-manager + ClusterIssuer pour Let’s Encrypt, le chart Helm Argo CD avec le mot de passe admin posé depuis un hash bcrypt généré, un Ingress avec TLS, un pointeur de config OIDC, un ConfigMap RBAC qui mappe le groupe argocd-admins à admin, et une boucle d’attente pour le certificat LE avant de déclarer la réussite.
#!/usr/bin/env bash
set -euo pipefail
### Ubuntu 22.04 Argo CD on k3s clean VM installer
### k3s single-node (HA optional via embedded etcd)
### ingress-nginx + cert-manager + Let's Encrypt
### Argo CD via Helm, admin password rotated at install
### OIDC SSO ready (Authelia/Keycloak/Okta etc.)
### No local backups; assumes VM-level backup of /var/lib/rancher/k3s
if [[ "$(id -u)" -ne 0 ]]; then
echo "Run as root."
exit 1
fi
: "${ARGOCD_DOMAIN:?Set ARGOCD_DOMAIN (e.g. argocd.example.com)}"
: "${LE_EMAIL:?Set LE_EMAIL}"
: "${OIDC_ISSUER:?Set OIDC_ISSUER (e.g. https://auth.example.com)}"
: "${OIDC_CLIENT_ID:?Set OIDC_CLIENT_ID}"
: "${OIDC_CLIENT_SECRET:?Set OIDC_CLIENT_SECRET}"
ARGOCD_CHART_VERSION="${ARGOCD_CHART_VERSION:-7.6.12}"
ARGOCD_ADMIN_PASSWORD="$(openssl rand -base64 24)"
echo
echo "========================================"
echo "Argo CD on k3s Ubuntu 22.04 Setup"
echo "Domain: ${ARGOCD_DOMAIN}"
echo "OIDC issuer: ${OIDC_ISSUER}"
echo "========================================"
echo
export DEBIAN_FRONTEND=noninteractive
echo "==> Updating base OS"
apt-get update
apt-get -y upgrade
apt-get -y install \
ca-certificates curl gnupg lsb-release \
vim chrony fail2ban unattended-upgrades \
iproute2 lsof tcpdump dnsutils tar gzip unzip jq apache2-utils
echo "==> Enabling time sync"
systemctl enable --now chrony
timedatectl set-ntp true
echo "==> Applying sysctl tuning"
cat > /etc/sysctl.d/99-argocd.conf <<'SYSCTL'
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
net.core.somaxconn = 4096
net.core.netdev_max_backlog = 250000
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_syncookies = 1
net.ipv4.ip_local_port_range = 10240 65535
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-iptables = 1
kernel.dmesg_restrict = 1
kernel.kptr_restrict = 2
fs.file-max = 2097152
fs.inotify.max_user_watches = 524288
fs.inotify.max_user_instances = 512
vm.max_map_count = 262144
SYSCTL
modprobe br_netfilter || true
modprobe tcp_bbr || true
echo br_netfilter > /etc/modules-load.d/br_netfilter.conf
echo tcp_bbr > /etc/modules-load.d/bbr.conf
sysctl --system
echo "==> Setting file limits"
cat > /etc/security/limits.d/99-argocd.conf <<'LIMITS'
* soft nofile 64000
* hard nofile 64000
root soft nofile 64000
root hard nofile 64000
LIMITS
echo "==> Hardening SSH"
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak.$(date +%F-%H%M%S)
set_sshd_option() {
local key="$1"
local value="$2"
if grep -qE "^[#[:space:]]*${key}[[:space:]]+" /etc/ssh/sshd_config; then
sed -i "s|^[#[:space:]]*${key}[[:space:]].*|${key} ${value}|" /etc/ssh/sshd_config
else
echo "${key} ${value}" >> /etc/ssh/sshd_config
fi
}
set_sshd_option PermitRootLogin prohibit-password
set_sshd_option PasswordAuthentication no
set_sshd_option PubkeyAuthentication yes
set_sshd_option KbdInteractiveAuthentication no
set_sshd_option X11Forwarding no
set_sshd_option ClientAliveInterval 300
set_sshd_option ClientAliveCountMax 2
set_sshd_option MaxAuthTries 4
sshd -t
systemctl restart ssh
echo "==> Configuring fail2ban"
mkdir -p /etc/fail2ban/jail.d
cat > /etc/fail2ban/jail.d/sshd.local <<'FAIL2BAN'
[sshd]
enabled = true
port = ssh
backend = systemd
maxretry = 4
findtime = 10m
bantime = 1h
FAIL2BAN
systemctl enable --now fail2ban
echo "==> Enabling unattended-upgrades for security"
cat > /etc/apt/apt.conf.d/20auto-upgrades <<'AUTOUPG'
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
APT::Periodic::AutocleanInterval "7";
AUTOUPG
echo "==> Installing k3s (no traefik, no servicelb, write kubeconfig 644)"
curl -sfL https://get.k3s.io | sh -s - \
--disable traefik \
--disable servicelb \
--write-kubeconfig-mode 644 \
--kubelet-arg "eviction-hard=memory.available<200Mi,nodefs.available<10%" \
--kube-controller-manager-arg "node-monitor-grace-period=30s"
echo "==> Waiting for k3s API"
for i in {1..60}; do
if kubectl get nodes >/dev/null 2>&1; then
break
fi
sleep 2
done
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
echo "==> Installing kubectl alias and Helm"
ln -sf /usr/local/bin/k3s /usr/local/bin/kubectl 2>/dev/null || true
curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
echo "==> Installing ingress-nginx via Helm"
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo add jetstack https://charts.jetstack.io
helm repo add argo https://argoproj.github.io/argo-helm
helm repo update
helm upgrade --install ingress-nginx ingress-nginx/ingress-nginx \
--namespace ingress-nginx --create-namespace \
--set controller.service.type=LoadBalancer \
--set controller.kind=DaemonSet \
--set controller.hostNetwork=true \
--set controller.dnsPolicy=ClusterFirstWithHostNet \
--set controller.publishService.enabled=false \
--set controller.config.use-forwarded-headers=true \
--wait --timeout 5m
echo "==> Installing cert-manager"
helm upgrade --install cert-manager jetstack/cert-manager \
--namespace cert-manager --create-namespace \
--set crds.enabled=true \
--wait --timeout 5m
echo "==> Creating Let's Encrypt ClusterIssuer"
cat <<ISSUER | kubectl apply -f -
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt-prod
spec:
acme:
server: https://acme-v02.api.letsencrypt.org/directory
email: ${LE_EMAIL}
privateKeySecretRef:
name: letsencrypt-prod-account
solvers:
- http01:
ingress:
class: nginx
ISSUER
echo "==> Generating bcrypt hash for Argo CD admin"
ARGOCD_ADMIN_HASH="$(htpasswd -nbBC 10 "" "${ARGOCD_ADMIN_PASSWORD}" | tr -d ':\n' | sed 's/\$2y/\$2a/')"
echo "==> Writing Argo CD values.yaml"
install -d /etc/argocd
cat > /etc/argocd/values.yaml <<VALS
global:
domain: ${ARGOCD_DOMAIN}
configs:
params:
server.insecure: true # TLS is terminated at ingress-nginx
secret:
argocdServerAdminPassword: '${ARGOCD_ADMIN_HASH}'
argocdServerAdminPasswordMtime: '$(date -u +%FT%TZ)'
cm:
url: https://${ARGOCD_DOMAIN}
oidc.config: |
name: SSO
issuer: ${OIDC_ISSUER}
clientID: ${OIDC_CLIENT_ID}
clientSecret: \$oidc.clientSecret
requestedScopes:
- openid
- profile
- email
- groups
admin.enabled: 'true'
accounts.readonly: apiKey, login
timeout.reconciliation: 180s
statusbadge.enabled: 'true'
rbac:
policy.default: role:readonly
policy.csv: |
g, argocd-admins, role:admin
g, argocd-devs, role:readonly
server:
replicas: 1
ingress:
enabled: true
ingressClassName: nginx
hostname: ${ARGOCD_DOMAIN}
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
nginx.ingress.kubernetes.io/backend-protocol: HTTP
nginx.ingress.kubernetes.io/ssl-passthrough: 'false'
tls: true
extraTls:
- hosts:
- ${ARGOCD_DOMAIN}
secretName: argocd-server-tls
controller:
replicas: 1
resources:
requests: { cpu: 250m, memory: 512Mi }
limits: { cpu: 2, memory: 2Gi }
repoServer:
replicas: 1
applicationSet:
enabled: true
notifications:
enabled: true
VALS
cat > /etc/argocd/oidc-secret.yaml <<OIDC
apiVersion: v1
kind: Secret
metadata:
name: argocd-secret
namespace: argocd
labels:
app.kubernetes.io/name: argocd-secret
app.kubernetes.io/part-of: argocd
type: Opaque
stringData:
oidc.clientSecret: '${OIDC_CLIENT_SECRET}'
OIDC
echo "==> Creating argocd namespace and OIDC client secret"
kubectl create namespace argocd --dry-run=client -o yaml | kubectl apply -f -
kubectl -n argocd apply -f /etc/argocd/oidc-secret.yaml
echo "==> Installing Argo CD via Helm"
helm upgrade --install argocd argo/argo-cd \
--version "${ARGOCD_CHART_VERSION}" \
--namespace argocd \
-f /etc/argocd/values.yaml \
--wait --timeout 10m
echo "==> Waiting for ingress cert to issue"
for i in {1..60}; do
if kubectl -n argocd get secret argocd-server-tls >/dev/null 2>&1; then
break
fi
sleep 5
done
if ! kubectl -n argocd get secret argocd-server-tls >/dev/null 2>&1; then
echo "Let's Encrypt cert not issued yet; check kubectl describe certificate -n argocd"
kubectl -n argocd get certificate || true
fi
echo "==> Installing argocd CLI"
ARGOCD_CLI_VER="$(curl -fsSL https://api.github.com/repos/argoproj/argo-cd/releases/latest | jq -r .tag_name)"
curl -fsSL -o /usr/local/bin/argocd \
"https://github.com/argoproj/argo-cd/releases/download/${ARGOCD_CLI_VER}/argocd-linux-amd64"
chmod 755 /usr/local/bin/argocd
echo
echo "========================================"
echo "DONE"
echo "========================================"
echo
echo "Kernel:"
uname -r
echo
echo "k3s and Argo CD:"
kubectl get nodes -o wide
echo
kubectl -n argocd get pods
echo
echo "Ingress and cert:"
kubectl -n argocd get ingress
kubectl -n argocd get certificate
echo
echo "Listeners on host:"
ss -lntp | grep -E ':(80|443|6443)\b' || true
echo
echo "Web UI:"
echo "https://${ARGOCD_DOMAIN}/"
echo
echo "Break-glass admin credentials (stored in secret argocd-secret):"
echo " user: admin"
echo " password: ${ARGOCD_ADMIN_PASSWORD}"
echo
echo "OIDC users in group 'argocd-admins' have admin role via RBAC ConfigMap."
echo "Rotate the admin password into your secrets manager and use SSO day-to-day."
Rendez-le exécutable et lancez-le :
chmod 700 /root/setup-argocd-ubuntu22.sh
ARGOCD_DOMAIN=argocd.example.com \
LE_EMAIL=ops@example.com \
OIDC_ISSUER=https://auth.example.com \
OIDC_CLIENT_ID=argocd \
OIDC_CLIENT_SECRET=... \
/root/setup-argocd-ubuntu22.sh
Après la première émission Let’s Encrypt réussie, connectez-vous une fois avec le mot de passe admin imprimé pour confirmer le chemin, puis basculez sur SSO et traitez admin comme bris-de-glace. Le claim de groupe OIDC doit s’appeler groups côté IdP pour que le ConfigMap RBAC mappe argocd-admins correctement. Les sauvegardes au niveau hôte sont hors périmètre : /var/lib/rancher/k3s/server/db et /var/lib/rancher/k3s/storage sont les chemins avec état, et la VM est présumée avoir des instantanés/sauvegardes au niveau cloud.
GitOps ne fonctionne que quand le cluster derrière est infogéré de bout en bout — voyez comment Stack Harbor opère la couche plateforme dans Environnements infogérés (Environnements infogérés) → ou démarrer une conversation.