This commit is contained in:
2026-01-22 22:20:11 +01:00
parent acf740ff46
commit 51d3ea0600
3 changed files with 250 additions and 11 deletions

View File

@@ -84,7 +84,7 @@ Créez une policy Vault pour accéder aux secrets OVH :
```bash
vault policy write cert-manager-webhook-ovh-policy - <<EOF
path "secret/data/ovh" {
path "secret/data/cert-manager-webhook-ovh" {
capabilities = ["read"]
}
EOF
@@ -94,16 +94,18 @@ Stockez les credentials OVH dans Vault :
```bash
# Pour Vault KV v2, utilisez cette commande :
vault kv put secret/ovh \
vault kv put secret/cert-manager-webhook-ovh \
application-key="VOTRE_APPLICATION_KEY" \
application-secret="VOTRE_APPLICATION_SECRET" \
consumer-key="VOTRE_CONSUMER_KEY"
# Vérifiez que le secret est bien stocké :
vault kv get secret/ovh
vault kv get secret/cert-manager-webhook-ovh
```
**Important** : Le format du chemin dans `remoteRef` pour External Secrets est `ovh#application-key` (sans le préfixe `secret/data/`), car le mount path `secret` est déjà défini dans le ClusterSecretStore.
**Important** :
- Le format du chemin dans `remoteRef` pour External Secrets est `cert-manager-webhook-ovh#application-key` (sans le préfixe `secret/data/`), car le mount path `secret` est déjà défini dans le ClusterSecretStore.
- Le nom du secret dans Vault (`cert-manager-webhook-ovh`) doit correspondre exactement au nom utilisé dans `remoteRef`.
#### Configuration dans values.yaml
@@ -115,9 +117,9 @@ externalSecret:
refreshInterval: "1h"
secretName: "cert-manager-webhook-ovh"
remoteRef:
applicationKey: "ovh#application-key"
applicationSecret: "ovh#application-secret"
consumerKey: "ovh#consumer-key"
applicationKey: "cert-manager-webhook-ovh#application-key"
applicationSecret: "cert-manager-webhook-ovh#application-secret"
consumerKey: "cert-manager-webhook-ovh#consumer-key"
vault:
secretStoreName: "vault-backend"
server: "https://vault.example.com:8200"
@@ -162,6 +164,93 @@ kubectl describe externalsecret cert-manager-webhook-ovh -n cert-manager-ops --c
## Dépannage
### Erreur "could not get secret data from provider" ou "permission denied"
Cette erreur indique que External Secrets Operator ne peut pas lire les secrets depuis Vault. Vérifiez les points suivants :
#### 1. Vérifier que le secret existe dans Vault
```bash
# Vérifier que le secret existe
vault kv get secret/cert-manager-webhook-ovh
# Si le secret n'existe pas, créez-le :
vault kv put secret/cert-manager-webhook-ovh \
application-key="VOTRE_APPLICATION_KEY" \
application-secret="VOTRE_APPLICATION_SECRET" \
consumer-key="VOTRE_CONSUMER_KEY"
```
#### 2. Vérifier la policy Vault
```bash
# Vérifier que la policy existe
vault policy read cert-manager-webhook-ovh-policy
# Si la policy n'existe pas, créez-la :
vault policy write cert-manager-webhook-ovh-policy - <<EOF
path "secret/data/cert-manager-webhook-ovh" {
capabilities = ["read"]
}
EOF
```
#### 3. Vérifier le rôle Vault et les permissions
```bash
# Vérifier la configuration du rôle
vault read auth/kubernetes/role/cert-manager-webhook-ovh-role
# Vérifier que le rôle utilise la bonne policy
# Le rôle doit avoir : policies = cert-manager-webhook-ovh-policy
```
#### 4. Vérifier que le ServiceAccount peut s'authentifier
```bash
# Vérifier que le ServiceAccount existe
kubectl get serviceaccount cert-manager-webhook-ovh-sa -n cert-manager-webhook-ovh-ops
# Vérifier les permissions RBAC
kubectl auth can-i use secret --namespace=cert-manager-webhook-ovh-ops \
--as=system:serviceaccount:cert-manager-webhook-ovh-ops:cert-manager-webhook-ovh-sa
```
#### 5. Vérifier la connexion à Vault
```bash
# Vérifier que le ClusterSecretStore peut se connecter à Vault
kubectl describe clustersecretstore vault-backend
# Vérifier les logs d'External Secrets Operator
kubectl logs -n external-secrets-system \
-l app.kubernetes.io/name=external-secrets \
--tail=50 | grep -i "vault\|error\|failed"
```
#### 6. Vérifier le format des chemins
Le format correct pour Vault KV v2 est `cert-manager-webhook-ovh#application-key` (sans le préfixe `secret/data/`).
Vérifiez dans `values.yaml` :
```yaml
remoteRef:
applicationKey: "cert-manager-webhook-ovh#application-key" # ✅ Correct
# ❌ Incorrect: "secret/data/cert-manager-webhook-ovh#application-key"
```
**Important** : Le nom du secret dans Vault doit correspondre exactement au nom utilisé dans `remoteRef` (ici `cert-manager-webhook-ovh`).
#### 7. Forcer une nouvelle synchronisation
```bash
# Forcer une synchronisation immédiate
kubectl annotate externalsecret cert-manager-webhook-ovh \
-n cert-manager-ops \
force-sync=$(date +%s) \
--overwrite
```
### Erreur "invalid bound_service_account_namespace_selector configured"
Cette erreur se produit lors de la création d'un rôle Vault. **Ne configurez PAS** `bound_service_account_namespace_selector`. Utilisez plutôt `bound_service_account_namespaces` :

View File

@@ -91,13 +91,14 @@ externalSecret:
# Références aux clés dans Vault
# Format pour Vault KV v2 avec External Secrets:
# - Si le mount path est "secret" et le secret est dans "ovh": "ovh#application-key"
# - Si le mount path est "secret" et le secret est dans "cert-manager-webhook-ovh": "cert-manager-webhook-ovh#application-key"
# - Le préfixe "secret/data/" n'est PAS nécessaire car il est géré par le ClusterSecretStore
# - Le format est: "chemin-du-secret#clef-dans-le-json"
# ⚠️ IMPORTANT: Le nom du secret dans Vault doit correspondre exactement ici
remoteRef:
applicationKey: "ovh#application-key" # ⚠️ Chemin: secret/ovh avec clé application-key
applicationSecret: "ovh#application-secret" # ⚠️ Chemin: secret/ovh avec clé application-secret
consumerKey: "ovh#consumer-key" # ⚠️ Chemin: secret/ovh avec clé consumer-key
applicationKey: "cert-manager-webhook-ovh#application-key" # ⚠️ Chemin: secret/cert-manager-webhook-ovh avec clé application-key
applicationSecret: "cert-manager-webhook-ovh#application-secret" # ⚠️ Chemin: secret/cert-manager-webhook-ovh avec clé application-secret
consumerKey: "cert-manager-webhook-ovh#consumer-key" # ⚠️ Chemin: secret/cert-manager-webhook-ovh avec clé consumer-key
# Configuration HashiCorp Vault
vault: