-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pick up kube credentials from env variables for k8s integration test (#…
…284) * Propagage kube test creds and add k8s integration test to CI * format code * added comment * add kubectl to unittests dockerfile * fix typo * fix unittests dockerfile * fixed dockerfile * address comments
- Loading branch information
1 parent
e596126
commit 66f4aca
Showing
5 changed files
with
109 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
from __future__ import print_function, absolute_import | ||
import os | ||
import yaml | ||
import sys | ||
|
||
cert_auth_env_var = "CLIPPER_K8S_CERT_AUTH" | ||
client_cert_env_var = "CLIPPER_K8S_CLIENT_CERT" | ||
client_key_env_var = "CLIPPER_K8S_CLIENT_KEY" | ||
pw_env_var = "CLIPPER_K8S_PASSWORD" | ||
required_vars = [ | ||
cert_auth_env_var, client_cert_env_var, client_key_env_var, pw_env_var | ||
] | ||
|
||
|
||
def write_config(dest_path): | ||
|
||
for v in required_vars: | ||
if v not in os.environ: | ||
print("{} not defined. Cannot construct kube config".format(v)) | ||
sys.exit(1) | ||
|
||
cert_auth_data = os.environ[cert_auth_env_var] | ||
client_cert_data = os.environ[client_cert_env_var] | ||
client_key_data = os.environ[client_key_env_var] | ||
pw_data = os.environ[pw_env_var] | ||
|
||
base_config = { | ||
'kind': | ||
'Config', | ||
'preferences': {}, | ||
'current-context': | ||
'cluster.clipper-k8s-testing.com', | ||
'contexts': [{ | ||
'name': 'cluster.clipper-k8s-testing.com', | ||
'context': { | ||
'cluster': 'cluster.clipper-k8s-testing.com', | ||
'user': 'cluster.clipper-k8s-testing.com' | ||
} | ||
}], | ||
'clusters': [{ | ||
'cluster': { | ||
'certificate-authority-data': cert_auth_data, | ||
'server': 'https://api.cluster.clipper-k8s-testing.com' | ||
}, | ||
'name': 'cluster.clipper-k8s-testing.com' | ||
}], | ||
'apiVersion': | ||
'v1', | ||
'users': [{ | ||
'name': 'cluster.clipper-k8s-testing.com', | ||
'user': { | ||
'username': 'admin', | ||
'password': pw_data, | ||
'client-key-data': client_key_data, | ||
'client-certificate-data': client_cert_data | ||
} | ||
}, { | ||
'name': 'cluster.clipper-k8s-testing.com-basic-auth', | ||
'user': { | ||
'username': 'admin', | ||
'password': pw_data | ||
} | ||
}] | ||
} | ||
with open(dest_path, "w") as f: | ||
yaml.dump(base_config, f) | ||
|
||
|
||
if __name__ == '__main__': | ||
config_path = sys.argv[1] | ||
config_path = os.path.abspath(os.path.expanduser(config_path)) | ||
print("Writing kube config to {}".format(config_path)) | ||
write_config(config_path) |
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