Kubebuilder project with a component config - could not decode file into runtime.Object #2704
-
I tried to add a custom config for a Kubernetes operator with a kubebuilder ComponentConfig, but I received the bellow mentioned error: ERROR setup unable to load the config file {"error": "could not decode file into runtime.Object"} I set the value of var configFile string
flag.StringVar(&configFile, "config", "config/manager/controller_manager_config.yaml",
"The controller will load its initial configuration from this file. "+
"Omit this flag to use the default configuration values. "+
"Command-line flags override configuration from this file.")
var err error
var options ctrl.Options
ctrlConfig := v1alpha1.ProjectConfig{}
if configFile != "" {
options = ctrl.Options{Scheme: scheme}
c := ctrl.ConfigFile().AtPath(configFile).OfKind(&ctrlConfig)
options, err = options.AndFrom(c)
if err != nil {
setupLog.Error(err, "unable to load the config file")
os.Exit(1)
}
} I'm not pasting all the changes I did because I also tried to run the example from kubebuilder's repository with the same result. When I try to load the options without the c := ctrl.ConfigFile().AtPath(configFile) //.OfKind(&ctrlConfig)
options, err = options.AndFrom(c) Is it a bug in one of the packages or is my require (
k8s.io/apimachinery v0.23.5 // for `kubebuilder alpha config-gen`
sigs.k8s.io/controller-runtime v0.11.2
sigs.k8s.io/controller-tools v0.8.0 // for `kubebuilder alpha config-gen`
sigs.k8s.io/kustomize/kyaml v0.13.6 // for `kubebuilder alpha config-gen`
sigs.k8s.io/yaml v1.3.0
) projectconfig_types.go:
Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I received an answer to this issue in Stackoverflow. It looks like that there is a bug in the sample controller_manager_config.yaml manifest. |
Beta Was this translation helpful? Give feedback.
-
Closing since it is answered. |
Beta Was this translation helpful? Give feedback.
I received an answer to this issue in Stackoverflow. It looks like that there is a bug in the sample controller_manager_config.yaml manifest.