docs: add guide for webhook self-signed certs without cert-manager - #5892
docs: add guide for webhook self-signed certs without cert-manager#5892Dasmat13 wants to merge 2 commits into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Dasmat13 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @Dasmat13. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
| self-signed certificates. This approach is intended **for development and | ||
| testing environments only** (e.g. local `kind` clusters). It is **not |
There was a problem hiding this comment.
we need here a note warning in the top of the document.
See how that is done in the others
There was a problem hiding this comment.
ok i will check how other warnings are formatted in the book and fix it
| - There is no automated renewal or revocation. | ||
|
|
||
| For production, use [cert-manager](https://cert-manager.io) as described in | ||
| [Deploying cert-manager](../cronjob-tutorial/cert-manager.md). |
There was a problem hiding this comment.
Or another cert manager of your choice
| ## Step 1: Scaffold the project (if starting fresh) | ||
|
|
||
| ```bash | ||
| mkdir my-project && cd my-project | ||
| kubebuilder init --domain example.com --repo example.com/my-project | ||
|
|
||
| # Scaffold an API | ||
| kubebuilder create api --group apps --version v1alpha1 --kind MyApp --resource --controller | ||
|
|
||
| # Scaffold a defaulting webhook for the API | ||
| kubebuilder create webhook --group apps --version v1alpha1 --kind MyApp --defaulting | ||
| ``` | ||
|
|
||
| > If you already have a project with webhooks, skip to Step 2. |
There was a problem hiding this comment.
We should only speak about How to add the certs manually.
Nobody that is looking for that does not know how to scaffold a basic project already.
There was a problem hiding this comment.
ok i will remove step 1 to keep it clen
|
|
||
| --- | ||
|
|
||
| ## Troubleshooting |
There was a problem hiding this comment.
We usually do not add this scetion. I think we can drop
There was a problem hiding this comment.
umm ok i will drop the troubleshooting table
| openssl req -new -x509 -days 365 \ | ||
| -key config/webhook/certs/ca.key \ | ||
| -subj "/CN=Webhook CA/O=Dev" \ | ||
| -out config/webhook/certs/ca.crt |
There was a problem hiding this comment.
If will doc that I think we need provide a script to make it easier and we need to do it like kube-rbac-proxy did in the past: kube-rbac-proxy/kube-rbac-proxy@a0b0950 and controller-runtime does as well to generate certs.
There was a problem hiding this comment.
let me check how kube-rbac-proxy/controller-runtime do it. I'll add a helper script to automate this instead of listing all the openssl commands
|
thanks for the quick review @camilamacedo86! I'll update the PR |
Add docs/book/src/reference/webhook-self-signed-cert.md with a step-by-step guide covering: - Generating a self-signed CA and TLS cert with openssl - Creating the webhook-server-cert Secret in the cluster - Disabling cert-manager components in config/default/kustomization.yaml - Manually patching the caBundle into MutatingWebhookConfiguration - Running locally with make run using --cert-dir - Troubleshooting table for common TLS errors The guide is clearly scoped to development and testing environments. Update SUMMARY.md to add the page under the webhook reference section.
445f63d to
8d73278
Compare
|
updated the PR with all the suggestions |
camilamacedo86
left a comment
There was a problem hiding this comment.
Thank you so much for looking on this one.
I think this guide still needs a simpler and safer flow before we merge it.
Could we add a small helper script and a Make target instead of asking users to run and maintain all the OpenSSL commands manually?
The expected flow could be:
make webhook-certs
make deploy IMG=<your-image>The helper should:
-
Generate a development CA and webhook certificate.
-
Use the final Service DNS name, including the project prefix:
<project-name>-webhook-service.<project-name>-system.svc -
Create or update the
webhook-server-certSecret. -
Inject the CA into all validating and mutating webhooks.
-
Support the CRD conversion webhook
caBundlewhen conversion webhooks are used.
A few other points:
- Do not patch only
/webhooks/0; a project can have more than one webhook. - Keep generated private keys outside tracked configuration, or add the directory to
.gitignore. - Use the current scaffold flag,
--webhook-cert-path, instead of--cert-dir. - Keep the guide focused on adding development certificates. We do not need to explain how to scaffold a basic project.
- Clearly state that this is only for development. Production users should use cert-manager or another certificate management solution.
The old controller-runtime certificate provisioner and kube-rbac-proxy certificate generation can be used as references for the helper implementation.
Let me know wdyt?
|
hey @camilamacedo86 thanks for the review! yeah makes sense the make target flow is much cleaner. ill look at how kube-rbac-proxy did it and base the script on that. couple of things i want to double check before i redo this - for patching caBundle should i loop over all webhooks or is there a better way? i was thinking of doing kubectl get mutatingwebhookconfigurations -o name and patch each one but not 100% sure thats the right approach ill update once i get clarity on these shouldnt take long |
|
small ping :) updated based on your feedback |
|
Hi @camilamacedo86 @varshaprasad96, quick ping — updates from the review feedback are in. Would appreciate another look when you get a chance. Thanks |
Closes #4292
What this PR adds
A new reference page
docs/book/src/reference/webhook-self-signed-cert.mdwith a step-by-step guide for using manually generated self-signed certificates in webhooks, without relying on cert-manager.The guide covers:
opensslwebhook-server-certSecret in the clusterconfig/default/kustomization.yamlcaBundleintoMutatingWebhookConfigurationusing a Kustomize JSON patchmake run --cert-dirThe guide is clearly scoped to development and testing environments only, with a prominent warning at the top recommending cert-manager for production.
Also updates
SUMMARY.mdto add the page under the webhook reference section.Checklist