Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Commit 45cebb7

Browse files
jadarsiejackfrancis
authored andcommitted
fix: use cached v1.15-azs kube-proxy on Azure Stack (#3757)
1 parent fe1182e commit 45cebb7

File tree

2 files changed

+62
-2
lines changed

2 files changed

+62
-2
lines changed

Diff for: pkg/api/addons.go

+13-1
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ func (cs *ContainerService) setAddonsConfig(isUpgrade bool) {
771771
Containers: []KubernetesContainerSpec{
772772
{
773773
Name: common.KubeProxyAddonName,
774-
Image: kubernetesImageBase + k8sComponents[common.KubeProxyAddonName],
774+
Image: kubernetesImageBase + k8sComponents[common.KubeProxyAddonName] + kubeProxyImageSuffix(*cs),
775775
},
776776
},
777777
}
@@ -1203,3 +1203,15 @@ func getCSISidecarComponent(csiDriverName, csiSidecarName string, k8sComponents
12031203
}
12041204
return k8sComponents[csiSidecarName]
12051205
}
1206+
1207+
// kubeProxyImageSuffix returns '-azs' if target cloud is Azure Stack and Kubernetes version is lower than v1.16.0.
1208+
// Otherwise, it returns empty string.
1209+
// Azure Stack needs the '-azs' suffix so kube-proxy's manifests uses the custom hyperkube image present in the VHD
1210+
func kubeProxyImageSuffix(cs ContainerService) string {
1211+
if cs.Properties.IsAzureStackCloud() {
1212+
if !common.IsKubernetesVersionGe(cs.Properties.OrchestratorProfile.OrchestratorVersion, "1.16.0") {
1213+
return common.AzureStackSuffix
1214+
}
1215+
}
1216+
return ""
1217+
}

Diff for: pkg/api/addons_test.go

+49-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package api
66
import (
77
"reflect"
88
"strconv"
9+
"strings"
910
"testing"
1011

1112
"github.com/Azure/aks-engine/pkg/api/common"
@@ -2157,7 +2158,7 @@ func TestSetAddonsConfig(t *testing.T) {
21572158
Containers: []KubernetesContainerSpec{
21582159
{
21592160
Name: common.KubeProxyAddonName,
2160-
Image: "MCRKubernetesImageBase" + k8sComponentsByVersionMap["1.15.12"][common.KubeProxyAddonName],
2161+
Image: "MCRKubernetesImageBase" + k8sComponentsByVersionMap["1.15.12"][common.KubeProxyAddonName] + common.AzureStackSuffix,
21612162
},
21622163
},
21632164
},
@@ -5375,3 +5376,50 @@ func TestGetCSISidecarComponent(t *testing.T) {
53755376
})
53765377
}
53775378
}
5379+
5380+
func TestKubeProxyImageSuffix(t *testing.T) {
5381+
cases := []struct {
5382+
name string
5383+
cs ContainerService
5384+
azurestack bool
5385+
expected string
5386+
}{
5387+
{
5388+
name: "return empty string if target cloud is NOT Azure Stack",
5389+
cs: getMockBaseContainerService("1.15.0"),
5390+
azurestack: false,
5391+
expected: "",
5392+
},
5393+
{
5394+
name: "return empty string if target cloud is NOT Azure Stack",
5395+
cs: getMockBaseContainerService("1.16.0"),
5396+
azurestack: false,
5397+
expected: "",
5398+
},
5399+
{
5400+
name: "return empty string if target version is v1.16 or greater",
5401+
cs: getMockBaseContainerService("1.16.0"),
5402+
azurestack: true,
5403+
expected: "",
5404+
},
5405+
{
5406+
name: "return '-azs' if target cloud is Azure Stack and K8s version lower than v1.16",
5407+
cs: getMockBaseContainerService("1.15.0"),
5408+
azurestack: true,
5409+
expected: common.AzureStackSuffix,
5410+
},
5411+
}
5412+
for _, tc := range cases {
5413+
c := tc
5414+
t.Run(c.name, func(t *testing.T) {
5415+
t.Parallel()
5416+
if c.azurestack {
5417+
c.cs.Properties.CustomCloudProfile = &CustomCloudProfile{}
5418+
}
5419+
actual := kubeProxyImageSuffix(c.cs)
5420+
if !strings.EqualFold(actual, c.expected) {
5421+
t.Errorf("expected %s to be %s", actual, c.expected)
5422+
}
5423+
})
5424+
}
5425+
}

0 commit comments

Comments
 (0)