Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support pool-coordinator component work in specified namespace #1355

Merged
merged 1 commit into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions charts/openyurt/templates/yurt-manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ spec:
- --health-probe-addr=:{{ .Values.yurtManager.healthProbe.port }}
- --logtostderr=true
- --v={{ .Values.yurtManager.log.level }}
- --working-namespace={{ .Release.Namespace | quote }}
command:
- /usr/local/bin/yurt-manager
image: {{ .Values.yurtManager.image.repository }}:{{ .Values.yurtManager.image.tag }}
Expand Down
6 changes: 4 additions & 2 deletions cmd/yurt-manager/app/options/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func NewGenericOptions() *GenericOptions {
LeaderElectionNamespace: "kube-system",
RestConfigQPS: 30,
RestConfigBurst: 50,
WorkingNamespace: "kube-system",
},
}
}
Expand All @@ -61,9 +62,10 @@ func (o *GenericOptions) ApplyTo(cfg *config.GenericConfiguration) error {

cfg.HealthProbeAddr = o.HealthProbeAddr
cfg.EnableLeaderElection = o.EnableLeaderElection
cfg.LeaderElectionNamespace = o.LeaderElectionNamespace
cfg.LeaderElectionNamespace = o.WorkingNamespace
cfg.RestConfigQPS = o.RestConfigQPS
cfg.RestConfigBurst = o.RestConfigBurst
cfg.WorkingNamespace = o.WorkingNamespace

return nil
}
Expand All @@ -78,8 +80,8 @@ func (o *GenericOptions) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&o.MetricsAddr, "metrics-addr", o.MetricsAddr, "The address the metric endpoint binds to.")
fs.StringVar(&o.HealthProbeAddr, "health-probe-addr", o.HealthProbeAddr, "The address the healthz/readyz endpoint binds to.")
fs.BoolVar(&o.EnableLeaderElection, "enable-leader-election", o.EnableLeaderElection, "Whether you need to enable leader election.")
fs.StringVar(&o.LeaderElectionNamespace, "leader-election-namespace", o.LeaderElectionNamespace, "This determines the namespace in which the leader election configmap/leases will be created, it will use in-cluster namespace if empty.")

fs.IntVar(&o.RestConfigQPS, "rest-config-qps", o.RestConfigQPS, "rest-config-qps.")
fs.IntVar(&o.RestConfigBurst, "rest-config-burst", o.RestConfigBurst, "rest-config-burst.")
fs.StringVar(&o.WorkingNamespace, "working-namespace", o.WorkingNamespace, "The namespace where the yurt-manager is working.")
}
1 change: 1 addition & 0 deletions pkg/controller/apis/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ type GenericConfiguration struct {
LeaderElectionNamespace string
RestConfigQPS int
RestConfigBurst int
WorkingNamespace string
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func init() {

var (
concurrentReconciles = 3
PoolcoordinatorNS = "kube-system"
)

const (
Expand All @@ -53,7 +54,6 @@ const (
certDir = "/tmp"

ComponentName = "yurt-controller-manager_poolcoordinator"
PoolcoordinatorNS = "kube-system"
PoolcoordinatorAPIServerSVC = "pool-coordinator-apiserver"
PoolcoordinatorETCDSVC = "pool-coordinator-etcd"

Expand Down Expand Up @@ -203,6 +203,10 @@ func Add(c *appconfig.CompletedConfig, mgr manager.Manager) error {
return err
}

// init global variables
cfg := c.ComponentConfig.Generic
PoolcoordinatorNS = cfg.WorkingNamespace

// init PoolCoordinator
// prepare some necessary assets (CA, certs, kubeconfigs) for pool-coordinator
err = initPoolCoordinator(r.Client, nil)
Expand Down