Skip to content

Commit 2945041

Browse files
Xavier R. GuérinXavier R Guérin
authored andcommitted
Merged patterns, Job controller example
1 parent cd74532 commit 2945041

39 files changed

+2153
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.sw?
2+
/target/

.idea/compiler.xml

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/jarRepositories.xml

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/saveactions_settings.xml

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 132 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,61 @@
1-
# cloud-native-patterns
2-
Design patterns for cloud-native systems
1+
# Cloud-native Patterns
2+
3+
This repository contains patterns that can be used to design complex,
4+
cloud-native applications. The paper [A Cloud Native Platform for Stateful Streaming](https://arxiv.org/abs/2006.00064)
5+
contains an in-depth description of these patterns.
6+
7+
## Patterns
8+
9+
### Controller
10+
11+
Kubernetes defines controllers as "control loops that tracks at least one
12+
resource type". We constrain that definition further: in cloud native Streams,
13+
a controller is a control loop that tracks a single resource type. Controllers
14+
take some action on creation, modification and deletion of a resource type. As
15+
with regular resources, custom resources can be monitored using controllers.
16+
17+
### Conductor
18+
19+
In contrast to controllers, the conductor pattern observes events from multiple
20+
resources and does not save state updates in a local cache. Instead, they are
21+
concurrent control loops that maintain a state machine that transitions based on
22+
resource events, all towards a final goal. Conductors do not own any resources.
23+
Rather, they register themselves with existing controllers as generic event
24+
listeners which receive the same notifications that each controller does.
25+
26+
### Coordinator
27+
28+
When asynchronous agents need to modify the same resource, we use the
29+
coordinator pattern. The coordinator pattern implements a multiple-reader,
30+
single-writer access model by granting ownership of the resource to a single
31+
agent and serializing asynchronous modification requests coming from other
32+
agents. Coordinators are synchronous command queues that serially execute
33+
modification commands on resources. In cloud native Streams, this pattern means
34+
that the controller for a resource owns that resource, and other controllers
35+
which want to modify it must make requests to that controller.
36+
37+
## Getting started
38+
39+
The repository contains a custom `Job` resource example that makes use of those
40+
patterns. It is located in the `com.ibm.cnp.samples` package.
41+
42+
### Compiling the code
43+
44+
To compile the code, simply import the repository as a `Maven` project in your
45+
favorite IDE, or run the following command at the root of the repository:
46+
```bash
47+
$ mvn package
48+
```
49+
50+
### Running the example
51+
52+
You need first to install the `Job` custom resource definition into your
53+
Kubernetes cluster:
54+
```bash
55+
$ kubectl apply -f ${REPO_ROOT}/crds/job.yaml
56+
```
57+
Then, run the `com.ibm.cnp.samples.Main` class either through your IDE or
58+
by typing the following command at the root of the repository:
59+
```bash
60+
$ mvn exec:java
61+
```

0 commit comments

Comments
 (0)