@@ -35,44 +35,40 @@ help: Makefile
35
35
36
36
upload-gcp-cluster-creds :
37
37
export GKE_CREDS=$$(terraform output -json gke_user_key ) && \
38
- echo ${ GKE_CREDS} > gcp-creds
38
+ echo $$ GKE_CREDS > gcp-creds
39
39
gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} --project=sh-automated-tests
40
- gsutil cp gcp-creds gs://nightly-tests/tf-state/${TF_VAR_TEST_ID} -gcp- creds
40
+ gsutil cp gcp-creds gs://nightly-tests/tf-state/${TF_VAR_TEST_ID} -creds
41
41
42
- key_file ?= ${GOOGLE_APPLICATION_CREDENTIALS}
43
- download-gcp-cluster-creds :
44
- gcloud auth activate-service-account --key-file=${key_file} --project=sh-automated-tests
45
- gsutil cp gs://nightly-tests/tf-state/${TF_VAR_TEST_ID} -gcp-creds gs-creds && cat gs-creds | base64 -d > ${TF_VAR_TEST_ID} -key.json || echo " No GCP credentials"
42
+ download-cluster-creds :
43
+ gcloud config set project sh-automated-tests
44
+ gsutil cp gs://nightly-tests/tf-state/${TF_VAR_TEST_ID} -creds gcs-creds && cat gcs-creds | tr -d ' "' | base64 -d > ${TF_VAR_TEST_ID} -key.json || echo " No GCP credentials"
45
+ rm -f gcs-creds
46
+ [[ -f ${TF_VAR_TEST_ID} -key.json ]] || cp ${GOOGLE_APPLICATION_CREDENTIALS} ${TF_VAR_TEST_ID} -key.json
46
47
47
48
upload-aws-cluster-creds :
48
49
49
- upload-azure-cluster-creds :
50
-
51
50
upload-kubeconfig-to-gcp :
52
51
gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} --project=sh-automated-tests
53
52
gsutil cp ${KUBECONFIG} gs://nightly-tests/tf-state/${TF_VAR_TEST_ID} -kubeconfig
54
53
55
- key_file ?= ${GOOGLE_APPLICATION_CREDENTIALS}
56
54
sync-kubeconfig :
57
- gcloud auth activate-service-account --key-file=key_file -- project= sh-automated-tests
55
+ gcloud config set project sh-automated-tests
58
56
gsutil cp gs://nightly-tests/tf-state/${TF_VAR_TEST_ID} -kubeconfig ${KUBECONFIG} || echo " No kubeconfig"
59
57
60
58
# # k3s-kubeconfig: Get the kubeconfig configuration for GCP K3s
61
59
k3s-kubeconfig : sync-kubeconfig
62
60
63
61
# # gcp-kubeconfig: Get the kubeconfig configuration for GCP GKE
64
62
gcp-kubeconfig :
65
- kubectl get secret -n sh-gcs-secret -o -o jsonpath=' {.data.key}' | base64 -d > gcs-key.json || echo " No access to core-dev cluster"
66
- [[ -f gcs-key.json ]] || echo ${GOOGLE_APPLICATION_CREDENTIALS} > gcs-key.json
67
- $(MAKE ) download-gcp-cluster-creds key_file=${key_file}
68
- [[ -f ${TF_VAR_TEST_ID} -key.json ]] && gcloud auth activate-service-account --key-file=${TF_VAR_TEST_ID} -key.json --project=sh-automated-tests
63
+ $(MAKE ) download-cluster-creds
64
+ gcloud auth activate-service-account --key-file=${TF_VAR_TEST_ID} -key.json --project=sh-automated-tests || { echo " Count not authenicate the service account" ; exit 1; }
69
65
export KUBECONFIG=${KUBECONFIG} && \
70
- gcloud container clusters get-credentials gp-${TF_VAR_TEST_ID} --zone europe-west1-d --project sh-automated-tests || $( MAKE ) sync-kubeconfig || echo " No cluster present"
66
+ gcloud container clusters get-credentials gp-${TF_VAR_TEST_ID} --zone europe-west1-d --project sh-automated-tests || echo " No cluster present"
71
67
rm -f ${TF_VAR_TEST_ID} -key.json
72
68
73
69
# # azure-kubeconfig: Get the kubeconfig configuration for Azure AKS
74
70
azure-kubeconfig :
75
- az login --service-principal -u $$ ARM_CLIENT_ID -p $$ ARM_CLIENT_SECRET --tenant $$ ARM_TENANT_ID
71
+ [[ -n " $$ ARM_CLIENT_SECRET " ]] && az login --service-principal -u $$ ARM_CLIENT_ID -p $$ ARM_CLIENT_SECRET --tenant $$ ARM_TENANT_ID || { echo " Please login to azure using az login command " ; exit 1 ; }
76
72
export KUBECONFIG=${KUBECONFIG} && \
77
73
az aks get-credentials --name p$$ TF_VAR_TEST_ID-cluster --resource-group p$$ TF_VAR_TEST_ID --file ${KUBECONFIG} || echo " No cluster present"
78
74
@@ -81,7 +77,6 @@ aws-kubeconfig:
81
77
export KUBECONFIG=${KUBECONFIG} && \
82
78
aws eks update-kubeconfig --name ${TF_VAR_TEST_ID} --region eu-west-1 --kubeconfig ${KUBECONFIG} || echo " No cluster present"
83
79
84
-
85
80
.PHONY :
86
81
# # gke-standard-cluster: Creates a zonal GKE cluster
87
82
gke-standard-cluster : check-env-cluster-version
@@ -90,6 +85,7 @@ gke-standard-cluster: check-env-cluster-version
90
85
rm -f ${KUBECONFIG} && \
91
86
$(MAKE ) get-kubeconfig && \
92
87
[[ -f ${KUBECONFIG} ]] || terraform apply -target=module.gke -var kubeconfig=${KUBECONFIG} --auto-approve
88
+ $(MAKE ) upload-gcp-cluster-creds
93
89
@echo " Done creating GKE cluster"
94
90
95
91
ami_id_121 := "ami-060637af2651bc8bb"
@@ -156,7 +152,6 @@ k3s-standard-cluster: check-env-cluster-version
156
152
$(MAKE ) get-kubeconfig && \
157
153
[[ -f ${KUBECONFIG} ]] || terraform apply -target=module.k3s -var kubeconfig=${KUBECONFIG} -var k3s_node_image_id=${image_id} --auto-approve && \
158
154
$(MAKE ) upload-kubeconfig-to-gcp # we upload the file to GCP since we cannot retrieve the file against without SSHing to the master
159
- $(MAKE ) upload-gcp-cluster-creds
160
155
@echo " Done creating k3s cluster"
161
156
162
157
.PHONY :
@@ -180,8 +175,10 @@ external-dns: check-env-cloud select-workspace
180
175
181
176
.PHONY :
182
177
# # get-kubeconfig: Returns KUBECONFIG of a just created cluster
183
- get-kubeconfig : ${cloud}-kubeconfig
184
-
178
+ get-kubeconfig :
179
+ echo " Getting kubeconfig for $$ TF_VAR_TEST_ID terraform state" && \
180
+ export provider =$$(echo "$$TF_VAR_TEST_ID" | sed 's/\(.*\ ) -/\1 /' | xargs | awk '{print $$2}') && \
181
+ $(MAKE ) $$provider-kubeconfig && echo "kubeconfig written to ${KUBECONFIG}"
185
182
186
183
get-github-config :
187
184
ifneq ($(GITHUB_SCM_OAUTH ) ,)
@@ -233,8 +230,8 @@ registry-config-azure:
233
230
yq m -i tmp_config.yml tmp_2_config.yml
234
231
235
232
storage-config-azure :
236
- export PASSWORD =$$(terraform output -json azure_storage | yq r - 'account_name' ) && \
237
- export USERNAME =$$(terraform output -json azure_storage | yq r - 'account_key' ) && \
233
+ export USERNAME =$$(terraform output -json azure_storage | yq r - 'account_name' ) && \
234
+ export PASSWORD =$$(terraform output -json azure_storage | yq r - 'account_key' ) && \
238
235
export REGION=$$(terraform output -json azure_storage | yq r - 'storage_region' ) && \
239
236
envsubst < ./manifests/kots-config-azure-storage.yaml > tmp_2_config.yml
240
237
yq m -i tmp_config.yml tmp_2_config.yml
@@ -409,7 +406,7 @@ kots-upgrade:
409
406
kubectl kots upstream upgrade --kubeconfig=${KUBECONFIG} gitpod -n gitpod --deploy
410
407
411
408
cloud ?= cluster
412
- cleanup : $( cloud ) -kubeconfig destroy-gitpod tf-init destroy-$(cloud ) destroy-workspace destroy-kubeconfig
409
+ cleanup : get -kubeconfig destroy-gitpod tf-init destroy-$(cloud ) destroy-workspace destroy-kubeconfig
413
410
414
411
cluster-kubeconfig : azure-kubeconfig aws-kubeconfig k3s-kubeconfig gcp-kubeconfig
415
412
@@ -421,6 +418,7 @@ destroy-cluster: destroy-gcp destroy-aws destroy-azure
421
418
destroy-kubeconfig :
422
419
gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} --project=sh-automated-tests
423
420
gsutil rm gs://nightly-tests/tf-state/${TF_VAR_TEST_ID} -kubeconfig || echo " No kubeconfig"
421
+ gsutil rm gs://nightly-tests/tf-state/${TF_VAR_TEST_ID} -creds || echo " No credentials file"
424
422
rm ${KUBECONFIG} || echo " No kubeconfig"
425
423
426
424
select-workspace :
0 commit comments