Skip to content

Commit

Permalink
chore: optimize namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
iziang committed Dec 24, 2023
1 parent 6256f16 commit 4d3c966
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions pkg/controllerutil/controller_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import (

"github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/constant"
viper "github.com/apecloud/kubeblocks/pkg/viperx"
)

// ResultToP converts a Result object to a pointer.
Expand Down Expand Up @@ -290,20 +291,16 @@ const (
// The TCP/IP port numbers below 1024 are special in that normal users are not allowed to run servers on them.
// This is a security feaure, in that if you connect to a service on one of these ports you can be fairly sure
// that you have the real thing, and not a fake which some hacker has put up for you.
hostPortMin = int32(1025)
hostPortMax = int32(65536)
hostPortConfigMapName = "kubeblocks-host-ports"
hostPortConfigMapNamespace = "default"
hostPortMin = int32(1025)
hostPortMax = int32(65536)
hostPortConfigMapName = "kubeblocks-host-ports"
)

func InitHostPortManager(cli client.Client) error {
cm := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: hostPortConfigMapName,
// TODO use the namespace where the operator is running in
Namespace: hostPortConfigMapNamespace,
// TODO add finalizers
Finalizers: make([]string, 0),
Name: hostPortConfigMapName,
Namespace: viper.GetString(constant.CfgKeyCtrlrMgrNS),
},
Data: make(map[string]string),
}
Expand Down Expand Up @@ -347,7 +344,10 @@ func NewPortManager(min, max int32, cli client.Client) (*PortManager, error) {

func (pm *PortManager) sync() error {
cm := &corev1.ConfigMap{}
objKey := types.NamespacedName{Name: hostPortConfigMapName, Namespace: hostPortConfigMapNamespace}
objKey := types.NamespacedName{
Name: hostPortConfigMapName,
Namespace: viper.GetString(constant.CfgKeyCtrlrMgrNS),
}
if err := pm.cli.Get(context.Background(), objKey, cm); err != nil {
return err
}
Expand Down

0 comments on commit 4d3c966

Please sign in to comment.