Skip to content

Documentation uses deprecated variables for defining namespace scope in manager options  #6843

@mmeknowis

Description

@mmeknowis

While reading the operator-scope section, it seems that the documentation contains a deprecated manager Options type:

...
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
    Scheme:             scheme,
    MetricsBindAddress: metricsAddr,
    Port:               9443,
    LeaderElection:     enableLeaderElection,
    LeaderElectionID:   "f1c5ece8.example.com",
    Cache: cache.Options{
      DefaultNamespaces: map[string]cache.Config{"operator-namespace": cache.Config{}},
    },
})
...

But if I check the type [Options}(https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/manager#Options) the variables Port and MetricsBindAddress are missing for me.

We tried on our own to find a valid solution, like:

...
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
    Scheme:             scheme,
    WebhookServer: webhook.NewServer(webhook.Options{Port: 9443}),
    Metrics:       server.Options{BindAddress: metricsAddr},
    LeaderElection:     enableLeaderElection,
    LeaderElectionID:   "f1c5ece8.example.com",
    Cache: cache.Options{
      DefaultNamespaces: map[string]cache.Config{"operator-namespace": cache.Config{}},
    },
})
...

But we are getting strange errors when we start the operator:

{"level":"ERROR","@timestamp":"2024-10-15T11:06:07.370Z","logger":"client-go","caller":"leaderelection/leaderelection.go:332","message":"error retrieving resource lock operator-namespace/f1c5ece8.example.com: Get \"https://172.30.0.1:443/apis/coordination.k8s.io/v1/namespaces/ioperator-namespace/leases/f1c5ece8.example.com\"

What would be a valid new example for watching resources in a specific namespace or are we doing something wrong?

Thanks a lot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions