Skip to content

Commit 2bc0e40

Browse files
jkljajicakshaysngupta
authored andcommitted
Adding option to select corect Cloud Environment endpoint (#675)
1 parent a80cb67 commit 2bc0e40

File tree

4 files changed

+26
-17
lines changed

4 files changed

+26
-17
lines changed

helm/ingress-azure/templates/configmap.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ data:
2121
APPGW_VERBOSITY_LEVEL: {{ .Values.verbosityLevel | quote }}
2222
HTTP_SERVICE_PORT: {{ .Values.kubernetes.httpServicePort | quote }}
2323
USE_PRIVATE_IP: {{ .Values.appgw.usePrivateIP | quote }}
24-
24+
{{- if .Values.appgw.environment }}
25+
AZURE_ENVIRONMENT: {{ .Values.appgw.environment | quote }}
26+
{{- end -}}
2527
{{- if .Values.appgw.applicationGatewayID }}
2628
APPGW_RESOURCE_ID: {{ .Values.appgw.applicationGatewayID | quote }}
2729
{{- else }}

helm/ingress-azure/values-template.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ kubernetes:
2121

2222
################################################################################
2323
# Specify which application gateway the ingress controller will manage
24+
# Specity which cloud environment will be used AZURECHINACLOUD,AZUREGERMANCLOUD,AZUREPUBLICCLOUD,AZUREUSGOVERNMENTCLOUD default: AZUREPUBLICCLOUD
2425
#
2526
# appgw:
27+
# environment: AZUREPUBLICCLOUD
2628
# subscriptionId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
2729
# resourceGroup: myResourceGroup
2830
# name: myApplicationGateway

helm/ingress-azure/values.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ verbosityLevel: 3
99

1010
image:
1111
repository: mcr.microsoft.com/azure-application-gateway/kubernetes-ingress
12-
tag: 0.7.1
12+
tag: 1.0.0
1313
pullPolicy: Always
1414

1515

@@ -25,12 +25,14 @@ kubernetes:
2525

2626
################################################################################
2727
# Specify which application gateway the ingress controller will manage
28+
# Specity which cloud environment will be used AZURECHINACLOUD,AZUREGERMANCLOUD,AZUREPUBLICCLOUD,AZUREUSGOVERNMENTCLOUD default: AZUREPUBLICCLOUD
2829
#
29-
appgw:
30-
subscriptionId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
31-
resourceGroup: myResourceGroup
32-
name: myApplicationGateway
33-
usePrivateIP: false
30+
# appgw:
31+
# environment: AZUREPUBLICCLOUD
32+
# subscriptionId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
33+
# resourceGroup: myResourceGroup
34+
# name: myApplicationGateway
35+
# usePrivateIP: false
3436

3537
################################################################################
3638
# Specify the authentication with Azure Resource Manager
@@ -54,5 +56,3 @@ appgw:
5456
# Specify if the cluster is RBAC enabled or not
5557
rbac:
5658
enabled: false # true/false
57-
58-
nodeSelector: {}

pkg/azure/client.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import (
1111
"errors"
1212
"fmt"
1313

14+
"github.com/Azure/application-gateway-kubernetes-ingress/pkg/version"
1415
r "github.com/Azure/azure-sdk-for-go/profiles/latest/resources/mgmt/resources"
1516
n "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2019-09-01/network"
1617
"github.com/Azure/go-autorest/autorest"
18+
"github.com/Azure/go-autorest/autorest/azure/auth"
1719
"github.com/golang/glog"
18-
19-
"github.com/Azure/application-gateway-kubernetes-ingress/pkg/version"
2020
)
2121

2222
// AzClient is an interface for client to Azure
@@ -48,14 +48,19 @@ type azClient struct {
4848

4949
// NewAzClient returns an Azure Client
5050
func NewAzClient(subscriptionID SubscriptionID, resourceGroupName ResourceGroup, appGwName ResourceName, authorizer autorest.Authorizer) AzClient {
51+
settings, err := auth.GetSettingsFromEnvironment()
52+
if err != nil {
53+
return nil
54+
}
55+
5156
userAgent := fmt.Sprintf("ingress-appgw/%s", version.Version)
5257
az := &azClient{
53-
appGatewaysClient: n.NewApplicationGatewaysClient(string(subscriptionID)),
54-
publicIPsClient: n.NewPublicIPAddressesClient(string(subscriptionID)),
55-
virtualNetworksClient: n.NewVirtualNetworksClient(string(subscriptionID)),
56-
subnetsClient: n.NewSubnetsClient(string(subscriptionID)),
57-
groupsClient: r.NewGroupsClient(string(subscriptionID)),
58-
deploymentsClient: r.NewDeploymentsClient(string(subscriptionID)),
58+
appGatewaysClient: n.NewApplicationGatewaysClientWithBaseURI(settings.Environment.ResourceManagerEndpoint, string(subscriptionID)),
59+
publicIPsClient: n.NewPublicIPAddressesClientWithBaseURI(settings.Environment.ResourceManagerEndpoint, string(subscriptionID)),
60+
virtualNetworksClient: n.NewVirtualNetworksClientWithBaseURI(settings.Environment.ResourceManagerEndpoint, string(subscriptionID)),
61+
subnetsClient: n.NewSubnetsClientWithBaseURI(settings.Environment.ResourceManagerEndpoint, string(subscriptionID)),
62+
groupsClient: r.NewGroupsClientWithBaseURI(settings.Environment.ResourceManagerEndpoint, string(subscriptionID)),
63+
deploymentsClient: r.NewDeploymentsClientWithBaseURI(settings.Environment.ResourceManagerEndpoint, string(subscriptionID)),
5964

6065
subscriptionID: subscriptionID,
6166
resourceGroupName: resourceGroupName,

0 commit comments

Comments
 (0)