-
Notifications
You must be signed in to change notification settings - Fork 280
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
Pick up kube credentials from env variables for k8s integration test #284
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
882bf21
Propagage kube test creds and add k8s integration test to CI
dcrankshaw 351a2d7
format code
dcrankshaw 4069320
added comment
dcrankshaw 82b61b3
add kubectl to unittests dockerfile
dcrankshaw a99424d
fix typo
dcrankshaw 8959363
fix unittests dockerfile
dcrankshaw 54f7774
fixed dockerfile
dcrankshaw 09f0ec8
address comments
dcrankshaw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be removed or uncommented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uncommented