Skip to content

Commit

Permalink
Merge pull request #705 from mjura/azure-sdk-go
Browse files Browse the repository at this point in the history
Remove deprecated azure-sdk-go modules
  • Loading branch information
yiannistri authored Oct 30, 2024
2 parents 72d18d7 + 8338522 commit 4486c7b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
13 changes: 6 additions & 7 deletions controller/aks-cluster-config-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v5"
"github.com/Azure/azure-sdk-for-go/services/containerservice/mgmt/2020-11-01/containerservice"
wranglerv1 "github.com/rancher/wrangler/v3/pkg/generated/controllers/core/v1"
"github.com/sirupsen/logrus"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -437,20 +436,20 @@ func (h *Handler) validateConfig(config *aksv1.AKSClusterConfig) error {
}

if config.Spec.NetworkPlugin != nil &&
aks.String(config.Spec.NetworkPlugin) != string(containerservice.Kubenet) &&
aks.String(config.Spec.NetworkPlugin) != string(containerservice.Azure) {
aks.String(config.Spec.NetworkPlugin) != string(armcontainerservice.NetworkPluginKubenet) &&
aks.String(config.Spec.NetworkPlugin) != string(armcontainerservice.NetworkPluginAzure) {
return fmt.Errorf("invalid network plugin value [%s] for [%s (id: %s)] cluster config", aks.String(config.Spec.NetworkPlugin), config.Spec.ClusterName, config.Name)
}
if config.Spec.NetworkPolicy != nil &&
aks.String(config.Spec.NetworkPolicy) != string(containerservice.NetworkPolicyAzure) &&
aks.String(config.Spec.NetworkPolicy) != string(containerservice.NetworkPolicyCalico) {
aks.String(config.Spec.NetworkPolicy) != string(armcontainerservice.NetworkPolicyAzure) &&
aks.String(config.Spec.NetworkPolicy) != string(armcontainerservice.NetworkPolicyCalico) {
return fmt.Errorf("invalid network policy value [%s] for [%s (id: %s)] cluster config", aks.String(config.Spec.NetworkPolicy), config.Spec.ClusterName, config.Name)
}
if aks.String(config.Spec.NetworkPolicy) == string(containerservice.NetworkPolicyAzure) && aks.String(config.Spec.NetworkPlugin) != string(containerservice.Azure) {
if aks.String(config.Spec.NetworkPolicy) == string(armcontainerservice.NetworkPolicyAzure) && aks.String(config.Spec.NetworkPlugin) != string(armcontainerservice.NetworkPluginAzure) {
return fmt.Errorf("azure network policy can be used only with Azure CNI network plugin for [%s (id: %s)] cluster", config.Spec.ClusterName, config.Name)
}
cannotBeNilErrorAzurePlugin := "field [%s] must be provided for cluster [%s (id: %s)] config when Azure CNI network plugin is used"
if aks.String(config.Spec.NetworkPlugin) == string(containerservice.Azure) {
if aks.String(config.Spec.NetworkPlugin) == string(armcontainerservice.NetworkPluginAzure) {
if config.Spec.VirtualNetwork == nil {
return fmt.Errorf(cannotBeNilErrorAzurePlugin, "virtualNetwork", config.Spec.ClusterName, config.Name)
}
Expand Down
21 changes: 10 additions & 11 deletions pkg/aks/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v5"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources"
"github.com/Azure/azure-sdk-for-go/services/containerservice/mgmt/2020-11-01/containerservice"
"github.com/rancher/aks-operator/pkg/aks/services"
aksv1 "github.com/rancher/aks-operator/pkg/apis/aks.cattle.io/v1"
"github.com/rancher/aks-operator/pkg/utils"
Expand Down Expand Up @@ -82,18 +81,18 @@ func createManagedCluster(ctx context.Context, cred *Credentials, workplacesClie
networkProfile := &armcontainerservice.NetworkProfile{}

switch String(spec.OutboundType) {
case string(containerservice.LoadBalancer):
case string(armcontainerservice.OutboundTypeLoadBalancer):
networkProfile.OutboundType = to.Ptr(armcontainerservice.OutboundTypeLoadBalancer)
case string(containerservice.UserDefinedRouting):
case string(armcontainerservice.OutboundTypeUserDefinedRouting):
networkProfile.OutboundType = to.Ptr(armcontainerservice.OutboundTypeUserDefinedRouting)
case "":
networkProfile.OutboundType = to.Ptr(armcontainerservice.OutboundTypeLoadBalancer)
}

switch String(spec.NetworkPolicy) {
case string(containerservice.NetworkPolicyAzure):
case string(armcontainerservice.NetworkPolicyAzure):
networkProfile.NetworkPolicy = to.Ptr(armcontainerservice.NetworkPolicyAzure)
case string(containerservice.NetworkPolicyCalico):
case string(armcontainerservice.NetworkPolicyCalico):
networkProfile.NetworkPolicy = to.Ptr(armcontainerservice.NetworkPolicyCalico)
case "":
networkProfile.NetworkPolicy = nil
Expand All @@ -102,34 +101,34 @@ func createManagedCluster(ctx context.Context, cred *Credentials, workplacesClie
}

switch String(spec.NetworkPlugin) {
case string(containerservice.Azure):
case string(armcontainerservice.NetworkPluginAzure):
networkProfile.NetworkPlugin = to.Ptr(armcontainerservice.NetworkPluginAzure)
case string(containerservice.Kubenet):
case string(armcontainerservice.NetworkPluginKubenet):
networkProfile.NetworkPlugin = to.Ptr(armcontainerservice.NetworkPluginKubenet)
case "":
networkProfile.NetworkPlugin = to.Ptr(armcontainerservice.NetworkPluginKubenet)
default:
return nil, fmt.Errorf("networkPlugin '%s' is not supported", String(spec.NetworkPlugin))
}

if *networkProfile.NetworkPlugin == armcontainerservice.NetworkPluginKubenet && String(spec.NetworkPolicy) == string(containerservice.NetworkPolicyAzure) {
if *networkProfile.NetworkPlugin == armcontainerservice.NetworkPluginKubenet && String(spec.NetworkPolicy) == string(armcontainerservice.NetworkPolicyAzure) {
return nil, fmt.Errorf("network plugin Kubenet is not compatible with network policy Azure")
}

networkProfile.LoadBalancerSKU = to.Ptr(armcontainerservice.LoadBalancerSKUStandard)

if String(spec.LoadBalancerSKU) == string(containerservice.Basic) {
if String(spec.LoadBalancerSKU) == string(armcontainerservice.LoadBalancerSKUBasic) {
logrus.Warnf("LoadBalancerSKU 'basic' is not supported")
networkProfile.LoadBalancerSKU = to.Ptr(armcontainerservice.LoadBalancerSKUBasic)
}

// Disable standard loadbalancer for UserDefinedRouting and use routing created by user pre-defined table for egress
if String(spec.OutboundType) == string(containerservice.UserDefinedRouting) {
if String(spec.OutboundType) == string(armcontainerservice.OutboundTypeUserDefinedRouting) {
networkProfile.LoadBalancerSKU = nil
}

virtualNetworkResourceGroup := spec.ResourceGroup
if containerservice.NetworkPlugin(String(spec.NetworkPlugin)) == containerservice.Azure || containerservice.NetworkPlugin(String(spec.NetworkPlugin)) == containerservice.Kubenet {
if armcontainerservice.NetworkPlugin(String(spec.NetworkPlugin)) == armcontainerservice.NetworkPluginAzure || armcontainerservice.NetworkPlugin(String(spec.NetworkPlugin)) == armcontainerservice.NetworkPluginKubenet {
// If a virtual network resource group is set, use it, otherwise assume it is the same as the cluster
if String(spec.VirtualNetworkResourceGroup) != "" {
virtualNetworkResourceGroup = String(spec.VirtualNetworkResourceGroup)
Expand Down

0 comments on commit 4486c7b

Please sign in to comment.