Use CircleCI version 2.1 at the top of your .circleci/config.yml file.
1
version: 2.1
Add the orbs
stanza below your version, invoking the orb:
1
2
orbs:
aws-eks: circleci/aws-eks@2.2.0
Use aws-eks
elements in your existing workflows and jobs.
Create an eks cluster together with the required VPC-related resources, test it, and tear it down.
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
version: '2.1'
orbs:
aws-eks: circleci/aws-eks@<<pipeline.parameters.dev-orb-version>>
kubernetes: circleci/kubernetes@1.3
jobs:
test-cluster:
docker:
- image: cimg/python:3.10
parameters:
cluster-name:
description: |
Name of the EKS cluster
type: string
steps:
- kubernetes/install:
kubectl-version: v1.22.0
- aws-eks/update-kubeconfig-with-authenticator:
cluster-name: << parameters.cluster-name >>
- run:
command: |
kubectl get services
name: Test cluster
workflows:
deployment:
jobs:
- aws-eks/create-cluster:
cluster-name: my-eks-demo
- test-cluster:
cluster-name: my-eks-demo
requires:
- aws-eks/create-cluster
- aws-eks/delete-cluster:
cluster-name: my-eks-demo
requires:
- test-cluster
Create a kubernetes deployment.
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
version: '2.1'
orbs:
aws-eks: circleci/aws-eks@<<pipeline.parameters.dev-orb-version>>
kubernetes: circleci/kubernetes@1.3
jobs:
create-deployment:
docker:
- image: cimg/python:3.10
parameters:
cluster-name:
description: |
Name of the EKS cluster
type: string
steps:
- checkout
- aws-eks/update-kubeconfig-with-authenticator:
cluster-name: << parameters.cluster-name >>
install-kubectl: true
- kubernetes/create-or-update-resource:
get-rollout-status: true
resource-file-path: tests/nginx-deployment/deployment.yaml
resource-name: deployment/nginx-deployment
workflows:
deployment:
jobs:
- aws-eks/create-cluster:
cluster-name: eks-demo-deployment
- create-deployment:
cluster-name: eks-demo-deployment
requires:
- aws-eks/create-cluster
- aws-eks/update-container-image:
cluster-name: eks-demo-deployment
container-image-updates: nginx=nginx:1.9.1
post-steps:
- kubernetes/delete-resource:
resource-names: nginx-deployment
resource-types: deployment
wait: true
requires:
- create-deployment
resource-name: deployment/nginx-deployment
- aws-eks/delete-cluster:
cluster-name: eks-demo-deployment
requires:
- aws-eks/update-container-image
Creates an EKS cluster and required resources (e.g. VPC) using the eksctl tool.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
authenticator-release-tag | Specifies which release-tag version of the authenticator to install.
| No | '' | string |
aws-max-polling-wait-time | Max wait time in any AWS polling operations
| No | 20m0s | string |
aws-profile | The AWS profile to be used. If not specified, the configured default
profile for your AWS CLI installation will be used.
| No | '' | string |
aws-region | AWS region that the EKS cluster will be created in.
| No | '' | string |
cluster-name | Name of the EKS cluster to be created
| No | '' | string |
no-output-timeout | Elapsed time that the cluster creation command can run on CircleCI without output.
The string is a decimal with unit suffix, such as “20m”, “1.25h”, “5s”
| No | 45m | string |
show-eksctl-command | Whether to show the eksctl command used.
| No | false | boolean |
ssh-access | Control SSH access for nodes
| No | false | boolean |
ssh-public-key | SSH public key to use for nodes (import from local path, or use existing EC2 key pair which
must not resolve to a local file path)
e.g. my_eks_node_id.pub
"~/.ssh/id_rsa.pub" will be taken as the path if a value is not specified.
| No | '' | string |
tag | Version of the CircleCI Python convenience image to use. For full list,
see https://hub.docker.com/r/cimg/python/tags
A version of Python supported by the AWS CLI is required.
| No | '3.10' | string |
tags | A list of key-value pairs used to tag the AWS resources (e.g. "Owner=John Doe,Team=Some Team")
| No | '' | string |
verbose | Set a value from 0 to 5 to control the verbosity level of the log output (the higher, the more verbose).
Use 0 to silence, 4 for debugging and 5 for debugging with AWS debug logging.
The logging verbosity level is set to 3 by default.
When set to 4 and above, verbose details of AWS resources will be displayed in the log output.
When set to 5, sensitive information such as credentials may be displayed in the log output.
| No | 3 | integer |
Deletes an EKS cluster together with the associated VPC resources on AWS, using the eksctl tool. The cluster should have been created with eksctl as well. It is recommended to delete any kubernetes resources that were deployed to the cluster (e.g. resources involving an AWS Elastic Load Balancer) before running the delete-cluster command, so that resources can be fully removed.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
authenticator-release-tag | Specifies which release-tag version of the authenticator to install.
| No | '' | string |
aws-profile | The AWS profile to be used. If not specified, the configured default
profile for your AWS CLI installation will be used.
| No | '' | string |
aws-region | AWS region that the EKS cluster is in.
| No | '' | string |
cluster-name | The name of the EKS cluster to be deleted.
| Yes | - | string |
kubectl-version | Version of kubectl to install
| No | v1.22.0 | string |
no-output-timeout | Elapsed time that the cluster creation command can run without output.
The string is a decimal with unit suffix, such as “20m”, “1.25h”, “5s” (default: 20 minutes)
| No | 30m | string |
tag | Version of the CircleCI Python convenience image to use. For full list,
see https://hub.docker.com/r/cimg/python/tags
A version of Python supported by the AWS CLI is required.
| No | '3.10' | string |
verbose | Set a value from 0 to 5 to control the verbosity level of the log output (the higher, the more verbose).
Use 0 to silence, 4 for debugging and 5 for debugging with AWS debug logging.
The logging verbosity level is set to 3 by default.
When set to 4 and above, verbose details of AWS resources will be displayed in the log output.
When set to 5, sensitive information such as credentials may be displayed in the log output.
| No | 3 | integer |
wait | Whether to wait for deletion of all resources before exiting
| No | false | boolean |
Updates the container image(s) of a resource on EKS.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
authenticator-release-tag | Specifies which release-tag version of the authenticator to install.
| No | '' | string |
aws-profile | The AWS profile to be used. If not specified, the configured default
profile for your AWS CLI installation will be used.
| No | '' | string |
aws-region | AWS region that the EKS cluster is in.
| No | '' | string |
cluster-name | The name of the EKS cluster.
| Yes | - | string |
container-image-updates | Specify a list of container image updates
(space-delimited name value pairs in the form
CONTAINER_NAME_1=CONTAINER_IMAGE_1 ... CONTAINER_NAME_N=CONTAINER_IMAGE_N)
to be applied to the resource via `kubectl set image`.
e.g. "busybox=busybox nginx=nginx:1.9.1"
| Yes | - | string |
get-rollout-status | Get the status of the rollout.
This can only be used for resource types that are valid
for usage with `kubectl rollout` subcommands.
| No | false | boolean |
kubectl-version | Version of kubectl to install
| No | v1.22.0 | string |
namespace | The kubernetes namespace that should be used.
| No | '' | string |
pinned-revision-to-watch | Pin a specific revision to be watched and abort watching if it is rolled
over by another revision.
Only effective if get-rollout-status is set to true.
| No | '' | string |
resource-name | Resource name in the format TYPE/NAME e.g. deployment/nginx-deployment
Either resource-file-path or resource-name need to be specified.
This is required if get-rollout-status is set to true.
| No | '' | string |
show-kubectl-command | Whether to show the kubectl command used.
| No | false | boolean |
tag | Version of the CircleCI Python convenience image to use. For full list,
see https://hub.docker.com/r/cimg/python/tags
A version of Python supported by the AWS CLI is required.
| No | '3.10' | string |
watch-rollout-status | Whether to watch the status of the latest rollout until it's done.
Only effective if get-rollout-status is set to true.
| No | true | boolean |
watch-timeout | The length of time to wait before ending the watch, zero means never.
Any other values should contain a corresponding time unit (e.g. 1s, 2m, 3h).
Only effective if get-rollout-status is set to true.
| No | '' | string |
Creates an EKS cluster and required resources (e.g. VPC) using the eksctl tool.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
asg-access | Set to true to enable IAM policy for cluster-autoscaler.
| No | false | boolean |
aws-max-polling-wait-time | Max wait time in any AWS polling operations
| No | 20m0s | string |
aws-profile | The AWS profile to be used. If not specified, the configured default
profile for your AWS CLI installation will be used.
| No | '' | string |
aws-region | AWS region that the EKS cluster will be created in.
| No | '' | string |
cfn-role-arn | Specify an IAM role to be used by CloudFormation to call AWS API on your behalf
| No | '' | string |
cluster-name | Name of the EKS cluster to be created
| No | '' | string |
config-file | Use this to specify a file if you wish to load configuration from it.
| No | '' | string |
external-dns-access | Set to true to enable IAM policy for external-dns.
| No | false | boolean |
fargate | Specify the node to run on fargate.
| No | false | boolean |
full-ecr-access | Set to true to enable full access to ECR.
| No | false | boolean |
kubectl-version | Version of kubectl to install
| No | v1.22.0 | string |
kubernetes-version | Specify a version of Kubernetes that is supported by eksctl.
If no value is specified, the version that eksctl defaults to will be used.
| No | '' | string |
max-pods-per-node | Sets the maximum number of pods per node, if a number other than -1 is set as the value.
Otherwise the maximum will be automatically set.
| No | -1 | integer |
no-output-timeout | Elapsed time that the cluster creation command can run on CircleCI without output.
The string is a decimal with unit suffix, such as “20m”, “1.25h”, “5s”
| No | 45m | string |
node-ami | Specify this in advanced use cases only.
Check the documentation for the --node-ami flag of eksctl for more details.
| No | '' | string |
node-ami-family | Specify this in advanced use cases only.
Check the documentation for the --node-ami-family flag of eksctl for more details.
| No | '' | string |
node-labels | Extra labels to add when registering the nodes in the nodegroup, e.g. "partition=backend,nodeclass=hugememory"
| No | '' | string |
node-private-networking | Set to true to make nodegroup networking private.
| No | false | boolean |
node-security-groups | Specify a comma-delimited list of security groups to be attached to nodes, for allowing
extra ingress/egress access from/to pods.
| No | '' | string |
node-type | Set this to specify a node instance type for the node group.
| No | '' | string |
node-volume-size | Sets the node volume size in GB, if a number other than -1 is set as the value.
| No | -1 | integer |
node-volume-type | Specify the node volume type.
| No | '' | string |
node-zones | Specify availability zones for the nodes e.g. us-east-1a,us-east-1b,us-east-1d
Zones will be inherited from the cluster if unspecified.
| No | '' | string |
nodegroup-name | Set this to specify a name for the nodegroup.
If unspecified, it will be generated.
| No | '' | string |
nodes | Sets the total number of nodes (for a static Auto Scaling Group), if a number other than -1 is set as the value.
Otherwise the default as determined by eksctl will be used.
| No | -1 | integer |
nodes-max | Sets the maximum number of nodes in the Auto Scaling Group, if a number other than -1 is set as the value.
Otherwise the default as determined by eksctl will be used.
| No | -1 | integer |
nodes-min | Sets the minimum number of nodes in the Auto Scaling Group, if a number other than -1 is set as the value.
Otherwise the default as determined by eksctl will be used.
| No | -1 | integer |
show-eksctl-command | Whether to show the eksctl command used.
| No | false | boolean |
skip-kubectl-install | Whether to skip the installation of kubectl.
| No | false | boolean |
ssh-access | Control SSH access for nodes
| No | false | boolean |
ssh-public-key | SSH public key to use for nodes (import from local path, or use existing EC2 key pair which
must not resolve to a local file path)
e.g. my_eks_node_id.pub
"~/.ssh/id_rsa.pub" will be taken as the path if a value is not specified.
| No | '' | string |
tags | A list of key-value pairs used to tag the AWS resources (e.g. "Owner=John Doe,Team=Some Team")
| No | '' | string |
verbose | Set a value from 0 to 5 to control the verbosity level of the log output (the higher, the more verbose).
Use 0 to silence, 4 for debugging and 5 for debugging with AWS debug logging.
The logging verbosity level is set to 3 by default.
When set to 4 and above, verbose details of AWS resources will be displayed in the log output.
When set to 5, sensitive information such as credentials may be displayed in the log output.
| No | 3 | integer |
vpc-cidr | Specify global CIDR to use for VPC.
e.g. 192.168.0.0/16
| No | '' | string |
vpc-from-kops-cluster | Specify this to re-use a VPC from a given kops cluster.
e.g. cluster-1.k8s.local
| No | '' | string |
vpc-private-subnets | Specify this to re-use private subnets of an existing VPC.
e.g. subnet-0ff156e0c4a6d300c,subnet-0426fb4a607393184
| No | '' | string |
vpc-public-subnets | Specify this to re-use public subnets of an existing VPC.
e.g. subnet-0ff156e0c4a6d300c,subnet-0426fb4a607393184
| No | '' | string |
without-nodegroup | Set to true to avoid creating initial nodegroup.
| No | false | boolean |
zones | The AWS availability zones to be used e.g. us-east-1a,us-east-1b,us-east-1d
If no value is specified, the availability zones will be auto-selected.
| No | '' | string |
Deletes the EKS cluster and resources that were created for it. The cluster must have been created with the create-cluster command of the orb. It is recommended to delete any kubernetes resources that were deployed to the cluster (e.g. resources involving an AWS Elastic Load Balancer) before running the delete-cluster command, so that resources can be fully removed.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
aws-max-polling-wait-time | Max wait time in any AWS polling operations
| No | 20m0s | string |
aws-profile | The AWS profile to be used. If not specified, the configured default
profile for your AWS CLI installation will be used.
| No | '' | string |
aws-region | AWS region that the EKS cluster will be created in.
If no value is specified, the cluster will be created in the us-west-2 region.
| No | '' | string |
cfn-role-arn | Specify an IAM role to be used by CloudFormation to call AWS API on your behalf
| No | '' | string |
cluster-name | Name of the EKS cluster
| Yes | - | string |
config-file | Use this to specify a file if you wish to load configuration from it.
| No | '' | string |
no-output-timeout | Elapsed time that the cluster creation command can run without output.
The string is a decimal with unit suffix, such as “20m”, “1.25h”, “5s”
| No | 30m | string |
show-eksctl-command | Whether to show the eksctl command used.
| No | false | boolean |
verbose | Set a value from 0 to 5 to control the verbosity level of the log output (the higher, the more verbose).
Use 0 to silence, 4 for debugging and 5 for debugging with AWS debug logging.
The logging verbosity level is set to 3 by default.
When set to 4 and above, verbose details of AWS resources will be displayed in the log output.
When set to 5, sensitive information such as credentials may be displayed in the log output.
| No | 3 | integer |
wait | Whether to wait for deletion of all resources before exiting
| No | false | boolean |
Install the AWS IAM Authenticator for Kubernetes Requirements: curl, amd64 architecture
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
release-tag | Use this to specify a tag to select which published release of the AWS IAM Authenticator,
as listed on https://github.com/kubernetes-sigs/aws-iam-authenticator/releases,
to install. If no value is specified, the latest release will be installed.
Note: Release versions earlier than v0.3.0 cannot be specified. Also,
pre or alpha releases cannot be specified.
| No | '' | string |
Install the Amazon eksctl command line utility. This command should be ran before invoking the eskctl cli.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
version | Specify the full semver versioned tag to use. | No | 0.77.0 | string |
Allows the stock kubectl client to work with Amazon EKS. Installs the AWS CLI, the AWS IAM Authenticator for Kubernetes and updates the kubectl configuration file to use the AWS IAM Authenticator.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
authenticator-release-tag | Specifies which release-tag version of the authenticator to install.
| No | '' | string |
aws-profile | The AWS profile to be used. If not specified, the configured default
profile for your AWS CLI installation will be used.
| No | '' | string |
aws-region | The AWS region that the cluster is in. If not specified, the configured default
region for your AWS CLI installation will be used.
| No | '' | string |
cluster-authentication-role-arn | To assume a role for cluster authentication, specify an IAM role ARN with
this option. For example, if you created a cluster while assuming an IAM
role, then you must also assume that role to connect to the cluster the
first time.
| No | '' | string |
cluster-context-alias | Alias for the cluster context name. If a value is not specified,
the cluster context name will be set to match the cluster ARN.
| No | '' | string |
cluster-name | The name of the cluster for which to create a kubeconfig entry.
| Yes | - | string |
dry-run | Print the merged kubeconfig to stdout instead of writing it to file.
| No | '' | enum |
install-aws-cli | Whether to install aws-cli
| No | true | boolean |
install-kubectl | Whether to install kubectl
| No | false | boolean |
kubeconfig-file-path | Specifies a kubeconfig file to append the configuration details to.
By default, the configuration is written to the first file path in the
KUBECONFIG environment variable (if it is set) or the default kubeconfig
path (.kube/config) in your home directory.
| No | '' | string |
kubectl-version | Version of kubectl to install
| No | v1.22.0 | string |
verbose | Print more detailed output when writing to the kubeconfig file.
| No | false | boolean |
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
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
# This code is licensed from CircleCI to the user under the MIT license.
# See here for details: https://circleci.com/developer/ja/orbs/licensing
version: 2.1
description: |
An orb for working with Amazon Elastic Container Service for Kubernetes (Amazon EKS).
display:
home_url: https://aws.amazon.com/eks/
source_url: https://github.com/CircleCI-Public/aws-eks-orb
orbs:
aws-cli: circleci/aws-cli@2.0
helm: circleci/helm@1.2
kubernetes: circleci/kubernetes@1.0
commands:
create-cluster:
description: |
Creates an EKS cluster and required resources (e.g. VPC) using the eksctl tool.
parameters:
asg-access:
default: false
description: |
Set to true to enable IAM policy for cluster-autoscaler.
type: boolean
aws-max-polling-wait-time:
default: 20m0s
description: |
Max wait time in any AWS polling operations
type: string
aws-profile:
default: ""
description: |
The AWS profile to be used. If not specified, the configured default
profile for your AWS CLI installation will be used.
type: string
aws-region:
default: ""
description: |
AWS region that the EKS cluster will be created in.
type: string
cfn-role-arn:
default: ""
description: |
Specify an IAM role to be used by CloudFormation to call AWS API on your behalf
type: string
cluster-name:
default: ""
description: |
Name of the EKS cluster to be created
type: string
config-file:
default: ""
description: |
Use this to specify a file if you wish to load configuration from it.
type: string
external-dns-access:
default: false
description: |
Set to true to enable IAM policy for external-dns.
type: boolean
fargate:
default: false
description: |
Specify the node to run on fargate.
type: boolean
full-ecr-access:
default: false
description: |
Set to true to enable full access to ECR.
type: boolean
kubectl-version:
default: v1.22.0
description: |
Version of kubectl to install
type: string
kubernetes-version:
default: ""
description: |
Specify a version of Kubernetes that is supported by eksctl.
If no value is specified, the version that eksctl defaults to will be used.
type: string
max-pods-per-node:
default: -1
description: |
Sets the maximum number of pods per node, if a number other than -1 is set as the value.
Otherwise the maximum will be automatically set.
type: integer
no-output-timeout:
default: 45m
description: |
Elapsed time that the cluster creation command can run on CircleCI without output.
The string is a decimal with unit suffix, such as “20m”, “1.25h”, “5s”
type: string
node-ami:
default: ""
description: |
Specify this in advanced use cases only.
Check the documentation for the --node-ami flag of eksctl for more details.
type: string
node-ami-family:
default: ""
description: |
Specify this in advanced use cases only.
Check the documentation for the --node-ami-family flag of eksctl for more details.
type: string
node-labels:
default: ""
description: |
Extra labels to add when registering the nodes in the nodegroup, e.g. "partition=backend,nodeclass=hugememory"
type: string
node-private-networking:
default: false
description: |
Set to true to make nodegroup networking private.
type: boolean
node-security-groups:
default: ""
description: |
Specify a comma-delimited list of security groups to be attached to nodes, for allowing
extra ingress/egress access from/to pods.
type: string
node-type:
default: ""
description: |
Set this to specify a node instance type for the node group.
type: string
node-volume-size:
default: -1
description: |
Sets the node volume size in GB, if a number other than -1 is set as the value.
type: integer
node-volume-type:
default: ""
description: |
Specify the node volume type.
type: string
node-zones:
default: ""
description: |
Specify availability zones for the nodes e.g. us-east-1a,us-east-1b,us-east-1d
Zones will be inherited from the cluster if unspecified.
type: string
nodegroup-name:
default: ""
description: |
Set this to specify a name for the nodegroup.
If unspecified, it will be generated.
type: string
nodes:
default: -1
description: |
Sets the total number of nodes (for a static Auto Scaling Group), if a number other than -1 is set as the value.
Otherwise the default as determined by eksctl will be used.
type: integer
nodes-max:
default: -1
description: |
Sets the maximum number of nodes in the Auto Scaling Group, if a number other than -1 is set as the value.
Otherwise the default as determined by eksctl will be used.
type: integer
nodes-min:
default: -1
description: |
Sets the minimum number of nodes in the Auto Scaling Group, if a number other than -1 is set as the value.
Otherwise the default as determined by eksctl will be used.
type: integer
show-eksctl-command:
default: false
description: |
Whether to show the eksctl command used.
type: boolean
skip-kubectl-install:
default: false
description: |
Whether to skip the installation of kubectl.
type: boolean
ssh-access:
default: false
description: |
Control SSH access for nodes
type: boolean
ssh-public-key:
default: ""
description: |
SSH public key to use for nodes (import from local path, or use existing EC2 key pair which
must not resolve to a local file path)
e.g. my_eks_node_id.pub
"~/.ssh/id_rsa.pub" will be taken as the path if a value is not specified.
type: string
tags:
default: ""
description: |
A list of key-value pairs used to tag the AWS resources (e.g. "Owner=John Doe,Team=Some Team")
type: string
verbose:
default: 3
description: |
Set a value from 0 to 5 to control the verbosity level of the log output (the higher, the more verbose).
Use 0 to silence, 4 for debugging and 5 for debugging with AWS debug logging.
The logging verbosity level is set to 3 by default.
When set to 4 and above, verbose details of AWS resources will be displayed in the log output.
When set to 5, sensitive information such as credentials may be displayed in the log output.
type: integer
vpc-cidr:
default: ""
description: |
Specify global CIDR to use for VPC.
e.g. 192.168.0.0/16
type: string
vpc-from-kops-cluster:
default: ""
description: |
Specify this to re-use a VPC from a given kops cluster.
e.g. cluster-1.k8s.local
type: string
vpc-private-subnets:
default: ""
description: |
Specify this to re-use private subnets of an existing VPC.
e.g. subnet-0ff156e0c4a6d300c,subnet-0426fb4a607393184
type: string
vpc-public-subnets:
default: ""
description: |
Specify this to re-use public subnets of an existing VPC.
e.g. subnet-0ff156e0c4a6d300c,subnet-0426fb4a607393184
type: string
without-nodegroup:
default: false
description: |
Set to true to avoid creating initial nodegroup.
type: boolean
zones:
default: ""
description: |
The AWS availability zones to be used e.g. us-east-1a,us-east-1b,us-east-1d
If no value is specified, the availability zones will be auto-selected.
type: string
steps:
- setup
- unless:
condition: << parameters.skip-kubectl-install >>
steps:
- kubernetes/install:
kubectl-version: << parameters.kubectl-version >>
- run:
command: |
#!/bin/bash
CLUSTER_NAME=$(eval echo "$PARAM_CLUSTER_NAME")
AWS_REGION=$(eval echo "$PARAM_AWS_REGION")
AWS_PROFILE=$(eval echo "$PARAM_AWS_PROFILE")
ZONES=$(eval echo "$PARAM_ZONES")
KUBERNETES_VERSION=$(eval echo "$PARAM_KUBERNETES_VERSION")
CONFIG_FILE=$(eval echo "$PARAM_CONFIG_FILE")
VPC_PRIVATE_SUBNETS=$(eval echo "$PARAM_VPC_PRIVATE_SUBNETS")
VPC_PUBLIC_SUBNETS=$(eval echo "$PARAM_VPC_PUBLIC_SUBNETS")
NODEGROUP_NAME=$(eval echo "$PARAM_NODEGROUP_NAME")
WITHOUT_NODEGROUP=$(eval echo "$PARAM_WITHOUT_NODEGROUP")
NODE_PRIVATE_NETWORKING=$(eval echo "$PARAM_NODE_PRIVATE_NETWORKING")
NODE_TYPE=$(eval echo "$PARAM_NODE_TYPE")
NODE_AMI=$(eval echo "$PARAM_NODE_AMI")
NODE_AMI_FAMILY=$(eval echo "$PARAM_NODE_AMI_FAMILY")
NODES=$(eval echo "$PARAM_NODES")
NODES_MIN=$(eval echo "$PARAM_NODES_MIN")
NODES_MAX=$(eval echo "$PARAM_NODES_MAX")
NODE_VOLUME_SIZE=$(eval echo "$PARAM_NODE_VOLUME_SIZE")
NODE_VOLUME_TYPE=$(eval echo "$PARAM_NODE_VOLUME_TYPE")
MAX_PODS_PER_NODE=$(eval echo "$PARAM_MAX_PODS_PER_NODE")
NODE_SECURITY_GROUPS=$(eval echo "$PARAM_NODE_SECURITY_GROUPS")
NODE_LABELS=$(eval echo "$PARAM_NODE_LABELS")
NODE_ZONES=$(eval echo "$PARAM_NODE_ZONES")
SSH_ACCESS=$(eval echo "$PARAM_SSH_ACCESS")
SSH_PUBLIC_KEY=$(eval echo "$PARAM_SSH_PUBLIC_KEY")
ASG_ACCESS=$(eval echo "$PARAM_ASG_ACCESS")
EXTERNAL_DNS_ACCESS=$(eval echo "$PARAM_EXTERNAL_DNS_ACCESS")
FULL_ECR_ACCESS=$(eval echo "$PARAM_FULL_ECR_ACCESS")
VPC_CIDR=$(eval echo "$PARAM_VPC_CIDR")
VPC_PRIVATE_SUBNETS=$(eval echo "$PARAM_VPC_PRIVATE_SUBNETS")
VPC_PUBLIC_SUBNETS=$(eval echo "$PARAM_VPC_PUBLIC_SUBNETS")
VPC_FROM_KOPS_CLUSTER=$(eval echo "$PARAM_VPC_FROM_KOPS_CLUSTER")
CFN_ROLE_ARN=$(eval echo "$PARAM_CFN_ROLE_ARN")
TAGS=$(eval echo "$PARAM_TAGS")
AWS_MAX_POLLING_WAIT_TIME=$(eval echo "$PARAM_AWS_MAX_POLLING_WAIT_TIM")
VERBOSE=$(eval echo "$PARAM_VERBOSE")
SHOW_EKSCTL_COMMAND=$(eval echo "$PARAM_SHOW_EKSCTL_COMMAND")
FARGATE=$(eval echo "$PARAM_FARGATE")
if [ -n "$CLUSTER_NAME" ]; then
set -- "$@" --name="$CLUSTER_NAME"
fi
if [ -n "$AWS_REGION" ]; then
set -- "$@" --region="$AWS_REGION"
fi
if [ -n "$AWS_PROFILE" ]; then
set -- "$@" --profile="$AWS_PROFILE"
fi
if [ -n "$ZONES" ]; then
set -- "$@" --zones="$ZONES"
fi
if [ -n "$KUBERNETES_VERSION" ]; then
set -- "$@" --version="$KUBERNETES_VERSION"
fi
if [ -n "$CONFIG_FILE" ]; then
set -- "$@" --config-file="$CONFIG_FILE"
fi
if [ -n "$VPC_PRIVATE_SUBNETS" ]; then
set -- "$@" --vpc-private-subnets="$VPC_PRIVATE_SUBNETS"
fi
if [ -n "$VPC_PUBLIC_SUBNETS" ]; then
set -- "$@" --vpc-public-subnets="$VPC_PUBLIC_SUBNETS"
fi
if [ -n "$NODEGROUP_NAME" ]; then
set -- "$@" --nodegroup-name="$NODEGROUP_NAME"
fi
if [ "$WITHOUT_NODEGROUP" == "1" ]; then
set -- "$@" --without-nodegroup
fi
if [ "$NODE_PRIVATE_NETWORKING" == "1" ]; then
set -- "$@" --node-private-networking
fi
if [ -n "$NODE_TYPE" ]; then
set -- "$@" --node-type="$NODE_TYPE"
fi
if [ -n "$NODE_AMI" ]; then
set -- "$@" --node-ami="$NODE_AMI"
fi
if [ -n "$NODE_AMI_FAMILY" ]; then
set -- "$@" --node-ami-family="$NODE_AMI_FAMILY"
fi
if [ "$NODES" != "-1" ]; then
set -- "$@" --nodes="$NODES"
fi
if [ "$NODES_MIN" != "-1" ]; then
set -- "$@" --nodes-min="$NODES_MIN"
fi
if [ "$NODES_MAX" != "-1" ]; then
set -- "$@" --nodes-max="$NODES_MAX"
fi
if [ "$NODE_VOLUME_SIZE" != "-1" ]; then
set -- "$@" --node-volume-size="$NODE_VOLUME_SIZE"
fi
if [ -n "$NODE_VOLUME_TYPE" ]; then
set -- "$@" --node-volume-type="$NODE_VOLUME_TYPE"
fi
if [ "$MAX_PODS_PER_NODE" != "-1" ]; then
set -- "$@" --max-pods-per-node="$MAX_PODS_PER_NODE"
fi
if [ -n "$NODE_SECURITY_GROUPS" ]; then
set -- "$@" --node-security-groups="$NODE_SECURITY_GROUPS"
fi
if [ -n "$NODE_LABELS" ]; then
set -- "$@" --node-labels="$NODE_LABELS"
fi
if [ -n "$NODE_ZONES" ]; then
set -- "$@" --node-zones="$NODE_ZONES"
fi
if [ "$SSH_ACCESS" == "1" ]; then
set -- "$@" --ssh-access
fi
if [ -n "$SSH_PUBLIC_KEY" ]; then
set -- "$@" --ssh-public-key="$SSH_PUBLIC_KEY"
fi
if [ "$ASG_ACCESS" == "1" ]; then
set -- "$@" --asg-access
fi
if [ "$EXTERNAL_DNS_ACCESS" == "1" ]; then
set -- "$@" --external-dns-access
fi
if [ "$FULL_ECR_ACCESS" == "1" ]; then
set -- "$@" --full-ecr-access
fi
if [ -n "$VPC_CIDR" ]; then
set -- "$@" --vpc-cidr="$VPC_CIDR"
fi
if [ -n "$VPC_PRIVATE_SUBNETS" ]; then
set -- "$@" --vpc-private-subnets="$VPC_PRIVATE_SUBNETS"
fi
if [ -n "$VPC_PUBLIC_SUBNETS" ]; then
set -- "$@" --vpc-public-subnets="$VPC_PUBLIC_SUBNETS"
fi
if [ -n "$VPC_FROM_KOPS_CLUSTER" ]; then
set -- "$@" --vpc-from-kops-cluster="$VPC_FROM_KOPS_CLUSTER"
fi
if [ -n "$CFN_ROLE_ARN" ]; then
set -- "$@" --cfn-role-arn="$CFN_ROLE_ARN"
fi
if [ -n "$AWS_MAX_POLLING_WAIT_TIME" ]; then
set -- "$@" --timeout="$AWS_MAX_POLLING_WAIT_TIME"
fi
if [ -n "$TAGS" ]; then
set -- "$@" --tags="$TAGS"
fi
set -- "$@" --verbose="$VERBOSE"
if [ "$FARGATE" == "1" ]; then
set -- "$@" --fargate
fi
if [ "$SHOW_EKSCTL_COMMAND" == "1" ]; then
set -x
fi
eksctl create cluster "$@"
if [ "$SHOW_EKSCTL_COMMAND" == "1" ]; then
set +x
fi
if [ -n "$CLUSTER_NAME" ]; then
echo Verify cluster
if [ -n "$CLUSTER_NAME" ]; then
set -- "$@" --name "$CLUSTER_NAME"
fi
if [ -n "$AWS_REGION" ]; then
set -- "$@" --region "$AWS_REGION"
echo "$AWS_REGION"
fi
if [ -n "$AWS_PROFILE" ]; then
set -- "$@" --profile="$AWS_PROFILE"
fi
set -- "$@" --verbose "$VERBOSE"
if [ "$SHOW_EKSCTL_COMMAND" == "1" ]; then
set -x
fi
eksctl get cluster --name="$CLUSTER_NAME" --region="$AWS_REGION"
if [ "$SHOW_EKSCTL_COMMAND" == "1" ]; then
set +x
fi
fi
environment:
PARAM_ASG_ACCESS: << parameters.asg-access >>
PARAM_AWS_MAX_POLLING_WAIT_TIME: << parameters.aws-max-polling-wait-time >>
PARAM_AWS_PROFILE: << parameters.aws-profile >>
PARAM_AWS_REGION: << parameters.aws-region >>
PARAM_CFN_ROLE_ARN: << parameters.cfn-role-arn >>
PARAM_CLUSTER_NAME: << parameters.cluster-name >>
PARAM_CONFIG_FILE: << parameters.config-file >>
PARAM_EXTERNAL_DNS_ACCESS: << parameters.external-dns-access >>
PARAM_FARGATE: << parameters.fargate >>
PARAM_FULL_ECR_ACCESS: << parameters.full-ecr-access >>
PARAM_KUBERNETES_VERSION: << parameters.kubernetes-version >>
PARAM_MAX_PODS_PER_NODE: << parameters.max-pods-per-node >>
PARAM_NODE_AMI: << parameters.node-ami >>
PARAM_NODE_AMI_FAMILY: << parameters.node-ami-family >>
PARAM_NODE_LABELS: << parameters.node-labels >>
PARAM_NODE_PRIVATE_NETWORKING: << parameters.node-private-networking >>
PARAM_NODE_SECURITY_GROUPS: << parameters.node-security-groups >>
PARAM_NODE_TYPE: << parameters.node-type >>
PARAM_NODE_VOLUME_SIZE: << parameters.node-volume-size >>
PARAM_NODE_VOLUME_TYPE: << parameters.node-volume-type >>
PARAM_NODE_ZONES: << parameters.node-zones >>
PARAM_NODEGROUP_NAME: << parameters.nodegroup-name >>
PARAM_NODES: << parameters.nodes >>
PARAM_NODES_MAX: << parameters.nodes-max >>
PARAM_NODES_MIN: << parameters.nodes-min >>
PARAM_SHOW_EKSCTL_COMMAND: <<parameters.show-eksctl-command>>
PARAM_SSH_ACCESS: << parameters.ssh-access >>
PARAM_SSH_PUBLIC_KEY: << parameters.ssh-public-key >>
PARAM_TAGS: << parameters.tags >>
PARAM_VERBOSE: << parameters.verbose >>
PARAM_VPC_CIDR: << parameters.vpc-cidr >>
PARAM_VPC_FROM_KOPS_CLUSTER: << parameters.vpc-from-kops-cluster >>
PARAM_VPC_PRIVATE_SUBNETS: << parameters.vpc-private-subnets >>
PARAM_VPC_PUBLIC_SUBNETS: << parameters.vpc-public-subnets >>
PARAM_WITHOUT_NODEGROUP: << parameters.without-nodegroup >>
PARAM_ZONES: << parameters.zones >>
name: Create EKS cluster and associated resources
no_output_timeout: << parameters.no-output-timeout >>
delete-cluster:
description: |
Deletes the EKS cluster and resources that were created for it.
The cluster must have been created with the create-cluster command of the orb.
It is recommended to delete any kubernetes resources that were deployed to the
cluster (e.g. resources involving an AWS Elastic Load Balancer)
before running the delete-cluster command, so that resources can be fully
removed.
parameters:
aws-max-polling-wait-time:
default: 20m0s
description: |
Max wait time in any AWS polling operations
type: string
aws-profile:
default: ""
description: |
The AWS profile to be used. If not specified, the configured default
profile for your AWS CLI installation will be used.
type: string
aws-region:
default: ""
description: |
AWS region that the EKS cluster will be created in.
If no value is specified, the cluster will be created in the us-west-2 region.
type: string
cfn-role-arn:
default: ""
description: |
Specify an IAM role to be used by CloudFormation to call AWS API on your behalf
type: string
cluster-name:
description: |
Name of the EKS cluster
type: string
config-file:
default: ""
description: |
Use this to specify a file if you wish to load configuration from it.
type: string
no-output-timeout:
default: 30m
description: |
Elapsed time that the cluster creation command can run without output.
The string is a decimal with unit suffix, such as “20m”, “1.25h”, “5s”
type: string
show-eksctl-command:
default: false
description: |
Whether to show the eksctl command used.
type: boolean
verbose:
default: 3
description: |
Set a value from 0 to 5 to control the verbosity level of the log output (the higher, the more verbose).
Use 0 to silence, 4 for debugging and 5 for debugging with AWS debug logging.
The logging verbosity level is set to 3 by default.
When set to 4 and above, verbose details of AWS resources will be displayed in the log output.
When set to 5, sensitive information such as credentials may be displayed in the log output.
type: integer
wait:
default: false
description: |
Whether to wait for deletion of all resources before exiting
type: boolean
steps:
- setup
- run:
command: |
#!/bin/bash
CLUSTER_NAME=$(eval echo "$PARAM_CLUSTER_NAME")
CONFIG_FILE=$(eval echo "$PARAM_CONFIG_FILE")
AWS_REGION=$(eval echo "$PARAM_AWS_REGION")
AWS_PROFILE=$(eval echo "$PARAM_AWS_PROFILE")
WAIT=$(eval echo "$PARAM_WAIT")
CFN_ROLE_ARN=$(eval echo "$PARAM_CFN_ROLE_ARN")
VERBOSE=$(eval echo "$PARAM_VERBOSE")
AWS_MAX_POLLING_WAIT_TIME=$(eval echo "$PARAM_AWS_MAX_POLLING_WAIT_TIME")
if [ -n "${CLUSTER_NAME}" ]; then
set -- "$@" --name="${CLUSTER_NAME}"
fi
if [ -n "${CONFIG_FILE}" ]; then
set -- "$@" --config-file="${CONFIG_FILE}"
fi
if [ -n "${AWS_REGION}" ]; then
set -- "$@" --region="${AWS_REGION}"
fi
if [ -n "${AWS_PROFILE}" ]; then
set -- "$@" --profile="${AWS_PROFILE}"
fi
if [ "${WAIT}" == "true" ]; then
set -- "$@" --wait
fi
if [ -n "${CFN_ROLE_ARN}" ]; then
set -- "$@" --cfn-role-arn="${CFN_ROLE_ARN}"
fi
if [ -n "${AWS_MAX_POLLING_WAIT_TIME}" ]; then
set -- "$@" --timeout="${AWS_MAX_POLLING_WAIT_TIME}"
fi
set -- "$@" --verbose="${VERBOSE}"
if [ "$SHOW_EKSCTL_COMMAND" == "1" ]; then
set -x
fi
eksctl delete cluster "$@"
if [ "$SHOW_EKSCTL_COMMAND" == "1" ]; then
set +x
fi
environment:
PARAM_AWS_MAX_POLLING_WAIT_TIME: << parameters.aws-max-polling-wait-time >>
PARAM_AWS_PROFILE: << parameters.aws-profile >>
PARAM_AWS_REGION: << parameters.aws-region >>
PARAM_CFN_ROLE_ARN: << parameters.cfn-role-arn >>
PARAM_CLUSTER_NAME: << parameters.cluster-name >>
PARAM_CONFIG_FILE: << parameters.config-file >>
PARAM_VERBOSE: << parameters.verbose >>
PARAM_WAIT: << parameters.wait >>
name: Delete EKS cluster and associated resources
no_output_timeout: << parameters.no-output-timeout >>
install-aws-iam-authenticator:
description: |
Install the AWS IAM Authenticator for Kubernetes
Requirements: curl, amd64 architecture
parameters:
release-tag:
default: ""
description: |
Use this to specify a tag to select which published release of the AWS IAM Authenticator,
as listed on https://github.com/kubernetes-sigs/aws-iam-authenticator/releases,
to install. If no value is specified, the latest release will be installed.
Note: Release versions earlier than v0.3.0 cannot be specified. Also,
pre or alpha releases cannot be specified.
type: string
steps:
- run:
command: "#!/bin/bash\nif which aws-iam-authenticator > /dev/null; then\n echo \"AWS IAM Authenticator for Kubernetes is already installed\"\n exit 0\nfi\nPLATFORM=\"linux\"\nif uname | grep -q 'Darwin' \nthen\n PLATFORM=\"darwin\"\nfi\nFILENAME=\"aws-iam-authenticator\"\nVERSION=0.5.6\nif [ -n \"${PARAM_RELEASE_TAG}\" ]; then\n export RELEASE_TAG=${PARAM_RELEASE_TAG}\n VERSION=\"${RELEASE_TAG}\"\n if [ \"${VERSION}\" == \"0.3.0\" ]; then\n FILENAME=\"heptio-authenticator-aws\"\n fi\nfi\n\nDOWNLOAD_URL=\"https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v${VERSION}/${FILENAME}_${VERSION}_${PLATFORM}_amd64\"\n\nprintf \"Downloading version ${VERSION}\\n\"\n\ncurl -L --fail --retry 3 -o aws-iam-authenticator \"$DOWNLOAD_URL\"\nchmod +x ./aws-iam-authenticator\n\nif [ \"$(id -u)\" -ne 0 ] && which sudo > /dev/null ; then\n SUDO=\"sudo\"\nfi\n$SUDO mv ./aws-iam-authenticator /usr/local/bin/aws-iam-authenticator\n"
environment:
PARAM_RELEASE_TAG: << parameters.release-tag>>
name: Install the AWS IAM Authenticator for Kubernetes
setup:
description: Install the Amazon eksctl command line utility. This command should be ran before invoking the eskctl cli.
parameters:
version:
default: 0.77.0
description: Specify the full semver versioned tag to use.
type: string
steps:
- run:
command: |
#!/bin/bash
# set smart sudo
if [[ $EUID == 0 ]]; then export SUDO=""; else export SUDO="sudo"; fi
# Define current platform
if [[ "$(uname -s)" == "Darwin" && "$(uname -m)" == "x86_64" ]]; then
export SYS_ENV_PLATFORM=macos
elif [[ "$(uname -s)" == "Linux" && "$(uname -m)" == "x86_64" ]]; then
export SYS_ENV_PLATFORM=linux_x86
elif [[ "$(uname -s)" == "Linux" && "$(uname -m)" == "aarch64" ]]; then
export SYS_ENV_PLATFORM=linux_arm
else
echo "This platform appears to be unsupported."
uname -a
exit 1
fi
if ! command -v eksctl >/dev/null 2>&1; then
echo "Installing the AWS eksctl CLI"
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
$SUDO mv /tmp/eksctl /usr/local/bin
# Validate install.
echo
command -v eksctl
echo "AWS eksctl CLI installed"
else
echo "AWS eksctl CLI is already installed."
fi
name: Install Amazon EKSCTL
update-kubeconfig-with-authenticator:
description: |
Allows the stock kubectl client to work with Amazon EKS.
Installs the AWS CLI, the AWS IAM Authenticator for Kubernetes and
updates the kubectl configuration file to use the AWS IAM Authenticator.
parameters:
authenticator-release-tag:
default: ""
description: |
Specifies which release-tag version of the authenticator to install.
type: string
aws-profile:
default: ""
description: |
The AWS profile to be used. If not specified, the configured default
profile for your AWS CLI installation will be used.
type: string
aws-region:
default: ""
description: |
The AWS region that the cluster is in. If not specified, the configured default
region for your AWS CLI installation will be used.
type: string
cluster-authentication-role-arn:
default: ""
description: |
To assume a role for cluster authentication, specify an IAM role ARN with
this option. For example, if you created a cluster while assuming an IAM
role, then you must also assume that role to connect to the cluster the
first time.
type: string
cluster-context-alias:
default: ""
description: |
Alias for the cluster context name. If a value is not specified,
the cluster context name will be set to match the cluster ARN.
type: string
cluster-name:
description: |
The name of the cluster for which to create a kubeconfig entry.
type: string
dry-run:
default: ""
description: |
Print the merged kubeconfig to stdout instead of writing it to file.
enum:
- ""
- server
- client
type: enum
install-aws-cli:
default: true
description: |
Whether to install aws-cli
type: boolean
install-kubectl:
default: false
description: |
Whether to install kubectl
type: boolean
kubeconfig-file-path:
default: ""
description: |
Specifies a kubeconfig file to append the configuration details to.
By default, the configuration is written to the first file path in the
KUBECONFIG environment variable (if it is set) or the default kubeconfig
path (.kube/config) in your home directory.
type: string
kubectl-version:
default: v1.22.0
description: |
Version of kubectl to install
type: string
verbose:
default: false
description: |
Print more detailed output when writing to the kubeconfig file.
type: boolean
steps:
- when:
condition: << parameters.install-kubectl >>
steps:
- kubernetes/install:
kubectl-version: << parameters.kubectl-version >>
- install-aws-iam-authenticator:
release-tag: << parameters.authenticator-release-tag >>
- when:
condition: << parameters.install-aws-cli >>
steps:
- aws-cli/setup
- run:
command: |
#!/bin/bash
CLUSTER_NAME=$(eval echo "$PARAM_CLUSTER_NAME")
AWS_REGION=$(eval echo "$PARAM_AWS_REGION")
AWS_PROFILE=$(eval echo "$PARAM_AWS_PROFILE")
KUBECONFIG_FILE_PATH=$(eval echo "$PARAM_KUBECONFIG_FILE_PATH")
ROLE_ARN=$(eval echo "$PARAM_ROLE_ARN")
CLUSTER_CONTEXT_ALIAS=$(eval echo "$PARAM_CLUSTER_CONTEXT_ALIAS")
DRY_RUN=$(eval echo "$PARAM_DRY_RUN")
VERBOSE=$(eval echo "$PARAM_VERBOSE")
if [ -n "${CLUSTER_NAME}" ]; then
set -- "$@" --name "${CLUSTER_NAME}"
fi
if [ -n "${AWS_REGION}" ]; then
set -- "$@" --region "${AWS_REGION}"
fi
if [ -n "${AWS_PROFILE}" ]; then
set -- "$@" --profile "${AWS_PROFILE}"
fi
if [ -n "${KUBECONFIG_FILE_PATH}" ]; then
set -- "$@" --kubeconfig "${KUBECONFIG_FILE_PATH}"
fi
if [ -n "${ROLE_ARN}" ]; then
set -- "$@" --role-arn "${ROLE_ARN}"
fi
if [ -n "${CLUSTER_CONTEXT_ALIAS}" ]; then
set -- "$@" --alias "${CLUSTER_CONTEXT_ALIAS}"
fi
if [ -n "${DRY_RUN}" ]; then
set -- "$@" --dry-run "${DRY_RUN}"
fi
if [ "${VERBOSE}" == "true" ]; then
set -- "$@" --verbose
fi
aws eks update-kubeconfig "$@"
environment:
PARAM_AWS_PROFILE: << parameters.aws-profile >>
PARAM_AWS_REGION: << parameters.aws-region >>
PARAM_CLUSTER_CONTEXT_ALIAS: << parameters.cluster-context-alias >>
PARAM_CLUSTER_NAME: << parameters.cluster-name >>
PARAM_DRY_RUN: << parameters.dry-run >>
PARAM_KUBECONFIG_FILE_PATH: << parameters.kubeconfig-file-path >>
PARAM_ROLE_ARN: << parameters.cluster-authentication-role-arn >>
PARAM_VERBOSE: << parameters.verbose >>
name: Update the kubectl configuration file to use the authenticator
jobs:
create-cluster:
description: |
Creates an EKS cluster and required resources (e.g. VPC) using the eksctl tool.
docker:
- image: cimg/python:<<parameters.tag>>
parameters:
authenticator-release-tag:
default: ""
description: |
Specifies which release-tag version of the authenticator to install.
type: string
aws-max-polling-wait-time:
default: 20m0s
description: |
Max wait time in any AWS polling operations
type: string
aws-profile:
default: ""
description: |
The AWS profile to be used. If not specified, the configured default
profile for your AWS CLI installation will be used.
type: string
aws-region:
default: ""
description: |
AWS region that the EKS cluster will be created in.
type: string
cluster-name:
default: ""
description: |
Name of the EKS cluster to be created
type: string
no-output-timeout:
default: 45m
description: |
Elapsed time that the cluster creation command can run on CircleCI without output.
The string is a decimal with unit suffix, such as “20m”, “1.25h”, “5s”
type: string
show-eksctl-command:
default: false
description: |
Whether to show the eksctl command used.
type: boolean
ssh-access:
default: false
description: |
Control SSH access for nodes
type: boolean
ssh-public-key:
default: ""
description: |
SSH public key to use for nodes (import from local path, or use existing EC2 key pair which
must not resolve to a local file path)
e.g. my_eks_node_id.pub
"~/.ssh/id_rsa.pub" will be taken as the path if a value is not specified.
type: string
tag:
default: "3.10"
description: |
Version of the CircleCI Python convenience image to use. For full list,
see https://hub.docker.com/r/cimg/python/tags
A version of Python supported by the AWS CLI is required.
type: string
tags:
default: ""
description: |
A list of key-value pairs used to tag the AWS resources (e.g. "Owner=John Doe,Team=Some Team")
type: string
verbose:
default: 3
description: |
Set a value from 0 to 5 to control the verbosity level of the log output (the higher, the more verbose).
Use 0 to silence, 4 for debugging and 5 for debugging with AWS debug logging.
The logging verbosity level is set to 3 by default.
When set to 4 and above, verbose details of AWS resources will be displayed in the log output.
When set to 5, sensitive information such as credentials may be displayed in the log output.
type: integer
steps:
- install-aws-iam-authenticator:
release-tag: << parameters.authenticator-release-tag >>
- create-cluster:
aws-max-polling-wait-time: << parameters.aws-max-polling-wait-time >>
aws-profile: << parameters.aws-profile >>
aws-region: << parameters.aws-region >>
cluster-name: << parameters.cluster-name >>
no-output-timeout: << parameters.no-output-timeout >>
show-eksctl-command: << parameters.show-eksctl-command >>
skip-kubectl-install: false
ssh-access: << parameters.ssh-access >>
ssh-public-key: << parameters.ssh-public-key >>
tags: << parameters.tags >>
verbose: << parameters.verbose >>
delete-cluster:
description: |
Deletes an EKS cluster together with the associated VPC resources on AWS,
using the eksctl tool. The cluster should have been created with eksctl
as well.
It is recommended to delete any kubernetes resources that were deployed to the
cluster (e.g. resources involving an AWS Elastic Load Balancer)
before running the delete-cluster command, so that resources can be fully
removed.
docker:
- image: cimg/python:<<parameters.tag>>
parameters:
authenticator-release-tag:
default: ""
description: |
Specifies which release-tag version of the authenticator to install.
type: string
aws-profile:
default: ""
description: |
The AWS profile to be used. If not specified, the configured default
profile for your AWS CLI installation will be used.
type: string
aws-region:
default: ""
description: |
AWS region that the EKS cluster is in.
type: string
cluster-name:
description: |
The name of the EKS cluster to be deleted.
type: string
kubectl-version:
default: v1.22.0
description: |
Version of kubectl to install
type: string
no-output-timeout:
default: 30m
description: |
Elapsed time that the cluster creation command can run without output.
The string is a decimal with unit suffix, such as “20m”, “1.25h”, “5s” (default: 20 minutes)
type: string
tag:
default: "3.10"
description: |
Version of the CircleCI Python convenience image to use. For full list,
see https://hub.docker.com/r/cimg/python/tags
A version of Python supported by the AWS CLI is required.
type: string
verbose:
default: 3
description: |
Set a value from 0 to 5 to control the verbosity level of the log output (the higher, the more verbose).
Use 0 to silence, 4 for debugging and 5 for debugging with AWS debug logging.
The logging verbosity level is set to 3 by default.
When set to 4 and above, verbose details of AWS resources will be displayed in the log output.
When set to 5, sensitive information such as credentials may be displayed in the log output.
type: integer
wait:
default: false
description: |
Whether to wait for deletion of all resources before exiting
type: boolean
steps:
- update-kubeconfig-with-authenticator:
authenticator-release-tag: << parameters.authenticator-release-tag >>
aws-profile: << parameters.aws-profile >>
aws-region: << parameters.aws-region >>
cluster-name: << parameters.cluster-name >>
install-kubectl: true
kubectl-version: << parameters.kubectl-version >>
- delete-cluster:
aws-profile: << parameters.aws-profile >>
aws-region: << parameters.aws-region >>
cluster-name: << parameters.cluster-name >>
no-output-timeout: << parameters.no-output-timeout >>
verbose: << parameters.verbose >>
wait: << parameters.wait >>
update-container-image:
description: |
Updates the container image(s) of a resource on EKS.
docker:
- image: cimg/python:<<parameters.tag>>
parameters:
authenticator-release-tag:
default: ""
description: |
Specifies which release-tag version of the authenticator to install.
type: string
aws-profile:
default: ""
description: |
The AWS profile to be used. If not specified, the configured default
profile for your AWS CLI installation will be used.
type: string
aws-region:
default: ""
description: |
AWS region that the EKS cluster is in.
type: string
cluster-name:
description: |
The name of the EKS cluster.
type: string
container-image-updates:
description: |
Specify a list of container image updates
(space-delimited name value pairs in the form
CONTAINER_NAME_1=CONTAINER_IMAGE_1 ... CONTAINER_NAME_N=CONTAINER_IMAGE_N)
to be applied to the resource via `kubectl set image`.
e.g. "busybox=busybox nginx=nginx:1.9.1"
type: string
get-rollout-status:
default: false
description: |
Get the status of the rollout.
This can only be used for resource types that are valid
for usage with `kubectl rollout` subcommands.
type: boolean
kubectl-version:
default: v1.22.0
description: |
Version of kubectl to install
type: string
namespace:
default: ""
description: |
The kubernetes namespace that should be used.
type: string
pinned-revision-to-watch:
default: ""
description: |
Pin a specific revision to be watched and abort watching if it is rolled
over by another revision.
Only effective if get-rollout-status is set to true.
type: string
resource-name:
default: ""
description: |
Resource name in the format TYPE/NAME e.g. deployment/nginx-deployment
Either resource-file-path or resource-name need to be specified.
This is required if get-rollout-status is set to true.
type: string
show-kubectl-command:
default: false
description: |
Whether to show the kubectl command used.
type: boolean
tag:
default: "3.10"
description: |
Version of the CircleCI Python convenience image to use. For full list,
see https://hub.docker.com/r/cimg/python/tags
A version of Python supported by the AWS CLI is required.
type: string
watch-rollout-status:
default: true
description: |
Whether to watch the status of the latest rollout until it's done.
Only effective if get-rollout-status is set to true.
type: boolean
watch-timeout:
default: ""
description: |
The length of time to wait before ending the watch, zero means never.
Any other values should contain a corresponding time unit (e.g. 1s, 2m, 3h).
Only effective if get-rollout-status is set to true.
type: string
steps:
- update-kubeconfig-with-authenticator:
authenticator-release-tag: << parameters.authenticator-release-tag >>
aws-profile: << parameters.aws-profile >>
aws-region: << parameters.aws-region >>
cluster-name: << parameters.cluster-name >>
install-kubectl: true
kubectl-version: << parameters.kubectl-version >>
- kubernetes/update-container-image:
container-image-updates: << parameters.container-image-updates >>
get-rollout-status: << parameters.get-rollout-status >>
namespace: << parameters.namespace >>
pinned-revision-to-watch: << parameters.pinned-revision-to-watch >>
resource-name: << parameters.resource-name >>
show-kubectl-command: << parameters.show-kubectl-command >>
watch-rollout-status: << parameters.watch-rollout-status >>
watch-timeout: << parameters.watch-timeout >>
examples:
create-eks-cluster:
description: |
Create an eks cluster together with the required VPC-related
resources, test it, and tear it down.
usage:
version: "2.1"
orbs:
aws-eks: circleci/aws-eks@<<pipeline.parameters.dev-orb-version>>
kubernetes: circleci/kubernetes@1.3
jobs:
test-cluster:
docker:
- image: cimg/python:3.10
parameters:
cluster-name:
description: |
Name of the EKS cluster
type: string
steps:
- kubernetes/install:
kubectl-version: v1.22.0
- aws-eks/update-kubeconfig-with-authenticator:
cluster-name: << parameters.cluster-name >>
- run:
command: |
kubectl get services
name: Test cluster
workflows:
deployment:
jobs:
- aws-eks/create-cluster:
cluster-name: my-eks-demo
- test-cluster:
cluster-name: my-eks-demo
requires:
- aws-eks/create-cluster
- aws-eks/delete-cluster:
cluster-name: my-eks-demo
requires:
- test-cluster
create-k8s-deployment:
description: |
Create a kubernetes deployment.
usage:
version: "2.1"
orbs:
aws-eks: circleci/aws-eks@<<pipeline.parameters.dev-orb-version>>
kubernetes: circleci/kubernetes@1.3
jobs:
create-deployment:
docker:
- image: cimg/python:3.10
parameters:
cluster-name:
description: |
Name of the EKS cluster
type: string
steps:
- checkout
- aws-eks/update-kubeconfig-with-authenticator:
cluster-name: << parameters.cluster-name >>
install-kubectl: true
- kubernetes/create-or-update-resource:
get-rollout-status: true
resource-file-path: tests/nginx-deployment/deployment.yaml
resource-name: deployment/nginx-deployment
workflows:
deployment:
jobs:
- aws-eks/create-cluster:
cluster-name: eks-demo-deployment
- create-deployment:
cluster-name: eks-demo-deployment
requires:
- aws-eks/create-cluster
- aws-eks/update-container-image:
cluster-name: eks-demo-deployment
container-image-updates: nginx=nginx:1.9.1
post-steps:
- kubernetes/delete-resource:
resource-names: nginx-deployment
resource-types: deployment
wait: true
requires:
- create-deployment
resource-name: deployment/nginx-deployment
- aws-eks/delete-cluster:
cluster-name: eks-demo-deployment
requires:
- aws-eks/update-container-image