Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make securityContext configurable for jmx exporter init container #670

Merged
merged 3 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/main/charts/bamboo-agent/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: common
repository: https://atlassian.github.io/data-center-helm-charts
version: 1.2.3
digest: sha256:19b32588659e732b2f75427b8bf2040b4daf93893f72f2de19ab76cc7f0e8623
generated: "2023-06-28T12:28:34.897846+10:00"
version: 1.2.4
digest: sha256:a373258f4c668f70e249c8310ba3a105e9b86301a9a7eb659b95d8449eafc05b
generated: "2023-09-18T10:41:52.696271+10:00"
2 changes: 1 addition & 1 deletion src/main/charts/bamboo-agent/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ annotations:
- "Update Helm chart version"
dependencies:
- name: common
version: 1.2.3
version: 1.2.4
repository: https://atlassian.github.io/data-center-helm-charts
2 changes: 1 addition & 1 deletion src/main/charts/bamboo-agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Kubernetes: `>=1.21.x-0`

| Repository | Name | Version |
|------------|------|---------|
| https://atlassian.github.io/data-center-helm-charts | common | 1.2.3 |
| https://atlassian.github.io/data-center-helm-charts | common | 1.2.4 |

## Values

Expand Down
6 changes: 3 additions & 3 deletions src/main/charts/bamboo/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: common
repository: https://atlassian.github.io/data-center-helm-charts
version: 1.2.3
digest: sha256:19b32588659e732b2f75427b8bf2040b4daf93893f72f2de19ab76cc7f0e8623
generated: "2023-06-28T12:28:14.264452+10:00"
version: 1.2.4
digest: sha256:a373258f4c668f70e249c8310ba3a105e9b86301a9a7eb659b95d8449eafc05b
generated: "2023-09-18T10:41:07.792956+10:00"
2 changes: 1 addition & 1 deletion src/main/charts/bamboo/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ annotations:
- "Disable startup probes by default (#653)"
dependencies:
- name: common
version: 1.2.3
version: 1.2.4
repository: https://atlassian.github.io/data-center-helm-charts
5 changes: 4 additions & 1 deletion src/main/charts/bamboo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Kubernetes: `>=1.21.x-0`

| Repository | Name | Version |
|------------|------|---------|
| https://atlassian.github.io/data-center-helm-charts | common | 1.2.3 |
| https://atlassian.github.io/data-center-helm-charts | common | 1.2.4 |

## Values

Expand Down Expand Up @@ -139,6 +139,9 @@ Kubernetes: `>=1.21.x-0`
| monitoring.jmxExporterCustomJarLocation | string | `nil` | Location of jmx_exporter jar file if mounted from a secret or manually copied to shared home |
| monitoring.jmxExporterImageRepo | string | `"bitnami/jmx-exporter"` | Image repository with jmx_exporter jar |
| monitoring.jmxExporterImageTag | string | `"0.18.0"` | Image tag to be used to pull jmxExporterImageRepo |
| monitoring.jmxExporterInitContainer | object | `{"customSecurityContext":{},"runAsRoot":true}` | JMX exporter init container configuration |
| monitoring.jmxExporterInitContainer.customSecurityContext | object | `{}` | Custom SecurityContext for the jmx exporter init container |
| monitoring.jmxExporterInitContainer.runAsRoot | bool | `true` | Whether to run jmx exporter init container as root to be able to copy jmx exporter binary to shared home volume. Set to false if running containers as root is not allowed in the cluster |
| 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 |
Expand Down
13 changes: 13 additions & 0 deletions src/main/charts/bamboo/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,19 @@ monitoring:
#
exposeJmxMetrics: false

# -- JMX exporter init container configuration
#
jmxExporterInitContainer:

# -- Whether to run jmx exporter init container as root to be able to copy jmx exporter binary to shared home volume.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# -- Whether to run jmx exporter init container as root to be able to copy jmx exporter binary to shared home volume.
# -- Whether to run JMX exporter init container as root to copy JMX exporter binary to shared home volume.

# Set to false if running containers as root is not allowed in the cluster
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Set to false if running containers as root is not allowed in the cluster
# Set to false if running containers as root is not allowed in the cluster.

#
runAsRoot: true

# -- Custom SecurityContext for the jmx exporter init container
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# -- Custom SecurityContext for the jmx exporter init container
# -- Custom SecurityContext for the JMX exporter init container

#
customSecurityContext: {}

# -- Annotations added to the jmx service
#
jmxServiceAnnotations: {}
Expand Down
6 changes: 3 additions & 3 deletions src/main/charts/bitbucket/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: common
repository: https://atlassian.github.io/data-center-helm-charts
version: 1.2.3
digest: sha256:19b32588659e732b2f75427b8bf2040b4daf93893f72f2de19ab76cc7f0e8623
generated: "2023-06-28T12:28:46.378103+10:00"
version: 1.2.4
digest: sha256:a373258f4c668f70e249c8310ba3a105e9b86301a9a7eb659b95d8449eafc05b
generated: "2023-09-18T10:41:59.662404+10:00"
2 changes: 1 addition & 1 deletion src/main/charts/bitbucket/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ annotations:

dependencies:
- name: common
version: 1.2.3
version: 1.2.4
repository: https://atlassian.github.io/data-center-helm-charts
5 changes: 4 additions & 1 deletion src/main/charts/bitbucket/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Kubernetes: `>=1.21.x-0`

| Repository | Name | Version |
|------------|------|---------|
| https://atlassian.github.io/data-center-helm-charts | common | 1.2.3 |
| https://atlassian.github.io/data-center-helm-charts | common | 1.2.4 |

## Values

Expand Down Expand Up @@ -172,6 +172,9 @@ Kubernetes: `>=1.21.x-0`
| monitoring.jmxExporterCustomJarLocation | string | `nil` | Location of jmx_exporter jar file if mounted from a secret or manually copied to shared home |
| monitoring.jmxExporterImageRepo | string | `"bitnami/jmx-exporter"` | Image repository with jmx_exporter jar |
| monitoring.jmxExporterImageTag | string | `"0.18.0"` | Image tag to be used to pull jmxExporterImageRepo |
| monitoring.jmxExporterInitContainer | object | `{"customSecurityContext":{},"runAsRoot":true}` | JMX exporter init container configuration |
| monitoring.jmxExporterInitContainer.customSecurityContext | object | `{}` | Custom SecurityContext for the jmx exporter init container |
| monitoring.jmxExporterInitContainer.runAsRoot | bool | `true` | Whether to run jmx exporter init container as root to be able to copy jmx exporter binary to shared home volume. Set to false if running containers as root is not allowed in the cluster |
| 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 |
Expand Down
13 changes: 13 additions & 0 deletions src/main/charts/bitbucket/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,19 @@ monitoring:
#
exposeJmxMetrics: false

# -- JMX exporter init container configuration
#
jmxExporterInitContainer:

# -- Whether to run jmx exporter init container as root to be able to copy jmx exporter binary to shared home volume.
# Set to false if running containers as root is not allowed in the cluster
#
runAsRoot: true

# -- Custom SecurityContext for the jmx exporter init container
#
customSecurityContext: {}

# -- Annotations added to the jmx service
#
jmxServiceAnnotations: {}
Expand Down
6 changes: 3 additions & 3 deletions src/main/charts/confluence/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: common
repository: https://atlassian.github.io/data-center-helm-charts
version: 1.2.3
digest: sha256:19b32588659e732b2f75427b8bf2040b4daf93893f72f2de19ab76cc7f0e8623
generated: "2023-06-28T12:28:55.882836+10:00"
version: 1.2.4
digest: sha256:a373258f4c668f70e249c8310ba3a105e9b86301a9a7eb659b95d8449eafc05b
generated: "2023-09-18T10:42:03.96129+10:00"
2 changes: 1 addition & 1 deletion src/main/charts/confluence/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ annotations:

dependencies:
- name: common
version: 1.2.3
version: 1.2.4
repository: https://atlassian.github.io/data-center-helm-charts
5 changes: 4 additions & 1 deletion src/main/charts/confluence/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Kubernetes: `>=1.21.x-0`

| Repository | Name | Version |
|------------|------|---------|
| https://atlassian.github.io/data-center-helm-charts | common | 1.2.3 |
| https://atlassian.github.io/data-center-helm-charts | common | 1.2.4 |

## Values

Expand Down Expand Up @@ -134,6 +134,9 @@ Kubernetes: `>=1.21.x-0`
| monitoring.jmxExporterCustomJarLocation | string | `nil` | Location of jmx_exporter jar file if mounted from a secret or manually copied to shared home |
| monitoring.jmxExporterImageRepo | string | `"bitnami/jmx-exporter"` | Image repository with jmx_exporter jar |
| monitoring.jmxExporterImageTag | string | `"0.18.0"` | Image tag to be used to pull jmxExporterImageRepo |
| monitoring.jmxExporterInitContainer | object | `{"customSecurityContext":{},"runAsRoot":true}` | JMX exporter init container configuration |
| monitoring.jmxExporterInitContainer.customSecurityContext | object | `{}` | Custom SecurityContext for the jmx exporter init container |
| monitoring.jmxExporterInitContainer.runAsRoot | bool | `true` | Whether to run jmx exporter init container as root to be able to copy jmx exporter binary to shared home volume. Set to false if running containers as root is not allowed in the cluster |
| 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 |
Expand Down
13 changes: 13 additions & 0 deletions src/main/charts/confluence/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,19 @@ monitoring:
#
exposeJmxMetrics: false

# -- JMX exporter init container configuration
#
jmxExporterInitContainer:

# -- Whether to run jmx exporter init container as root to be able to copy jmx exporter binary to shared home volume.
# Set to false if running containers as root is not allowed in the cluster
#
runAsRoot: true

# -- Custom SecurityContext for the jmx exporter init container
#
customSecurityContext: {}

# -- Annotations added to the jmx service
#
jmxServiceAnnotations: {}
Expand Down
6 changes: 3 additions & 3 deletions src/main/charts/crowd/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: common
repository: https://atlassian.github.io/data-center-helm-charts
version: 1.2.3
digest: sha256:19b32588659e732b2f75427b8bf2040b4daf93893f72f2de19ab76cc7f0e8623
generated: "2023-06-28T12:29:08.571023+10:00"
version: 1.2.4
digest: sha256:a373258f4c668f70e249c8310ba3a105e9b86301a9a7eb659b95d8449eafc05b
generated: "2023-09-18T10:42:11.392333+10:00"
2 changes: 1 addition & 1 deletion src/main/charts/crowd/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ annotations:

dependencies:
- name: common
version: 1.2.3
version: 1.2.4
repository: https://atlassian.github.io/data-center-helm-charts
5 changes: 4 additions & 1 deletion src/main/charts/crowd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Kubernetes: `>=1.21.x-0`

| Repository | Name | Version |
|------------|------|---------|
| https://atlassian.github.io/data-center-helm-charts | common | 1.2.3 |
| https://atlassian.github.io/data-center-helm-charts | common | 1.2.4 |

## Values

Expand Down Expand Up @@ -113,6 +113,9 @@ Kubernetes: `>=1.21.x-0`
| monitoring.jmxExporterCustomJarLocation | string | `nil` | Location of jmx_exporter jar file if mounted from a secret or manually copied to shared home |
| monitoring.jmxExporterImageRepo | string | `"bitnami/jmx-exporter"` | Image repository with jmx_exporter jar |
| monitoring.jmxExporterImageTag | string | `"0.18.0"` | Image tag to be used to pull jmxExporterImageRepo |
| monitoring.jmxExporterInitContainer | object | `{"customSecurityContext":{},"runAsRoot":true}` | JMX exporter init container configuration |
| monitoring.jmxExporterInitContainer.customSecurityContext | object | `{}` | Custom SecurityContext for the jmx exporter init container |
| monitoring.jmxExporterInitContainer.runAsRoot | bool | `true` | Whether to run jmx exporter init container as root to be able to copy jmx exporter binary to shared home volume. Set to false if running containers as root is not allowed in the cluster |
| 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 |
Expand Down
13 changes: 13 additions & 0 deletions src/main/charts/crowd/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,19 @@ monitoring:
#
exposeJmxMetrics: false

# -- JMX exporter init container configuration
#
jmxExporterInitContainer:

# -- Whether to run jmx exporter init container as root to be able to copy jmx exporter binary to shared home volume.
# Set to false if running containers as root is not allowed in the cluster
#
runAsRoot: true

# -- Custom SecurityContext for the jmx exporter init container
#
customSecurityContext: {}

# -- Annotations added to the jmx service
#
jmxServiceAnnotations: {}
Expand Down
6 changes: 3 additions & 3 deletions src/main/charts/jira/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: common
repository: https://atlassian.github.io/data-center-helm-charts
version: 1.2.3
digest: sha256:19b32588659e732b2f75427b8bf2040b4daf93893f72f2de19ab76cc7f0e8623
generated: "2023-06-28T12:29:27.369749+10:00"
version: 1.2.4
digest: sha256:a373258f4c668f70e249c8310ba3a105e9b86301a9a7eb659b95d8449eafc05b
generated: "2023-09-18T10:42:18.321112+10:00"
2 changes: 1 addition & 1 deletion src/main/charts/jira/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ annotations:

dependencies:
- name: common
version: 1.2.3
version: 1.2.4
repository: https://atlassian.github.io/data-center-helm-charts
5 changes: 4 additions & 1 deletion src/main/charts/jira/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Kubernetes: `>=1.21.x-0`

| Repository | Name | Version |
|------------|------|---------|
| https://atlassian.github.io/data-center-helm-charts | common | 1.2.3 |
| https://atlassian.github.io/data-center-helm-charts | common | 1.2.4 |

## Values

Expand Down Expand Up @@ -130,6 +130,9 @@ Kubernetes: `>=1.21.x-0`
| monitoring.jmxExporterCustomJarLocation | string | `nil` | Location of jmx_exporter jar file if mounted from a secret or manually copied to shared home |
| monitoring.jmxExporterImageRepo | string | `"bitnami/jmx-exporter"` | Image repository with jmx_exporter jar |
| monitoring.jmxExporterImageTag | string | `"0.18.0"` | Image tag to be used to pull jmxExporterImageRepo |
| monitoring.jmxExporterInitContainer | object | `{"customSecurityContext":{},"runAsRoot":true}` | JMX exporter init container configuration |
| monitoring.jmxExporterInitContainer.customSecurityContext | object | `{}` | Custom SecurityContext for the jmx exporter init container |
| monitoring.jmxExporterInitContainer.runAsRoot | bool | `true` | Whether to run jmx exporter init container as root to be able to copy jmx exporter binary to shared home volume. Set to false if running containers as root is not allowed in the cluster |
| 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 |
Expand Down
13 changes: 13 additions & 0 deletions src/main/charts/jira/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,19 @@ monitoring:
#
exposeJmxMetrics: false

# -- JMX exporter init container configuration
#
jmxExporterInitContainer:

# -- Whether to run jmx exporter init container as root to be able to copy jmx exporter binary to shared home volume.
# Set to false if running containers as root is not allowed in the cluster
#
runAsRoot: true

# -- Custom SecurityContext for the jmx exporter init container
#
customSecurityContext: {}

# -- Annotations added to the jmx service
#
jmxServiceAnnotations: {}
Expand Down
35 changes: 35 additions & 0 deletions src/test/java/test/JmxMetricsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,41 @@ void expose_jmx_metrics_enabled_init_container(Product product) throws Exception
}
}

@ParameterizedTest
@EnumSource(value = Product.class, names = {"bamboo_agent"}, mode = EnumSource.Mode.EXCLUDE)
void expose_jmx_metrics_enabled_init_container_run_as_root(Product product) throws Exception {
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of(
"monitoring.exposeJmxMetrics", "true"
));
StatefulSet statefulSet = resources.getStatefulSet(product.getHelmReleaseName());
assertThat(statefulSet.getInitContainer("fetch-jmx-exporter").get().path("securityContext").path("runAsUser")).hasValueEqualTo(0);
}

@ParameterizedTest
@EnumSource(value = Product.class, names = {"bamboo_agent"}, mode = EnumSource.Mode.EXCLUDE)
void expose_jmx_metrics_enabled_init_container_no_root(Product product) throws Exception {
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of(
"monitoring.exposeJmxMetrics", "true",
"monitoring.jmxExporterInitContainer.runAsRoot", "false"
));
StatefulSet statefulSet = resources.getStatefulSet(product.getHelmReleaseName());
assertThat(statefulSet.getInitContainer("fetch-jmx-exporter").get().path("securityContext")).isEmpty();
}

@ParameterizedTest
@EnumSource(value = Product.class, names = {"bamboo_agent"}, mode = EnumSource.Mode.EXCLUDE)
void expose_jmx_metrics_enabled_init_container_custom_security_context(Product product) throws Exception {
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of(
"monitoring.exposeJmxMetrics", "true",
"monitoring.jmxExporterInitContainer.runAsRoot", "false",
"monitoring.jmxExporterInitContainer.customSecurityContext.fsGroup", "1009",
"monitoring.jmxExporterInitContainer.customSecurityContext.runAsUser", "true"
));
StatefulSet statefulSet = resources.getStatefulSet(product.getHelmReleaseName());
assertThat(statefulSet.getInitContainer("fetch-jmx-exporter").get().path("securityContext").path("fsGroup")).hasValueEqualTo(1009);
assertThat(statefulSet.getInitContainer("fetch-jmx-exporter").get().path("securityContext").path("runAsUser")).hasToString("true");
}

@ParameterizedTest
@EnumSource(value = Product.class, names = {"bamboo_agent"}, mode = EnumSource.Mode.EXCLUDE)
void expose_jmx_metrics_enabled_custom_vol_paths(Product product) throws Exception {
Expand Down
Loading