Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Add ability to add Kubernetes Secrets and SecretKeyRefs #3702

Merged
merged 4 commits into from
Jul 11, 2021

Conversation

nicknezis
Copy link
Contributor

@nicknezis nicknezis commented Jul 9, 2021

Added support for dynamically adding Secrets as VolumeMounts and as ENV variables. The design mimics the design found in Apache Spark which is documented here: https://spark.apache.org/docs/latest/running-on-kubernetes.html#secret-management

This feature is important for loading TLS artifacts (i.e. certs, keys, certificate authority files)

@nicknezis
Copy link
Contributor Author

Currently testing. I was able to add a secret as a volume mount, but the submission failed when I tried to add an ENV variable. Will try to fix that code next.

@nicknezis
Copy link
Contributor Author

Apparently Array.asList produces a fixed sized array. This code existed for the two already existing EnvVars. This was causing my code to fail when trying to add a third. I was finally able to test. Can now mount Secrets as files and as ENV variables.

@nicknezis nicknezis marked this pull request as ready for review July 9, 2021 18:45
@nicknezis
Copy link
Contributor Author

To test you can create a secret like this:

kubectl create secret generic dev-user-pass \
  --from-literal=username=devuser \
  --from-literal=password='S!B\*d$zDsb='

Can then use it with the following config-properties:
--config-property heron.kubernetes.pod.secret.db-user-pass=/heron/db-pass
This will mount a secret to a path. db-user-pass secret to /heron/db-pass volume
Can also make an ENV variable:
--config-property heron.kubernetes.pod.secretKeyRef.DBPASS=db-user-pass:password
This will create a DBPASS ENV variable which has the password key from the db-user-user secret.

@joshfischer1108
Copy link
Member

Thanks @nicknezis . Could you add this feature to the documentation somewhere? I'd hate for it to get lost.

@nicknezis
Copy link
Contributor Author

Thanks @nicknezis . Could you add this feature to the documentation somewhere? I'd hate for it to get lost.

Yeah we currently have two pages dedicated to the Kubernetes scheduler. I'd like to consolidate them and have a good location for general config information like this. Was planning to do that as another ticket related to all of these changes I'm making. I'll try to add that soon.

@nicknezis nicknezis merged commit ed93aa5 into master Jul 11, 2021
@nicknezis nicknezis deleted the nicknezis/k8s-secrets branch July 11, 2021 02:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants