Pass through environment to scheduler, web and launcher

These components may need to have http_proxy set, so let the user
pass env variables.

Change-Id: I6191dd9c8ded70c715f13179c3d904e8f65e144d
This commit is contained in:
James E. Blair 2021-04-12 16:38:38 -07:00
parent 182a563a9e
commit 3df4bc0ad1
4 changed files with 25 additions and 4 deletions

View File

@ -355,6 +355,13 @@ verbatim):
* ``tls.crt``
* ``tls.key``
.. attr:: env
A list of environment variables. This will be passed through
to the Pod specifications for the scheduler, launcher, and
web. This may be used to set http_proxy environment
variables.
.. attr:: scheduler
.. attr:: config

View File

@ -28,9 +28,7 @@ spec:
containers:
- name: launcher
image: {{ spec.imagePrefix }}/nodepool-launcher:{{ spec.nodepoolImageVersion }}
env:
- name: KUBECONFIG
value: /etc/kubernetes/kube.config
env: {{ spec.env | zuul_to_json }}
volumeMounts:
- name: nodepool-config
mountPath: /etc/nodepool

View File

@ -166,6 +166,7 @@ spec:
readOnly: true
{%- endif %}
{%- endfor %}
env: {{ spec.env | zuul_to_json }}
volumes:
- name: zuul-config
secret:
@ -232,6 +233,7 @@ spec:
- name: zookeeper-client-tls
mountPath: /tls/client
readOnly: true
env: {{ spec.env | zuul_to_json }}
volumes:
- name: zuul-config
secret:
@ -365,7 +367,7 @@ spec:
- name: nodepool-private-key
secret:
secretName: {{ executor_ssh_secret }}
{%- endif %}
{%- endif %}
{%- for volume in spec.get('jobVolumes', []) %}
- {{ volume.volume | zuul_to_json }}
{%- endfor %}

View File

@ -86,6 +86,20 @@ class Zuul:
self.spec.setdefault('zuulRegistryImageVersion', 'latest')
self.spec.setdefault('nodepoolImageVersion', 'latest')
default_env = {
'KUBECONFIG': '/etc/kubernetes/kube.config'
}
env = self.spec.setdefault('env', [])
for default_key, default_value in default_env.items():
# Don't allow the user to override our defaults
for item in env:
if item.get('name') == default_key:
env.remove(item)
break
# Set our defaults
env.append({'name': default_key,
'value': default_value})
self.cert_manager = certmanager.CertManager(
self.api, self.namespace, self.log)
self.installing_cert_manager = False