Skip to content

Commit

Permalink
feat: volumes + volumeMounts support
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloHiro authored and eshepelyuk committed Nov 20, 2023
1 parent 55fc43b commit 30ba8ac
Show file tree
Hide file tree
Showing 7 changed files with 208 additions and 0 deletions.
8 changes: 8 additions & 0 deletions templates/deployment-registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,12 @@ spec:
resources:
{{ . | toYaml | nindent 12 }}
{{- end }}
{{- with .Values.registry.extraVolumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.registry.extraVolumes }}
volumes:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
8 changes: 8 additions & 0 deletions templates/deployment-sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,12 @@ spec:
resources:
{{ . | toYaml | nindent 12 }}
{{- end }}
{{- with .Values.sync.extraVolumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.sync.extraVolumes }}
volumes:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
45 changes: 45 additions & 0 deletions test/linter/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,51 @@ if [ $? -eq 0 ]; then
exit 1
fi

# extraVolumeMounts - correct
helm lint . --strict --set registry.extraVolumeMounts[0].name=foo,registry.extraVolumeMounts[0].mountPath=/bar
if [ $? -ne 0 ]; then
exit 1
fi

helm lint . --strict --set sync.extraVolumeMounts[0].name=foo,registry.extraVolumeMounts[0].mountPath=/bar
if [ $? -ne 0 ]; then
exit 1
fi

# extraVolumeMounts - wrong
helm lint . --strict --set registry.extraVolumeMounts.name=foo,registry.extraVolumeMounts.mountPath=/bar
if [ $? -eq 0 ]; then
exit 1
fi

helm lint . --strict --set sync.extraVolumeMounts.name=foo,registry.extraVolumeMounts.mountPath=/bar
if [ $? -eq 0 ]; then
exit 1
fi

# extraVolumes - correct
helm lint . --strict --set registry.extraVolumes[0].name=foo,registry.extraVolumes[0].emptyDir=true
if [ $? -ne 0 ]; then
exit 1
fi

helm lint . --strict --set sync.extraVolumes[0].name=foo,sync.extraVolumes[0].emptyDir=true
if [ $? -ne 0 ]; then
exit 1
fi

# extraVolumes - wrong
helm lint . --strict --set registry.extraVolumes.name=foo,registry.extraVolumes.emptyDir=true
if [ $? -eq 0 ]; then
exit 1
fi

helm lint . --strict --set sync.extraVolumes.name=foo,sync.extraVolumes.emptyDir=true
if [ $? -eq 0 ]; then
exit 1
fi


echo "=================================================================================="
echo " LINT PASSED"
echo "=================================================================================="
60 changes: 60 additions & 0 deletions test/unit/volume_registry_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
suite: test registry volumes
templates:
- deployment-registry.yaml
tests:
- it: no volumes
asserts:
- notExists:
path: spec.template.spec.volumes
- it: volumes
set:
registry:
extraVolumes:
- name: baz
emptyDir: {}
- name: foo
secret:
secretName: bar
optional: false
asserts:
- exists:
path: spec.template.spec.volumes
- equal:
path: spec.template.spec.volumes[0].name
value: baz
- equal:
path: spec.template.spec.volumes[0].emptyDir
value: {}
- equal:
path: spec.template.spec.volumes[1].name
value: foo
- equal:
path: spec.template.spec.volumes[1].secret.secretName
value: bar
- equal:
path: spec.template.spec.volumes[1].secret.optional
value: false
- it: no volume mounts
asserts:
- notExists:
path: spec.template.spec.containers[0].volumeMounts
- it: volume mounts
set:
registry:
extraVolumeMounts:
- name: foo
mountPath: /bar
readOnly: true
asserts:
- exists:
path: spec.template.spec.containers[0].volumeMounts
- equal:
path: spec.template.spec.containers[0].volumeMounts[0].name
value: foo
- equal:
path: spec.template.spec.containers[0].volumeMounts[0].mountPath
value: /bar
- equal:
path: spec.template.spec.containers[0].volumeMounts[0].readOnly
value: true
57 changes: 57 additions & 0 deletions test/unit/volume_sync_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
suite: test sync volumes
templates:
- deployment-sync.yaml
tests:
- it: no volumes
asserts:
- notExists:
path: spec.template.spec.volumes
- it: volumes
set:
sync:
extraVolumes:
- name: baz
emptyDir: {}
- name: foo
secret:
secretName: bar
optional: false
asserts:
- exists:
path: spec.template.spec.volumes
- equal:
path: spec.template.spec.volumes[0].name
value: baz
- equal:
path: spec.template.spec.volumes[0].emptyDir
value: {}
- equal:
path: spec.template.spec.volumes[1].name
value: foo
- equal:
path: spec.template.spec.volumes[1].secret.secretName
value: bar
- it: no volume mounts
asserts:
- notExists:
path: spec.template.spec.containers[0].volumeMounts
- it: volume mounts
set:
sync:
extraVolumeMounts:
- name: foo
mountPath: /bar
readOnly: true
asserts:
- exists:
path: spec.template.spec.containers[0].volumeMounts
- equal:
path: spec.template.spec.containers[0].volumeMounts[0].name
value: foo
- equal:
path: spec.template.spec.containers[0].volumeMounts[0].mountPath
value: /bar
- equal:
path: spec.template.spec.containers[0].volumeMounts[0].readOnly
value: true
10 changes: 10 additions & 0 deletions values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
"initContainers": {
"type": "array", "default": []
},
"volumeMounts": {
"type": "array", "default": []
},
"volumes": {
"type": "array", "default": []
},
"ingress": {
"type": "object", "title": "ingress resource for registry",
"required": ["enabled", "host", "path"],
Expand Down Expand Up @@ -89,6 +95,8 @@
"items": {"$ref": "#/definitions/keyValue"}
},
"resources": {"$ref": "#/definitions/podResources"},
"extraVolumeMounts": {"$ref": "#/definitions/volumeMounts"},
"extraVolumes": {"$ref": "#/definitions/volumes"},
"kafka": {"$ref": "#/definitions/persistence/kafka"},
"sql": {"$ref": "#/definitions/persistence/sql"},
"ingress": {"$ref": "#/definitions/ingress"}
Expand All @@ -103,6 +111,8 @@
"nodeSelector": {"type": "object", "title": "node selector for registry content sync"},
"initContainers": {"$ref": "#/definitions/initContainers"},
"resources": {"$ref": "#/definitions/podResources"},
"extraVolumeMounts": {"$ref": "#/definitions/volumeMounts"},
"extraVolumes": {"$ref": "#/definitions/volumes"},
"registryUrl": {"type": ["null", "string"], "default": null}
}
}
Expand Down
20 changes: 20 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ registry:
# requests:
# cpu: 200m
# memory: 600Mi
# list of extra volume mounts
extraVolumeMounts: []
# - name: kafkauser
# mountPath: /opt/user
# readOnly: true
# list of extra volumes
extraVolumes: []
# - name: kafkauser
# secret:
# secretName: kafka-user

ingress:
enabled: false
Expand Down Expand Up @@ -57,4 +67,14 @@ sync:
# requests:
# cpu: 200m
# memory: 600Mi
# list of extra volume mounts
extraVolumeMounts: []
# - name: kafkauser
# mountPath: /opt/user
# readOnly: true
# list of extra volumes
extraVolumes: []
# - name: kafkauser
# secret:
# secretName: kafka-user

0 comments on commit 30ba8ac

Please sign in to comment.