From de823a521e24c93d5617d4cfe7aec431712b4bc1 Mon Sep 17 00:00:00 2001 From: lohgannash Date: Wed, 11 Aug 2021 12:45:33 +1000 Subject: [PATCH 1/2] Add support for Addons via CFN --- eks-cluster.cfndsl.rb | 12 ++++++++++++ tests/add_ons.test.yaml | 7 +++++++ 2 files changed, 19 insertions(+) create mode 100644 tests/add_ons.test.yaml diff --git a/eks-cluster.cfndsl.rb b/eks-cluster.cfndsl.rb index bc80b16..23052e6 100644 --- a/eks-cluster.cfndsl.rb +++ b/eks-cluster.cfndsl.rb @@ -208,6 +208,18 @@ LaunchTemplateData(template_data) } + resolve_addon_conflicts = external_parameters.fetch(:resolve_addon_conflicts, nil) + add_ons = external_parameters.fetch(:add_ons, {}) + add_ons.each do | add_on, version | + safe_addon_name = add_on.dup.gsub!('-','') || add_on + EKS_Addon("#{safe_addon_name.capitalize}Addon") { + AddonName add_on + AddonVersion version + ResolveConflicts resolve_addon_conflicts unless resolve_addon_conflicts.nil? + ClusterName Ref(:EksCluster) + Tags tags + } + end unless add_ons.empty? asg_tags = [ { Key: FnSub("k8s.io/cluster/${EksCluster}"), Value: 'owned' }, diff --git a/tests/add_ons.test.yaml b/tests/add_ons.test.yaml new file mode 100644 index 0000000..20cb30f --- /dev/null +++ b/tests/add_ons.test.yaml @@ -0,0 +1,7 @@ +test_metadata: + type: config + name: add_ons + description: test with some basic configuration and an add on + +add_ons: + kube-proxy: v1.21.2-eksbuild.2 \ No newline at end of file From 105b6802681aed8de88bfaf61d6090c858236be2 Mon Sep 17 00:00:00 2001 From: lohgannash Date: Thu, 12 Aug 2021 14:22:29 +1000 Subject: [PATCH 2/2] Allow resolve conflicts property per addon --- eks-cluster.cfndsl.rb | 7 +++---- tests/add_ons.test.yaml | 4 +++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/eks-cluster.cfndsl.rb b/eks-cluster.cfndsl.rb index 23052e6..bb835e7 100644 --- a/eks-cluster.cfndsl.rb +++ b/eks-cluster.cfndsl.rb @@ -208,14 +208,13 @@ LaunchTemplateData(template_data) } - resolve_addon_conflicts = external_parameters.fetch(:resolve_addon_conflicts, nil) add_ons = external_parameters.fetch(:add_ons, {}) - add_ons.each do | add_on, version | + add_ons.each do | add_on, config | safe_addon_name = add_on.dup.gsub!('-','') || add_on EKS_Addon("#{safe_addon_name.capitalize}Addon") { AddonName add_on - AddonVersion version - ResolveConflicts resolve_addon_conflicts unless resolve_addon_conflicts.nil? + AddonVersion config['version'] + ResolveConflicts config['resolve_conflicts'] if config.has_key?('resolve_conflicts') ClusterName Ref(:EksCluster) Tags tags } diff --git a/tests/add_ons.test.yaml b/tests/add_ons.test.yaml index 20cb30f..94dadc5 100644 --- a/tests/add_ons.test.yaml +++ b/tests/add_ons.test.yaml @@ -4,4 +4,6 @@ test_metadata: description: test with some basic configuration and an add on add_ons: - kube-proxy: v1.21.2-eksbuild.2 \ No newline at end of file + kube-proxy: + version: v1.21.2-eksbuild.2 + resolve_conflicts: OVERWRITE \ No newline at end of file