kubernetes/kops · critical

error creating KopsConfig controller: %w

Error message

error creating KopsConfig controller: %w

What it means

This error wraps failures from NewKopsConfigReconciler during RegisterControllers (pkg/controllers/clusterapi/register.go:27-29). The reconciler constructor calls ctrl.NewControllerManagedBy(mgr).For(&api.KopsConfig{}).Complete(r), so the error surfaces if the controller-runtime builder cannot set up watches for KopsConfig — most commonly because the KopsConfig CRD is not registered in the manager's scheme or the CRD is not installed in the cluster.

Source

Thrown at pkg/controllers/clusterapi/register.go:28

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package clusterapi

import (
	"fmt"

	"k8s.io/kops/pkg/client/simple"
	"sigs.k8s.io/controller-runtime/pkg/manager"
)

func RegisterControllers(mgr manager.Manager, clientset simple.Clientset) error {
	if err := NewKopsConfigReconciler(mgr, clientset); err != nil {
		return fmt.Errorf("error creating KopsConfig controller: %w", err)
	}

	if err := NewClusterReconciler(mgr); err != nil {
		return fmt.Errorf("error creating Cluster controller: %w", err)
	}

	return nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Check the wrapped error: if it mentions 'no kind is registered' / 'no matches', the scheme lacks the KopsConfig type — ensure main registers kops v1beta1 bootstrap/controlplane types via AddToScheme before RegisterControllers.
  2. Install the kops cluster-api CRDs in the management cluster (apply the CRDs from the kops release / helm chart matching the controller version).
  3. Verify the controller image and CRD manifests are the same version — mismatched chart and binary cause scheme/CRD drift.
  4. Restart the controller after installing the CRDs; the manager performs a fresh discovery at startup.
  5. Confirm the manager is built with the correct scheme in main (scheme literal / clientgoscheme + kops AddToScheme calls).

Example fix

// before: scheme missing kops types in main
mgr, err := ctrl.NewManager(cfg, ctrl.Options{Scheme: scheme}) // scheme lacks kops bootstrap types
// after
if err := bootstrapv1.AddToScheme(scheme); err != nil { // api/v1beta1 (bootstrap.kops.k8s.io)
	return err
}
mgr, err := ctrl.NewManager(cfg, ctrl.Options{Scheme: scheme})
Defensive patterns

Strategy: validation

Validate before calling

// Startup validation before RegisterControllers in main
scheme := runtime.NewScheme()
if err := clientgoscheme.AddToScheme(scheme); err != nil {
	return err
}
if err := bootstrapkopsapi.AddToScheme(scheme); err != nil { // KopsConfig kind
	return fmt.Errorf("kops bootstrap scheme not registered: %w", err)
}
// Verify CRDs exist in the cluster:
_, err := discoveryClient.ServerResourcesForGroupVersion("bootstrap.kops.k8s.io/v1beta1")
if err != nil {
	return fmt.Errorf("KopsConfig CRD not installed in management cluster: %w", err)
}

Try / catch

if err := RegisterControllers(mgr, clientset); err != nil {
	setupLog.Error(err, "cannot register controllers — check scheme registration and installed CRDs")
	os.Exit(1) // fail fast; do not run a manager with missing controllers
}

Prevention

When it happens

Trigger: The kops v1beta1 API types are not added to the manager's scheme so Complete fails to build the controller for the unknown type; the KopsConfig CRD (bootstrap.kops.k8s.io) is not installed in the management cluster; the manager has not started / scheme is misconfigured in main.

Common situations: Deploying the kops cluster-api controller against a management cluster where the kops bootstrap provider CRDs were never applied (make release / helm chart skipped); a version mismatch where the controller binary expects CRDs (v1beta1) that the installed chart provides at a different version; running the controller binary outside the intended main entrypoint with a scheme lacking kops types.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/724d0ec8da9fcbe0. Report an issue: GitHub.