Skip to content

Commit 352daeb

Browse files
authored
OWLS-101705 Support resource limits on the monitoring exporter container (#3441)
* OWLS-101705 Support resource limits on the monitoring exporter container
1 parent 9a08695 commit 352daeb

File tree

12 files changed

+109
-2
lines changed

12 files changed

+109
-2
lines changed

documentation/domains/Domain.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,10 @@
744744
"port": {
745745
"description": "The port exposed by the WebLogic Monitoring Exporter running in the sidecar container. Defaults to 8080. The port value must not conflict with a port used by any WebLogic Server instance, including the ports of built-in channels or network access points (NAPs).",
746746
"type": "number"
747+
},
748+
"resources": {
749+
"description": "Memory and CPU minimum requirements and limits for the Monitoring Exporter sidecar. See `kubectl explain pods.spec.containers.resources`.",
750+
"$ref": "https://github.com/garethr/kubernetes-json-schema/blob/master/v1.13.5/_definitions.json#/definitions/io.k8s.api.core.v1.ResourceRequirements"
747751
}
748752
}
749753
},

documentation/domains/Domain.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ The current status of the operation of the WebLogic domain. Updated automaticall
146146
| `image` | string | The WebLogic Monitoring Exporter sidecar container image name. Defaults to ghcr.io/oracle/weblogic-monitoring-exporter:2.0.7 |
147147
| `imagePullPolicy` | string | The image pull policy for the WebLogic Monitoring Exporter sidecar container image. Legal values are Always, Never, and IfNotPresent. Defaults to Always if image ends in :latest; IfNotPresent, otherwise. |
148148
| `port` | number | The port exposed by the WebLogic Monitoring Exporter running in the sidecar container. Defaults to 8080. The port value must not conflict with a port used by any WebLogic Server instance, including the ports of built-in channels or network access points (NAPs). |
149+
| `resources` | [Resource Requirements](k8s1.13.5.md#resource-requirements) | Memory and CPU minimum requirements and limits for the Monitoring Exporter sidecar. See `kubectl explain pods.spec.containers.resources`. |
149150

150151
### Server Pod
151152

documentation/domains/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,6 +1665,10 @@
16651665
"port": {
16661666
"description": "The port exposed by the WebLogic Monitoring Exporter running in the sidecar container. Defaults to 8080. The port value must not conflict with a port used by any WebLogic Server instance, including the ports of built-in channels or network access points (NAPs).",
16671667
"type": "number"
1668+
},
1669+
"resources": {
1670+
"description": "Memory and CPU minimum requirements and limits for the Monitoring Exporter sidecar. See `kubectl explain pods.spec.containers.resources`.",
1671+
"$ref": "https://github.com/garethr/kubernetes-json-schema/blob/master/v1.13.5/_definitions.json#/definitions/io.k8s.api.core.v1.ResourceRequirements"
16681672
}
16691673
}
16701674
},

kubernetes/crd/domain-crd.yaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ apiVersion: apiextensions.k8s.io/v1
55
kind: CustomResourceDefinition
66
metadata:
77
annotations:
8-
weblogic.sha256: bbd63d4e4cdbf643e599cdb9d28490c2692cf192fba2d2b69185742343d451b1
8+
weblogic.sha256: 1641aa9f4ae5186be388438aef308f41280e72198f1a1318e3a8078af876fe7d
99
name: domains.weblogic.oracle
1010
spec:
1111
group: weblogic.oracle
@@ -66,6 +66,19 @@ spec:
6666
instance, including the ports of built-in channels or network
6767
access points (NAPs).
6868
type: number
69+
resources:
70+
description: Memory and CPU minimum requirements and limits for
71+
the Monitoring Exporter sidecar. See `kubectl explain pods.spec.containers.resources`.
72+
properties:
73+
requests:
74+
additionalProperties:
75+
type: string
76+
type: object
77+
limits:
78+
additionalProperties:
79+
type: string
80+
type: object
81+
type: object
6982
type: object
7083
configuration:
7184
description: Models and overrides affecting the WebLogic domain configuration.

operator/src/main/java/oracle/kubernetes/operator/helpers/PodStepContext.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,6 +1441,7 @@ private V1Container createMonitoringExporterContainer() {
14411441
.name(EXPORTER_CONTAINER_NAME)
14421442
.image(getDomain().getMonitoringExporterImage())
14431443
.imagePullPolicy(getDomain().getMonitoringExporterImagePullPolicy())
1444+
.resources(getDomain().getMonitoringExporterResources())
14441445
.addEnvItem(new V1EnvVar().name("JAVA_OPTS").value(createJavaOptions()))
14451446
.addPortsItem(new V1ContainerPort()
14461447
.name(getMetricsPortName()).protocol("TCP").containerPort(getPort()));

operator/src/main/java/oracle/kubernetes/weblogic/domain/DomainConfigurator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import io.kubernetes.client.openapi.models.V1LocalObjectReference;
1616
import io.kubernetes.client.openapi.models.V1PodReadinessGate;
1717
import io.kubernetes.client.openapi.models.V1PodSecurityContext;
18+
import io.kubernetes.client.openapi.models.V1ResourceRequirements;
1819
import io.kubernetes.client.openapi.models.V1SecurityContext;
1920
import io.kubernetes.client.openapi.models.V1Toleration;
2021
import oracle.kubernetes.operator.DomainSourceType;
@@ -34,7 +35,7 @@ public abstract class DomainConfigurator {
3435

3536
private Domain domain;
3637

37-
public DomainConfigurator() {
38+
protected DomainConfigurator() {
3839
}
3940

4041
protected DomainConfigurator(Domain domain) {
@@ -335,6 +336,8 @@ protected DomainSpec getDomainSpec() {
335336

336337
public abstract DomainConfigurator withMonitoringExporterConfiguration(String configuration);
337338

339+
public abstract DomainConfigurator withMonitoringExporterResources(V1ResourceRequirements resourceRequirements);
340+
338341
public abstract DomainConfigurator withMonitoringExporterImage(String imageName);
339342

340343
public abstract DomainConfigurator withMonitoringExporterPort(Integer port);

operator/src/main/java/oracle/kubernetes/weblogic/domain/model/Domain.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import io.kubernetes.client.openapi.models.V1EnvVar;
2626
import io.kubernetes.client.openapi.models.V1ObjectMeta;
2727
import io.kubernetes.client.openapi.models.V1PodSpec;
28+
import io.kubernetes.client.openapi.models.V1ResourceRequirements;
2829
import io.kubernetes.client.openapi.models.V1SecretReference;
2930
import io.kubernetes.client.openapi.models.V1VolumeMount;
3031
import jakarta.validation.Valid;
@@ -281,6 +282,10 @@ public MonitoringExporterSpecification getMonitoringExporterSpecification() {
281282
return spec.getMonitoringExporterSpecification();
282283
}
283284

285+
public V1ResourceRequirements getMonitoringExporterResources() {
286+
return spec.getMonitoringExporterResourceRequirements();
287+
}
288+
284289
public String getMonitoringExporterImage() {
285290
return spec.getMonitoringExporterImage();
286291
}

operator/src/main/java/oracle/kubernetes/weblogic/domain/model/DomainCommonConfigurator.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import io.kubernetes.client.openapi.models.V1EnvVar;
1313
import io.kubernetes.client.openapi.models.V1PodReadinessGate;
1414
import io.kubernetes.client.openapi.models.V1PodSecurityContext;
15+
import io.kubernetes.client.openapi.models.V1ResourceRequirements;
1516
import io.kubernetes.client.openapi.models.V1SecretReference;
1617
import io.kubernetes.client.openapi.models.V1SecurityContext;
1718
import io.kubernetes.client.openapi.models.V1Toleration;
@@ -174,6 +175,12 @@ public DomainConfigurator withMonitoringExporterConfiguration(String configurati
174175
return this;
175176
}
176177

178+
@Override
179+
public DomainConfigurator withMonitoringExporterResources(V1ResourceRequirements resourceRequirements) {
180+
getDomainSpec().setMonitoringExporterResources(resourceRequirements);
181+
return this;
182+
}
183+
177184
@Override
178185
public DomainConfigurator withMonitoringExporterImage(String imageName) {
179186
getDomainSpec().setMonitoringExporterImage(imageName);

operator/src/main/java/oracle/kubernetes/weblogic/domain/model/DomainSpec.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import com.google.gson.annotations.SerializedName;
1515
import io.kubernetes.client.openapi.models.V1LocalObjectReference;
16+
import io.kubernetes.client.openapi.models.V1ResourceRequirements;
1617
import io.kubernetes.client.openapi.models.V1SecretReference;
1718
import jakarta.validation.Valid;
1819
import jakarta.validation.constraints.NotNull;
@@ -348,6 +349,20 @@ public Integer getMonitoringExporterPort() {
348349
return monitoringExporter == null ? null : monitoringExporter.getPort();
349350
}
350351

352+
V1ResourceRequirements getMonitoringExporterResourceRequirements() {
353+
return Optional.ofNullable(monitoringExporter).map(MonitoringExporterSpecification::getResources).orElse(null);
354+
}
355+
356+
/**
357+
* Specifies the image for the monitoring exporter sidecar.
358+
* @param resourceRequirements the name of the docker image
359+
*/
360+
public void setMonitoringExporterResources(V1ResourceRequirements resourceRequirements) {
361+
assert monitoringExporter != null : "May not set resources without configuration";
362+
363+
monitoringExporter.setResources(resourceRequirements);
364+
}
365+
351366
/**
352367
* Specifies the image for the monitoring exporter sidecar.
353368
* @param imageName the name of the docker image

operator/src/main/java/oracle/kubernetes/weblogic/domain/model/MonitoringExporterSpecification.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import javax.annotation.Nullable;
99

1010
import com.google.gson.Gson;
11+
import io.kubernetes.client.openapi.models.V1ResourceRequirements;
1112
import oracle.kubernetes.json.Description;
1213
import oracle.kubernetes.json.EnumClass;
1314
import oracle.kubernetes.json.PreserveUnknown;
@@ -44,6 +45,14 @@ public class MonitoringExporterSpecification {
4445
@EnumClass(ImagePullPolicy.class)
4546
private String imagePullPolicy;
4647

48+
/**
49+
* Defines the requirements and limits for the monitoring exporter sidecar.
50+
*
51+
*/
52+
@Description("Memory and CPU minimum requirements and limits for the Monitoring Exporter sidecar. "
53+
+ "See `kubectl explain pods.spec.containers.resources`.")
54+
private V1ResourceRequirements resources;
55+
4756
@Description(
4857
"The port exposed by the WebLogic Monitoring Exporter running in the sidecar container. "
4958
+ "Defaults to 8080. The port value must not conflict with a port used by any WebLogic Server "
@@ -78,6 +87,14 @@ private Map<String, Object> parse(String yaml) {
7887
return new Yaml().load(yaml);
7988
}
8089

90+
public V1ResourceRequirements getResources() {
91+
return resources;
92+
}
93+
94+
public void setResources(V1ResourceRequirements resources) {
95+
this.resources = resources;
96+
}
97+
8198
String getImage() {
8299
return Optional.ofNullable(image).orElse(DEFAULT_EXPORTER_IMAGE);
83100
}
@@ -106,6 +123,7 @@ void setPort(Integer port) {
106123
public String toString() {
107124
return new ToStringBuilder(this)
108125
.append("configuration", configuration)
126+
.append("resources", resources)
109127
.append("image", image)
110128
.append("imagePullPolicy", imagePullPolicy)
111129
.append("port", port)
@@ -121,6 +139,7 @@ public boolean equals(Object o) {
121139
private boolean equals(MonitoringExporterSpecification that) {
122140
return new EqualsBuilder()
123141
.append(configuration, that.configuration)
142+
.append(resources, that.resources)
124143
.append(image, that.image)
125144
.append(imagePullPolicy, that.imagePullPolicy)
126145
.append(port, that.port)
@@ -131,6 +150,7 @@ private boolean equals(MonitoringExporterSpecification that) {
131150
public int hashCode() {
132151
return new HashCodeBuilder(17, 37)
133152
.append(configuration)
153+
.append(resources)
134154
.append(image)
135155
.append(imagePullPolicy)
136156
.append(port)

0 commit comments

Comments
 (0)