-
Notifications
You must be signed in to change notification settings - Fork 102
/
route-operator-config.go
35 lines (33 loc) · 1.24 KB
/
route-operator-config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package controllers
import (
configv1alpha1 "github.com/liqoTech/liqo/api/config/v1alpha1"
"github.com/liqoTech/liqo/pkg/clusterConfig"
"github.com/liqoTech/liqo/pkg/crdClient"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
"k8s.io/klog/v2"
"os"
)
func (r *RouteController) WatchConfiguration(config *rest.Config, gv *schema.GroupVersion) {
config.ContentConfig.GroupVersion = gv
config.APIPath = "/apis"
config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()
config.UserAgent = rest.DefaultKubernetesUserAgent()
CRDclient, err := crdClient.NewFromConfig(config)
if err != nil {
klog.Error(err, err.Error())
os.Exit(1)
}
go clusterConfig.WatchConfiguration(func(configuration *configv1alpha1.ClusterConfig) {
if !r.IsConfigured {
r.ClusterPodCIDR = configuration.Spec.LiqonetConfig.PodCIDR
r.Configured <- true
}
//check if the podCIDR is different from the one on the cluster config
//TODO: a go routine which removes all the configuration with the old podCIDR and triggers a new configuration for the new podCIDR
if r.ClusterPodCIDR != configuration.Spec.LiqonetConfig.PodCIDR {
r.ClusterPodCIDR = configuration.Spec.LiqonetConfig.PodCIDR
}
}, CRDclient, "")
}