kubebuilder: Error `/tmp/k8s-webhook-server/serving-certs/tls.crt: no such file or directory"` has been faced
Error:
$ kubectl logs deployment.apps/project-v3-multigroup-controller-manager -n project-v3-multigroup-system manager
2020-05-08T01:36:20.968Z INFO controller-runtime.metrics metrics server is starting to listen {"addr": "127.0.0.1:8080"}
2020-05-08T01:36:20.968Z INFO controller-runtime.builder Registering a mutating webhook {"GVK": "crew.testproject.org/v1, Kind=Captain", "path": "/mutate-crew-testproject-org-v1-captain"}
2020-05-08T01:36:20.968Z INFO controller-runtime.webhook registering webhook {"path": "/mutate-crew-testproject-org-v1-captain"}
2020-05-08T01:36:20.968Z INFO controller-runtime.builder Registering a validating webhook {"GVK": "crew.testproject.org/v1, Kind=Captain", "path": "/validate-crew-testproject-org-v1-captain"}
2020-05-08T01:36:20.968Z INFO controller-runtime.webhook registering webhook {"path": "/validate-crew-testproject-org-v1-captain"}
2020-05-08T01:36:20.969Z INFO controller-runtime.builder skip registering a mutating webhook, admission.Defaulter interface is not implemented {"GVK": "ship.testproject.org/v1beta1, Kind=Frigate"}
2020-05-08T01:36:20.969Z INFO controller-runtime.builder skip registering a validating webhook, admission.Validator interface is not implemented {"GVK": "ship.testproject.org/v1beta1, Kind=Frigate"}
2020-05-08T01:36:20.969Z INFO setup starting manager
I0508 01:36:20.969662 1 leaderelection.go:242] attempting to acquire leader lease project-v3-multigroup-system/14be1926.testproject.org...
2020-05-08T01:36:20.969Z INFO controller-runtime.manager starting metrics server {"path": "/metrics"}
2020-05-08T01:36:20.970Z INFO controller-runtime.webhook.webhooks starting webhook server
2020-05-08T01:36:20.970Z DEBUG controller-runtime.manager non-leader-election runnable finished {"runnable type": "*webhook.Server"}
2020-05-08T01:36:20.970Z ERROR setup problem running manager {"error": "open /tmp/k8s-webhook-server/serving-certs/tls.crt: no such file or directory"}
github.com/go-logr/zapr.(*zapLogger).Error
/go/pkg/mod/github.com/go-logr/zapr@v0.1.0/zapr.go:128
main.main
/workspace/main.go:153
runtime.main
/usr/local/go/src/runtime/proc.go:203
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 8
- Comments: 18 (4 by maintainers)
@libratiger how to do if I want to use webhooks ?
Check
default/kustomization.yamlandcrd/kustomization.yamlfor[WEBHOOK]and[CERTMANAGER], we only need to uncomment some lines to get it to work. Also need to have cert-manager installed.in
main.go,it works for me.for minikube example
1. ssh to minikube node
2. find the location of .cert file and .key file used by apiserver
ps -ef | grep apiserver3. new tls.cert file and tls.key in /tmp/k8s-webhook-server/serving-certs dir, and paste the content from step 2.
I commented
SetupWebhookWithManagerinmain.go, which works for me.@jgillich we are talking about the go binary here, you just can’t run it in http mode (in order to use an https proxy in front of it for example)
the WebHookServer just won’t run in http mode.
Uncomment the lines in your config. https://github.com/kubernetes-sigs/kubebuilder/issues/1501#issuecomment-1002478317
documented already; https://github.com/kubernetes-sigs/kubebuilder/pull/776/files