Skip to content

Commit

Permalink
Fix issue with apiserver when using AADProfile (Azure#2047) (Azure#2055)
Browse files Browse the repository at this point in the history
* Fix issue with apiserver when using AADProfile (Azure#2047)

* fixing failed test

* missed another test
  • Loading branch information
tesharp authored and jackfrancis committed Jan 16, 2018
1 parent 39ec217 commit d53a2fc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
6 changes: 0 additions & 6 deletions parts/k8s/kubernetesmastercustomdata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,6 @@ MASTER_ARTIFACTS_CONFIG_PLACEHOLDER
sed -i "s|<kubernetesControllerManagerConfig>|{{GetK8sRuntimeConfigKeyVals .OrchestratorProfile.KubernetesConfig.ControllerManagerConfig}}|g" "/etc/kubernetes/manifests/kube-controller-manager.yaml"
sed -i "s|<kubernetesAPIServerConfig>|{{GetK8sRuntimeConfigKeyVals .OrchestratorProfile.KubernetesConfig.APIServerConfig}}|g" "/etc/kubernetes/manifests/kube-apiserver.yaml"
sed -i "s|<kubernetesAPIServerIP>|{{WrapAsVariable "kubernetesAPIServerIP"}}|g" "/etc/kubernetes/manifests/kube-apiserver.yaml"
{{ if .HasAadProfile }}
VAR_AAD_TENANT_ID={{WrapAsVariable "aadTenantId"}}
VAR_TENANT_ID={{WrapAsVariable "tenantId"}}
AAD_TENANT_ID=${VAR_AAD_TENANT_ID:-$VAR_TENANT_ID}
sed -i "/--oidc-issuer-url/s/$/$AAD_TENANT_ID/" "/etc/kubernetes/manifests/kube-apiserver.yaml"
{{end}}

- path: "/opt/azure/containers/provision.sh"
permissions: "0744"
Expand Down
2 changes: 1 addition & 1 deletion pkg/acsengine/defaults-apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func setAPIServerConfig(cs *api.ContainerService) {
if GetCloudTargetEnv(cs.Location) == "AzureChinaCloud" {
issuerHost = "sts.chinacloudapi.cn"
}
staticLinuxAPIServerConfig["--oidc-issuer-url"] = "https://" + issuerHost + "/"
staticLinuxAPIServerConfig["--oidc-issuer-url"] = "https://" + issuerHost + "/" + cs.Properties.AADProfile.TenantID + "/"
}

staticWindowsAPIServerConfig := make(map[string]string)
Expand Down
6 changes: 4 additions & 2 deletions pkg/acsengine/defaults-apiserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ func TestAPIServerConfigHasAadProfile(t *testing.T) {
cs := createContainerService("testcluster", common.KubernetesVersion1Dot7Dot12, 3, 2)
cs.Properties.AADProfile = &api.AADProfile{
ServerAppID: "test-id",
TenantID: "test-tenant",
}
setAPIServerConfig(cs)
a := cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig
Expand All @@ -130,7 +131,7 @@ func TestAPIServerConfigHasAadProfile(t *testing.T) {
t.Fatalf("got unexpected '--oidc-client-id' API server config value for HasAadProfile=true: %s",
a["--oidc-client-id"])
}
if a["--oidc-issuer-url"] != "https://sts.windows.net/" {
if a["--oidc-issuer-url"] != "https://sts.windows.net/"+cs.Properties.AADProfile.TenantID+"/" {
t.Fatalf("got unexpected '--oidc-issuer-url' API server config value for HasAadProfile=true: %s",
a["--oidc-issuer-url"])
}
Expand All @@ -139,11 +140,12 @@ func TestAPIServerConfigHasAadProfile(t *testing.T) {
cs = createContainerService("testcluster", common.KubernetesVersion1Dot7Dot12, 3, 2)
cs.Properties.AADProfile = &api.AADProfile{
ServerAppID: "test-id",
TenantID: "test-tenant",
}
cs.Location = "chinaeast"
setAPIServerConfig(cs)
a = cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig
if a["--oidc-issuer-url"] != "https://sts.chinacloudapi.cn/" {
if a["--oidc-issuer-url"] != "https://sts.chinacloudapi.cn/"+cs.Properties.AADProfile.TenantID+"/" {
t.Fatalf("got unexpected '--oidc-issuer-url' API server config value for HasAadProfile=true using China cloud: %s",
a["--oidc-issuer-url"])
}
Expand Down

0 comments on commit d53a2fc

Please sign in to comment.