Skip to content

Commit

Permalink
Switch back to use kube-system as default namespace to look for confi…
Browse files Browse the repository at this point in the history
…g map of pool

Signed-off-by: Lubron Zhan <lubronzhan@gmail.com>
  • Loading branch information
lubronzhan committed Jan 19, 2024
1 parent c140aeb commit 4380fe3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions pkg/provider/loadBalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ const (
// kubevipLoadBalancerManager -
type kubevipLoadBalancerManager struct {
kubeClient kubernetes.Interface
nameSpace string
namespace string
cloudConfigMap string
}

func newLoadBalancer(kubeClient kubernetes.Interface, ns, cm string) cloudprovider.LoadBalancer {
k := &kubevipLoadBalancerManager{
kubeClient: kubeClient,
nameSpace: ns,
namespace: ns,
cloudConfigMap: cm,
}
return k
Expand Down Expand Up @@ -145,11 +145,11 @@ func (k *kubevipLoadBalancerManager) syncLoadBalancer(ctx context.Context, servi
}

// Get the clound controller configuration map
controllerCM, err := k.GetConfigMap(ctx, k.cloudConfigMap, k.nameSpace)
controllerCM, err := k.GetConfigMap(ctx, k.cloudConfigMap, k.namespace)
if err != nil {
klog.Errorf("Unable to retrieve kube-vip ipam config from configMap [%s] in %s", k.cloudConfigMap, k.nameSpace)
klog.Errorf("Unable to retrieve kube-vip ipam config from configMap [%s] in %s", k.cloudConfigMap, k.namespace)
// TODO - determine best course of action, create one if it doesn't exist
controllerCM, err = k.CreateConfigMap(ctx, k.cloudConfigMap, k.nameSpace)
controllerCM, err = k.CreateConfigMap(ctx, k.cloudConfigMap, k.namespace)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/provider/loadBalancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -864,15 +864,15 @@ func Test_syncLoadBalancer(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ns := KubeVipClientConfigNamespace
cm := KubeVipCloudConfig
cm := KubeVipClientConfig
if tt.poolConfigMap != nil {
ns = tt.poolConfigMap.GetObjectMeta().GetNamespace()
cm = tt.poolConfigMap.GetObjectMeta().GetName()
}

mgr := &kubevipLoadBalancerManager{
kubeClient: fake.NewSimpleClientset(),
nameSpace: ns,
namespace: ns,
cloudConfigMap: cm,
}

Expand Down
10 changes: 5 additions & 5 deletions pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/klog"

cloudprovider "k8s.io/cloud-provider"
)
Expand All @@ -22,9 +23,6 @@ const (
//ProviderName is the name of the cloud provider
ProviderName = "kubevip"

//KubeVipCloudConfig is the default name of the load balancer config Map
KubeVipCloudConfig = "kubevip"

//KubeVipClientConfig is the default name of the load balancer config Map
KubeVipClientConfig = "kubevip"

Expand All @@ -51,13 +49,15 @@ func newKubeVipCloudProvider(io.Reader) (cloudprovider.Interface, error) {
cm := os.Getenv("KUBEVIP_CONFIG_MAP")

if cm == "" {
cm = KubeVipCloudConfig
cm = KubeVipClientConfig
}

if ns == "" {
ns = "default"
ns = KubeVipClientConfigNamespace
}

klog.Infof("Watching configMap for pool config with name: '%s', namespace: '%s'", cm, ns)

var cl *kubernetes.Clientset
if !OutSideCluster {
// This will attempt to load the configuration when running within a POD
Expand Down

0 comments on commit 4380fe3

Please sign in to comment.