From 882bf21cfd542846b7df71812b8c4dfb4c7ae351 Mon Sep 17 00:00:00 2001 From: Dan Crankshaw Date: Sun, 3 Sep 2017 11:46:05 -0700 Subject: [PATCH 1/8] Propagage kube test creds and add k8s integration test to CI --- bin/ci_checks.sh | 26 ++++++++++++- bin/construct_kube_config.py | 72 ++++++++++++++++++++++++++++++++++++ bin/run_ci.sh | 7 +++- bin/run_unittests.sh | 4 +- 4 files changed, 103 insertions(+), 6 deletions(-) create mode 100644 bin/construct_kube_config.py diff --git a/bin/ci_checks.sh b/bin/ci_checks.sh index 1426f68b9..f6e0c4193 100755 --- a/bin/ci_checks.sh +++ b/bin/ci_checks.sh @@ -4,6 +4,13 @@ set -e set -u set -o pipefail +function clean_up { + # Clean up credentials + rm $KUBECONFIG + exit +} + + unset CDPATH # one-liner from http://stackoverflow.com/a/246128 # Determines absolute path of the directory containing @@ -16,8 +23,23 @@ tag=$( Date: Sun, 3 Sep 2017 11:46:48 -0700 Subject: [PATCH 2/8] format code --- bin/construct_kube_config.py | 69 ++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/bin/construct_kube_config.py b/bin/construct_kube_config.py index ef494e127..407e9e55a 100644 --- a/bin/construct_kube_config.py +++ b/bin/construct_kube_config.py @@ -7,7 +7,9 @@ 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] +required_vars = [ + cert_auth_env_var, client_cert_env_var, client_key_env_var, pw_env_var +] def write_config(dest_path): @@ -23,43 +25,42 @@ def write_config(dest_path): pw_data = os.environ[pw_env_var] base_config = { - 'kind': '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' + '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' } - ], - '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 - } + }], + 'clusters': [{ + 'cluster': { + 'certificate-authority-data': cert_auth_data, + 'server': 'https://api.cluster.clipper-k8s-testing.com' }, - { - 'name': 'cluster.clipper-k8s-testing.com-basic-auth', - 'user': { - 'username': 'admin', - 'password': pw_data - } + '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) From 40693204acf91e040954cec4b084856e08a65de1 Mon Sep 17 00:00:00 2001 From: Dan Crankshaw Date: Sun, 3 Sep 2017 12:06:47 -0700 Subject: [PATCH 3/8] added comment --- bin/ci_checks.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/ci_checks.sh b/bin/ci_checks.sh index f6e0c4193..52eee5e11 100755 --- a/bin/ci_checks.sh +++ b/bin/ci_checks.sh @@ -39,6 +39,8 @@ trap clean_up SIGHUP SIGINT SIGTERM EXIT # + CLIPPER_K8S_CLIENT_KEY # + CLIPPER_K8S_PASSWORD python $DIR/construct_kube_config.py $KUBECONFIG + +# Test K8s cluster access kubectl get nodes $DIR/check_format.sh From 82b61b33cb4fc2ac2f523ce08b65186ee3455c68 Mon Sep 17 00:00:00 2001 From: Dan Crankshaw Date: Sun, 3 Sep 2017 12:17:29 -0700 Subject: [PATCH 4/8] add kubectl to unittests dockerfile --- dockerfiles/ClipperTestsDockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dockerfiles/ClipperTestsDockerfile b/dockerfiles/ClipperTestsDockerfile index 10ca2f50c..80d27bd5b 100644 --- a/dockerfiles/ClipperTestsDockerfile +++ b/dockerfiles/ClipperTestsDockerfile @@ -41,6 +41,10 @@ ENV MAVEN_HOME /usr/share/maven ENV MAVEN_CONFIG /root/.m2 ENV JZMQ_HOME /usr/local/lib/ +# Install kubectl +RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl \ + && chmod +x ./kubectl \ + mv ./kubectl /usr/localbin/kubectl COPY ./ /clipper From a99424dead6a0070dc2fa46e4c124696c2dbde6f Mon Sep 17 00:00:00 2001 From: Dan Crankshaw Date: Sun, 3 Sep 2017 12:27:17 -0700 Subject: [PATCH 5/8] fix typo --- dockerfiles/ClipperTestsDockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockerfiles/ClipperTestsDockerfile b/dockerfiles/ClipperTestsDockerfile index 80d27bd5b..06022b84f 100644 --- a/dockerfiles/ClipperTestsDockerfile +++ b/dockerfiles/ClipperTestsDockerfile @@ -44,7 +44,7 @@ ENV JZMQ_HOME /usr/local/lib/ # Install kubectl RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl \ && chmod +x ./kubectl \ - mv ./kubectl /usr/localbin/kubectl + mv ./kubectl /usr/local/bin/kubectl COPY ./ /clipper From 8959363694d050127c6f5aa9615f794915727f2f Mon Sep 17 00:00:00 2001 From: Dan Crankshaw Date: Sun, 3 Sep 2017 12:43:39 -0700 Subject: [PATCH 6/8] fix unittests dockerfile --- dockerfiles/ClipperTestsDockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dockerfiles/ClipperTestsDockerfile b/dockerfiles/ClipperTestsDockerfile index 06022b84f..8b2bba1d9 100644 --- a/dockerfiles/ClipperTestsDockerfile +++ b/dockerfiles/ClipperTestsDockerfile @@ -43,8 +43,8 @@ ENV JZMQ_HOME /usr/local/lib/ # Install kubectl RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl \ - && chmod +x ./kubectl \ - mv ./kubectl /usr/local/bin/kubectl + && chmod +x kubectl \ + mv kubectl /usr/local/bin/ COPY ./ /clipper From 54f777492196d2bc805a8ac26657b6a0f8bac446 Mon Sep 17 00:00:00 2001 From: Dan Crankshaw Date: Sun, 3 Sep 2017 13:13:57 -0700 Subject: [PATCH 7/8] fixed dockerfile --- dockerfiles/ClipperTestsDockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockerfiles/ClipperTestsDockerfile b/dockerfiles/ClipperTestsDockerfile index 8b2bba1d9..0c1b37a6e 100644 --- a/dockerfiles/ClipperTestsDockerfile +++ b/dockerfiles/ClipperTestsDockerfile @@ -44,7 +44,7 @@ ENV JZMQ_HOME /usr/local/lib/ # Install kubectl RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl \ && chmod +x kubectl \ - mv kubectl /usr/local/bin/ + && mv kubectl /usr/local/bin/ COPY ./ /clipper From 09f0ec8531f061f8aa97176e892cbae4696b50bd Mon Sep 17 00:00:00 2001 From: Dan Crankshaw Date: Sun, 3 Sep 2017 16:22:04 -0700 Subject: [PATCH 8/8] address comments --- bin/ci_checks.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ci_checks.sh b/bin/ci_checks.sh index 52eee5e11..5a1c1552d 100755 --- a/bin/ci_checks.sh +++ b/bin/ci_checks.sh @@ -23,7 +23,7 @@ tag=$(