Skip to content

Commit c44c824

Browse files
authored
Merge pull request #1158 from kmala/ssl-hack
fix(apiserver): Add an option to skip ssl verification when interacti…
2 parents 35b3726 + 1609d89 commit c44c824

6 files changed

Lines changed: 15 additions & 6 deletions

File tree

charts/controller/templates/controller-deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ spec:
5858
# NOTE(bacongobbler): use deis/registry_proxy to work around Docker --insecure-registry requirements
5959
- name: "DEIS_REGISTRY_SERVICE_HOST"
6060
value: "localhost"
61+
- name: "K8S_API_VERIFY_TLS"
62+
value: "{{ .Values.k8s_api_verify_tls }}"
6163
- name: "DEIS_REGISTRY_SERVICE_PORT"
6264
value: "{{ .Values.global.host_port }}"
6365
- name: "APP_STORAGE"

charts/controller/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ app_pull_policy: "Always"
99
# disabled - turns off open registration
1010
# admin_only - allows for registration by an admin only.
1111
registration_mode: "enabled"
12+
# Option to disable ssl verification to connect to k8s api server
13+
k8s_api_verify_tls: "true"
1214

1315
global:
1416
# Set the storage backend

rootfs/api/models/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Meta:
4747
@property
4848
def _scheduler(self):
4949
mod = importlib.import_module(settings.SCHEDULER_MODULE)
50-
return mod.SchedulerClient(settings.SCHEDULER_URL)
50+
return mod.SchedulerClient(settings.SCHEDULER_URL, settings.K8S_API_VERIFY_TLS)
5151

5252
def _fetch_service_config(self, app):
5353
try:

rootfs/api/settings/production.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@
247247
os.environ.get('KUBERNETES_SERVICE_PORT', '443')
248248
)
249249

250+
K8S_API_VERIFY_TLS = bool(strtobool(os.environ.get('K8S_API_VERIFY_TLS', 'true')))
251+
250252
# security keys and auth tokens
251253
random_secret = 'CHANGEME_sapm$s%upvsw5l_zuy_&29rkywd^78ff(qi*#@&*^'
252254
SECRET_KEY = os.environ.get('DEIS_SECRET_KEY', random_secret)

rootfs/scheduler/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
resource_mapping = OrderedDict()
1818

1919

20-
def get_session():
20+
def get_session(k8s_api_verify_tls):
2121
global session
2222
if session is None:
2323
with open('/var/run/secrets/kubernetes.io/serviceaccount/token') as token_file:
@@ -28,18 +28,21 @@ def get_session():
2828
'Content-Type': 'application/json',
2929
'User-Agent': user_agent('Deis Controller', deis_version)
3030
}
31-
session.verify = '/var/run/secrets/kubernetes.io/serviceaccount/ca.crt'
31+
if k8s_api_verify_tls:
32+
session.verify = '/var/run/secrets/kubernetes.io/serviceaccount/ca.crt'
33+
else:
34+
session.verify = False
3235
return session
3336

3437

3538
class KubeHTTPClient(object):
3639
# ISO-8601 which is used by kubernetes
3740
DATETIME_FORMAT = '%Y-%m-%dT%H:%M:%SZ'
3841

39-
def __init__(self, url):
42+
def __init__(self, url, k8s_api_verify_tls=True):
4043
global resource_mapping
4144
self.url = url
42-
self.session = get_session()
45+
self.session = get_session(k8s_api_verify_tls)
4346

4447
# map the various k8s Resources to an internal property
4548
from scheduler.resources import Resource # lazy load

rootfs/scheduler/mock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ def session():
907907

908908

909909
class MockSchedulerClient(KubeHTTPClient):
910-
def __init__(self, url):
910+
def __init__(self, url, k8s_api_verify_tls=True):
911911
super().__init__(url)
912912

913913
# set version data

0 commit comments

Comments
 (0)