Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow NMA certs to be read from GSM #618

Merged
merged 5 commits into from
Dec 5, 2023
Merged

Conversation

spilchen
Copy link
Collaborator

@spilchen spilchen commented Dec 4, 2023

The key change here is to allow the NMA certs to be read in from Google Secret Manager (GSM). This is triggered based on a secret path reference given for the spec.nmaTLSSecret secret. The secret path reference for GSM is gsm://. So, the secret name has to be filled in like gsm://projects/1680942424/secrets/mspilchen/versions/6.

Some other changes that were made:

  • secrets stored in GSM need to be saved in a JSON format. The values for each key in the JSON doc is expected to be a byte-array so must be stored as base64 encoded. Previously the values were stored as plaintext strings. Using base64 encoded will allow us to easily store multi-line certs in them.
  • generalized the secret reader in the operator so that it can use GSM or K8s depending on the path reference. This was added in a new struct called MultiSourceSecretFetcher in the cloud package.
  • new helm chart parameters to allow you to specify annotations for the service account used to deploy the operator. This was added as a convenience because the annotation is necessary to link a GCP service account with the k8s service account.

@spilchen spilchen self-assigned this Dec 4, 2023
Copy link
Collaborator

@roypaulin roypaulin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

}
tlsCerts := &corev1.Secret{}
err := v.Client.Get(ctx, nm, tlsCerts)
tlsCerts, err := fetcher.Fetch(ctx, names.GenNamespacedName(v.VDB, v.VDB.Spec.NMATLSSecret))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we refactor this into a generic function that gets a secret and retrieve https certs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where would you think we would use this generic function?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant to rename retrieveHTTPSCerts to retrieveNMACerts and have a function called retrieveHTTPSCerts that gets the secret name. But we don't need it for now as nma certs are the only one we retrieve.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can rename to retriveNMACerts though. That's probably a better name.

@spilchen spilchen merged commit 26d2c86 into main Dec 5, 2023
27 checks passed
@spilchen spilchen deleted the spilchen/read-from-gsm branch December 5, 2023 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants