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

Add custom ENV values to pod deployment specs. #1161

Closed
Denney-tech opened this issue Nov 30, 2023 · 1 comment · Fixed by #1171
Closed

Add custom ENV values to pod deployment specs. #1161

Denney-tech opened this issue Nov 30, 2023 · 1 comment · Fixed by #1171
Labels

Comments

@Denney-tech
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I have a need to provide environment variables to worker nodes for Python to behave the way I want it to.

E.g.

extra_env:
  - name: REQUESTS_CA_BUNDLE
    value: /etc/ssl/certs/ca-bundle.crt

Describe the solution you'd like
I would like to have an extra_env or <pod_role>_extra_env keys to add environment vars to deployments. While the ca-bundle for python is probably fine as a global extra environment var, there might be scenarios where you only want some environment variable applied to the web pods or content pods. So, having web_extra_env or content_extra_env etc might be ideal.

Describe alternatives you've considered
As a workaround, since I'm already building the galaxy image myself for other reasons unrelated to the operator, so I'm going to add the environment variables I need directly to the image.

Additional context
I have been researching, but I can't find anything in the docs specifically for adding environment vars to deployments. The pulp_settings key will add extra pythonic dictionaries to the settings.py file, but unless I'm misunderstanding something, that file doesn't necessarily import the key/values as real environment vars.

Looking at the controllers/deployment.go#L922 file, the setcontainers function, as well as a couple others, do actually define the Env: of the container specs, but I'm not sure where it gets this from upstream or if it's always null because it isn't configurable in the pulp CRD?

If there should already be a way to add env vars to deployments, please provide guidance and documentation on this.

@git-hyagi
Copy link
Collaborator

Hi @Denney-tech,

Thank you for opening this issue!
Unfortunately, it is not possible to define custom env vars to the containers yet.

Looking at the controllers/deployment.go#L922 file, the setcontainers function, as well as a couple others, do actually define the Env: of the container specs, but I'm not sure where it gets this from upstream or if it's always null because it isn't configurable in the pulp CRD?

The operator defines the containers envVars through the setEnvVars method:

func (d *CommonDeployment) setEnvVars(resources any, pulpcoreType settings.PulpcoreType) {

but we don't provide a field in Pulp CR to add custom env vars.

As a workaround, since I'm already building the galaxy image myself for other reasons unrelated to the operator, so I'm going to add the environment variables I need directly to the image.

That was a good idea! Just to document, in case others are having this same issue, another workaround (if building a new image is not possible/wanted) would be to put the operator in an unmanaged state and manually modify the deployments with the env vars.

Here are some thoughts/ideas of implementation:

  • will need to check and overwrite if the user provided an env var that is already managed by the operator (and output a warn log message to inform that the env var has been overwritten)
  • the field should be of type []corev1.EnvVar so that users could also provide env vars from secrets and configmaps
  • we need to add new fields to .spec.{api,content,worker} and also PulpContainer (allowing to add the env vars to initContainers and containers' jobs)
  • update the tests in controller_test.go to validate the custom env vars
  • document, with examples, how to configure it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants