@@ -77,6 +77,7 @@ def __init__(
7777 inst_data = None ,
7878 namespace = None ,
7979 kubeconfig_file = None ,
80+ k8s_api_ssl_ca_cert_file = None ,
8081 pull_policy = None ,
8182 env_config_maps = None ,
8283 env_secrets = None ,
@@ -147,6 +148,13 @@ def __init__(
147148 else :
148149 kubernetes .config .load_incluster_config ()
149150
151+ # Override the SSL CA cert if a custom CA bundle is provided
152+ if k8s_api_ssl_ca_cert_file :
153+ # Get the active configuration and override the ssl_ca_cert
154+ config = kubernetes .client .Configuration .get_default_copy ()
155+ config .ssl_ca_cert = k8s_api_ssl_ca_cert_file
156+ kubernetes .client .Configuration .set_default (config )
157+
150158 self ._k8s_apps_api_client = k8s_apps_api_client
151159 self ._k8s_core_api_client = k8s_core_api_client
152160
@@ -202,14 +210,15 @@ def __init__(
202210 run_k8s_config = self ._run_k8s_config ,
203211 fail_pod_on_run_failure = fail_pod_on_run_failure ,
204212 kubeconfig_file = kubeconfig_file ,
213+ k8s_api_ssl_ca_cert_file = k8s_api_ssl_ca_cert_file ,
205214 load_incluster_config = not kubeconfig_file ,
206215 security_context = self ._security_context ,
207216 # leave out the code server specific fields from only_allow_user_defined_k8s_config_fields
208217 only_allow_user_defined_k8s_config_fields = (
209218 {
210219 key : val
211220 for key , val in only_allow_user_defined_k8s_config_fields .items ()
212- if key not in {"service_metadata" , "deployment_metadata" }
221+ if key not in {"service_metadata" , "deployment_metadata" , "service_spec_config" }
213222 }
214223 if only_allow_user_defined_k8s_config_fields
215224 else only_allow_user_defined_k8s_config_fields
@@ -244,6 +253,15 @@ def config_type(cls):
244253 "dagster_home" : Field (StringSource , is_required = True ),
245254 "instance_config_map" : Field (StringSource , is_required = True ),
246255 "kubeconfig_file" : Field (StringSource , is_required = False ),
256+ "k8s_api_ssl_ca_cert_file" : Field (
257+ StringSource ,
258+ is_required = False ,
259+ description = (
260+ "Path to a custom CA bundle file for TLS verification when connecting to "
261+ "the Kubernetes API. Use this in enterprise environments with custom CA "
262+ "chains where the default service account CA cert is not sufficient."
263+ ),
264+ ),
247265 "deployment_startup_timeout" : Field (
248266 IntSource ,
249267 is_required = False ,
@@ -302,6 +320,7 @@ def config_type(cls):
302320 "pod_template_spec_metadata" : Permissive (),
303321 "deployment_metadata" : Permissive (),
304322 "service_metadata" : Permissive (),
323+ "service_spec_config" : Permissive (),
305324 }
306325 ),
307326 is_required = False ,
@@ -331,6 +350,9 @@ def config_type(cls):
331350 "service_metadata" : Field (
332351 Map (key_type = str , inner_type = bool ), is_required = False
333352 ),
353+ "service_spec_config" : Field (
354+ Map (key_type = str , inner_type = bool ), is_required = False
355+ ),
334356 "namespace" : Field (bool , is_required = False ),
335357 }
336358 ),
0 commit comments