Skip to content

Commit

Permalink
Remove multiclustercidr logic from code
Browse files Browse the repository at this point in the history
Remove all logic around multiclustercidr flag becasuse
Kubernetes 1.29 has removed ClusterCIDR type completely from the networking group

Signed-off-by: galal-hussein <[email protected]>
  • Loading branch information
galal-hussein committed Dec 13, 2023
1 parent 0179277 commit 16edba0
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 16edba0

Please sign in to comment.