I'm currently working in an environment where the priviledged database user's password I'm referencing in a DatabaseSecretEngineConfig is updated regularly using an ExternalSecret with a Generator. Database engine is postgresql and, if it matters to the issue at hand, it's provisioned on GCP CloudSQL through yaml resources too (kubernetes config connector). The priviledged user's password is correctly updated in the pg instance.
Contrary to what is written in the documentation for the DatabaseSecretEngineConfig, it seems vault-config-operator does not watch for changes in kubernetes secrets where user credentials are provided. I mean here that when the DatabaseSecretEngineConfig is first created, DatabaseSecretEngineRole are then working as intended. I'm able to create dynamic roles in the database without issue. After a while (after the priviledged account's password rotated), I get the following error:
* unable to start transaction: failed to connect to `host=instance-postgres-1.foo.bar user=baz database=quux`: failed SASL auth (FATAL: password authentication failed for user "baz" (SQLSTATE 28P01))
This is the manifest I wrote to define a connexion (minus some later kustomization patches):
# ExternalSecret resources for reference (you can see the type basic-auth of the secret it will generate)
---
apiVersion: external-secrets.io/v1
kind: ExternalSecret
metadata:
name: user
spec:
refreshInterval: "10080m" # 1 week
target:
template:
type: kubernetes.io/basic-auth
engineVersion: v2
data:
password: "{{ .password }}"
username: user
dataFrom:
- sourceRef:
generatorRef:
apiVersion: generators.external-secrets.io/v1alpha1
kind: Password
name: password
---
apiVersion: redhatcop.redhat.io/v1alpha1
kind: DatabaseSecretEngineConfig
metadata:
name: base
spec:
authentication:
path: ${cluster_name}
role: database-engine-admin
serviceAccount:
name: vault
pluginName: postgresql-database-plugin
allowedRoles:
- role-read-write
- role-read-only
rootCredentials:
secret:
name: user
rootPasswordRotation:
enable: false
passwordAuthentication: scram-sha-256
passwordPolicy: password-policy
connectionURL: replaceme
path: replaceme
I'm actually reproducing this on every DatabaseSecretEngineConfig I set up. I'm saddly using an older version of Hashicorp Vault but since secret watching is done on kubernetes sides, I believe it should not impact how this feature works.
If I delete the DatabaseSecretEngineConfig resources and recreate it, the connection is also recreated in Vault, with an updated password.
I did not find any issue referencing this and it seems pretty basic so I'm wondering if I missed something. Please do not hesitate to tell me if the problem is between the chair and the keyboard.
I'm currently working in an environment where the priviledged database user's password I'm referencing in a
DatabaseSecretEngineConfigis updated regularly using an ExternalSecret with a Generator. Database engine is postgresql and, if it matters to the issue at hand, it's provisioned on GCP CloudSQL through yaml resources too (kubernetes config connector). The priviledged user's password is correctly updated in the pg instance.Contrary to what is written in the documentation for the
DatabaseSecretEngineConfig, it seems vault-config-operator does not watch for changes in kubernetes secrets where user credentials are provided. I mean here that when theDatabaseSecretEngineConfigis first created,DatabaseSecretEngineRoleare then working as intended. I'm able to create dynamic roles in the database without issue. After a while (after the priviledged account's password rotated), I get the following error:This is the manifest I wrote to define a connexion (minus some later kustomization patches):
I'm actually reproducing this on every
DatabaseSecretEngineConfigI set up. I'm saddly using an older version of Hashicorp Vault but since secret watching is done on kubernetes sides, I believe it should not impact how this feature works.If I delete the
DatabaseSecretEngineConfigresources and recreate it, the connection is also recreated in Vault, with an updated password.I did not find any issue referencing this and it seems pretty basic so I'm wondering if I missed something. Please do not hesitate to tell me if the problem is between the chair and the keyboard.