Skip to content

Commit

Permalink
feat: improve traefikee helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
mloiseleur authored Apr 27, 2023
1 parent 440ed9b commit 8b8e6a5
Show file tree
Hide file tree
Showing 7 changed files with 177 additions and 16 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
.PHONY: lint test

test:
docker run ${DOCKER_ARGS} --entrypoint /bin/sh --rm -v $(CURDIR):/charts -w /charts quintush/helm-unittest:3.10.0-0.2.9 /charts/hack/test.sh
traefikee/tests/__snapshot__:
@mkdir traefikee/tests/__snapshot__

test: traefikee/tests/__snapshot__
docker run ${DOCKER_ARGS} --entrypoint /bin/sh --rm -v $(CURDIR):/charts -w /charts helmunittest/helm-unittest:3.11.2-0.3.1 /charts/hack/test.sh

lint:
docker run ${DOCKER_ARGS} --env GIT_SAFE_DIR="true" --entrypoint /bin/sh --rm -v $(CURDIR):/charts -w /charts quay.io/helmpack/chart-testing:v3.7.1 /charts/hack/lint.sh
2 changes: 1 addition & 1 deletion hack/test.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

/usr/bin/helm unittest --helm3 --color ./traefikee;
/usr/bin/helm unittest --color ./traefikee;
13 changes: 9 additions & 4 deletions traefikee/templates/proxy/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ spec:
affinity:
{{- tpl (toYaml .Values.proxy.affinity) . | nindent 8 }}
{{- end }}
{{- with .Values.priorityClassName }}
priorityClassName: {{ . }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.proxy.terminationGracePeriodSeconds | default 30 }}
automountServiceAccountToken: false
initContainers:
Expand Down Expand Up @@ -90,13 +93,15 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- with .Values.proxy.resources }}
resources:
requests:
memory: "100Mi"
cpu: "100m"
memory: {{ .requests.memory }}
cpu: {{ .requests.cpu }}
limits:
memory: "4Gi"
cpu: "1000m"
memory: {{ .limits.memory }}
cpu: {{ .limits.cpu }}
{{- end }}
volumeMounts:
- name: {{ .Values.cluster }}-proxy-data
mountPath: "/var/lib/traefikee"
Expand Down
26 changes: 18 additions & 8 deletions traefikee/templates/stateful-sets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ spec:
affinity:
{{- tpl (toYaml .Values.registry.affinity) . | nindent 8 }}
{{- end }}
{{- with .Values.priorityClassName }}
priorityClassName: {{ . }}
{{- end }}
terminationGracePeriodSeconds: 30
automountServiceAccountToken: false
initContainers:
Expand Down Expand Up @@ -108,13 +111,15 @@ spec:
name: http
- containerPort: 443
name: https
{{- with .Values.controller.resources }}
resources:
requests:
memory: "100Mi"
cpu: "100m"
memory: {{ .requests.memory }}
cpu: {{ .requests.cpu }}
limits:
memory: "4Gi"
cpu: "1000m"
memory: {{ .limits.memory }}
cpu: {{ .limits.cpu }}
{{- end }}
volumeMounts:
- name: {{ .Values.cluster }}-plugin-registry-data
mountPath: "/var/lib/traefikee"
Expand Down Expand Up @@ -198,6 +203,9 @@ spec:
affinity:
{{- tpl (toYaml .Values.controller.affinity) . | nindent 8 }}
{{- end }}
{{- with .Values.priorityClassName }}
priorityClassName: {{ . }}
{{- end }}
terminationGracePeriodSeconds: 30
initContainers:
- name: wait-dns
Expand Down Expand Up @@ -253,13 +261,15 @@ spec:
port: control-port
initialDelaySeconds: 10
periodSeconds: 5
{{- with .Values.controller.resources }}
resources:
requests:
memory: "100Mi"
cpu: "100m"
memory: {{ .requests.memory }}
cpu: {{ .requests.cpu }}
limits:
memory: "4Gi"
cpu: "1000m"
memory: {{ .limits.memory }}
cpu: {{ .limits.cpu }}
{{- end }}
volumeMounts:
- name: data
mountPath: /var/lib/traefikee
Expand Down
77 changes: 76 additions & 1 deletion traefikee/tests/controller_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,79 @@ tests:
asserts:
- failedTemplate:
errorMessage: "failed to lookup token from secret NAMESPACE/test"
- it: should fail
- it: should not set priorityClassName by default
asserts:
- isNull:
path: spec.template.spec.priorityClassName
- it: should be possible to set priorityClassName
set:
priorityClassName: important
asserts:
- equal:
path: spec.template.spec.priorityClassName
value: important
documentIndex: 1
- equal:
path: spec.template.spec.priorityClassName
value: important
documentIndex: 2
- it: should set expected resources by default
asserts:
- isSubset:
path: spec.template.spec.containers[0].resources
content:
requests:
cpu: "100m"
memory: "128Mi"
limits:
cpu: "1000m"
memory: "4Gi"
documentIndex: 1
- isSubset:
path: spec.template.spec.containers[0].resources
content:
requests:
cpu: "100m"
memory: "128Mi"
limits:
cpu: "1000m"
memory: "4Gi"
documentIndex: 2
- it: should be possible to remove resources
set:
controller:
resources: null
asserts:
- isNull:
path: spec.template.spec.containers[0].resources
- it: should set custom resources requests & limits on registry & controller
set:
controller:
resources:
requests:
cpu: "100m"
memory: "50Mi"
limits:
cpu: "300m"
memory: "150Mi"
asserts:
- isSubset:
path: spec.template.spec.containers[0].resources
content:
requests:
cpu: "100m"
memory: "50Mi"
limits:
cpu: "300m"
memory: "150Mi"
documentIndex: 1
- isSubset:
path: spec.template.spec.containers[0].resources
content:
requests:
cpu: "100m"
memory: "50Mi"
limits:
cpu: "300m"
memory: "150Mi"
documentIndex: 2
50 changes: 50 additions & 0 deletions traefikee/tests/proxy_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,56 @@ tests:
- equal:
path: spec.template.spec.imagePullSecrets[0].name
value: regcred
- it: should not set priorityClassName by default
asserts:
- isNull:
path: spec.template.spec.priorityClassName
- it: should set priorityClassName
set:
priorityClassName: important
asserts:
- equal:
path: spec.template.spec.priorityClassName
value: important
- it: should set default resources
asserts:
- isSubset:
path: spec.template.spec.containers[0].resources
content:
requests:
cpu: "400m"
memory: "256Mi"
limits:
cpu: "1000m"
memory: "1Gi"
- it: should be possible to remove resources
set:
proxy:
resources: null
asserts:
- isNull:
path: spec.template.spec.containers[0].resources
- it: should set custom resources requests & limits
set:
proxy:
resources:
requests:
cpu: "100m"
memory: "50Mi"
limits:
cpu: "300m"
memory: "150Mi"
asserts:
- isSubset:
path: spec.template.spec.containers[0].resources
content:
requests:
cpu: "100m"
memory: "50Mi"
limits:
cpu: "300m"
memory: "150Mi"

---
suite: proxy service test
templates:
Expand Down
18 changes: 18 additions & 0 deletions traefikee/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ registry:

controller:
replicas: 1
resources:
requests:
cpu: "100m"
memory: "128Mi"
limits:
cpu: "1000m"
memory: "4Gi"

# To disable affinity at all set this value to null
affinity:
nodeAffinity:
Expand Down Expand Up @@ -113,6 +121,13 @@ controller:

proxy:
replicas: 2
resources:
requests:
cpu: "400m"
memory: "256Mi"
limits:
cpu: "1000m"
memory: "1Gi"
serviceType: LoadBalancer
ports:
- name: http
Expand Down Expand Up @@ -174,6 +189,9 @@ proxy:
# maxUnavailable: 1
# terminationGracePeriodSeconds: 30

# priorityClassName will be set on all pods.
priorityClassName: ""

mesh:
enabled: false
kubedns: false
Expand Down

0 comments on commit 8b8e6a5

Please sign in to comment.