Skip to content

Commit

Permalink
simple-worker: 0.1.4 - Synchronize volumes configuration, and update …
Browse files Browse the repository at this point in the history
…version
  • Loading branch information
elephantum committed Feb 9, 2024
1 parent 2fed5e5 commit c9f52ff
Show file tree
Hide file tree
Showing 10 changed files with 548 additions and 5 deletions.
4 changes: 4 additions & 0 deletions charts/simple-worker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.1.4

* Synchonize volumes configuration between simple-app and simple-worker

# 0.1.3

* Synchronize fullname generation between simple-app and simple-worker
Expand Down
2 changes: 1 addition & 1 deletion charts/simple-worker/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: "0.1.3"
version: "0.1.4"

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
4 changes: 4 additions & 0 deletions charts/simple-worker/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# helm plugin install https://github.com/helm-unittest/helm-unittest.git

test:
helm unittest .
18 changes: 16 additions & 2 deletions charts/simple-worker/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,18 @@ spec:
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
volumes:
{{- if .Values.shmSize }}
- name: shared-memory
emptyDir:
medium: Memory
sizeLimit: {{ .Values.shmSize }}
{{- end }}
{{- range .Values.volumes }}
- name: {{ .name }}
{{- if .size }}
{{- if .emptyDir }}
emptyDir:
sizeLimit: {{ .size }}
{{- else if .size }}
persistentVolumeClaim:
claimName: {{ $fullName }}-{{ .name }}
{{- else if .configMap }}
Expand Down Expand Up @@ -79,13 +88,18 @@ spec:
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
{{- if .Values.shmSize }}
- name: shared-memory
mountPath: /dev/shm
{{- end }}
{{- range .Values.volumes }}
- name: {{ .name }}
mountPath: {{ .mountPath }}
{{- end }}
{{- range .Values.configs }}
- name: configs
mountPath: "/configs"
mountPath: {{ if .mountPath }}"{{ .mountPath }}"{{ else }}"/configs/{{ .name }}"{{ end }}
subPath: {{ .name }}
readOnly: true
{{- end }}
{{- with .Values.nodeSelector }}
Expand Down
4 changes: 2 additions & 2 deletions charts/simple-worker/templates/pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{- $labels := include "simple-app.labels" . | nindent 4 -}}

{{ range .Values.volumes }}
{{ if .size }}
{{- if not .emptyDir }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
Expand All @@ -16,6 +16,6 @@ spec:
requests:
storage: {{ .size }}

---
---
{{ end }}
{{ end }}
82 changes: 82 additions & 0 deletions charts/simple-worker/tests/__snapshot__/simple_test.yaml.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
All manifests should match snapshot:
1: |
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/instance: simple
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: simple-worker
app.kubernetes.io/version: 1.16.0
helm.sh/chart: simple-worker-0.0.0
name: simple
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/instance: simple
app.kubernetes.io/name: simple-worker
strategy:
type: Recreate
template:
metadata:
labels:
app.kubernetes.io/instance: simple
app.kubernetes.io/name: simple-worker
spec:
containers:
- env:
- name: TEST
value: test
image: test:1.1.1
imagePullPolicy: IfNotPresent
livenessProbe:
exec:
command:
- echo
- ok
name: simple
readinessProbe:
exec:
command:
- echo
- ok
resources: {}
securityContext: {}
volumeMounts:
- mountPath: /data
name: data
securityContext: {}
serviceAccountName: simple
volumes:
- name: data
persistentVolumeClaim:
claimName: simple-data
2: |
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
app.kubernetes.io/instance: simple
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: simple-worker
app.kubernetes.io/version: 1.16.0
helm.sh/chart: simple-worker-0.0.0
name: simple-data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
3: |
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app.kubernetes.io/instance: simple
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: simple-worker
app.kubernetes.io/version: 1.16.0
helm.sh/chart: simple-worker-0.0.0
name: simple
21 changes: 21 additions & 0 deletions charts/simple-worker/tests/simple-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# yaml-language-server: $schema=../values.schema.json

image:
repository: test
tag: 1.1.1

port: 9000

domain: test.epoch8.co

ingress:
enabled: true

env:
- name: TEST
value: test

volumes:
- name: data
size: 1Gi
mountPath: /data
183 changes: 183 additions & 0 deletions charts/simple-worker/tests/simple_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
suite: simple-app simple case

values:
- simple-values.yaml

release:
name: simple
namespace: default

chart:
version: 0.0.0

tests:
- it: All manifests should match snapshot
templates:
- deployment.yaml
- serviceaccount.yaml
- pvc.yaml
asserts:
- matchSnapshot: {}

- it: Deployment should be named as release
template: deployment.yaml
asserts:
- isKind:
of: Deployment
- equal:
path: metadata.name
value: simple

- it: Deployment image tag should be set correctly
template: deployment.yaml
asserts:
- isKind:
of: Deployment
- equal:
path: spec.template.spec.containers[0].image
value: test:1.1.1

- it: Deployment should use imagePullSecrets if specified
template: deployment.yaml
set:
imagePullSecrets:
- name: test
asserts:
- isKind:
of: Deployment
- equal:
path: spec.template.spec.imagePullSecrets
value:
- name: test

- it: Deployment should mount shared memory volume if shmMem specified
template: deployment.yaml
set:
shmSize: 1Gi
asserts:
- isKind:
of: Deployment
- equal:
path: spec.template.spec.containers[0].volumeMounts[0]
value:
mountPath: /dev/shm
name: shared-memory
- equal:
path: spec.template.spec.volumes[0]
value:
emptyDir:
medium: Memory
sizeLimit: 1Gi
name: shared-memory

- it: Deployment should have correctly mounted configs
template: deployment.yaml
set:
configs:
- name: test.json
mountPath: /etc/test.json
value: |
{
"test": "test"
}
- name: test2.json
value: |
{
"test2": "test2"
}
asserts:
- isKind:
of: Deployment
- equal:
path: spec.template.spec.containers[0].volumeMounts[1]
value:
mountPath: /etc/test.json
name: configs
subPath: test.json
readOnly: true
- equal:
path: spec.template.spec.containers[0].volumeMounts[2]
value:
mountPath: /configs/test2.json
name: configs
subPath: test2.json
readOnly: true
- contains:
path: spec.template.spec.volumes
content:
configMap:
name: simple
name: configs

- it: Deployment should have correctly mounted volumes with pvc
template: deployment.yaml
asserts:
- isKind:
of: Deployment
- equal:
path: spec.template.spec.containers[0].volumeMounts[0]
value:
mountPath: /data
name: data
- equal:
path: spec.template.spec.volumes[0]
value:
name: data
persistentVolumeClaim:
claimName: simple-data

- it: Deployment should have correctly mounted volumes without pvc
template: deployment.yaml
set:
volumes:
- name: data
size: 1Gi
mountPath: /data
emptyDir: true
asserts:
- isKind:
of: Deployment
- equal:
path: spec.template.spec.containers[0].volumeMounts[0]
value:
mountPath: /data
name: data
- equal:
path: spec.template.spec.volumes[0]
value:
name: data
emptyDir:
sizeLimit: 1Gi

- it: PVC should not be created if emptyDir
template: pvc.yaml
set:
volumes:
- name: data
size: 1Gi
mountPath: /data
emptyDir: true
asserts:
- hasDocuments:
count: 0

- it: PVC should have correctly mounted volumes with pvc
template: pvc.yaml
asserts:
- isKind:
of: PersistentVolumeClaim
- equal:
path: spec.resources.requests.storage
value: 1Gi

- it: PVC should have correctly mounted volumes without pvc
template: pvc.yaml
set:
volumes:
- name: data
size: 1Gi
mountPath: /data
emptyDir: true
asserts:
- hasDocuments:
count: 0
Loading

0 comments on commit c9f52ff

Please sign in to comment.