Skip to content

Commit 5c86b64

Browse files
authored
Merge pull request #48168 from sheriff-rh/osdocs-2933.3
Java-based Operator code update
2 parents dbef8e6 + df5adea commit 5c86b64

File tree

2 files changed

+38
-48
lines changed

2 files changed

+38
-48
lines changed

modules/osdk-java-controller-memcached-deployment.adoc

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,11 @@ The `createMemcachedDeployment` method uses the link:https://fabric8.io/[fabric8
1111
[source,java]
1212
----
1313
private Deployment createMemcachedDeployment(Memcached m) {
14-
return new DeploymentBuilder()
14+
Deployment deployment = new DeploymentBuilder()
1515
.withMetadata(
1616
new ObjectMetaBuilder()
1717
.withName(m.getMetadata().getName())
1818
.withNamespace(m.getMetadata().getNamespace())
19-
.withOwnerReferences(
20-
new OwnerReferenceBuilder()
21-
.withApiVersion("v1")
22-
.withKind("Memcached")
23-
.withName(m.getMetadata().getName())
24-
.withUid(m.getMetadata().getUid())
25-
.build())
2619
.build())
2720
.withSpec(
2821
new DeploymentSpecBuilder()
@@ -50,5 +43,7 @@ The `createMemcachedDeployment` method uses the link:https://fabric8.io/[fabric8
5043
.build())
5144
.build())
5245
.build();
46+
deployment.addOwnerReference(m);
47+
return deployment;
5348
}
5449
----

modules/osdk-java-implement-controller.adoc

Lines changed: 35 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -113,46 +113,41 @@ public class MemcachedReconciler implements Reconciler<Memcached> {
113113
}
114114

115115
private Deployment createMemcachedDeployment(Memcached m) {
116-
return new DeploymentBuilder()
117-
.withMetadata(
118-
new ObjectMetaBuilder()
119-
.withName(m.getMetadata().getName())
120-
.withNamespace(m.getMetadata().getNamespace())
121-
.withOwnerReferences(
122-
new OwnerReferenceBuilder()
123-
.withApiVersion("v1")
124-
.withKind("Memcached")
125-
.withName(m.getMetadata().getName())
126-
.withUid(m.getMetadata().getUid())
127-
.build())
128-
.build())
129-
.withSpec(
130-
new DeploymentSpecBuilder()
131-
.withReplicas(m.getSpec().getSize())
132-
.withSelector(
133-
new LabelSelectorBuilder().withMatchLabels(labelsForMemcached(m)).build())
134-
.withTemplate(
135-
new PodTemplateSpecBuilder()
136-
.withMetadata(
137-
new ObjectMetaBuilder().withLabels(labelsForMemcached(m)).build())
138-
.withSpec(
139-
new PodSpecBuilder()
140-
.withContainers(
141-
new ContainerBuilder()
142-
.withImage("memcached:1.4.36-alpine")
143-
.withName("memcached")
144-
.withCommand("memcached", "-m=64", "-o", "modern", "-v")
145-
.withPorts(
146-
new ContainerPortBuilder()
147-
.withContainerPort(11211)
148-
.withName("memcached")
149-
.build())
150-
.build())
151-
.build())
152-
.build())
153-
.build())
154-
.build();
155-
}
116+
Deployment deployment = new DeploymentBuilder()
117+
.withMetadata(
118+
new ObjectMetaBuilder()
119+
.withName(m.getMetadata().getName())
120+
.withNamespace(m.getMetadata().getNamespace())
121+
.build())
122+
.withSpec(
123+
new DeploymentSpecBuilder()
124+
.withReplicas(m.getSpec().getSize())
125+
.withSelector(
126+
new LabelSelectorBuilder().withMatchLabels(labelsForMemcached(m)).build())
127+
.withTemplate(
128+
new PodTemplateSpecBuilder()
129+
.withMetadata(
130+
new ObjectMetaBuilder().withLabels(labelsForMemcached(m)).build())
131+
.withSpec(
132+
new PodSpecBuilder()
133+
.withContainers(
134+
new ContainerBuilder()
135+
.withImage("memcached:1.4.36-alpine")
136+
.withName("memcached")
137+
.withCommand("memcached", "-m=64", "-o", "modern", "-v")
138+
.withPorts(
139+
new ContainerPortBuilder()
140+
.withContainerPort(11211)
141+
.withName("memcached")
142+
.build())
143+
.build())
144+
.build())
145+
.build())
146+
.build())
147+
.build();
148+
deployment.addOwnerReference(m);
149+
return deployment;
150+
}
156151
}
157152
----
158153
====

0 commit comments

Comments
 (0)