Skip to content

Commit

Permalink
fix: ensure addon hostNetwork ports don't conflict (Azure#3894)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackfrancis authored and penggu committed Oct 28, 2020
1 parent d26aa60 commit a519330
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 9 deletions.
3 changes: 2 additions & 1 deletion parts/k8s/addons/aad-pod-identity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ spec:
args:
- "--host-ip=$(HOST_IP)"
- "--node=$(NODE_NAME)"
- "--http-probe-port={{ContainerConfig "probePort"}}"
env:
- name: HOST_IP
valueFrom:
Expand Down Expand Up @@ -182,7 +183,7 @@ spec:
livenessProbe:
httpGet:
path: /healthz
port: 8080
port: {{ContainerConfig "probePort"}}
initialDelaySeconds: 10
periodSeconds: 5
nodeSelector:
Expand Down
2 changes: 1 addition & 1 deletion parts/k8s/addons/secrets-store-csi-driver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ spec:
- "--nodeid=$(KUBE_NODE_NAME)"
- "--provider-volume=/etc/kubernetes/secrets-store-csi-providers"
- "--grpc-supported-providers=azure"
- "--metrics-addr=:8080"
- "--metrics-addr=:{{ContainerConfig "metricsPort"}}"
env:
- name: CSI_ENDPOINT
value: unix:///csi/csi.sock
Expand Down
6 changes: 6 additions & 0 deletions pkg/api/addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@ func (cs *ContainerService) setAddonsConfig(isUpgrade bool) {
defaultsAADPodIdentityAddonsConfig := KubernetesAddon{
Name: common.AADPodIdentityAddonName,
Enabled: to.BoolPtr(DefaultAADPodIdentityAddonEnabled && !cs.Properties.IsAzureStackCloud()),
Config: map[string]string{
"probePort": "8085",
},
Containers: []KubernetesContainerSpec{
{
Name: common.NMIContainerName,
Expand Down Expand Up @@ -839,6 +842,9 @@ func (cs *ContainerService) setAddonsConfig(isUpgrade bool) {

defaultSecretsStoreCSIDriverAddonsConfig := KubernetesAddon{
Name: common.SecretsStoreCSIDriverAddonName,
Config: map[string]string{
"metricsPort": "8095",
},
Enabled: to.BoolPtr(!o.KubernetesConfig.IsAddonEnabled(common.KeyVaultFlexVolumeAddonName) && DefaultSecretStoreCSIDriverAddonEnabled &&
common.IsKubernetesVersionGe(o.OrchestratorVersion, "1.16.0")),
Containers: []KubernetesContainerSpec{
Expand Down
9 changes: 9 additions & 0 deletions pkg/api/addons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1916,6 +1916,9 @@ func TestSetAddonsConfig(t *testing.T) {
{
Name: common.AADPodIdentityAddonName,
Enabled: to.BoolPtr(true),
Config: map[string]string{
"probePort": "8085",
},
Containers: []KubernetesContainerSpec{
{
Name: common.NMIContainerName,
Expand Down Expand Up @@ -4425,6 +4428,9 @@ func TestSetAddonsConfig(t *testing.T) {
{
Name: common.SecretsStoreCSIDriverAddonName,
Enabled: to.BoolPtr(true),
Config: map[string]string{
"metricsPort": "8095",
},
},
}, "1.15.4"),
},
Expand Down Expand Up @@ -5200,6 +5206,9 @@ func getDefaultAddons(version, kubernetesImageBase, kubernetesImageBaseType stri
addons = append(addons, KubernetesAddon{
Name: common.SecretsStoreCSIDriverAddonName,
Enabled: to.BoolPtr(true),
Config: map[string]string{
"metricsPort": "8095",
},
Containers: []KubernetesContainerSpec{
{
Name: common.CSILivenessProbeContainerName,
Expand Down
5 changes: 3 additions & 2 deletions pkg/engine/templates_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions test/e2e/kubernetes/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -800,10 +800,16 @@ func AreAllPodsRunning(podPrefix, namespace string) (bool, error) {
return false, regexErr
}
if matched {
if pod.Status.Phase != "Running" {
if pod.Status.Phase == "Running" {
for _, containerStatus := range pod.Status.ContainerStatuses {
if containerStatus.Ready {
status = append(status, true)
} else {
status = append(status, false)
}
}
} else if pod.Status.Phase != "Pending" && pod.Status.Phase != "ImagePullBackOff" && pod.Status.Phase != "ContainerCreating" {
status = append(status, false)
} else {
status = append(status, true)
}
}
}
Expand All @@ -814,11 +820,11 @@ func AreAllPodsRunning(podPrefix, namespace string) (bool, error) {

for _, s := range status {
if !s {
return false, nil
return false, errors.Errorf("At least one pod has a container in a non-Ready state")
}
}

return true, err
return true, nil
}

// AreAllPodsSucceededResult is a return struct for AreAllPodsSucceeded
Expand Down

0 comments on commit a519330

Please sign in to comment.