Skip to content

Commit

Permalink
add support for extraVolumes and extraMounts
Browse files Browse the repository at this point in the history
populate volumes and mounts from value keys
adds logprep-cache-dir in memory volume and mounts it to
/home/logprep/.cache
  • Loading branch information
ekneg54 committed Jul 18, 2024
1 parent e1d054b commit 8bc9bd1
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
11 changes: 11 additions & 0 deletions charts/logprep/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ spec:
mountPath: /tmp
- name: prometheus-multiproc
mountPath: /prometheus
- name: logprep-cache-dir
mountPath: /home/logprep/.cache
{{- range $key, $value := .Values.configurations }}
{{- if $value.data }}
- name: configurations
Expand Down Expand Up @@ -107,6 +109,9 @@ spec:
subPath: {{ $value.name }}
{{ end }}
{{- end }}
{{- if .Values.extraMounts }}
{{- toYaml .Values.extraMounts | nindent 12 }}
{{- end }}
{{- if or .Values.exporter.enabled (eq .Values.input.type "http_input") }}
{{- if eq .Values.input.type "http_input" }}
readinessProbe:
Expand Down Expand Up @@ -150,6 +155,9 @@ spec:
- name: prometheus-multiproc
emptyDir:
medium: "Memory"
- name: logprep-cache-dir
emptyDir:
medium: "Memory"
- name: configurations
configMap:
name: {{ include "logprep.fullname" . }}-configurations
Expand Down Expand Up @@ -177,6 +185,9 @@ spec:
secretName: {{ $value.name }}
{{- end }}
{{- end }}
{{- if .Values.extraVolumes }}
{{- toYaml .Values.extraVolumes | nindent 8 }}
{{- end }}
{{- if .Values.affinity }}
affinity:
podAntiAffinity:
Expand Down
15 changes: 15 additions & 0 deletions charts/logprep/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@ affinity: false
# inject extra labels to all resources metadata
extraLabels: {}

# extraVolumes to populate the pod with
# Example:
# extraVolumes:
# - name: my-volume
# configMap:
# name: my-configmap
extraVolumes: []

# extraMounts to populate the pod with
# Example:
# extraMounts:
# - name: my-volume
# mountPath: /path/to/mount
extraMounts: []

# Use this to annotate the logprep pods
# podAnnotations:
# sidecar.istio.io/rewriteAppHTTPProbers: "false"
Expand Down
51 changes: 51 additions & 0 deletions tests/unit/charts/test_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,3 +439,54 @@ def test_environment_variables_populated_from_secrets(self):
assert my_var["value"] == "my_value"
my_var = [variable for variable in env if variable["name"] == "MY_OTHER_VAR"].pop()
assert my_var["valueFrom"]["secretKeyRef"]["name"] == "my-secret"

def test_extra_volumes_are_populated(self):
logprep_values = {
"extraVolumes": [
{
"name": "my-volume",
"configMap": {"name": "my-configmap"},
},
{
"name": "my-volume2",
"configMap": {"name": "my-configmap"},
},
]
}
self.manifests = self.render_chart("logprep", logprep_values)
volumes = self.deployment["spec.template.spec.volumes"]
volume = [volume for volume in volumes if volume["name"] == "my-volume"].pop()
assert volume["configMap"]["name"] == "my-configmap"

def test_extra_mounts_are_populated(self):
logprep_values = {
"extraMounts": [
{
"name": "my-volume",
"mountPath": "/my-path",
},
{
"name": "my-volume2",
"mountPath": "/my-path2",
"subPath": "sub-path",
},
]
}
self.manifests = self.render_chart("logprep", logprep_values)
mounts = self.deployment["spec.template.spec.containers.0.volumeMounts"]
mount = [mount for mount in mounts if mount["name"] == "my-volume"].pop()
assert mount["mountPath"] == "/my-path"
mount = [mount for mount in mounts if mount["name"] == "my-volume2"].pop()
assert mount["subPath"] == "sub-path"

def test_logprep_cache_dir_is_populated(self):
volumes = self.deployment["spec.template.spec.volumes"]
cache_dir_volume = [
volume for volume in volumes if volume["name"] == "logprep-cache-dir"
].pop()
assert cache_dir_volume
assert cache_dir_volume["emptyDir"] == {"medium": "Memory"}
mounts = self.deployment["spec.template.spec.containers.0.volumeMounts"]
cache_dir_mount = [mount for mount in mounts if mount["name"] == "logprep-cache-dir"].pop()
assert cache_dir_mount
assert cache_dir_mount["mountPath"] == "/home/logprep/.cache"

0 comments on commit 8bc9bd1

Please sign in to comment.