forked from hashicorp/consul-helm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.yml
757 lines (659 loc) · 25.8 KB
/
config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
version: 2.1
orbs:
slack: circleci/[email protected]
executors:
go:
docker:
- image: docker.mirror.hashicorp.services/circleci/golang:1.16
environment:
- TEST_RESULTS: /tmp/test-results
commands:
install-prereqs:
steps:
- run:
name: Install gotestsum, kind, kubectl, and helm
command: |
wget https://golang.org/dl/go1.16.5.linux-amd64.tar.gz
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz
rm go1.16.5.linux-amd64.tar.gz
echo 'export PATH=$PATH:/usr/local/go/bin' >> $BASH_ENV
wget https://github.com/gotestyourself/gotestsum/releases/download/v1.6.4/gotestsum_1.6.4_linux_amd64.tar.gz
sudo tar -C /usr/local/bin -xzf gotestsum_1.6.4_linux_amd64.tar.gz
rm gotestsum_1.6.4_linux_amd64.tar.gz
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
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
sudo mv ./kubectl /usr/local/bin/kubectl
curl https://baltocdn.com/helm/signing.asc | sudo apt-key add -
sudo apt-get install apt-transport-https --yes
echo "deb https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
sudo apt-get update
sudo apt-get install helm
create-kind-clusters:
parameters:
version:
type: string
steps:
- run:
name: Create kind clusters
command: |
kind create cluster --name dc1 --image kindest/node:<< parameters.version >>
kind create cluster --name dc2 --image kindest/node:<< parameters.version >>
run-acceptance-tests:
parameters:
failfast:
type: boolean
default: false
additional-flags:
type: string
consul-k8s-image:
type: string
default: "docker.mirror.hashicorp.services/hashicorpdev/consul-k8s:latest"
steps:
- when:
condition: << parameters.failfast >>
steps:
- run:
name: Run acceptance tests
working_directory: test/acceptance/tests
no_output_timeout: 2h
command: |
# Enterprise tests can't run on fork PRs because they require
# a secret.
if [ -z "$CIRCLE_PR_NUMBER" ]; then
ENABLE_ENTERPRISE=true
fi
# We have to run the tests for each package separately so that we can
# exit early if any test fails (-failfast only works within a single
# package).
exit_code=0
pkgs=$(go list ./... | circleci tests split --split-by=timings --timings-type=classname)
echo "Running $(echo $pkgs | wc -w) packages:"
echo $pkgs
for pkg in $pkgs
do
if ! gotestsum --no-summary=all --jsonfile=jsonfile-${pkg////-} -- $pkg -p 1 -timeout 2h -failfast \
<< parameters.additional-flags >> \
${ENABLE_ENTERPRISE:+-enable-enterprise} \
-enable-multi-cluster \
-debug-directory="$TEST_RESULTS/debug" \
-consul-k8s-image=<< parameters.consul-k8s-image >>
then
echo "Tests in ${pkg} failed, aborting early"
exit_code=1
break
fi
done
gotestsum --raw-command --junitfile "$TEST_RESULTS/gotestsum-report.xml" -- cat jsonfile*
exit $exit_code
- unless:
condition: << parameters.failfast >>
steps:
- run:
name: Run acceptance tests
working_directory: test/acceptance/tests
no_output_timeout: 2h
command: |
# Enterprise tests can't run on fork PRs because they require
# a secret.
if [ -z "$CIRCLE_PR_NUMBER" ]; then
ENABLE_ENTERPRISE=true
fi
pkgs=$(go list ./... | circleci tests split --split-by=timings --timings-type=classname)
echo "Running $pkgs"
gotestsum --junitfile "$TEST_RESULTS/gotestsum-report.xml" -- $pkgs -p 1 -timeout 2h -failfast \
<< parameters.additional-flags >> \
-enable-multi-cluster \
${ENABLE_ENTERPRISE:+-enable-enterprise} \
-debug-directory="$TEST_RESULTS/debug" \
-consul-k8s-image=<< parameters.consul-k8s-image >>
jobs:
unit-helm:
docker:
- image: docker.mirror.hashicorp.services/hashicorpdev/consul-helm-test:0.10.0
steps:
- checkout
- run:
name: Run Unit Tests
command: bats --jobs 4 ./test/unit
go-fmt-and-vet-acceptance:
executor: go
steps:
- checkout
# Restore go module cache if there is one
- restore_cache:
keys:
- consul-helm-acceptance-modcache-v1-{{ checksum "test/acceptance/go.mod" }}
- run:
name: go mod download
working_directory: test/acceptance
command: go mod download
# Save go module cache if the go.mod file has changed
- save_cache:
key: consul-helm-acceptance-modcache-v1-{{ checksum "test/acceptance/go.mod" }}
paths:
- "/go/pkg/mod"
# check go fmt output because it does not report non-zero when there are fmt changes
- run:
name: check go fmt
working_directory: test/acceptance
command: |
files=$(go fmt ./...)
if [ -n "$files" ]; then
echo "The following file(s) do not conform to go fmt:"
echo "$files"
exit 1
fi
- run:
name: go vet
working_directory: test/acceptance
command: go vet ./...
unit-acceptance-framework:
executor: go
steps:
- checkout
# Restore go module cache if there is one
- restore_cache:
keys:
- consul-helm-acceptance-modcache-v1-{{ checksum "test/acceptance/go.mod" }}
- run: mkdir -p $TEST_RESULTS
- run:
name: Run tests
working_directory: test/acceptance/framework
command: |
gotestsum --junitfile $TEST_RESULTS/gotestsum-report.xml ./... -- -p 4
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results
acceptance:
environment:
- TEST_RESULTS: /tmp/test-results
machine:
image: ubuntu-2004:202010-01
resource_class: xlarge
parallelism: 6
steps:
- checkout
- install-prereqs
- create-kind-clusters:
version: "v1.20.7"
- restore_cache:
keys:
- consul-helm-modcache-v2-{{ checksum "test/acceptance/go.mod" }}
- run:
name: go mod download
working_directory: test/acceptance
command: go mod download
- save_cache:
key: consul-helm-modcache-v2-{{ checksum "test/acceptance/go.mod" }}
paths:
- ~/.go_workspace/pkg/mod
- run: mkdir -p $TEST_RESULTS
- run-acceptance-tests:
failfast: true
additional-flags: -use-kind -kubecontext="kind-dc1" -secondary-kubecontext="kind-dc2"
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results
acceptance-tproxy:
environment:
- TEST_RESULTS: /tmp/test-results
machine:
image: ubuntu-2004:202010-01
resource_class: xlarge
parallelism: 6
steps:
- checkout
- install-prereqs
- create-kind-clusters:
version: "v1.20.7"
- restore_cache:
keys:
- consul-helm-modcache-v2-{{ checksum "test/acceptance/go.mod" }}
- run:
name: go mod download
working_directory: test/acceptance
command: go mod download
- save_cache:
key: consul-helm-modcache-v2-{{ checksum "test/acceptance/go.mod" }}
paths:
- ~/.go_workspace/pkg/mod
- run: mkdir -p $TEST_RESULTS
- run-acceptance-tests:
failfast: true
additional-flags: -use-kind -kubecontext="kind-dc1" -secondary-kubecontext="kind-dc2" -enable-transparent-proxy
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results
acceptance-gke-1-17:
environment:
- TEST_RESULTS: /tmp/test-results
docker:
# This image is built from test/docker/Test.dockerfile
- image: docker.mirror.hashicorp.services/hashicorpdev/consul-helm-test:0.10.0
steps:
- run:
name: Exit if forked PR
command: |
if [ -n "$CIRCLE_PR_NUMBER" ]; then
echo "Skipping acceptance tests for forked PRs; marking step successful."
circleci step halt
fi
- checkout
- run:
name: terraform init & apply
working_directory: test/terraform/gke
command: |
terraform init
echo "${GOOGLE_CREDENTIALS}" | gcloud auth activate-service-account --key-file=-
# On GKE, we're setting the build number instead of build URL because label values
# cannot contain '/'.
terraform apply \
-var project=${CLOUDSDK_CORE_PROJECT} \
-var init_cli=true \
-var cluster_count=2 \
-var labels="{\"build_number\": \"$CIRCLE_BUILD_NUM\"}" \
-auto-approve
primary_kubeconfig=$(terraform output -json | jq -r .kubeconfigs.value[0])
secondary_kubeconfig=$(terraform output -json | jq -r .kubeconfigs.value[1])
echo "export primary_kubeconfig=$primary_kubeconfig" >> $BASH_ENV
echo "export secondary_kubeconfig=$secondary_kubeconfig" >> $BASH_ENV
# Restore go module cache if there is one
- restore_cache:
keys:
- consul-helm-acceptance-modcache-v1-{{ checksum "test/acceptance/go.mod" }}
- run: mkdir -p $TEST_RESULTS
- run-acceptance-tests:
additional-flags: -kubeconfig="$primary_kubeconfig" -secondary-kubeconfig="$secondary_kubeconfig" -enable-pod-security-policies -enable-transparent-proxy
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results
- run:
name: terraform destroy
working_directory: test/terraform/gke
command: |
terraform destroy -var project=${CLOUDSDK_CORE_PROJECT} -auto-approve
when: always
- slack/status:
fail_only: true
failure_message: "GKE acceptance tests failed. Check the logs at: ${CIRCLE_BUILD_URL}"
acceptance-aks-1-19:
environment:
- TEST_RESULTS: /tmp/test-results
docker:
# This image is built from test/docker/Test.dockerfile
- image: docker.mirror.hashicorp.services/hashicorpdev/consul-helm-test:0.10.0
steps:
- checkout
- run:
name: terraform init & apply
working_directory: test/terraform/aks
command: |
terraform init
terraform apply \
-var client_id="$ARM_CLIENT_ID" \
-var client_secret="$ARM_CLIENT_SECRET" \
-var cluster_count=2 \
-var tags="{\"build_url\": \"$CIRCLE_BUILD_URL\"}" \
-auto-approve
primary_kubeconfig=$(terraform output -json | jq -r .kubeconfigs.value[0])
secondary_kubeconfig=$(terraform output -json | jq -r .kubeconfigs.value[1])
echo "export primary_kubeconfig=$primary_kubeconfig" >> $BASH_ENV
echo "export secondary_kubeconfig=$secondary_kubeconfig" >> $BASH_ENV
# Restore go module cache if there is one
- restore_cache:
keys:
- consul-helm-acceptance-modcache-v1-{{ checksum "test/acceptance/go.mod" }}
- run: mkdir -p $TEST_RESULTS
- run-acceptance-tests:
additional-flags: -kubeconfig="$primary_kubeconfig" -secondary-kubeconfig="$secondary_kubeconfig" -enable-transparent-proxy
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results
- run:
name: terraform destroy
working_directory: test/terraform/aks
command: |
terraform destroy -auto-approve
when: always
- slack/status:
fail_only: true
failure_message: "AKS acceptance tests failed. Check the logs at: ${CIRCLE_BUILD_URL}"
acceptance-eks-1-18:
environment:
- TEST_RESULTS: /tmp/test-results
docker:
# This image is built from test/docker/Test.dockerfile
- image: docker.mirror.hashicorp.services/hashicorpdev/consul-helm-test:0.10.0
steps:
- checkout
- run:
name: configure aws
command: |
aws configure --profile helm_user set aws_access_key_id "$AWS_ACCESS_KEY_ID"
aws configure --profile helm_user set aws_secret_access_key "$AWS_SECRET_ACCESS_KEY"
aws configure set role_arn "$AWS_ROLE_ARN"
aws configure set source_profile helm_user
echo "unset AWS_ACCESS_KEY_ID" >> $BASH_ENV
echo "unset AWS_SECRET_ACCESS_KEY" >> $BASH_ENV
- run:
name: terraform init & apply
working_directory: test/terraform/eks
command: |
terraform init
terraform apply -var cluster_count=2 -var tags="{\"build_url\": \"$CIRCLE_BUILD_URL\"}" -auto-approve
primary_kubeconfig=$(terraform output -json | jq -r .kubeconfigs.value[0])
secondary_kubeconfig=$(terraform output -json | jq -r .kubeconfigs.value[1])
echo "export primary_kubeconfig=$primary_kubeconfig" >> $BASH_ENV
echo "export secondary_kubeconfig=$secondary_kubeconfig" >> $BASH_ENV
# Change file permissions of the kubecofig files to avoid warnings by helm.
# TODO: remove when https://github.com/terraform-aws-modules/terraform-aws-eks/pull/1114 is merged.
chmod 600 "$primary_kubeconfig"
chmod 600 "$secondary_kubeconfig"
# Restore go module cache if there is one
- restore_cache:
keys:
- consul-helm-acceptance-modcache-v1-{{ checksum "test/acceptance/go.mod" }}
- run: mkdir -p $TEST_RESULTS
- run-acceptance-tests:
additional-flags: -kubeconfig="$primary_kubeconfig" -secondary-kubeconfig="$secondary_kubeconfig" -enable-transparent-proxy
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results
- run:
name: terraform destroy
working_directory: test/terraform/eks
command: |
terraform destroy -auto-approve
when: always
- slack/status:
fail_only: true
failure_message: "EKS acceptance tests failed. Check the logs at: ${CIRCLE_BUILD_URL}"
acceptance-openshift:
environment:
TEST_RESULTS: /tmp/test-results
parallelism: 3
docker:
# This image is built from test/docker/Test.dockerfile
- image: docker.mirror.hashicorp.services/hashicorpdev/consul-helm-test:0.10.0
steps:
- checkout
- run:
name: terraform init & apply
working_directory: test/terraform/openshift
command: |
terraform init
az login --service-principal -u "$ARM_CLIENT_ID" -p "$ARM_CLIENT_SECRET" --tenant "$ARM_TENANT_ID" > /dev/null
terraform apply \
-var cluster_count=2 \
-var tags="{\"build_url\": \"$CIRCLE_BUILD_URL\"}" \
-auto-approve
primary_kubeconfig=$(terraform output -json | jq -r .kubeconfigs.value[0])
secondary_kubeconfig=$(terraform output -json | jq -r .kubeconfigs.value[1])
echo "export primary_kubeconfig=$primary_kubeconfig" >> $BASH_ENV
echo "export secondary_kubeconfig=$secondary_kubeconfig" >> $BASH_ENV
# Restore go module cache if there is one
- restore_cache:
keys:
- consul-helm-acceptance-modcache-v1-{{ checksum "test/acceptance/go.mod" }}
- run: mkdir -p $TEST_RESULTS
- run-acceptance-tests:
additional-flags: -kubeconfig="$primary_kubeconfig" -secondary-kubeconfig="$secondary_kubeconfig" -enable-openshift -enable-transparent-proxy
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results
- run:
name: terraform destroy
working_directory: test/terraform/openshift
command: |
terraform destroy -auto-approve
when: always
- slack/status:
fail_only: true
failure_message: "OpenShift acceptance tests failed. Check the logs at: ${CIRCLE_BUILD_URL}"
acceptance-kind-1-21:
environment:
- TEST_RESULTS: /tmp/test-results
machine:
image: ubuntu-2004:202010-01
resource_class: xlarge
steps:
- checkout
- install-prereqs
- create-kind-clusters:
version: "v1.21.1"
- restore_cache:
keys:
- consul-helm-modcache-v2-{{ checksum "test/acceptance/go.mod" }}
- run:
name: go mod download
working_directory: test/acceptance
command: go mod download
- save_cache:
key: consul-helm-modcache-v2-{{ checksum "test/acceptance/go.mod" }}
paths:
- ~/.go_workspace/pkg/mod
- run: mkdir -p $TEST_RESULTS
- run-acceptance-tests:
additional-flags: -use-kind -kubecontext="kind-dc1" -secondary-kubecontext="kind-dc2" -enable-transparent-proxy
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results
- slack/status:
fail_only: true
failure_message: "Acceptance tests against Kind with Kubernetes v1.21 failed. Check the logs at: ${CIRCLE_BUILD_URL}"
go-fmt-and-vet-helm-gen:
executor: go
steps:
- checkout
# Restore go module cache if there is one
- restore_cache:
keys:
- consul-helm-helm-gen-modcache-v1-{{ checksum "hack/helm-reference-gen/go.mod" }}
- run:
name: go mod download
working_directory: hack/helm-reference-gen
command: go mod download
# Save go module cache if the go.mod file has changed
- save_cache:
key: consul-helm-helm-gen-modcache-v1-{{ checksum "hack/helm-reference-gen/go.mod" }}
paths:
- "/go/pkg/mod"
# check go fmt output because it does not report non-zero when there are fmt changes
- run:
name: check go fmt
working_directory: hack/helm-reference-gen
command: |
files=$(go fmt ./...)
if [ -n "$files" ]; then
echo "The following file(s) do not conform to go fmt:"
echo "$files"
exit 1
fi
- run:
name: go vet
working_directory: hack/helm-reference-gen
command: go vet ./...
unit-helm-gen:
executor: go
steps:
- checkout
# Restore go module cache if there is one
- restore_cache:
keys:
- consul-helm-helm-gen-modcache-v1-{{ checksum "hack/helm-reference-gen/go.mod" }}
- run: mkdir -p $TEST_RESULTS
- run:
name: Run tests
working_directory: hack/helm-reference-gen
command: |
gotestsum --junitfile $TEST_RESULTS/gotestsum-report.xml ./... -- -p 4
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results
test-helm-gen:
executor: go
steps:
- checkout
# Restore go module cache if there is one
- restore_cache:
keys:
- consul-helm-helm-gen-modcache-v1-{{ checksum "hack/helm-reference-gen/go.mod" }}
- run: mkdir -p $TEST_RESULTS
- run:
name: Run tests
working_directory: hack/helm-reference-gen
command: |
go run ./... -validate
update-helm-charts-index:
docker:
- image: docker.mirror.hashicorp.services/circleci/golang:latest
steps:
- checkout
- run:
name: verify Chart version matches tag version
command: |
GO111MODULE=on go get github.com/mikefarah/yq/v2
git_tag=$(echo "${CIRCLE_TAG#v}")
chart_tag=$(yq r Chart.yaml version)
if [ "${git_tag}" != "${chart_tag}" ]; then
echo "chart version (${chart_tag}) did not match git version (${git_tag})"
exit 1
fi
- run:
name: update helm-charts index
command: |
curl --show-error --silent --fail --user "${CIRCLE_TOKEN}:" \
-X POST \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d "{\"branch\": \"master\",\"parameters\":{\"SOURCE_REPO\": \"${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}\",\"SOURCE_TAG\": \"${CIRCLE_TAG}\"}}" \
"${CIRCLE_ENDPOINT}/${CIRCLE_PROJECT}/pipeline"
- slack/status:
fail_only: true
failure_message: "Failed to trigger an update to the helm charts index. Check the logs at: ${CIRCLE_BUILD_URL}"
cleanup-azure-resources:
docker:
- image: docker.mirror.hashicorp.services/hashicorpdev/consul-helm-test:0.10.0
steps:
- run:
name: cleanup leftover resources
command: |
az login --service-principal -u "$ARM_CLIENT_ID" -p "$ARM_CLIENT_SECRET" --tenant "$ARM_TENANT_ID" > /dev/null
resource_groups=$(az group list -o json | jq -r '.[] | select(.name | test("^consul-k8s-\\d+$")) | .name')
for group in $resource_groups; do
echo "Deleting $group resource group"
az group delete -n $group --yes
done
- slack/status:
fail_only: true
failure_message: "AKS cleanup failed"
cleanup-gcp-resources:
docker:
- image: docker.mirror.hashicorp.services/hashicorpdev/consul-helm-test:0.10.0
steps:
- run:
name: cleanup leftover resources
command: |
echo "${GOOGLE_CREDENTIALS}" | gcloud auth activate-service-account --key-file=-
clusters=$(gcloud container clusters list --zone us-central1-a --project ${CLOUDSDK_CORE_PROJECT} --format json | jq -r '.[] | select(.name | test("^consul-k8s-\\d+$")) | .name')
for cluster in $clusters; do
echo "Deleting $cluster GKE cluster"
gcloud container clusters delete $cluster --zone us-central1-a --project ${CLOUDSDK_CORE_PROJECT} --quiet
done
- slack/status:
fail_only: true
failure_message: "GKE cleanup failed"
cleanup-eks-resources:
docker:
- image: docker.mirror.hashicorp.services/hashicorpdev/consul-helm-test:0.9.0
steps:
- checkout
- run:
name: cleanup eks resources
command: |
# Assume the role and set environment variables.
aws sts assume-role --role-arn "$AWS_ROLE_ARN" --role-session-name "consul-helm-$CIRCLE_BUILD_NUM" --duration-seconds 10800 > assume-role.json
export AWS_ACCESS_KEY_ID="$(jq -r .Credentials.AccessKeyId assume-role.json)"
export AWS_SECRET_ACCESS_KEY="$(jq -r .Credentials.SecretAccessKey assume-role.json)"
export AWS_SESSION_TOKEN="$(jq -r .Credentials.SessionToken assume-role.json)"
cd hack/aws-acceptance-test-cleanup
go run ./... -auto-approve
- slack/status:
fail_only: true
failure_message: "EKS cleanup failed"
disable-ci:
docker:
- image: docker.mirror.hashicorp.services/hashicorpdev/consul-helm-test:0.9.0
steps:
- run:
name: CI is disabled
command: echo "CI is disabled for this repository"
workflows:
version: 2
test:
jobs:
- disable-ci
# - go-fmt-and-vet-acceptance
# - go-fmt-and-vet-helm-gen
# - unit-acceptance-framework:
# requires:
# - go-fmt-and-vet-acceptance
# - unit-helm-gen:
# requires:
# - go-fmt-and-vet-helm-gen
# - test-helm-gen
# - unit-helm
# - acceptance:
# requires:
# - unit-helm
# - unit-acceptance-framework
# - acceptance-tproxy:
# requires:
# - unit-helm
# - unit-acceptance-framework
# nightly-acceptance-tests:
# triggers:
# - schedule:
# cron: "0 0 * * *"
# filters:
# branches:
# only:
# - master
# jobs:
# - cleanup-gcp-resources
# - cleanup-azure-resources
# - cleanup-eks-resources
## - acceptance-openshift: <-- Disabled until we can make them less flakey.
## requires:
## - cleanup-azure-resources
# - acceptance-gke-1-17:
# requires:
# - cleanup-gcp-resources
# - acceptance-eks-1-18:
# requires:
# - cleanup-eks-resources
# - acceptance-aks-1-19:
# requires:
# - cleanup-azure-resources
# - acceptance-kind-1-21
# update-helm-charts-index:
# jobs:
# - update-helm-charts-index:
# context: helm-charts-trigger-consul
# filters:
# tags:
# only: /^v.*/
# branches:
# ignore: /.*/