@@ -43,7 +43,7 @@ An operator isn't much good without an API to work with. Create a new Custom
43
43
Resource Definition (CRD) API with group ` cache ` , version ` v1 ` , and Kind
44
44
` Memcached ` .
45
45
46
- Use the ` create api ` command to scaffold the ` MemcachedController ` ,
46
+ Use the ` create api ` command to scaffold the ` MemcachedReconciler ` ,
47
47
` MemcachedSpec ` , ` MemcachedStatus ` and ` Memcached ` . These files represent the
48
48
API. The plugin may show some debug statements which is normal as it is still in
49
49
the alpha state.
67
67
│ └── com
68
68
│ └── example
69
69
│ ├── Memcached.java
70
- │ ├── MemcachedController .java
70
+ │ ├── MemcachedReconciler .java
71
71
│ ├── MemcachedSpec.java
72
72
│ └── MemcachedStatus.java
73
73
└── resources
@@ -87,7 +87,7 @@ The `java-operator-plugins` project uses the APIs from [java-operator-sdk](https
87
87
88
88
#### ` MemcachedSpec `
89
89
90
- Initially, the scaffolded Spec file will be empty. The operator developer needs
90
+ Initially, the scaffolded Spec file, ` MemcachedSpec ` , will be empty. The operator developer needs
91
91
to add attributes to this file according to their needs. For the ` Memcached `
92
92
example, we will add the size field as shown in the example below.
93
93
@@ -251,11 +251,11 @@ By now we have the API defined in `Memcached.java`, `MemcachedSpec.java`,
251
251
` MemcachedStatus.java ` . We also have the CRD and the sample Custom Resource.
252
252
This isn't enough, we still need a controller to reconcile these items.
253
253
254
- The ` create api ` command will have scaffolded a skeleton ` MemcachedController .java` .
254
+ The ` create api ` command will have scaffolded a skeleton ` MemcachedReconciler .java` .
255
255
This controller implements the ` ResourceController ` interface from the
256
256
` java-operator-sdk ` . This interface has some important and useful methods.
257
257
258
- Initially the ` MemcachedController .java` will contain the empty stubs for
258
+ Initially the ` MemcachedReconciler .java` will contain the empty stubs for
259
259
` reconcile ` . In this section we will fill in
260
260
the controller logic in these methods. We will also add a
261
261
` createMemcachedDeployment ` method that will create the Deployment for our
@@ -268,7 +268,7 @@ changes to the Deployment.
268
268
### reconcile
269
269
270
270
In this section we will focus on implementing the ` reconcile `
271
- method. In the ` MemcachedController .java` you will see a ` // TODO: fill in logic `
271
+ method. In the ` MemcachedReconciler .java` you will see a ` // TODO: fill in logic `
272
272
comment. At this line we will first add code to get the Deployment.
273
273
274
274
```
@@ -303,7 +303,7 @@ else we need to return `UpdateControl.updateStatus(resource)`
303
303
304
304
After getting the Deployment, we get the current and required replicas. Add the
305
305
following lines below the ` if (deployment == null) ` block in your
306
- ` MemcachedController .java` file.
306
+ ` MemcachedReconciler .java` file.
307
307
308
308
```
309
309
int currentReplicas = deployment.getSpec().getReplicas();
@@ -327,7 +327,7 @@ The above sections will cover reconciling any `size` changes to the Spec. In the
327
327
next section, we will look at handling the changes to the ` nodes ` list from the
328
328
Status.
329
329
330
- Let's get the list of pods and their names. In the ` MemcachedController .java` ,
330
+ Let's get the list of pods and their names. In the ` MemcachedReconciler .java` ,
331
331
add the following code below the ` if (currentReplicas != requiredReplicas) { `
332
332
block.
333
333
@@ -443,7 +443,7 @@ In the next section, we will walk you through creating the
443
443
444
444
Creating Kubernetes objects via APIs can be quite verbose which is why putting
445
445
them in helper methods can make the code more readable. The
446
- ` MemcachedController .java` needs to create a Deployment if it does not exist. In
446
+ ` MemcachedReconciler .java` needs to create a Deployment if it does not exist. In
447
447
the ` reconcile ` we make a call to a helper,
448
448
` createMemcachedDeployment ` .
449
449
@@ -452,7 +452,7 @@ the [`fabric8`](https://fabric8.io/) `DeploymentBuilder` class. Notice the
452
452
Deployment specifies the ` memcached ` image for the pod.
453
453
454
454
Below your ` labelsForMemcached(Memcached m) ` block in the
455
- ` MemcachedController .java` , add the following method.
455
+ ` MemcachedReconciler .java` , add the following method.
456
456
457
457
```
458
458
private Deployment createMemcachedDeployment(Memcached m) {
@@ -496,11 +496,11 @@ Below your `labelsForMemcached(Memcached m)` block in the
496
496
Now we have a ` reconcile ` method. It calls
497
497
` createMemcachedDeployment ` which we have implemented above.
498
498
499
- We have now implemented the ` MemcachedController .java` .
499
+ We have now implemented the ` MemcachedReconciler .java` .
500
500
501
501
## Include Dependencies
502
502
503
- Please add below dependencies in ` MemcachedController .java` file.
503
+ Please add below dependencies in ` MemcachedReconciler .java` file.
504
504
505
505
```
506
506
import io.fabric8.kubernetes.api.model.ContainerBuilder;
@@ -564,15 +564,20 @@ The following steps will show how to run your operator in the cluster.
564
564
565
565
The ` java-operator-plugins ` project will scaffold out a Makefile to give
566
566
Operator SDK users a familiar interface. Using the ` docker-* ` targets you can
567
- conveniently build your and push your operator's image to registry. In our
568
- example, we are using ` quay.io ` , but any docker registry should work.
567
+ conveniently build and push your operator's image to a registry.
568
+
569
+ To build and push the docker image, you will need to specify the name of the image, ` IMG ` ,
570
+ that will be built as well as the operating system, ` OS ` , and the architecture,
571
+ ` ARCH ` , that the image will be built for. In this example, we are using
572
+ ` quay.io ` as the registry the image will be pushed to, but any docker registry should work.
569
573
570
574
```
571
- make docker-build docker-push IMG=quay.io/YOURUSER/memcached-quarkus-operator:v0.0.1
575
+ make docker-build docker-push IMG=quay.io/YOURUSER/memcached-quarkus-operator:v0.0.1 OS=linux ARCH=arm64
572
576
```
573
577
574
- This will build the docker image
575
- ` quay.io/YOURUSER/memcached-quarkus-operator:v0.0.1 ` and push it to the registry.
578
+ This will build the docker image
579
+ ` quay.io/YOURUSER/memcached-quarkus-operator:v0.0.1 ` for linux/arm64 and push it
580
+ to the ` quay.io ` registry.
576
581
577
582
You can verify it is in your docker registry:
578
583
0 commit comments