eksctl
eksctl copied to clipboard
Don't re-create existing addons when taking a config file as input
Description
When using eksctl create addon command with the --config-file flag, there is a bug in that instead of filtering out addons that already exist in the cluster, it's attempting to recreate all addons specified in the file. This results in the error below
Error: creating CloudFormation stack "eksctl-cluster-with-addons-addon-vpc-cni": operation error CloudFormation: CreateStack, https response error StatusCode: 400, RequestID: 97b7e7ab-36e8-4e40-9e11-785a6dbfdf29, AlreadyExistsException: Stack [eksctl-cluster-with-addons-addon-vpc-cni] already exists
This PR modifies the eksctl create addon command such that it first checks whether the addon is already present in the cluster (as an EKS managed addon), and based on this info, only creates the ones from the file that are actually new.
Fixes: #5613
Manual test ouput
tiberiu-weave@192-168-0-100 eksctl % ./eksctl create addon --config-file examples/25-addons.yaml
2022-09-02 13:39:04 [ℹ] getting all addons
2022-09-02 13:39:06 [ℹ] Addon vpc-cni is already present in this cluster, and won't be recreated
2022-09-02 13:39:06 [ℹ] Addon coredns is already present in this cluster, and won't be recreated
2022-09-02 13:39:06 [ℹ] Addon kube-proxy is already present in this cluster, and won't be recreated
2022-09-02 13:39:06 [ℹ] creating role using recommended policies
2022-09-02 13:39:07 [ℹ] deploying stack "eksctl-cluster-with-addons-addon-aws-ebs-csi-driver"
...
2022-09-02 13:40:22 [ℹ] creating addon
2022-09-02 13:42:16 [ℹ] addon "aws-ebs-csi-driver" active
tiberiu-weave@192-168-0-100 eksctl % ./eksctl get addon --region eu-north-1 --cluster cluster-with-addons --name aws-ebs-csi-driver
<cluster-name>`
NAME VERSION STATUS ISSUES IAMROLE UPDATE AVAILABLE
aws-ebs-csi-driver v1.10.0-eksbuild.1 ACTIVE 0 arn:aws:iam::083751696308:role/eksctl-cluster-with-addons-addon-aws-ebs-csi-Role1-1J9R313SWX1MS
Integration test output
STEP - successfully creating the aws-ebs-csi-driver addon via config file
starting '../../../eksctl "create" "addon" "--config-file" "-"'
2022-09-02 12:55:40 getting all addons
2022-09-02 12:55:42 Addon vpc-cni is already present in this cluster, and won't be recreated
2022-09-02 12:55:42 Addon coredns is already present in this cluster, and won't be recreated
2022-09-02 12:55:44 deploying stack "eksctl-ti-it-addons-ferocious-monster-1662111355-addon-aws-ebs-csi
...
2022-09-02 12:58:53 addon "aws-ebs-csi-driver" active
starting '../../../eksctl "--region" "us-west-2" "get" "addon" "--name" "aws-ebs-csi-driver" "--cluster" "ti-it-addons-ferocious-monster-1662111355" "--verbose" "2"'
NAME VERSION STATUS ISSUES IAMROLE UPDATE AVAILABLE
aws-ebs-csi-driver v1.10.0-eksbuild.1 ACTIVE 0 arn:aws:iam::083751696308:role/eksctl-ti-it-addons-ferocious-monster-166211-Role1-1ISSF0XSMT7ZD
Checklist
- [x] Added tests that cover your change (if possible)
- [ ] Added/modified documentation as required (such as the
README.md, or theuserdocsdirectory) - [x] Manually tested
- [x] Made sure the title of the PR is a good description that can go into the release notes
- [x] (Core team) Added labels for change area (e.g.
area/nodegroup) and kind (e.g.kind/improvement)
BONUS POINTS checklist: complete for good vibes and maybe prizes?! :exploding_head:
- [ ] Backfilled missing tests for code in same general area :tada:
- [ ] Refactored something and made the world a better place :star2: