3scale-ops / saas-operator

3scale SaaS Operator - www.3scale.net
Apache License 2.0
8 stars 2 forks source link

Replace current SecretDefinitions by ExternalSecrets #140

Closed slopezz closed 2 years ago

slopezz commented 2 years ago

We are in the process of switching from SecretDefinitons (from secrets-manager) to ExternalSecrets (external-secrets operator).

We need to update our saas-operator to create this new ExternalSecrets custom resources instead of current SecretDefinitons.

We will need to update current CRDs by adding to the fromVault spec:

Example, from:

apiVersion: secrets-manager.tuenti.io/v1alpha1
kind: SecretDefinition
metadata:
  name: system-database-seed
spec:
  name: system-database-seed
  type: Opaque
  keysMap:
    DB_NAME:
      path: secret/data/kubernetes/dev-eng/ocp4-5/3scale-saas/system-database
      key: DB_NAME
    DB_USER:
      path: secret/data/kubernetes/dev-eng/ocp4-5/3scale-saas/system-database
      key: DB_USER
    DB_PASSWORD:
      path: secret/data/kubernetes/dev-eng/ocp4-5/3scale-saas/system-database
      key: DB_PASSWORD
    URL:
      path: secret/data/kubernetes/dev-eng/ocp4-5/3scale-saas/system-database
      key: URL

To:

apiVersion: external-secrets.io/v1alpha1
kind: ExternalSecret
metadata:
  name: system-database-seed
spec:
  refreshInterval: 60s
  secretStoreRef:
    name: vault-mgmt
    kind: ClusterSecretStore
  target:
    name: system-database-seed
  data:
  - secretKey: DB_NAME
    remoteRef:
      key: kubernetes/dev-eng/ocp4-5/3scale-saas/system-database
      property: DB_NAME
  - secretKey: DB_USER
    remoteRef:
      key: kubernetes/dev-eng/ocp4-5/3scale-saas/system-database
      property: DB_USER
  - secretKey: DB_PASSWORD
    remoteRef:
      key: kubernetes/dev-eng/ocp4-5/3scale-saas/system-database
      property: DB_PASSWORD
  - secretKey: URL
    remoteRef:
      key: kubernetes/dev-eng/ocp4-5/3scale-saas/system-database
      property: URL 

As the target secrets will remain the same (the secret.spec.data won't change, so won't be triggered any deployment), to avoid the target secrets being removed temporarily and recreated by external-secrets-operator, it will be needed to:

slopezz commented 2 years ago

Closed by https://github.com/3scale-ops/saas-operator/pull/181

Deployed at https://github.com/3scale-ops/saas-operator/pull/184