-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch Kube-in-Kube setup: use internal DNS and support SSL terminatio…
…n in proxies
- Loading branch information
Showing
10 changed files
with
92 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ | |
from .container import * | ||
from .kubernetes import * | ||
from .utils import * | ||
from .noverify_kubernetes import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
workflows/pipe-common/pipeline/common/noverify_kubernetes.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import os | ||
import pykube | ||
import requests | ||
from requests.packages.urllib3.exceptions import InsecureRequestWarning | ||
|
||
class NoVerify_Requests_Session(requests.Session): | ||
"""A wrapper for requests.Session to override 'verify' property, ignoring REQUESTS_CA_BUNDLE environment variable. | ||
This is a workaround for https://github.com/kennethreitz/requests/issues/3829 | ||
""" | ||
def merge_environment_settings(self, url, proxies, stream, verify, *args, **kwargs): | ||
if self.verify is False: | ||
verify = False | ||
return super(NoVerify_Requests_Session, self).merge_environment_settings(url, proxies, stream, verify, *args, **kwargs) | ||
|
||
|
||
def _noverify_session_object(strategy=None, config=None, gcloud_file=None): | ||
if strategy in ["token", "client-certificate", "basic-auth"]: | ||
return NoVerify_Requests_Session() | ||
elif strategy in ["gcp"]: | ||
return GCPSession(config, gcloud_file).create() | ||
else: | ||
return NoVerify_Requests_Session() | ||
|
||
class NoVerify_Kube_Client(object): | ||
""" | ||
Wrapper for PyKube interface which prioritizes session.verify before REQUESTS_CA_BUNDLE | ||
Default version will ignoe session.verify=False if REQUESTS_CA_BUNDLE is set | ||
""" | ||
@staticmethod | ||
def get_client(config): | ||
pykube.session._session_object = _noverify_session_object | ||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning) | ||
return pykube.HTTPClient(config) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters