Skip to content

Commit 485a24a

Browse files
authored
Merge pull request #1501 from kevindelgado/doc-webhook-tls
📖 Better document TLS requirements for webhook servers
2 parents e10bf72 + d0fe020 commit 485a24a

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

pkg/webhook/admission/webhook.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ type StandaloneOptions struct {
230230
// and instrumenting the webhook with metrics.
231231
//
232232
// Use this to attach your webhook to an arbitrary HTTP server or mux.
233+
//
234+
// Note that you are responsible for terminating TLS if you use StandaloneWebhook
235+
// in your own server/mux. In order to be accessed by a kubernetes cluster,
236+
// all webhook servers require TLS.
233237
func StandaloneWebhook(hook *Webhook, opts StandaloneOptions) (http.Handler, error) {
234238
if opts.Scheme == nil {
235239
opts.Scheme = scheme.Scheme

pkg/webhook/example_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ func Example() {
8383

8484
// This example creates a webhook server that can be
8585
// ran without a controller manager.
86+
//
87+
// Note that this assumes and requires a valid TLS
88+
// cert and key at the default locations
89+
// tls.crt and tls.key
8690
func ExampleServer_StartStandalone() {
8791
// Create a webhook server
8892
hookServer := &Server{

pkg/webhook/server.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ var DefaultPort = 9443
4141

4242
// Server is an admission webhook server that can serve traffic and
4343
// generates related k8s resources for deploying.
44+
//
45+
// TLS is required for a webhook to be accessed by kubernetes, so
46+
// you must provide a CertName and KeyName or have valid cert/key
47+
// at the default locations (tls.crt and tls.key). If you do not
48+
// want to configure TLS (i.e for testing purposes) run an
49+
// admission.StandaloneWebhook in your own server.
4450
type Server struct {
4551
// Host is the address that the server will listen on.
4652
// Defaults to "" - all addresses.

0 commit comments

Comments
 (0)