From 71cb0f8992097d78cda149549789e1b27ee33f6f Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Wed, 27 Nov 2024 13:38:46 -0500 Subject: [PATCH 1/5] feat(eventtemplates): declarative configuration of Event Template ConfigMaps --- charts/cryostat/README.md | 1 + .../templates/cryostat_deployment.yaml | 11 ++++++++ .../tests/cryostat_deployment_test.yaml | 27 +++++++++++++++++++ charts/cryostat/values.schema.json | 16 +++++++++++ charts/cryostat/values.yaml | 4 +++ 5 files changed, 59 insertions(+) diff --git a/charts/cryostat/README.md b/charts/cryostat/README.md index 6234921..4a05ffb 100644 --- a/charts/cryostat/README.md +++ b/charts/cryostat/README.md @@ -84,6 +84,7 @@ helm install cryostat ./charts/cryostat | `core.discovery.kubernetes.portNames` | List of port names that the Cryostat application should look for in order to consider a target as JMX connectable | `[]` | | `core.discovery.kubernetes.builtInPortNumbersDisabled` | When false and `portNumbers` is empty, the Cryostat application will use the default port number `9091` to look for JMX connectable targets. | `false` | | `core.discovery.kubernetes.portNumbers` | List of port numbers that the Cryostat application should look for in order to consider a target as JMX connectable | `[]` | +| `core.config.eventTemplates.configMapNames` | List of ConfigMap names. Each ConfigMap is expected to contain one or more files, which are .jfc (XML) JFR Event Templates, to be mounted to the Cryostat container. | `[]` | ### Report Generator Deployment diff --git a/charts/cryostat/templates/cryostat_deployment.yaml b/charts/cryostat/templates/cryostat_deployment.yaml index cb0fbca..64c2ac3 100644 --- a/charts/cryostat/templates/cryostat_deployment.yaml +++ b/charts/cryostat/templates/cryostat_deployment.yaml @@ -141,6 +141,12 @@ spec: failureThreshold: 18 resources: {{- toYaml .Values.core.resources | nindent 12 }} + volumeMounts: + {{- range .Values.core.config.eventTemplates.configMapNames }} + - name: {{ . }} + mountPath: /opt/cryostat.d/templates.d/{{ . }} + readOnly: true + {{- end }} - name: {{ printf "%s-%s" .Chart.Name "grafana" }} securityContext: {{- toYaml .Values.grafana.securityContext | nindent 12 }} @@ -216,3 +222,8 @@ spec: secret: secretName: {{ .Release.Name }}-proxy-tls {{- end }} + {{- range .Values.core.config.eventTemplates.configMapNames}} + - name: {{ . }} + configMap: + name: {{ . }} + {{- end }} diff --git a/charts/cryostat/tests/cryostat_deployment_test.yaml b/charts/cryostat/tests/cryostat_deployment_test.yaml index 0548fc7..3352fb8 100644 --- a/charts/cryostat/tests/cryostat_deployment_test.yaml +++ b/charts/cryostat/tests/cryostat_deployment_test.yaml @@ -180,6 +180,8 @@ tests: requests: cpu: 500m memory: 384Mi + - notExists: + path: spec.template.spec.contains[?(@.name=='cryostat')].volumeMounts - it: should set log level set: @@ -514,3 +516,28 @@ tests: path: spec.template.spec.containers[?(@.name=='cryostat-jfr-datasource')].imagePullPolicy value: "IfNotPresent" + - it: should add volume mounts for declarative event templates + set: + core.config.eventTemplates.configMapNames: ['a', 'b'] + asserts: + - equal: + path: spec.template.spec.containers[?(@.name=='cryostat')].volumeMounts + value: + - name: a + mountPath: /opt/cryostat.d/templates.d/a + readOnly: true + - name: b + mountPath: /opt/cryostat.d/templates.d/b + readOnly: true + - equal: + path: spec.template.spec.volumes + value: + - name: alpha-config + configMap: + name: RELEASE-NAME-alpha-config + - name: a + configMap: + name: a + - name: b + configMap: + name: b diff --git a/charts/cryostat/values.schema.json b/charts/cryostat/values.schema.json index 88c3baf..d37ee74 100644 --- a/charts/cryostat/values.schema.json +++ b/charts/cryostat/values.schema.json @@ -258,6 +258,22 @@ } } } + }, + "config": { + "type": "object", + "properties": { + "eventTemplates": { + "type": "object", + "properties": { + "configMapNames": { + "type": "array", + "description": "List of ConfigMap names. Each ConfigMap is expected to contain one or more files, which are .jfc (XML) JFR Event Templates, to be mounted to the Cryostat container.", + "default": [], + "items": {} + } + } + } + } } } }, diff --git a/charts/cryostat/values.yaml b/charts/cryostat/values.yaml index 79fdd4d..a45efec 100644 --- a/charts/cryostat/values.yaml +++ b/charts/cryostat/values.yaml @@ -85,6 +85,10 @@ core: builtInPortNumbersDisabled: false ## @param core.discovery.kubernetes.portNumbers [array] List of port numbers that the Cryostat application should look for in order to consider a target as JMX connectable portNumbers: [] + config: + eventTemplates: + ## @param core.config.eventTemplates.configMapNames [array] List of ConfigMap names. Each ConfigMap is expected to contain one or more files, which are .jfc (XML) JFR Event Templates, to be mounted to the Cryostat container. + configMapNames: [] ## @section Report Generator Deployment ## @extra reports Configuration for the Reports Generator deployment From 871ae558d191171fca910358056ddc95b5991516 Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Mon, 2 Dec 2024 10:34:35 -0500 Subject: [PATCH 2/5] explicitly non-optional --- charts/cryostat/templates/cryostat_deployment.yaml | 1 + charts/cryostat/tests/cryostat_deployment_test.yaml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/charts/cryostat/templates/cryostat_deployment.yaml b/charts/cryostat/templates/cryostat_deployment.yaml index 64c2ac3..3ebe0ed 100644 --- a/charts/cryostat/templates/cryostat_deployment.yaml +++ b/charts/cryostat/templates/cryostat_deployment.yaml @@ -226,4 +226,5 @@ spec: - name: {{ . }} configMap: name: {{ . }} + optional: false {{- end }} diff --git a/charts/cryostat/tests/cryostat_deployment_test.yaml b/charts/cryostat/tests/cryostat_deployment_test.yaml index 3352fb8..f02b414 100644 --- a/charts/cryostat/tests/cryostat_deployment_test.yaml +++ b/charts/cryostat/tests/cryostat_deployment_test.yaml @@ -538,6 +538,8 @@ tests: - name: a configMap: name: a + optional: false - name: b configMap: name: b + optional: false From 3f0dbc81b5d11e2c516d2a7112798b033868d93e Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Mon, 2 Dec 2024 10:41:29 -0500 Subject: [PATCH 3/5] projected volume --- .../templates/cryostat_deployment.yaml | 20 +++++++++------- .../tests/cryostat_deployment_test.yaml | 24 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/charts/cryostat/templates/cryostat_deployment.yaml b/charts/cryostat/templates/cryostat_deployment.yaml index 3ebe0ed..4a2ea02 100644 --- a/charts/cryostat/templates/cryostat_deployment.yaml +++ b/charts/cryostat/templates/cryostat_deployment.yaml @@ -141,10 +141,10 @@ spec: failureThreshold: 18 resources: {{- toYaml .Values.core.resources | nindent 12 }} + {{- if .Values.core.config.eventTemplates.configMapNames}} volumeMounts: - {{- range .Values.core.config.eventTemplates.configMapNames }} - - name: {{ . }} - mountPath: /opt/cryostat.d/templates.d/{{ . }} + - name: declarative-event-templates + mountPath: /opt/cryostat.d/templates.d readOnly: true {{- end }} - name: {{ printf "%s-%s" .Chart.Name "grafana" }} @@ -222,9 +222,11 @@ spec: secret: secretName: {{ .Release.Name }}-proxy-tls {{- end }} - {{- range .Values.core.config.eventTemplates.configMapNames}} - - name: {{ . }} - configMap: - name: {{ . }} - optional: false - {{- end }} + - name: declarative-event-templates + projected: + sources: + {{- range .Values.core.config.eventTemplates.configMapNames}} + - configMap: + name: {{ . }} + optional: false + {{- end }} diff --git a/charts/cryostat/tests/cryostat_deployment_test.yaml b/charts/cryostat/tests/cryostat_deployment_test.yaml index f02b414..4978db3 100644 --- a/charts/cryostat/tests/cryostat_deployment_test.yaml +++ b/charts/cryostat/tests/cryostat_deployment_test.yaml @@ -523,11 +523,8 @@ tests: - equal: path: spec.template.spec.containers[?(@.name=='cryostat')].volumeMounts value: - - name: a - mountPath: /opt/cryostat.d/templates.d/a - readOnly: true - - name: b - mountPath: /opt/cryostat.d/templates.d/b + - name: declarative-event-templates + mountPath: /opt/cryostat.d/templates.d readOnly: true - equal: path: spec.template.spec.volumes @@ -535,11 +532,12 @@ tests: - name: alpha-config configMap: name: RELEASE-NAME-alpha-config - - name: a - configMap: - name: a - optional: false - - name: b - configMap: - name: b - optional: false + - name: declarative-event-templates + projected: + sources: + - configMap: + name: a + optional: false + - configMap: + name: b + optional: false From ad25e1cb71a3640fde14ba7b95f9211b57037498 Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Wed, 4 Dec 2024 14:04:56 -0500 Subject: [PATCH 4/5] fs mode --- .../templates/cryostat_deployment.yaml | 1 + .../tests/cryostat_deployment_test.yaml | 29 +++++++++++++++++++ charts/cryostat/values.yaml | 2 ++ 3 files changed, 32 insertions(+) diff --git a/charts/cryostat/templates/cryostat_deployment.yaml b/charts/cryostat/templates/cryostat_deployment.yaml index 4a2ea02..14c0a2f 100644 --- a/charts/cryostat/templates/cryostat_deployment.yaml +++ b/charts/cryostat/templates/cryostat_deployment.yaml @@ -224,6 +224,7 @@ spec: {{- end }} - name: declarative-event-templates projected: + defaultMode: {{ .Values.core.config.declarative.fsMode }} sources: {{- range .Values.core.config.eventTemplates.configMapNames}} - configMap: diff --git a/charts/cryostat/tests/cryostat_deployment_test.yaml b/charts/cryostat/tests/cryostat_deployment_test.yaml index 4978db3..67d0e3a 100644 --- a/charts/cryostat/tests/cryostat_deployment_test.yaml +++ b/charts/cryostat/tests/cryostat_deployment_test.yaml @@ -534,6 +534,35 @@ tests: name: RELEASE-NAME-alpha-config - name: declarative-event-templates projected: + defaultMode: 0440 + sources: + - configMap: + name: a + optional: false + - configMap: + name: b + optional: false + + - it: should add volume mounts for declarative event templates with specific fs mode + set: + core.config.eventTemplates.configMapNames: ['a', 'b'] + core.config.declarative.fsMode: 0644 + asserts: + - equal: + path: spec.template.spec.containers[?(@.name=='cryostat')].volumeMounts + value: + - name: declarative-event-templates + mountPath: /opt/cryostat.d/templates.d + readOnly: true + - equal: + path: spec.template.spec.volumes + value: + - name: alpha-config + configMap: + name: RELEASE-NAME-alpha-config + - name: declarative-event-templates + projected: + defaultMode: 0644 sources: - configMap: name: a diff --git a/charts/cryostat/values.yaml b/charts/cryostat/values.yaml index a45efec..8f485fb 100644 --- a/charts/cryostat/values.yaml +++ b/charts/cryostat/values.yaml @@ -86,6 +86,8 @@ core: ## @param core.discovery.kubernetes.portNumbers [array] List of port numbers that the Cryostat application should look for in order to consider a target as JMX connectable portNumbers: [] config: + declarative: + fsMode: 0440 eventTemplates: ## @param core.config.eventTemplates.configMapNames [array] List of ConfigMap names. Each ConfigMap is expected to contain one or more files, which are .jfc (XML) JFR Event Templates, to be mounted to the Cryostat container. configMapNames: [] From cdacc38c24064f5645201db27c1b6e124bc5dbbc Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Wed, 4 Dec 2024 14:11:42 -0500 Subject: [PATCH 5/5] readme --- charts/cryostat/README.md | 1 + charts/cryostat/values.schema.json | 10 ++++++++++ charts/cryostat/values.yaml | 1 + 3 files changed, 12 insertions(+) diff --git a/charts/cryostat/README.md b/charts/cryostat/README.md index 4a05ffb..d6d3f9c 100644 --- a/charts/cryostat/README.md +++ b/charts/cryostat/README.md @@ -84,6 +84,7 @@ helm install cryostat ./charts/cryostat | `core.discovery.kubernetes.portNames` | List of port names that the Cryostat application should look for in order to consider a target as JMX connectable | `[]` | | `core.discovery.kubernetes.builtInPortNumbersDisabled` | When false and `portNumbers` is empty, the Cryostat application will use the default port number `9091` to look for JMX connectable targets. | `false` | | `core.discovery.kubernetes.portNumbers` | List of port numbers that the Cryostat application should look for in order to consider a target as JMX connectable | `[]` | +| `core.config.declarative.fsMode` | default filesystem mode (permissions) for declarative configuration volumes | `440` | | `core.config.eventTemplates.configMapNames` | List of ConfigMap names. Each ConfigMap is expected to contain one or more files, which are .jfc (XML) JFR Event Templates, to be mounted to the Cryostat container. | `[]` | ### Report Generator Deployment diff --git a/charts/cryostat/values.schema.json b/charts/cryostat/values.schema.json index d37ee74..8874a08 100644 --- a/charts/cryostat/values.schema.json +++ b/charts/cryostat/values.schema.json @@ -262,6 +262,16 @@ "config": { "type": "object", "properties": { + "declarative": { + "type": "object", + "properties": { + "fsMode": { + "type": "number", + "description": "default filesystem mode (permissions) for declarative configuration volumes", + "default": 440 + } + } + }, "eventTemplates": { "type": "object", "properties": { diff --git a/charts/cryostat/values.yaml b/charts/cryostat/values.yaml index 8f485fb..26eb681 100644 --- a/charts/cryostat/values.yaml +++ b/charts/cryostat/values.yaml @@ -87,6 +87,7 @@ core: portNumbers: [] config: declarative: + ## @param core.config.declarative.fsMode default filesystem mode (permissions) for declarative configuration volumes fsMode: 0440 eventTemplates: ## @param core.config.eventTemplates.configMapNames [array] List of ConfigMap names. Each ConfigMap is expected to contain one or more files, which are .jfc (XML) JFR Event Templates, to be mounted to the Cryostat container.