From cffc7db8173796fb97dd74faca22c41db5801c17 Mon Sep 17 00:00:00 2001 From: Petri Autero Date: Wed, 16 Nov 2022 19:29:08 +0200 Subject: [PATCH] Add support for 1.24 and drop support of 1.20 --- eks/sync.go | 35 +++++++++++++++++++++------------- eks/sync_test.go | 49 +++++++++++++++--------------------------------- 2 files changed, 37 insertions(+), 47 deletions(-) diff --git a/eks/sync.go b/eks/sync.go index e90343c..9ea4037 100644 --- a/eks/sync.go +++ b/eks/sync.go @@ -32,6 +32,7 @@ import ( const ( kubeProxyRepoPath = "eks/kube-proxy" coreDNSRepoPath = "eks/coredns" + vpcCniRepoPath = "amazon-k8s-cni" // Largest eksbuild tag we will try looking for. maxEKSBuild = 10 @@ -39,30 +40,30 @@ const ( var ( // NOTE: Ensure that there is an entry for each supported version in the following tables. - supportedVersions = []string{"1.23", "1.22", "1.21", "1.20"} + supportedVersions = []string{"1.24", "1.23", "1.22", "1.21"} // Reference: https://docs.aws.amazon.com/eks/latest/userguide/managing-coredns.html coreDNSVersionLookupTable = map[string]string{ + "1.24": "1.8.7-eksbuild", "1.23": "1.8.7-eksbuild", - "1.22": "1.8.7-eksbuild", - "1.21": "1.8.4-eksbuild", - "1.20": "1.8.3-eksbuild", + "1.22": "1.8.7", + "1.21": "1.8.4", } // Reference: https://docs.aws.amazon.com/eks/latest/userguide/managing-kube-proxy.html#updating-kube-proxy-add-on kubeProxyVersionLookupTable = map[string]string{ - "1.23": "1.23.7-minimal-eksbuild", - "1.22": "1.22.11-eksbuild", - "1.21": "1.21.14-eksbuild", - "1.20": "1.20.15-eksbuild", + "1.24": "1.24.7-minimal-eksbuild", + "1.23": "1.23.8-minimal-eksbuild", + "1.22": "1.22.11-minimal-eksbuild", + "1.21": "1.21.14-minimal-eksbuild", } // Reference: https://docs.aws.amazon.com/eks/latest/userguide/managing-vpc-cni.html amazonVPCCNIVersionLookupTable = map[string]string{ - "1.23": "1.11.3", - "1.22": "1.11.3", - "1.21": "1.11.3", - "1.20": "1.11.3", + "1.24": "1.11.4-eksbuild", + "1.23": "1.11.4-eksbuild", + "1.22": "1.11.4-eksbuild", + "1.21": "1.11.4-eksbuild", } defaultContainerImageAccount = "602401143452" @@ -156,7 +157,10 @@ func SyncClusterComponents( return err } - amznVPCCNIVersion := amazonVPCCNIVersionLookupTable[k8sVersion] + amznVPCCNIVersion, err := findLatestEKSBuild(dockerToken, repoDomain, vpcCniRepoPath, amazonVPCCNIVersionLookupTable[k8sVersion]) + if err != nil { + return err + } logger.Info("Syncing Kubernetes Applications to:") if !skipConfig.KubeProxy { @@ -617,6 +621,11 @@ func findLatestEKSBuild(token, repoDomain, repoPath, tagBase string) (string, er logger := logging.GetProjectLogger() logger.Debugf("Looking up latest eksbuild for repo %s/%s", repoDomain, repoPath) + if !strings.Contains(tagBase, "eksbuild") { + logger.Debugf("Not an eksbuild for repo %s/%s, returning %s", repoDomain, repoPath, tagBase) + return tagBase, nil + } + var existingTag string for i := 0; i < maxEKSBuild; i++ { version := fmt.Sprintf("%s.%d", tagBase, i+1) diff --git a/eks/sync_test.go b/eks/sync_test.go index 68a3e21..41f40e1 100644 --- a/eks/sync_test.go +++ b/eks/sync_test.go @@ -187,58 +187,39 @@ func TestRemoveUpstreamKeywordFromCorednsConfigMap(t *testing.T) { assert.Equal(t, expectedSampleConfigData, testConfigMapUpdated.Data[corednsConfigMapConfigKey]) } -func TestFindLatestEKSBuild(t *testing.T) { +func TestFindLatestEKSBuilds(t *testing.T) { t.Parallel() testCase := []struct { + lookupTable map[string]string + repoPath string k8sVersion string region string expectedVersion string }{ - {"1.20", "us-east-1", "1.20.15-eksbuild.2"}, - {"1.22", "us-east-1", "1.22.11-eksbuild.2"}, - {"1.23", "us-east-1", "1.23.7-minimal-eksbuild.1"}, + {coreDNSVersionLookupTable, coreDNSRepoPath, "1.24", "us-east-1", "1.8.7-eksbuild.3"}, + {coreDNSVersionLookupTable, coreDNSRepoPath, "1.23", "us-east-1", "1.8.7-eksbuild.3"}, + {coreDNSVersionLookupTable, coreDNSRepoPath, "1.22", "us-east-1", "1.8.7"}, + {amazonVPCCNIVersionLookupTable, vpcCniRepoPath, "1.24", "us-east-1", "1.11.4-eksbuild.2"}, + {amazonVPCCNIVersionLookupTable, vpcCniRepoPath, "1.23", "us-east-1", "1.11.4-eksbuild.2"}, + {amazonVPCCNIVersionLookupTable, vpcCniRepoPath, "1.22", "us-east-1", "1.11.4-eksbuild.2"}, + {kubeProxyVersionLookupTable, kubeProxyRepoPath, "1.24", "us-east-1", "1.24.7-minimal-eksbuild.2"}, + {kubeProxyVersionLookupTable, kubeProxyRepoPath, "1.23", "us-east-1", "1.23.8-minimal-eksbuild.2"}, + {kubeProxyVersionLookupTable, kubeProxyRepoPath, "1.22", "us-east-1", "1.22.11-minimal-eksbuild.2"}, } for _, tc := range testCase { tc := tc - t.Run(tc.k8sVersion, func(t *testing.T) { + t.Run(fmt.Sprintf("%s-%s", tc.repoPath, tc.k8sVersion), func(t *testing.T) { t.Parallel() repoDomain := getRepoDomain(tc.region) dockerToken, err := eksawshelper.GetDockerLoginToken(tc.region) require.NoError(t, err) - kubeProxyVersion, err := findLatestEKSBuild(dockerToken, repoDomain, kubeProxyRepoPath, kubeProxyVersionLookupTable[tc.k8sVersion]) + appVersion, err := findLatestEKSBuild(dockerToken, repoDomain, tc.repoPath, tc.lookupTable[tc.k8sVersion]) require.NoError(t, err) - assert.Equal(t, tc.expectedVersion, kubeProxyVersion) - }) - } -} - -func TestFindLatestEKSBuildPetri(t *testing.T) { - t.Parallel() - - testCase := []struct { - k8sVersion string - region string - expectedVersion string - }{ - {"1.23", "us-east-1", "1.8.7-eksbuild.3"}, - } - - for _, tc := range testCase { - tc := tc - t.Run(tc.k8sVersion, func(t *testing.T) { - t.Parallel() - - repoDomain := getRepoDomain(tc.region) - dockerToken, err := eksawshelper.GetDockerLoginToken(tc.region) - require.NoError(t, err) - - coreDNSVersion, err := findLatestEKSBuild(dockerToken, repoDomain, coreDNSRepoPath, coreDNSVersionLookupTable[tc.k8sVersion]) - require.NoError(t, err) - assert.Equal(t, tc.expectedVersion, coreDNSVersion) + assert.Equal(t, tc.expectedVersion, appVersion) }) } }