-
Notifications
You must be signed in to change notification settings - Fork 31
add trusted-ca configmap support for Kubernetes and Openshift 4.x #137
Comments
@LaVLaS I have been in contact with @romeokienzler regarding this. Is there any chance we can get this into v 1.3.0 of ODH? Please see my comment in elyra-ai/elyra#2797 (comment) and the places I think such a trusted-ca configmap could be mounted at in the filesystem of the container. No need for a PVC, as a configmap holds the trusted-ca info. Depeding on your contribution guidelines, I might also be able to help by branching and making a PR myself. The maintainers of this project could then review. This needs to be present regardless of the move, whenever that might be, to KF Notebook controller ... as it is enterprise-level readiness and critical in disconnected / airgapped environments such as biotech, banking, insurance etc. |
+1 ;) |
The best option for right now is to extend the The jupyterhub_config.py property in Here is an example: spawner = c.OpenShiftSpawner
def custom_apply_pod_profile(spawner, pod):
"""
Example function for overriding JupyterHub server functionality to modify the user notebook Pod spec
Should only be called via a function referenced by spawner.modify_pod_hook
See https://jupyterhub-kubespawner.readthedocs.io/en/latest/spawner.html
"""
# Apply profile from singleuser-profiles. REQUIRED since we want to extend the current pod spec
# configs supported by the JH server
apply_pod_profile(spawner, pod)
# Pod container zero is the 'notebook' container with the env var we need to check
nb_container_env = pod.spec.containers[0].env
# Example EnvVar name that is included in the notebook spawn
extra_mount_point_var_name = 'EXTRA_MOUNT_POINT_NAME'
for item in nb_container_env:
if item.name == extra_mount_point_var_name:
# <CODE TO ADD ADDITIONAL MOUNT POINTS TO THE NOTEBOOK POD>
# Modify the pod object according to the V1PodSpec
# https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/V1PodSpec.md
return pod
spawner.modify_pod_hook = custom_apply_pod_profile Since we do not have an environment to reproduce the issue and test functionality, I would recommend testing this in your environment to confirm it works and then we can work with you to provide an additonal jupyterhub overlay in odh-manifests that can load this custom config |
Very nice, and thank you for the pointers. Conceptually sound. I will test this next week on our environment and keep you apprised here. OK, I was able to add to jupyterhub-cfg, temporarily setting immutable: true, part jupyterhub_config.py. It correctly got inserted at /opt/app-root/custom/jupyterhub-cfg.py Any print statements were just for my personal debugging.
Result, as wanted, the CACerts from the openshift configmap with label config.openshift.io/inject-trusted-cabundle: 'true' is mounted at /opt/app-root/etc/jupyter/custom/cacerts/trustedcas.pem and usable in the spawned container. As you can see above, I am using V1ConfigMapVolumeSource, which can only be referenced by name, not by labelSelectors, but that is ok; the custom spawner code works as intended. The referenced configmap I created is defined like this.
After creation, a ca-bundle.crt key section is added under data, containing all the custom trusted CAs / additonal CAs from the central openshift config. Openshift system admins need to make sure that root CAs precede intermediate CAs, but that should be default practice; at least it was on our cluster. @LaVLaS
Thus, I would suggest adding this configmap to overlays. I tested this, in the case the configmap is missing, the target directory in the spawned container just contains no content file trustedcas.pem, no errors come up in the main jupyterhub pod logs as well as the spawned container logs.
In the case the configmap trusted-cabundle is present, the spawned container filesystem looks like this. Example, a spawned Elyra Image Container. I assume, in Jupyter, /opt/app-root/etc/jupyter/custom/ or, more generally, /etc/jupyter/custom is always present. PEM file is present in a new cacerts directory, leading to any content under /opt/app-root/etc/jupyter/custom/ being preserved, like custom.css in the case of the Elyra Jupyter Image.
|
@LaVLaS @ptitzler @vpavlin Any news on this? Basically, I need assistance with an optional CA bundle path ENV variable, a new configmap trusted-cabundle and custom jupyterhub-cfg configmap code in an overlay of odh-manifests. Regarding a ca_cert_bundle_path entry / CA_CERT_BUNDLE_PATH env variable provided via configmap https://github.com/opendatahub-io/odh-manifests/blob/master/jupyterhub/jupyterhub/base/jupyterhub-configmap.yaml#L8, what is your opinion on whether such an extra ENV is even needed, given that /opt/app-root/etc/jupyter/custom/cacerts seems to be universally applicable, at least for Jupyterlab. See also my comment at elyra-ai/elyra#2797 (comment) |
A hard coded default won't work because Elyra (the code making the HTTP requests) needs some sort of indication whether to use it or not when |
At first glance, REQUESTS_CA_BUNDLE as an env seems good. But then, that will define the trusted CAs for each request globally, which might be problematic when in some location not covered in the code, or forgotten about, a regular https site is called, with regular publicly-trusted certificates, and then validation fails. So, I think explicitely having a custom env variable here, as you suggested, CA_CERT_BUNDLE_PATH, or maybe better TRUSTED_CA_BUNDLE_PATH, is best, as you suggest at elyra-ai/elyra@1efda70#diff-3d0156c36fecf796956ced71c6f80a2fbddfdea51566878b335097ae4156c295. |
@LaVLaS @romeokienzler @vpavlin As suggested, I have added an overlay to odh-manifests in a fork. Please review the PR. I oriented myself on the parameter storage_class and did something similar for trusted_ca_bundle_path. That makes an ENV available in spawned containers in a sample location specified in KfDef overlay params. |
Is your feature request related to a problem? Please describe.
Currently, when companies use repositories, regardless of whether for Docker or for machine learning packages or for pipeline extensions (python, R), connecting to such servers is not possible when the use SSL certificates that were generated by a custom, internal PKI. This is due to those SSL certificates not being publicly trusted. There are ways in openshift to define trusted CAs at a cluster-level and to auto-inject them into a configmap at the namespace-level.
https://docs.openshift.com/container-platform/4.8/networking/configuring-a-custom-pki.html#certificate-injection-using-operators_configuring-a-custom-pki
Describe the solution you'd like
Auto-inject configmap containing trusted-bundle CAs should be added to namespace. Map / pem certs should then be mounted to a spawned jupyter lab container, be it Elyra or others. proposed location /opt/app-root/etc/jupyter/custom/certs
configmap example from another project
https://github.com/trevorbox/reloader-operator/blob/f07d1858825cc8515f45c2cf03b84c23e994aa7e/helm/app/templates/configmap-trusted-cabundle.yaml
and mounting it into a location in the spawned container that e.g. python then uses for request.get trust later
https://github.com/trevorbox/reloader-operator/blob/f07d1858825cc8515f45c2cf03b84c23e994aa7e/helm/app/templates/app-nginx-echo-headers.yaml#L50
Describe alternatives you've considered
PKI internal CA trust support is needed, regardless which clients (python, curl, others) are accessing urls of servers containing resources.
Additional context
See e.g. Elyra Ticket conceptual notes
elyra-ai/elyra#2797
there, the question came up in the context of Airflow pipeline components
and also air-gapped elyra elyra-ai/elyra#2812
The non-publicly-trusted CA-bundle-issue is also touched on here https://github.com/opendatahub-io/odh-manifests/issues/575#issuecomment-1167486544
The text was updated successfully, but these errors were encountered: