Skip to content

Commit 6f6e6f3

Browse files
Updated sample and Tutorial according to new changes (#77)
Co-authored-by: Chris Laprun <[email protected]>
1 parent 838b886 commit 6f6e6f3

19 files changed

+415
-566
lines changed

docs/tutorial.md

+14-17
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,7 @@ The `Memcached` is the Schema for the Memcacheds API.
164164
165165
@Version("v1")
166166
@Group("cache.example.com")
167-
@Kind("Memcached")
168-
@Plural("memcacheds")
169-
public class Memcached extends CustomResource<MemcachedSpec, MemcachedStatus>
170-
implements Namespaced {}
167+
public class Memcached extends CustomResource<MemcachedSpec, MemcachedStatus> implements Namespaced {}
171168
```
172169

173170
You have now created the necessary classes for the API.
@@ -259,18 +256,18 @@ This controller implements the `ResourceController` interface from the
259256
`java-operator-sdk`. This interface has some important and useful methods.
260257

261258
Initially the `MemcachedController.java` will contain the empty stubs for
262-
`createOrUpdateResource`. In this section we will fill in
259+
`reconcile`. In this section we will fill in
263260
the controller logic in these methods. We will also add a
264261
`createMemcachedDeployment` method that will create the Deployment for our
265262
operator and a `labelsForMemcached` method that returns the labels.
266263

267-
The `createOrUpdateResource` get called whenever some
268-
update/create/delete event occurs in the cluster. This will allow us to react to
264+
The `reconcile` get called whenever some
265+
update/create event occurs in the cluster. This will allow us to react to
269266
changes to the Deployment.
270267

271-
### createOrUpdateResource
268+
### reconcile
272269

273-
In this section we will focus on implementing the `createOrUpdateResource`
270+
In this section we will focus on implementing the `reconcile`
274271
method. In the `MemcachedController.java` you will see a `// TODO: fill in logic`
275272
comment. At this line we will first add code to get the Deployment.
276273

@@ -285,7 +282,7 @@ comment. At this line we will first add code to get the Deployment.
285282

286283
Once we get the `deployment`, we have a couple of decisions to make. If it is
287284
`null` it does not exist which means we need to create the deployment. In the
288-
`MemachedController.java`, in the `createOrUpdateResource` method just below the
285+
`MemachedController.java`, in the `reconcile` method just below the
289286
get deployment code we added above, add the following:
290287

291288
```
@@ -302,7 +299,7 @@ method.
302299

303300
Once we create the deployment, we need to decide whether we have to reconcile it or not.
304301
If there is no need of reconciliation then return `UpdateControl.noUpdate()`
305-
else we need to return `UpdateControl.updateStatusSubResource(resource)`
302+
else we need to return `UpdateControl.updateStatus(resource)`
306303

307304
After getting the Deployment, we get the current and required replicas. Add the
308305
following lines below the `if (deployment == null)` block in your
@@ -358,13 +355,13 @@ mismatch in either of these conditions then we need to do a reconciliation.
358355
}
359356
```
360357

361-
That's it we have completed the `createOrUpdateResource` method. The method
358+
That's it we have completed the `reconcile` method. The method
362359
should now look like the following:
363360

364361
```
365362
@Override
366-
public UpdateControl<Memcached> createOrUpdateResource(
367-
Memcached resource, Context<Memcached> context) {
363+
public UpdateControl<Memcached> reconcile(
364+
Memcached resource, Context context) {
368365
// TODO: fill in logic
369366
Deployment deployment = client.apps()
370367
.deployments()
@@ -427,7 +424,7 @@ Let's create the utility method first.
427424
### labelsForMemcached
428425

429426
A simple utility method to return a map of the labels we want to attach to some
430-
of the resources. Below the `createOrUpdateResource` method add the following
427+
of the resources. Below the `reconcile` method add the following
431428
helper:
432429

433430
```
@@ -447,7 +444,7 @@ In the next section, we will walk you through creating the
447444
Creating Kubernetes objects via APIs can be quite verbose which is why putting
448445
them in helper methods can make the code more readable. The
449446
`MemcachedController.java` needs to create a Deployment if it does not exist. In
450-
the `createOrUpdateResource` we make a call to a helper,
447+
the `reconcile` we make a call to a helper,
451448
`createMemcachedDeployment`.
452449

453450
Let's create the `createMemcachedDeployment` method. The following code will use
@@ -501,7 +498,7 @@ Below your `labelsForMemcached(Memcached m)` block in the
501498
}
502499
```
503500

504-
Now we have a `createOrUpdateResource` method. It calls
501+
Now we have a `reconcile` method. It calls
505502
`createMemcachedDeployment` which we have implemented above.
506503

507504
We have now implemented the `MemcachedController.java`.

testdata/memcached-quarkus-operator/java-op.iml

-146
This file was deleted.

0 commit comments

Comments
 (0)