I am attempting to use Kubernetes secrets as Env variables within a user pod. I am overwriting various items, for my pod profiles with kubespawner_override. I would like to be able to pull in secrets (specific to pod type selection) and set them as environment variables. Currently I am attempting to do this by utilizing the “modify_pod_hook” key, but I receive the following error:
traitlets.traitlets.TraitError: The 'modify_pod_hook' trait of a KubeSpawner instance must be a callable, but a value of "def modify_pod_hook(spawner, pod):\n from kubernetes import client\n print(pod.spec.containers)\n pod.spec.containers.env.append(\n client.V1EnvVar(\n name='SECRET_STUFF', \n value_from=client.V1EnvVarSource(\n secret_key_ref=client.V1SecretKeySelector(\n name='aws-credentials',\n key=SECRET_STUFF',\n )\n )\n )\n )\n return pod\n" <class 'str'> was specified.
Here is the config I am trying to use:
profileList: - display_name: "Some Container Type" allowed_groups: ["jhub-admins"] description: "Light weight user container - 1 CPU 1GB Memory" kubespawner_override: modify_pod_hook: | def modify_pod_hook(spawner, pod): from kubernetes import client print(pod.spec.containers) pod.spec.containers.env.append( client.V1EnvVar( name='SECRET_STUFF', value_from=client.V1EnvVarSource( secret_key_ref=client.V1SecretKeySelector( name='aws-credentials', key='SECRET_STUFF', ) ) ) ) return pod
Has anyone attempted to do this from within the profileList? I was able to do it successfully at the hub level under extraConfig, but have been running into roadblocks when trying to do it at the singleUser level.
Z2JH, helm chart version 0.9.0b2