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

Running the tutorial locally fails due to webhook certs #2837

Closed
camilamacedo86 opened this issue Jul 27, 2022 Discussed in #2702 · 4 comments · Fixed by #2967
Closed

Running the tutorial locally fails due to webhook certs #2837

camilamacedo86 opened this issue Jul 27, 2022 Discussed in #2702 · 4 comments · Fixed by #2967
Assignees
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@camilamacedo86
Copy link
Member

Discussed in #2702

Originally posted by smileisak May 26, 2022
Following the kubebuilder book tutorial, I am facing an issue when running the controller locally by disabling the webhooks.

make run ENABLE_WEBHOOKS=false

as described in the documentation: https://book.kubebuilder.io/cronjob-tutorial/running.html#running-webhooks-locally

Got this error:

1.6535567690158641e+09  ERROR   setup   problem running manager {"error": "open /var/folders/gn/jhjjkq191nl3ggqp77qsc1pr0000gn/T/k8s-webhook-server/serving-certs/tls.crt: no such file or directory"}

It looks like the environment variable is ignored.

@zamonia500
Copy link

I got same error too.
My kubebuilder version is as followed
Version: main.version{KubeBuilderVersion:"3.6.0", KubernetesVendor:"1.24.1", GitCommit:"f20414648f1851ae97997f4a5f8eb4329f450f6d", BuildDate:"2022-08-03T11:47:17Z", GoOs:"darwin", GoArch:"amd64"}

@camilamacedo86 camilamacedo86 added the kind/bug Categorizes issue or PR as related to a bug. label Aug 14, 2022
@jakobmoellerdev
Copy link
Contributor

if os.Getenv("ENABLE_WEBHOOKS") != "false" {
        if err = (&batchv1.CronJob{}).SetupWebhookWithManager(mgr); err != nil {
            setupLog.Error(err, "unable to create webhook", "webhook", "CronJob")
            os.Exit(1)
        }
    }

this statement in main.go should recover this normally.

@camilamacedo86
Copy link
Member Author

camilamacedo86 commented Aug 16, 2022

Hi @jakobmoellersap and @zamonia500,

Technically, the webhooks can be run locally, but for it to work you need to generate certificates for the webhook server and store them at /tmp/k8s-webhook-server/serving-certs/tls.{crt,key}. For more details about running webhook locally, refer here.

Then, to disable this one we need to ensure that we have the ENV VAR exported in the same place where you will execute the make run.

Did you tried :

export ENABLE_WEBHOOKS=false
make run

To see if that works?

Also, I think the fix here is only to update the docs with the above instructions.
Can you check it out and would you like to contribute to the project by opening a PR so we can fix it?

@camilamacedo86 camilamacedo86 added the good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. label Sep 12, 2022
@camilamacedo86 camilamacedo86 added the triage/accepted Indicates an issue or PR is ready to be actively worked on. label Sep 22, 2022
@yashsingh74
Copy link
Member

/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants