add letsencrypt certificates

This commit is contained in:
2026-01-20 05:45:52 +01:00
parent cdc1b7c3cc
commit 8d543258cc
12 changed files with 158 additions and 89 deletions

View File

@@ -0,0 +1,44 @@
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: certificates-apps
namespace: argocd-ops
spec:
generators:
# Les certificats sont créés UNIQUEMENT dans le cluster OPS
# qui a cert-manager installé et accès à Internet pour Let's Encrypt
- merge:
generators:
# Premier générateur : scanne les répertoires Helm pour les certificats
- git:
repoURL: https://git.gkdomaine.fr/kubernetes/argocd.git
revision: main
directories:
- path: "helm/certificates/*"
# Deuxième générateur : lit la config OPS uniquement
- git:
repoURL: https://git.gkdomaine.fr/kubernetes/argocd.git
revision: main
files:
- path: "configs/ops/config.json"
mergeKeys:
- path.basename
template:
metadata:
name: 'certificates-{{path.basename}}'
spec:
project: default
source:
repoURL: '{{repository}}'
targetRevision: '{{targetRevision}}'
path: '{{helmPath}}/certificates/{{path.basename}}'
destination:
# Déploie uniquement sur le cluster OPS
name: '{{name}}'
namespace: default
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true

7
configs/ops/config.json Normal file
View File

@@ -0,0 +1,7 @@
{
"environment": "ops",
"name": "cluster-ops",
"repository": "https://git.gkdomaine.fr/kubernetes/argocd.git",
"targetRevision": "main",
"helmPath": "helm"
}

View File

@@ -1,6 +0,0 @@
dependencies:
- name: cert-manager
repository: https://charts.jetstack.io
version: v1.19.2
digest: sha256:b02bda9b9f2fc886af11d017a27a5761513defee603f9e3aa1d7add2749b925c
generated: "2026-01-19T16:07:10.9508021+01:00"

View File

@@ -1,11 +0,0 @@
apiVersion: v2
name: cert-manager-wrapper
description: Wrapper pour cert-manager avec ClusterIssuer Let's Encrypt
type: application
version: 1.0.0
dependencies:
- name: cert-manager
version: v1.19.2
repository: https://charts.jetstack.io

View File

@@ -1,19 +0,0 @@
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt-prod
spec:
acme:
# URL du serveur Let's Encrypt Production
server: https://acme-v02.api.letsencrypt.org/directory
# Email utilisé pour l'enregistrement et les notifications de renouvellement
email: gkpoubelle78@gmail.com # ⚠️ À MODIFIER avec votre email
# Secret pour stocker la clé privée du compte ACME
privateKeySecretRef:
name: letsencrypt-prod
# Méthode de validation HTTP-01 (via Traefik)
solvers:
- http01:
ingress:
class: traefik

View File

@@ -1,19 +0,0 @@
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt-staging
spec:
acme:
# URL du serveur Let's Encrypt Staging (pour les tests)
server: https://acme-staging-v02.api.letsencrypt.org/directory
# Email utilisé pour l'enregistrement et les notifications de renouvellement
email: gkpoubelle78@gmail.com # ⚠️ À MODIFIER avec votre email
# Secret pour stocker la clé privée du compte ACME
privateKeySecretRef:
name: letsencrypt-staging
# Méthode de validation HTTP-01 (via Traefik)
solvers:
- http01:
ingress:
class: traefik

View File

@@ -1,34 +0,0 @@
# Configuration pour cert-manager
cert-manager:
# Installation de cert-manager
installCRDs: true
# Configuration des images depuis Harbor
image:
registry: harbor.gkdomaine.local
repository: images/cert-manager-controller
tag: v1.19.2
webhook:
image:
registry: harbor.gkdomaine.local
repository: images/cert-manager-webhook
tag: v1.19.2
cainjector:
image:
registry: harbor.gkdomaine.local
repository: images/cert-manager-cainjector
tag: v1.19.2
# Configuration de sécurité
securityContext:
enabled: true
# Prometheus metrics
# Désactivé car Prometheus Operator (ServiceMonitor CRD) n'est pas installé
prometheus:
enabled: false
servicemonitor:
enabled: false

View File

@@ -0,0 +1,5 @@
apiVersion: v2
name: certificates
description: Certificats Let's Encrypt générés dans OPS via cert-manager
type: application
version: 1.0.0

View File

@@ -0,0 +1,63 @@
# Certificats Let's Encrypt pour le cluster OPS
Ce chart gère les certificats Let's Encrypt générés par cert-manager dans le cluster OPS.
## Structure
- `Chart.yaml` : Définition du chart Helm
- `templates/` : Dossiers organisés par application
- `homarr/` : Certificats pour l'application Homarr
- `[autre-app]/` : Certificats pour d'autres applications
Chaque dossier d'application contient les certificats pour tous les environnements de cette application.
## Ajout d'un nouveau certificat
### Pour une application existante
Ajoutez un fichier dans le dossier de l'application (ex: `templates/homarr/`) :
```yaml
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: <app>-<env>-tls
namespace: <app>-<env> # Le namespace où sera utilisé le secret TLS
spec:
secretName: <app>-<env>-tls
issuerRef:
name: letsencrypt-prod # ou letsencrypt-staging pour les tests
kind: ClusterIssuer
dnsNames:
- <domain>
```
### Pour une nouvelle application
1. Créez un nouveau dossier dans `templates/` : `templates/<app>/`
2. Créez le fichier Certificate dans ce dossier
3. Optionnellement, créez un `README.md` dans le dossier pour documenter les certificats de cette application
## Déploiement
Les certificats sont déployés automatiquement via l'ApplicationSet `certificates-apps` dans ArgoCD.
## Vérification
```bash
# Vérifier les certificats
kubectl get certificates -A
# Vérifier un certificat spécifique
kubectl describe certificate homarr-dev-tls -n homarr-dev
# Vérifier le secret TLS créé
kubectl get secret homarr-dev-tls -n homarr-dev
```
## Notes importantes
- Les certificats sont créés dans le cluster OPS où cert-manager est installé
- Le namespace du Certificate doit correspondre au namespace où le secret TLS sera utilisé
- Pour utiliser le certificat dans d'autres clusters (DEV, RCT, PRD), le secret TLS doit être synchronisé depuis OPS

View File

@@ -0,0 +1,27 @@
# Certificats pour Homarr
Ce dossier contient les certificats Let's Encrypt pour l'application Homarr.
## Certificats disponibles
- `certificate-homarr-dev.yaml` : Certificat pour Homarr DEV (homarr.dev.gkdomaine.fr)
## Ajout d'un nouveau certificat Homarr
Pour ajouter un certificat pour un nouvel environnement (ex: RCT, PRD), créez un nouveau fichier :
```yaml
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: homarr-<env>-tls
namespace: homarr-<env>
spec:
secretName: homarr-<env>-tls
issuerRef:
name: letsencrypt-prod
kind: ClusterIssuer
dnsNames:
- homarr.<env>.gkdomaine.fr
```

View File

@@ -0,0 +1,12 @@
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: homarr-dev-tls
namespace: homarr-dev
spec:
secretName: homarr-dev-tls
issuerRef:
name: letsencrypt-prod
kind: ClusterIssuer
dnsNames:
- homarr.dev.gkdomaine.fr