-
Notifications
You must be signed in to change notification settings - Fork 1.2k
update godoc for webhook #147
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
Conversation
pkg/doc.go
Outdated
|
||
There are 2 types of admission webhook: mutating and validating admission webhook. | ||
Mutating webhook is used to mutate a core API object or a CRD instance before the API server admit it. | ||
Validting webhook is used to validate if a core API object or a CRD instance meet certain requirements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
pkg/doc.go
Outdated
@@ -49,6 +49,18 @@ system must be read for each Reconciler. | |||
|
|||
* Controller require Watches to be configured to enqueue reconcile.Requests in response to events. | |||
|
|||
Webhook | |||
|
|||
Admission Webhook is a mechanism for extending kubernetes APIs. The API server will send AdmissionRequests to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Admission Webhooks are
pkg/doc.go
Outdated
mutate and (or) validate the object embedded in the AdmissionReview requests. | ||
|
||
There are 2 types of admission webhook: mutating and validating admission webhook. | ||
Mutating webhook is used to mutate a core API object or a CRD instance before the API server admit it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
before the API server admits it
pkg/doc.go
Outdated
|
||
There are 2 types of admission webhook: mutating and validating admission webhook. | ||
Mutating webhook is used to mutate a core API object or a CRD instance before the API server admit it. | ||
Validting webhook is used to validate if a core API object or a CRD instance meet certain requirements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validate if an object meets certain
pkg/webhook/admission/builder/doc.go
Outdated
/* | ||
Package builder provides methods to build admission webhooks. | ||
|
||
For most users, we recommend to use Operations and ForType to construct a webhook. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either explain why these or recommended or omit this line
pkg/webhook/admission/builder/doc.go
Outdated
// handle error | ||
} | ||
|
||
Note: To build a webhook for CRD, you need to ensure the manager is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
webhook for a CRD
pkg/webhook/admission/builder/doc.go
Outdated
} | ||
|
||
Note: To build a webhook for CRD, you need to ensure the manager is | ||
constructed from the scheme that understands your CRD. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explain what this means more, show a code snippet of getting a manager constructed from a Scheme
pkg/webhook/admission/doc.go
Outdated
return nil | ||
} | ||
|
||
// InjectDecoder injects the decoder into the Handler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// InjectDecoder is called by the Manager and provides a types.Decoder to the Mutator instance.
pkg/webhook/admission/doc.go
Outdated
return admission.PatchResponse(pod, copy) | ||
} | ||
|
||
// InjectClient injects the client into the Handler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// InjectClient is called by the Manager and provides a client.Client to the Mutator instance.
Addressed comments. PTAL |
pkg/doc.go
Outdated
Webhook | ||
|
||
Admission Webhooks are a mechanism for extending kubernetes APIs. The API server will send AdmissionRequests to | ||
the webhooks according to the configured target event type (object Create, Update, Delete). The webhooks may |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe change to
When webhooks are configured with target event type(object Create, Update, Delete), the API server will send AdmissionRequests to them when those events happen.
pkg/doc.go
Outdated
|
||
Admission Webhooks are a mechanism for extending kubernetes APIs. The API server will send AdmissionRequests to | ||
the webhooks according to the configured target event type (object Create, Update, Delete). The webhooks may | ||
mutate and (or) validate the object embedded in the AdmissionReview requests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and send back the response to API server.
pkg/webhook/admission/builder/doc.go
Outdated
|
||
For most users, we recommend to use Operations and ForType to construct a webhook, | ||
since it is more intuitive and easier to pass the target operations to Operations method and | ||
a empty target object to ForType method than passing a complex RuleWithOperations struct to Rules method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move this explanation to the later part of the doc and show the example webhooks first.
since it is more intuitive and easier to pass the target operations to Operations method and
a empty target object to ForType method than passing a complex RuleWithOperations struct to Rules method.
pkg/webhook/doc.go
Outdated
Package webhook provides functions to build and bootstrap an admission webhook server for a k8s cluster. | ||
Package webhook provides methods to build and bootstrap a webhook server. | ||
|
||
Currently, it only supports hosting admission webhooks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add some explanation of hosting admission webhooks
?
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED Approval requirements bypassed by manually added approval. This pull-request has been approved by: mengqiy The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
update godoc for webhook
No description provided.