Skip to content

Commit cd74a47

Browse files
committed
improve readme and docs & add logo!
1 parent c87e2e2 commit cd74a47

File tree

3 files changed

+62
-75
lines changed

3 files changed

+62
-75
lines changed

README.md

Lines changed: 28 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,47 @@
1-
# java-operator-sdk
2-
![Java CI with Maven](https://github.com/ContainerSolutions/java-operator-sdk/workflows/Java%20CI%20with%20Maven/badge.svg)
1+
# ![java-operator-sdk](logo.png)
2+
![Java CI with Maven](https://github.com/ContainerSolutions/java-operator-sdk/workflows/Java%20CI%20with%20Maven/badge.svg | width = 300)
33

4-
SDK for building Kubernetes Operators in Java. Inspired by [operator-sdk](https://github.com/operator-framework/operator-sdk).
5-
User (you) only writes the logic in a Controller that creates/updates or deletes resources related to a custom resource.
6-
All the issues around are handled by the framework for you.
7-
Check out this [blog post](https://blog.container-solutions.com/a-deep-dive-into-the-java-operator-sdk)
8-
about the non-trivial yet common problems needs to be solved for every operator.
9-
10-
## Join us on Discord!
4+
Build Kubernetes Operators in Java without hassle. Inspired by [operator-sdk](https://github.com/operator-framework/operator-sdk).
115

12-
[Discord Invite Link](https://discord.gg/DacEhAy)
6+
#### Features
7+
* Framework for handling Kubernetes API events
8+
* Registering Custom Resource watches
9+
* Retry action on failure
10+
* Smart event scheduling (only handle latest event for the same resource)
1311

14-
## Roadmap
12+
Check out this [blog post](https://blog.container-solutions.com/a-deep-dive-into-the-java-operator-sdk)
13+
about the non-trivial yet common problems needs to be solved for every operator.
1514

16-
Feature we would like to implement and invite the community to help us implement in the future:
15+
#### Why build your own Operator?
16+
* Infrastructure automation using the power and flexibility of Java. See [blog post](https://blog.container-solutions.com/cloud-native-java-infrastructure-automation-with-kubernetes-operators).
17+
* Provisioning of complex applications - avoiding Helm chart hell
18+
* Integration with Cloud services - e.g. Secret stores
19+
* Safer deployment of applications - only expose cluster to users by Custom Resources
1720

18-
* ~~Spring Boot support~~
19-
* Class generation from CRD to POJO
20-
* GraalVM / Quarkus support
21+
#### Roadmap
22+
* Testing of the framework and all samples while running on a real cluster.
23+
* Generate a project skeleton
24+
* Generate Java classes from CRD definion (and/or the other way around)
25+
* Integrate with Quarkus (including native image build)
26+
* Integrate with OLM (Operator Lifecycle Manager)
2127

22-
## Additional Features
28+
#### Join us on Discord!
2329

24-
* Configurable Retry Handling
25-
* Smart Event Processing Scheduling
30+
[Discord Invite Link](https://discord.gg/DacEhAy)
2631

27-
## User Guide
32+
#### User Guide
2833

2934
You can (will) find detailed documentation [here](docs/DOCS.md).
3035
Note that these docs are currently in progress.
3136

32-
## Usage
37+
#### Usage
3338

3439
We have several sample Operators under the samples directory:
3540
* *basic*: Minimal Operator implementation which only parses the Custom Resource and prints to stdout.
3641
Implemented with and without Spring Boot support. The two samples share the common module.
3742
* *webserver*: More realistic example creating an nginx webserver from a Custom Resource containing html code.
43+
* *mysql-schema*: Operator managing schemas in a MySQL database
44+
* *spring-boot-plain/auto-config*: Samples showing integration with Spring Boot.
3845

3946
Add [dependency](https://search.maven.org/search?q=a:operator-framework) to your project:
4047

@@ -120,7 +127,7 @@ public class WebServerSpec {
120127
}
121128
```
122129

123-
### Spring Boot
130+
#### Spring Boot
124131

125132
You can also let Spring Boot wire your application together and automatically register the controllers.
126133

@@ -143,55 +150,3 @@ public class Application {
143150
}
144151
}
145152
```
146-
147-
add Spring's `@Service` annotation to your controller classes so they will be automatically registered as resource controllers.
148-
149-
The Operator's Spring Boot integration leverages [Spring's configuration mechanisms](https://docs.spring.io/spring-boot/docs/1.0.1.RELEASE/reference/html/boot-features-external-config.html) to configure
150-
- [The Kubernetes client](spring-boot-starter/src/main/java/com/github/containersolutions/operator/spingboot/starter/OperatorProperties.java)
151-
- [Retries](spring-boot-starter/src/main/java/com/github/containersolutions/operator/spingboot/starter/RetryProperties.java)
152-
153-
## Implementation / Design details
154-
155-
This library relies on the amazing [kubernetes-client](https://github.com/fabric8io/kubernetes-client) from fabric8.
156-
Most of the heavy lifting is actually done by kubernetes-client.
157-
158-
What the framework adds on top of the bare client:
159-
* Management of events from the Kubernetes API. All events are inserted into a queue by the EventScheduler. The
160-
framework makes sure only the latest event for a certain resource is processed. This is especially important since
161-
on startup the operator can receive a whole series of obsolete events.
162-
* Retrying of failed actions. When an event handler throws an exception the event is put back in the queue.
163-
* A clean interface to the user of the framework to receive events related to the Controller's resource.
164-
165-
### Dealing with Consistency
166-
167-
#### Run Single Instance
168-
169-
There should be always just one instance of an operator running at a time (think process). If there there would be
170-
two ore more, in general it could lead to concurrency issues. Note that we are also doing optimistic locking when we update a resource.
171-
In this way the operator is not highly available. However for operators this not necessary an issue,
172-
if the operator just gets restarted after it went down.
173-
174-
#### At Least Once
175-
176-
To implement controller logic, we have to override two methods: `createOrUpdateResource` and `deleteResource`.
177-
These methods are called if a resource is create/changed or marked for deletion. In most cases these methods will be
178-
called just once, but in some rare cases can happen that are called more then once. In practice this means that the
179-
implementation needs to be **idempotent**.
180-
181-
#### Smart Scheduling
182-
183-
In our scheduling algorithm we make sure, that no events are processed concurrently for a resource. In addition we provide
184-
a customizable retry mechanism to deal with temporal errors.
185-
186-
#### Operator Restarts
187-
188-
When an operator is started we got events for every resource (of a type we listen to) already on the cluster. Even if the resource is not changed
189-
(We use `kubectl get ... --watch` in the background). This can be a huge amount of resources depending on your use case.
190-
So it could be a good case just have a status field on the resource which is checked, if there anything needs to be done.
191-
192-
#### Deleting a Resource
193-
194-
During deletion process we use [Kubernetes finalizers](https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/#finalizers
195-
"Kubernetes docs") finalizers. This is required, since it can happen that the operator is not running while the delete
196-
of resource is executed (think `oc delete`). In this case we would not catch the delete event. So we automatically add a
197-
finalizer first time we update the resource if its not there.

docs/DOCS.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ the cluster's API server.
3535
Controllers are where you implement the business logic of the Operator. An Operator can host multiple Controllers,
3636
each handling a different type of Custom Resource. In our samples each Operator has a single Controller.
3737

38-
### Generation Awareness
39-
4038
## Automatic Retries
4139

4240
## Running The Operator
@@ -53,3 +51,37 @@ TODO: explain running operator locally against a cluster
5351
### Generation Awareness
5452

5553
## Spring Boot Support
54+
55+
## Dealing with Consistency
56+
57+
### Run Single Instance
58+
59+
There should be always just one instance of an operator running at a time (think process). If there there would be
60+
two ore more, in general it could lead to concurrency issues. Note that we are also doing optimistic locking when we update a resource.
61+
In this way the operator is not highly available. However for operators this not necessary an issue,
62+
if the operator just gets restarted after it went down.
63+
64+
### At Least Once
65+
66+
To implement controller logic, we have to override two methods: `createOrUpdateResource` and `deleteResource`.
67+
These methods are called if a resource is create/changed or marked for deletion. In most cases these methods will be
68+
called just once, but in some rare cases can happen that are called more then once. In practice this means that the
69+
implementation needs to be **idempotent**.
70+
71+
### Smart Scheduling
72+
73+
In our scheduling algorithm we make sure, that no events are processed concurrently for a resource. In addition we provide
74+
a customizable retry mechanism to deal with temporal errors.
75+
76+
### Operator Restarts
77+
78+
When an operator is started we got events for every resource (of a type we listen to) already on the cluster. Even if the resource is not changed
79+
(We use `kubectl get ... --watch` in the background). This can be a huge amount of resources depending on your use case.
80+
So it could be a good case just have a status field on the resource which is checked, if there anything needs to be done.
81+
82+
### Deleting a Resource
83+
84+
During deletion process we use [Kubernetes finalizers](https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/#finalizers
85+
"Kubernetes docs") finalizers. This is required, since it can happen that the operator is not running while the delete
86+
of resource is executed (think `oc delete`). In this case we would not catch the delete event. So we automatically add a
87+
finalizer first time we update the resource if its not there.

logo.png

34.5 KB
Loading

0 commit comments

Comments
 (0)