Skip to content

Commit

Permalink
update sku to use new workload id auth patterning as the backing with…
Browse files Browse the repository at this point in the history
… wrapper
  • Loading branch information
charliedmcb committed Jan 9, 2024
1 parent da40a1c commit 48bdef2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
1 change: 0 additions & 1 deletion Makefile-az.mk
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ az-patch-skaffold: ## Update Azure client env vars and settings in skaffold con
$(eval SSH_PUBLIC_KEY=$(shell cat ~/.ssh/id_rsa.pub) azureuser)
yq -i '(.manifests.helm.releases[0].overrides.controller.env[] | select(.name=="ARM_SUBSCRIPTION_ID")) .value = "$(AZURE_SUBSCRIPTION_ID)"' skaffold.yaml
yq -i '(.manifests.helm.releases[0].overrides.controller.env[] | select(.name=="LOCATION")) .value = "$(AZURE_LOCATION)"' skaffold.yaml
yq -i '(.manifests.helm.releases[0].overrides.controller.env[] | select(.name=="ARM_USER_ASSIGNED_IDENTITY_ID")) .value = "$(KARPENTER_USER_ASSIGNED_CLIENT_ID)"' skaffold.yaml
yq -i '(.manifests.helm.releases[0].overrides.controller.env[] | select(.name=="AZURE_NODE_RESOURCE_GROUP")) .value = "$(AZURE_RESOURCE_GROUP_MC)"' skaffold.yaml
yq -i '.manifests.helm.releases[0].overrides.settings.azure.clusterName = "$(AZURE_CLUSTER_NAME)"' skaffold.yaml
yq -i '.manifests.helm.releases[0].overrides.settings.azure.clusterEndpoint = "$(CLUSTER_ENDPOINT)"' skaffold.yaml
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ require (
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jongio/azidext/go/azidext v0.5.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kelseyhightower/envconfig v1.4.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jongio/azidext/go/azidext v0.5.0 h1:uPInXD4NZ3J0k79FPwIA0YXknFn+WcqZqSgs3/jPgvQ=
github.com/jongio/azidext/go/azidext v0.5.0/go.mod h1:TVRX/hJhzbsCKaOIzicH6a8IvOH0hpjWk/JwZZgtXeU=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
Expand Down
13 changes: 12 additions & 1 deletion pkg/auth/autorest_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,21 @@ import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/adal"
"github.com/Azure/go-autorest/autorest/azure"
klog "k8s.io/klog/v2"
"k8s.io/klog/v2"

"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/jongio/azidext/go/azidext"
)

func NewAuthorizer(config *Config, env *azure.Environment) (autorest.Authorizer, error) {
if config.UseNewCredWorkflow {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
return nil, fmt.Errorf("default cred: %w", err)
}
return azidext.NewTokenCredentialAdapter(cred, []string{azidext.DefaultManagementScope}), nil
}

token, err := newServicePrincipalTokenFromCredentials(config, env)
if err != nil {
return nil, fmt.Errorf("retrieve service principal token: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ manifests:
- name: ARM_USE_NEW_CRED_WORKFLOW
value: "true"
- name: ARM_USE_MANAGED_IDENTITY_EXTENSION
value: "true"
value: "false"
- name: ARM_USER_ASSIGNED_IDENTITY_ID
value: ""
- name: AZURE_NODE_RESOURCE_GROUP
Expand Down

0 comments on commit 48bdef2

Please sign in to comment.