Skip to content

Commit

Permalink
Merge pull request #1838 from galal-hussein/remove_mulitcluster_cidr_…
Browse files Browse the repository at this point in the history
…logic

Remove multiclustercidr logic from code
  • Loading branch information
manuelbuil committed Dec 18, 2023
2 parents 0179277 + 16edba0 commit 207d5cd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 138 deletions.
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ func newSubnetManager(ctx context.Context) (subnet.Manager, error) {
opts.kubeConfigFile,
opts.kubeAnnotationPrefix,
opts.netConfPath,
opts.setNodeNetworkUnavailable,
false)
opts.setNodeNetworkUnavailable)
}

cfg := &etcd.EtcdConfig{
Expand Down
101 changes: 0 additions & 101 deletions pkg/subnet/kube/cluster_cidr.go

This file was deleted.

38 changes: 3 additions & 35 deletions pkg/subnet/kube/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"github.com/flannel-io/flannel/pkg/subnet"
"golang.org/x/net/context"
v1 "k8s.io/api/core/v1"
networkingv1alpha1 "k8s.io/api/networking/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -77,7 +76,7 @@ type kubeSubnetManager struct {
snFileInfo *subnetFileInfo
}

func NewSubnetManager(ctx context.Context, apiUrl, kubeconfig, prefix, netConfPath string, setNodeNetworkUnavailable, useMultiClusterCidr bool) (subnet.Manager, error) {
func NewSubnetManager(ctx context.Context, apiUrl, kubeconfig, prefix, netConfPath string, setNodeNetworkUnavailable bool) (subnet.Manager, error) {
var cfg *rest.Config
var err error
// Try to build kubernetes config from a master url or a kubeconfig filepath. If neither masterUrl
Expand Down Expand Up @@ -124,14 +123,7 @@ func NewSubnetManager(ctx context.Context, apiUrl, kubeconfig, prefix, netConfPa
return nil, fmt.Errorf("error parsing subnet config: %s", err)
}

if useMultiClusterCidr {
err = readFlannelNetworksFromClusterCIDRList(ctx, c, sc)
if err != nil {
return nil, fmt.Errorf("error reading flannel networks from k8s api: %s", err)
}
}

sm, err := newKubeSubnetManager(ctx, c, sc, nodeName, prefix, useMultiClusterCidr)
sm, err := newKubeSubnetManager(ctx, c, sc, nodeName, prefix)
if err != nil {
return nil, fmt.Errorf("error creating network manager: %s", err)
}
Expand All @@ -157,7 +149,7 @@ func NewSubnetManager(ctx context.Context, apiUrl, kubeconfig, prefix, netConfPa

// newKubeSubnetManager fills the kubeSubnetManager. The most important part is the controller which will
// watch for kubernetes node updates
func newKubeSubnetManager(ctx context.Context, c clientset.Interface, sc *subnet.Config, nodeName, prefix string, useMultiClusterCidr bool) (*kubeSubnetManager, error) {
func newKubeSubnetManager(ctx context.Context, c clientset.Interface, sc *subnet.Config, nodeName, prefix string) (*kubeSubnetManager, error) {
var err error
var ksm kubeSubnetManager
ksm.annotations, err = newAnnotations(prefix)
Expand Down Expand Up @@ -228,30 +220,6 @@ func newKubeSubnetManager(ctx context.Context, c clientset.Interface, sc *subnet
ksm.nodeStore = listers.NewNodeLister(indexer)
}

if useMultiClusterCidr {
_, clusterController := cache.NewIndexerInformer(
&cache.ListWatch{
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return ksm.client.NetworkingV1alpha1().ClusterCIDRs().List(ctx, options)
},
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return ksm.client.NetworkingV1alpha1().ClusterCIDRs().Watch(ctx, options)
},
},
&networkingv1alpha1.ClusterCIDR{},
resyncPeriod,
cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
ksm.handleAddClusterCidr(obj)
},
DeleteFunc: func(obj interface{}) {
ksm.handleDeleteClusterCidr(obj)
},
},
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
ksm.clusterCIDRController = clusterController
}
return &ksm, nil
}

Expand Down

0 comments on commit 207d5cd

Please sign in to comment.