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 k8s_api_verify_ssl config #801

Merged
merged 3 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion kubespawner/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async def close_client_task():


@lru_cache()
def load_config(host=None, ssl_ca_cert=None):
def load_config(host=None, ssl_ca_cert=None, verify_ssl=None):
"""
Loads global configuration for the Python client we use to communicate with
a Kubernetes API server, and optionally tweaks that configuration based on
Expand Down Expand Up @@ -98,3 +98,7 @@ def load_config(host=None, ssl_ca_cert=None):
global_conf = Configuration.get_default_copy()
global_conf.host = host
Configuration.set_default(global_conf)
if verify_ssl is not None:
global_conf = Configuration.get_default_copy()
global_conf.verify_ssl = verify_ssl
Configuration.set_default(global_conf)
16 changes: 15 additions & 1 deletion kubespawner/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,23 @@ def _namespace_default(self):
""",
)

k8s_api_verify_ssl = Bool(
True,
devenami marked this conversation as resolved.
Show resolved Hide resolved
config=True,
help="""
SSL/TLS verification
devenami marked this conversation as resolved.
Show resolved Hide resolved
Set this to false to skip verifying SSL certificate when calling API
devenami marked this conversation as resolved.
Show resolved Hide resolved
from https server.
""",
)

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
load_config(host=self.k8s_api_host, ssl_ca_cert=self.k8s_api_ssl_ca_cert)
load_config(
host=self.k8s_api_host,
ssl_ca_cert=self.k8s_api_ssl_ca_cert,
verify_ssl=self.k8s_api_verify_ssl,
)
self.core_api = shared_client('CoreV1Api')
self.networking_api = shared_client('NetworkingV1Api')

Expand Down
16 changes: 15 additions & 1 deletion kubespawner/spawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,23 @@ def __init__(self, *args, **kwargs):
# The attribute needs to exist, even though it is unset to start with
self._start_future = None

load_config(host=self.k8s_api_host, ssl_ca_cert=self.k8s_api_ssl_ca_cert)
load_config(
host=self.k8s_api_host,
ssl_ca_cert=self.k8s_api_ssl_ca_cert,
verify_ssl=self.k8s_api_verify_ssl,
)
self.api = shared_client("CoreV1Api")

k8s_api_verify_ssl = Bool(
True,
config=True,
help="""
SSL/TLS verification
devenami marked this conversation as resolved.
Show resolved Hide resolved
Set this to false to skip verifying SSL certificate when calling API
devenami marked this conversation as resolved.
Show resolved Hide resolved
from https server.
""",
)

k8s_api_ssl_ca_cert = Unicode(
"",
config=True,
Expand Down