Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated azure-sdk-go modules #705

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading