mgob icon indicating copy to clipboard operation
mgob copied to clipboard

Pass database credentials as secret

Open IngaldiCSB opened this issue 6 years ago • 6 comments

Hello!

in kubernetes manifests, I describe a mgob configuration file, mounted as configMap. In this file i have to provide user database credentials and it's not a good practice. Is there some way to configure db credentials creating a secret and mounting it along mogb configuration?

Thanks in advance and congratulations for the project

IngaldiCSB avatar Feb 14 '19 07:02 IngaldiCSB

The mogb config files can be stored as Secrets instead of ConfigMaps.

stefanprodan avatar Feb 14 '19 09:02 stefanprodan

@stefanprodan I think it can be a good user experience to still be able to see my configs and use a secret. How about the following?

target:
  host: "172.18.7.21"
  port: 27017
  database: "test"
  username: "admin"
#  password: "secret"
  k8s_secret:
    name: mgob-secret
    key: MONGODB_PASSWORD

I can help with this one if you think it is ok.

bzon avatar Sep 13 '19 13:09 bzon

I think the simplest way would be to support environment variable interpolation in the config files. You could then mount the secret as ENV.

Then you could do just password: "${MONGO_BACKUP_PASSWORD}"

ambis avatar Feb 02 '21 09:02 ambis

The mogb config files can be stored as Secrets instead of ConfigMaps.

Can someone explain to me how this is achieved?

I've created my backup plan as a Secret so mongo connection details aren't stored as plain text within a ConfigMap but the container keeps crashing with the following error:

level=fatal msg="No backup plans found in /config

Which makes perfect sense as it's actually mounted here:

/secret/mongo-backup-conf

CptQuint avatar Feb 10 '21 12:02 CptQuint

@CptQuint .. just mount it in the correct directory then?

ambis avatar Feb 11 '21 07:02 ambis

@ambis I should be clear, I'm trying to use the Helm chart for deployment.

CptQuint avatar Feb 11 '21 07:02 CptQuint