Skip to content

Commit 8a58f48

Browse files
authoredDec 18, 2020
Merge pull request #238 from halkyonio/quarkus-support
Extract controller configuration handling and provide Quarkus extension
·
v5.1.1v1.6.0
2 parents 488d0ef + 06033fc commit 8a58f48

File tree

122 files changed

+1917
-421
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+1917
-421
lines changed
 

‎README.md

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,15 @@ Add [dependency](https://search.maven.org/search?q=a:operator-framework) to your
6363
</dependency>
6464
```
6565

66-
Main method initializing the Operator and registering a controller..
66+
Main method initializing the Operator and registering a controller.
6767

6868
```java
6969
public class Runner {
7070

7171
public static void main(String[] args) {
72-
Operator operator = new Operator(new DefaultKubernetesClient());
73-
operator.registerController(new WebServerController());
72+
Operator operator = new Operator(new DefaultKubernetesClient(),
73+
DefaultConfigurationService.instance());
74+
operator.register(new WebServerController());
7475
}
7576
}
7677
```
@@ -135,18 +136,62 @@ public class WebServerSpec {
135136
}
136137
}
137138
```
139+
140+
#### Quarkus
141+
142+
A [Quarkus](https://quarkus.io) extension is also provided to ease the development of Quarkus-based operators.
143+
144+
Add [this dependency] (https://search.maven.org/search?q=a:operator-framework-quarkus-extension)
145+
to your project:
146+
147+
```xml
148+
<dependency>
149+
<groupId>io.javaoperatorsdk</groupId>
150+
<artifactId>operator-framework-quarkus-extension</artifactId>
151+
<version>{see https://search.maven.org/search?q=a:operator-framework-quarkus-extension for latest version}</version>
152+
</dependency>
153+
```
154+
155+
Create an Application, Quarkus will automatically create and inject a `KubernetesClient`, `Operator`
156+
and `ConfigurationService` instances that your application can use, as shown below:
157+
158+
```java
159+
@QuarkusMain
160+
public class QuarkusOperator implements QuarkusApplication {
161+
162+
@Inject KubernetesClient client;
163+
164+
@Inject Operator operator;
165+
166+
@Inject ConfigurationService configuration;
167+
168+
public static void main(String... args) {
169+
Quarkus.run(QuarkusOperator.class, args);
170+
}
171+
172+
@Override
173+
public int run(String... args) throws Exception {
174+
final var config = configuration.getConfigurationFor(new CustomServiceController(client));
175+
System.out.println("CR class: " + config.getCustomResourceClass());
176+
System.out.println("Doneable class = " + config.getDoneableClass());
177+
178+
Quarkus.waitForExit();
179+
return 0;
180+
}
181+
}
182+
```
138183

139184
#### Spring Boot
140185

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

143-
Add [this dependency](https://search.maven.org/search?q=a:spring-boot-operator-framework-starter) to your project:
188+
Add [this dependency](https://search.maven.org/search?q=a:operator-framework-spring-boot-starter) to your project:
144189

145190
```xml
146191
<dependency>
147192
<groupId>io.javaoperatorsdk</groupId>
148-
<artifactId>spring-boot-operator-framework-starter</artifactId>
149-
<version>{see https://search.maven.org/search?q=a:spring-boot-operator-framework-starter for latest version}</version>
193+
<artifactId>operator-framework-spring-boot-starter</artifactId>
194+
<version>{see https://search.maven.org/search?q=a:operator-framework-spring-boot-starter for latest version}</version>
150195
</dependency>
151196
```
152197

‎operator-framework-core/pom.xml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>io.javaoperatorsdk</groupId>
8+
<artifactId>java-operator-sdk</artifactId>
9+
<version>1.5.1-SNAPSHOT</version>
10+
<relativePath>../pom.xml</relativePath>
11+
</parent>
12+
13+
<artifactId>operator-framework-core</artifactId>
14+
<name>Operator SDK - Framework - Core</name>
15+
<description>Core framework for implementing Kubernetes operators</description>
16+
<packaging>jar</packaging>
17+
18+
<properties>
19+
<java.version>11</java.version>
20+
<maven.compiler.source>11</maven.compiler.source>
21+
<maven.compiler.target>11</maven.compiler.target>
22+
</properties>
23+
24+
<build>
25+
<plugins>
26+
<plugin>
27+
<groupId>org.apache.maven.plugins</groupId>
28+
<artifactId>maven-surefire-plugin</artifactId>
29+
<version>${surefire.version}</version>
30+
</plugin>
31+
</plugins>
32+
</build>
33+
34+
35+
<dependencies>
36+
<dependency>
37+
<groupId>io.fabric8</groupId>
38+
<artifactId>openshift-client</artifactId>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.slf4j</groupId>
42+
<artifactId>slf4j-api</artifactId>
43+
</dependency>
44+
45+
<dependency>
46+
<groupId>org.junit.jupiter</groupId>
47+
<artifactId>junit-jupiter-api</artifactId>
48+
<scope>test</scope>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.junit.jupiter</groupId>
52+
<artifactId>junit-jupiter-engine</artifactId>
53+
<scope>test</scope>
54+
</dependency>
55+
<dependency>
56+
<groupId>org.mockito</groupId>
57+
<artifactId>mockito-core</artifactId>
58+
<scope>test</scope>
59+
</dependency>
60+
<dependency>
61+
<groupId>org.apache.logging.log4j</groupId>
62+
<artifactId>log4j-slf4j-impl</artifactId>
63+
<version>2.13.3</version>
64+
<scope>test</scope>
65+
</dependency>
66+
<dependency>
67+
<groupId>org.assertj</groupId>
68+
<artifactId>assertj-core</artifactId>
69+
<version>3.18.0</version>
70+
<scope>test</scope>
71+
</dependency>
72+
</dependencies>
73+
</project>

0 commit comments

Comments
 (0)
Please sign in to comment.