Skip to content

Commit

Permalink
Add support for 1.24 and drop support of 1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
autero1 committed Nov 16, 2022
1 parent 1f37504 commit cffc7db
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 47 deletions.
35 changes: 22 additions & 13 deletions eks/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,37 +32,38 @@ import (
const (
kubeProxyRepoPath = "eks/kube-proxy"
coreDNSRepoPath = "eks/coredns"
vpcCniRepoPath = "amazon-k8s-cni"

// Largest eksbuild tag we will try looking for.
maxEKSBuild = 10
)

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"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
49 changes: 15 additions & 34 deletions eks/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
}
Expand Down

0 comments on commit cffc7db

Please sign in to comment.