Skip to content

docs: simple docs for conversion hooks #38

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 5 commits into from
Nov 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# admission-controller-framework

Framework and tooling to support
implementing [admission controllers](https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/) for
Kubernetes in Java. Supports both **quarkus** and **spring boot**. Both Sync and Async programing model.
implementing [admission controllers](https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/)
and [conversion hooks](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definition-versioning/#webhook-conversion)
for Kubernetes in Java. Supports both **quarkus** and **spring boot**. Both Sync and Async programing model.

## Sample Usage

### Admission Controllers

Defining a mutation or validation controller is simple as:

https://github.com/java-operator-sdk/admission-controller-framework/blob/0946595d941b789caef6a69b34c2e5be8c6b59cf/samples/quarkus/src/main/java/io/javaoperatorsdk/admissioncontroller/sample/quarkus/AdmissionControllerConfig.java#L31-L68
Expand All @@ -15,3 +18,19 @@ What can be then simple used in an endpoint:
https://github.com/java-operator-sdk/admission-controller-framework/blob/0946595d941b789caef6a69b34c2e5be8c6b59cf/samples/quarkus/src/main/java/io/javaoperatorsdk/admissioncontroller/sample/quarkus/AdmissionEndpoint.java#L57-L89

See samples also for details.

### Conversion Hooks

Conversion hooks follows the same patter described
in [Kuberbuilder](https://book.kubebuilder.io/multiversion-tutorial/conversion-concepts.html), thus first converts the
custom resource from actual version to a hub, and as next step from the hub to the target resource version.

To create the controller
register [mappers](https://github.com/java-operator-sdk/admission-controller-framework/blob/main/core/src/main/java/io/javaoperatorsdk/webhook/conversion/Mapper.java)
:

https://github.com/java-operator-sdk/admission-controller-framework/blob/2a2bce54b49ea3398bef95a9102ee8645e11cf87/samples/quarkus/src/main/java/io/javaoperatorsdk/webhook/admission/sample/quarkus/conversion/ConversionControllerConfig.java#L15-L29

and use the controllers in the endpoint:

https://github.com/java-operator-sdk/admission-controller-framework/blob/2a2bce54b49ea3398bef95a9102ee8645e11cf87/samples/spring-boot/src/main/java/io/javaoperatorsdk/webhook/sample/springboot/conversion/ConversionEndpoint.java#L29-L40