{"record":{"id":"5febbcf09df2980f","repo":"kubernetes/kops","slug":"failed-to-initialize-the-ingress-controller-error","errorCode":null,"errorMessage":"failed to initialize the ingress controller, error: %v","messagePattern":"failed to initialize the ingress controller, error: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dns-controller/cmd/dns-controller/main.go","lineNumber":175,"sourceCode":"\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to initialize the node controller, error: %v\", err)\n\t}\n\n\tpodController, err := watchers.NewPodController(client, dnsctl, namespace)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to initialize the pod controller, error: %v\", err)\n\t}\n\n\tserviceController, err := watchers.NewServiceController(client, dnsctl, namespace)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to initialize the service controller, error: %v\", err)\n\t}\n\n\tvar ingressController *watchers.IngressController\n\tif watchIngress {\n\t\tingressController, err = watchers.NewIngressController(client, dnsctl, namespace)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to initialize the ingress controller, error: %v\", err)\n\t\t}\n\t} else {\n\t\tklog.Infof(\"Ingress controller disabled\")\n\t}\n\n\tgo nodeController.Run()\n\tgo podController.Run()\n\tgo serviceController.Run()\n\n\tif watchIngress {\n\t\tgo ingressController.Run()\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":157,"sourceCodeEnd":191,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/dns-controller/cmd/dns-controller/main.go#L157-L191","documentation":"Wraps a failure of watchers.NewIngressController during dns-controller startup when --watch-ingress is enabled. The ingress watcher could not be constructed, so the DNS controller cannot start watching ingress resources.","triggerScenarios":"Running with --watch-ingress=true and NewIngressController receives invalid inputs (nil client, nil dnsctl, bad namespace) and errors out.","commonSituations":"Ingress watching enabled against an environment where the client can't access networking.k8s.io resources; invalid namespace flag; older Kubernetes API version without needed ingress support.","solutions":["Read the wrapped inner error to identify the constructor failure.","If ingress records are not needed, drop --watch-ingress to skip this controller entirely.","Verify RBAC permissions for ingresses and a compatible Kubernetes API server version."],"exampleFix":"// before\ndns-controller --watch-ingress --kubernetes=...  // fails in restricted env\n// after\ndns-controller --kubernetes=...  // ingress controller disabled","handlingStrategy":"try-catch","validationCode":"if watchIngress && client == nil {\n\treturn errors.New(\"cannot watch ingress without an initialized kubernetes client\")\n}","typeGuard":"func ingressWatchReady(watchIngress bool, client kubernetes.Interface) bool {\n\treturn !watchIngress || client != nil\n}","tryCatchPattern":"if err := initializeWatchers(client, dnsctl, ns, watchIngress, types); err != nil {\n\tklog.Fatalf(\"failed to init watchers: %v\", err)\n}","preventionTips":["Only pass --watch-ingress when ingress DNS records are actually required.","Grant ingress list/watch RBAC before enabling the flag.","Confirm the cluster's API server supports networking.k8s.io/v1 ingresses."],"tags":["dns-controller","kubernetes","ingress","initialization"],"backgroundTag":"controller-init-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}