You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* modified the version of quarkus operator sdk and tutorial too
* updated quarkus version
* updated tutorial and readme
* modified content with new changes
* removed note as .placeholder file will be there
* updated wih spec and status
* updated doc with note
* updated readme
* updated turotial
* updated turotial
* updated turotial
* updated turotial
* updated turotial
* updated turotial
**Note** Please do not commit this file structure to the `GitHub` immediately after the `init` command. The directory structure does not contain any file, and GitHub will not create an empty directory.
34
+
33
35
#### A note on dependency management
34
36
35
37
`operator-sdk init` generates `pom.xml` file. This file contains all the dependencies required to run the operator.
36
38
37
-
### MemcachedQuarkusOperator
38
-
39
-
The quarkus plugin will scaffold out several files during the `init` phase. One
40
-
of these files is the operator's main program, `MemcachedQuarkusOperator.java`.
41
-
This file initializes and runs the operator. The operator uses java-operator-sdk,
42
-
which is similar to
43
-
[controller-runtime](https://github.com/kubernetes-sigs/controller-runtime), to
44
-
make operator development easier.
45
-
46
-
The important part of the `MemcachedQuarkusOperator.java` is the `run` method
47
-
which will start the operator and initializes the informers and watches for your
48
-
operator.
49
-
50
-
Here is an example of the `run` method that will typically be scaffolded out by
51
-
this plugin:
52
-
53
-
```
54
-
@Override
55
-
public int run(String... args) throws Exception {
56
-
operator.start();
57
-
58
-
Quarkus.waitForExit();
59
-
return 0;
60
-
}
61
-
```
62
39
63
40
## Create a new API and Controller
64
41
@@ -81,16 +58,16 @@ one shown as below.
81
58
```
82
59
$ tree
83
60
.
84
-
├── pom.xml
61
+
├── Makefile
85
62
├── PROJECT
63
+
├── pom.xml
86
64
└── src
87
65
└── main
88
66
├── java
89
67
│ └── com
90
68
│ └── example
91
-
│ ├── MemcachedController.java
92
69
│ ├── Memcached.java
93
-
│ ├── MemcachedQuarkusOperator.java
70
+
│ ├── MemcachedController.java
94
71
│ ├── MemcachedSpec.java
95
72
│ └── MemcachedStatus.java
96
73
└── resources
@@ -99,6 +76,7 @@ $ tree
99
76
6 directories, 8 files
100
77
```
101
78
79
+
102
80
#### Understanding Kubernetes APIs
103
81
104
82
For an in-depth explanation of Kubernetes APIs and the group-version-kind model, check out these [kubebuilder docs](https://book.kubebuilder.io/cronjob-tutorial/gvks.html).
@@ -200,24 +178,35 @@ There are a couple of ways to create the CRD. You can either create the file
200
178
manually. Or let the quarkus extensions defined in `pom.xml` use the annotations
201
179
on your Spec/Status classes to create the crd files for you.
202
180
203
-
#### Manually create `crd.yaml`
181
+
#### Via Quarkus extension
182
+
183
+
Running `mvn clean install` will invoke the CRD generator extension which will analyze
184
+
the annotations on the model objects, `Memcached`, `MemcachedSpec`,
185
+
`MemcachedStatus`, and generate the CRD in `target/kubernetes`.
186
+
187
+
CRD generated in `memcacheds.cache.example.com-v1.yml`.
188
+
189
+
```
190
+
.
191
+
├── kubernetes.json
192
+
├── kubernetes.yml
193
+
└── memcacheds.cache.example.com-v1.yml
194
+
195
+
0 directories, 3 files
196
+
```
204
197
205
-
Create a file with the name `crd.yaml`. A CRD enables users to add their
206
-
own/custom objects to the Kubernetes cluster. Below you will find an example
207
-
`Memcached` CRD.
198
+
The content of the `memcacheds.cache.example.com-v1.yml` file is as shown below.
208
199
209
200
```
201
+
# Generated by Fabric8 CRDGenerator, manual edits might get overwritten!
210
202
apiVersion: apiextensions.k8s.io/v1
211
203
kind: CustomResourceDefinition
212
204
metadata:
213
-
annotations:
214
-
controller-gen.kubebuilder.io/version: v0.4.1
215
205
name: memcacheds.cache.example.com
216
206
spec:
217
207
group: cache.example.com
218
208
names:
219
209
kind: Memcached
220
-
listKind: MemcachedList
221
210
plural: memcacheds
222
211
singular: memcached
223
212
scope: Namespaced
@@ -226,16 +215,9 @@ spec:
226
215
schema:
227
216
openAPIV3Schema:
228
217
properties:
229
-
apiVersion:
230
-
type: string
231
-
kind:
232
-
type: string
233
-
metadata:
234
-
type: object
235
218
spec:
236
219
properties:
237
220
size:
238
-
format: int32
239
221
type: integer
240
222
type: object
241
223
status:
@@ -250,27 +232,6 @@ spec:
250
232
storage: true
251
233
subresources:
252
234
status: {}
253
-
status:
254
-
acceptedNames:
255
-
kind: ""
256
-
plural: ""
257
-
conditions: []
258
-
storedVersions: []
259
-
```
260
-
261
-
#### Via Quarkus extension
262
-
263
-
**Note** there is currently an issue with the CRD generation that the schema
264
-
validation is not properly generated. Because of this issue, we will not cover
265
-
using this portion during this tutorial. Proceed to the
Next we will install the CRD into the `default` namespace. Using the `crd.yaml`
601
-
you created in the [Manually created crd.yaml](#manually-create-crdyaml)
602
-
section, apply it to the cluster.
587
+
Next we will install the CRD into the `default` namespace. Using the `target/kubernetes/memcacheds.cache.example.com-v1.yml` , apply it to the cluster.
603
588
604
589
<!--
605
590
TODO: Uncomment this when the crd generator works properly.
@@ -610,7 +595,7 @@ customresourcedefinition.apiextensions.k8s.io/memcacheds.cache.example.com creat
customresourcedefinition.apiextensions.k8s.io/memcacheds.cache.example.com created
615
600
```
616
601
@@ -722,9 +707,7 @@ You should see a nice `BUILD SUCCESS` method like the one below:
722
707
723
708
2. Install the CRD
724
709
725
-
Next we will install the CRD into the `default` namespace. Using the `crd.yaml`
726
-
you created in the [Manually created crd.yaml](#manually-create-crdyaml)
727
-
section, apply it to the cluster.
710
+
Next we will install the CRD into the `default` namespace. Using the `target/kubernetes/memcacheds.cache.example.com-v1.yml` , apply it to the cluster.
0 commit comments