Skip to content

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

Merged
merged 1 commit into from
Sep 18, 2018
Merged

Conversation

mengqiy
Copy link
Member

@mengqiy mengqiy commented Sep 18, 2018

No description provided.

@mengqiy mengqiy requested a review from pwittrock September 18, 2018 08:22
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Sep 18, 2018
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.
Copy link
Contributor

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
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

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

/*
Package builder provides methods to build admission webhooks.

For most users, we recommend to use Operations and ForType to construct a webhook.
Copy link
Contributor

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

// handle error
}

Note: To build a webhook for CRD, you need to ensure the manager is
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

webhook for a CRD

}

Note: To build a webhook for CRD, you need to ensure the manager is
constructed from the scheme that understands your CRD.
Copy link
Contributor

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

return nil
}

// InjectDecoder injects the decoder into the Handler
Copy link
Contributor

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.

return admission.PatchResponse(pod, copy)
}

// InjectClient injects the client into the Handler
Copy link
Contributor

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.

@mengqiy
Copy link
Member Author

mengqiy commented Sep 18, 2018

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
Copy link
Contributor

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.
Copy link
Contributor

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.


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.
Copy link
Contributor

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.

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.
Copy link
Contributor

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?

@Liujingfang1
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 18, 2018
@mengqiy mengqiy added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 18, 2018
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 0f4719b into kubernetes-sigs:master Sep 18, 2018
@mengqiy mengqiy deleted the godoc branch September 18, 2018 22:13
justinsb pushed a commit to justinsb/controller-runtime that referenced this pull request Dec 7, 2018
DirectXMan12 pushed a commit that referenced this pull request Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants