-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Question about how to run examples #491
Comments
For the ones that rely on CRDs, you'll have to generate CRD YAML and then apply it to the cluster. In either case, Can you be more specific in what issues you were having? |
Thanks for the pointer. I generated CRD YAML and applied it. Then ran 'go run main.go'. Here is the error that I am seeing: 2019-06-19T06:03:27.484-0500 ERROR setup problem running manager {"error": "open /tmp/k8s-webhook-server/serving-certs/tls.crt: no such file or directory"} exit status 1 The manager fails to start because seems like it expects a certificate. |
Do we need to generate a certificate that the manager needs? |
@devdattakulkarni yes, see this pr for docs on how to do this using cert-manager kubernetes-sigs/kubebuilder#776 |
I have the same question, how do I actually run the example_test.go? |
If you want to serve webhooks, yes, you'll have to have certificates.
|
Is there a way to change the default CertDir |
You can create the webhook server directly, and use the |
Should be fixed by #569. |
How do I disable webhook altogether? |
For me ENABLE_WEBHOOKS=false is not working |
@desourav @Abhishek-Srivastava If you need a way to disable webhook altogether, you can just add the |
I checked out the master branch to carry on the tutorial -- I may have missed something so it didn't work by following the tutorial. Firstly, I needed to apply this patch: Then I tried to run it locally but it wouldn't work -- please run it and wait for a couple of seconds to see it crash. # I tried this
make run ENABLE_WEBHOOKS=false
# and this
ENABLE_WEBHOOKS=false make run Please note that I'd printed out the setupLog.Info("ENABLE_WEBHOOKS setting", "ENABLE_WEBHOOKS", os.Getenv("ENABLE_WEBHOOKS"))
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
setupLog.Info("set up webhook")
if err = (&batchv1.CronJob{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "Captain")
os.Exit(1)
}
} $ ENABLE_WEBHOOKS=false make run
/Users/brightzheng/development/go/GOPATH/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
go fmt ./...
go vet ./...
/Users/brightzheng/development/go/GOPATH/bin/controller-gen "crd:trivialVersions=true" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
go run ./main.go
2020-11-24T20:48:19.447+0800 INFO controller-runtime.metrics metrics server is starting to listen {"addr": ":8080"}
2020-11-24T20:48:19.448+0800 INFO controller-runtime.builder Registering a mutating webhook {"GVK": "batch.tutorial.kubebuilder.io/v1, Kind=CronJob", "path": "/mutate-batch-tutorial-kubebuilder-io-v1-cronjob"}
2020-11-24T20:48:19.448+0800 INFO controller-runtime.webhook registering webhook {"path": "/mutate-batch-tutorial-kubebuilder-io-v1-cronjob"}
2020-11-24T20:48:19.448+0800 INFO controller-runtime.builder Registering a validating webhook {"GVK": "batch.tutorial.kubebuilder.io/v1, Kind=CronJob", "path": "/validate-batch-tutorial-kubebuilder-io-v1-cronjob"}
2020-11-24T20:48:19.448+0800 INFO controller-runtime.webhook registering webhook {"path": "/validate-batch-tutorial-kubebuilder-io-v1-cronjob"}
2020-11-24T20:48:19.448+0800 INFO setup ENABLE_WEBHOOKS setting {"ENABLE_WEBHOOKS": "false"}
2020-11-24T20:48:19.448+0800 INFO setup starting manager
2020-11-24T20:48:19.548+0800 INFO controller-runtime.webhook.webhooks starting webhook server
2020-11-24T20:48:19.548+0800 INFO controller-runtime.manager starting metrics server {"path": "/metrics"}
2020-11-24T20:48:19.548+0800 INFO controller Starting EventSource {"reconcilerGroup": "batch.tutorial.kubebuilder.io", "reconcilerKind": "CronJob", "controller": "cronjob", "source": "kind source: /, Kind="}
2020-11-24T20:48:49.548+0800 ERROR setup problem running manager {"error": "[open /var/folders/0n/fwbj43n15v3g_gc74x682qgh0000gn/T/k8s-webhook-server/serving-certs/tls.crt: no such file or directory, failed waiting for all runnables to end within grace period of 30s: context deadline exceeded]", "errorCauses": [{"error": "open /var/folders/0n/fwbj43n15v3g_gc74x682qgh0000gn/T/k8s-webhook-server/serving-certs/tls.crt: no such file or directory"}, {"error": "failed waiting for all runnables to end within grace period of 30s: context deadline exceeded"}]}
github.com/go-logr/zapr.(*zapLogger).Error
/Users/brightzheng/development/go/GOPATH/pkg/mod/github.com/go-logr/zapr@v0.1.0/zapr.go:128
main.main
/Users/brightzheng/development/go/projects/cronjob-tutorial-repo/main.go:126
runtime.main
/usr/local/go/src/runtime/proc.go:204
exit status 1
make: *** [run] Error 1 |
Hmm, I saw the bug, here: if err = (&batchv1.CronJob{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "CronJob")
os.Exit(1)
}
/*
We'll also set up webhooks for our type, which we'll talk about next.
We just need to add them to the manager. Since we might want to run
the webhooks separately, or not run them when testing our controller
locally, we'll put them behind an environment variable.
We'll just make sure to set `ENABLE_WEBHOOKS=false` when we run locally.
*/
setupLog.Info("ENABLE_WEBHOOKS setting", "ENABLE_WEBHOOKS", os.Getenv("ENABLE_WEBHOOKS"))
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
setupLog.Info("set up webhook")
if err = (&batchv1.CronJob{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "Captain")
os.Exit(1)
}
} |
@yoichiwo7 |
I was wondering if there are any pointers on how to run examples from the examples folder.
The text was updated successfully, but these errors were encountered: