Skip to content

Commit

Permalink
Decouple server and jmx annotations (#654)
Browse files Browse the repository at this point in the history
Co-authored-by: Yevhen Ivantsov <[email protected]>
  • Loading branch information
bianchi2 and Yevhen Ivantsov authored Aug 28, 2023
1 parent 43137ea commit 568ebfc
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/main/charts/bamboo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ Kubernetes: `>=1.21.x-0`
| monitoring.jmxExporterImageTag | string | `"0.18.0"` | Image tag to be used to pull jmxExporterImageRepo |
| monitoring.jmxExporterPort | int | `9999` | Port number on which metrics will be available |
| monitoring.jmxExporterPortType | string | `"ClusterIP"` | JMX exporter port type |
| monitoring.jmxServiceAnnotations | object | `{}` | Annotations added to the jmx service |
| monitoring.serviceMonitor.create | bool | `false` | Create ServiceMonitor to start scraping metrics. ServiceMonitor CRD needs to be created in advance. |
| monitoring.serviceMonitor.prometheusLabelSelector | object | `{}` | ServiceMonitorSelector of the prometheus instance. |
| monitoring.serviceMonitor.scrapeIntervalSeconds | int | `30` | Scrape interval for the JMX service. |
Expand Down
2 changes: 1 addition & 1 deletion src/main/charts/bamboo/templates/service-jmx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
labels:
{{- include "common.labels.commonLabels" . | nindent 4 }}
annotations:
{{- with .Values.bamboo.service.annotations }}
{{- with .Values.monitoring.jmxServiceAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
Expand Down
4 changes: 4 additions & 0 deletions src/main/charts/bamboo/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,10 @@ monitoring:
#
exposeJmxMetrics: false

# -- Annotations added to the jmx service
#
jmxServiceAnnotations: {}

# -- Fetch jmx_exporter jar from the image. If set to false make sure to manually copy the jar
# to shared home and provide an absolute path in jmxExporterCustomJarLocation
#
Expand Down
1 change: 1 addition & 0 deletions src/main/charts/bitbucket/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ Kubernetes: `>=1.21.x-0`
| monitoring.jmxExporterImageTag | string | `"0.18.0"` | Image tag to be used to pull jmxExporterImageRepo |
| monitoring.jmxExporterPort | int | `9999` | Port number on which metrics will be available |
| monitoring.jmxExporterPortType | string | `"ClusterIP"` | JMX exporter port type |
| monitoring.jmxServiceAnnotations | object | `{}` | Annotations added to the jmx service |
| monitoring.serviceMonitor.create | bool | `false` | Create ServiceMonitor to start scraping metrics. ServiceMonitor CRD needs to be created in advance. |
| monitoring.serviceMonitor.prometheusLabelSelector | object | `{}` | ServiceMonitorSelector of the prometheus instance. |
| monitoring.serviceMonitor.scrapeIntervalSeconds | int | `30` | Scrape interval for the JMX service. |
Expand Down
2 changes: 1 addition & 1 deletion src/main/charts/bitbucket/templates/service-jmx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
labels:
{{- include "common.labels.commonLabels" . | nindent 4 }}
annotations:
{{- with .Values.bitbucket.service.annotations }}
{{- with .Values.monitoring.jmxServiceAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
Expand Down
4 changes: 4 additions & 0 deletions src/main/charts/bitbucket/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,10 @@ monitoring:
#
exposeJmxMetrics: false

# -- Annotations added to the jmx service
#
jmxServiceAnnotations: {}

# -- Fetch jmx_exporter jar from the image. If set to false make sure to manually copy the jar
# to shared home and provide an absolute path in jmxExporterCustomJarLocation
#
Expand Down
1 change: 1 addition & 0 deletions src/main/charts/confluence/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ Kubernetes: `>=1.21.x-0`
| monitoring.jmxExporterImageTag | string | `"0.18.0"` | Image tag to be used to pull jmxExporterImageRepo |
| monitoring.jmxExporterPort | int | `9999` | Port number on which metrics will be available |
| monitoring.jmxExporterPortType | string | `"ClusterIP"` | JMX exporter port type |
| monitoring.jmxServiceAnnotations | object | `{}` | Annotations added to the jmx service |
| monitoring.serviceMonitor.create | bool | `false` | Create ServiceMonitor to start scraping metrics. ServiceMonitor CRD needs to be created in advance. |
| monitoring.serviceMonitor.prometheusLabelSelector | object | `{}` | ServiceMonitorSelector of the prometheus instance. |
| monitoring.serviceMonitor.scrapeIntervalSeconds | int | `30` | Scrape interval for the JMX service. |
Expand Down
2 changes: 1 addition & 1 deletion src/main/charts/confluence/templates/service-jmx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
labels:
{{- include "common.labels.commonLabels" . | nindent 4 }}
annotations:
{{- with .Values.confluence.service.annotations }}
{{- with .Values.monitoring.jmxServiceAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
Expand Down
4 changes: 4 additions & 0 deletions src/main/charts/confluence/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,10 @@ monitoring:
#
exposeJmxMetrics: false

# -- Annotations added to the jmx service
#
jmxServiceAnnotations: {}

# -- Fetch jmx_exporter jar from the image. If set to false make sure to manually copy the jar
# to shared home and provide an absolute path in jmxExporterCustomJarLocation
#
Expand Down
1 change: 1 addition & 0 deletions src/main/charts/crowd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Kubernetes: `>=1.21.x-0`
| monitoring.jmxExporterImageTag | string | `"0.18.0"` | Image tag to be used to pull jmxExporterImageRepo |
| monitoring.jmxExporterPort | int | `9999` | Port number on which metrics will be available |
| monitoring.jmxExporterPortType | string | `"ClusterIP"` | JMX exporter port type |
| monitoring.jmxServiceAnnotations | object | `{}` | Annotations added to the jmx service |
| monitoring.serviceMonitor.create | bool | `false` | Create ServiceMonitor to start scraping metrics. ServiceMonitor CRD needs to be created in advance. |
| monitoring.serviceMonitor.prometheusLabelSelector | object | `{}` | ServiceMonitorSelector of the prometheus instance. |
| monitoring.serviceMonitor.scrapeIntervalSeconds | int | `30` | Scrape interval for the JMX service. |
Expand Down
2 changes: 1 addition & 1 deletion src/main/charts/crowd/templates/service-jmx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
labels:
{{- include "common.labels.commonLabels" . | nindent 4 }}
annotations:
{{- with .Values.crowd.service.annotations }}
{{- with .Values.monitoring.jmxServiceAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
Expand Down
4 changes: 4 additions & 0 deletions src/main/charts/crowd/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,10 @@ monitoring:
#
exposeJmxMetrics: false

# -- Annotations added to the jmx service
#
jmxServiceAnnotations: {}

# -- Fetch jmx_exporter jar from the image. If set to false make sure to manually copy the jar
# to shared home and provide an absolute path in jmxExporterCustomJarLocation
#
Expand Down
1 change: 1 addition & 0 deletions src/main/charts/jira/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ Kubernetes: `>=1.21.x-0`
| monitoring.jmxExporterImageTag | string | `"0.18.0"` | Image tag to be used to pull jmxExporterImageRepo |
| monitoring.jmxExporterPort | int | `9999` | Port number on which metrics will be available |
| monitoring.jmxExporterPortType | string | `"ClusterIP"` | JMX exporter port type |
| monitoring.jmxServiceAnnotations | object | `{}` | Annotations added to the jmx service |
| monitoring.serviceMonitor.create | bool | `false` | Create ServiceMonitor to start scraping metrics. ServiceMonitor CRD needs to be created in advance. |
| monitoring.serviceMonitor.prometheusLabelSelector | object | `{}` | ServiceMonitorSelector of the prometheus instance. |
| monitoring.serviceMonitor.scrapeIntervalSeconds | int | `30` | Scrape interval for the JMX service. |
Expand Down
2 changes: 1 addition & 1 deletion src/main/charts/jira/templates/service-jmx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
labels:
{{- include "common.labels.commonLabels" . | nindent 4 }}
annotations:
{{- with .Values.jira.service.annotations }}
{{- with .Values.monitoring.jmxServiceAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
Expand Down
4 changes: 4 additions & 0 deletions src/main/charts/jira/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,10 @@ monitoring:
# -- Expose JMX metrics with jmx_exporter https://github.com/prometheus/jmx_exporter
#
exposeJmxMetrics: false

# -- Annotations added to the jmx service
#
jmxServiceAnnotations: {}

# -- Fetch jmx_exporter jar from the image. If set to false make sure to manually copy the jar
# to shared home and provide an absolute path in jmxExporterCustomJarLocation
Expand Down
6 changes: 5 additions & 1 deletion src/test/java/test/JmxMetricsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ void jmx_service_test(Product product) throws Exception {
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of(
"monitoring.exposeJmxMetrics", "true",
"monitoring.jmxExporterPort", "9000",
"monitoring.jmxExporterPortType", "NodePort"
"monitoring.jmxExporterPortType", "NodePort",
"monitoring.jmxServiceAnnotations.foo", "bar"
));

final var service = resources.get(Kind.Service, Service.class, product.getHelmReleaseName()+"-jmx");
Expand All @@ -143,6 +144,9 @@ void jmx_service_test(Product product) throws Exception {
.hasTextEqualTo("NodePort");
VavrAssertions.assertThat(service.getPort("jmx"))
.hasValueSatisfying(node -> assertThat(node.path("port")).hasValueEqualTo(9000));
assertThat(service.getAnnotations()).isObject(Map.of(
"foo", "bar"
));
}

@ParameterizedTest
Expand Down

0 comments on commit 568ebfc

Please sign in to comment.