Skip to content

Commit dbbec62

Browse files
committed
feat(charts): add helm chart for traefik-errors
1 parent 1735811 commit dbbec62

File tree

7 files changed

+217
-0
lines changed

7 files changed

+217
-0
lines changed

charts/traefik-errors/Chart.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v2
2+
type: application
3+
name: traefik-errors
4+
description: A Helm chart for custom traefik error pages
5+
version: 0.0.1
6+
appVersion: "0.0.0"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
1. Get the application URL by running these commands:
2+
{{- if contains "NodePort" .Values.service.type }}
3+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "traefik-errors.fullname" . }})
4+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
5+
echo http://$NODE_IP:$NODE_PORT
6+
{{- else if contains "LoadBalancer" .Values.service.type }}
7+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
8+
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "traefik-errors.fullname" . }}'
9+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "traefik-errors.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
10+
echo http://$SERVICE_IP:{{ .Values.ports.http.port }}
11+
{{- else if contains "ClusterIP" .Values.service.type }}
12+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "traefik-errors.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
13+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
14+
echo "Visit http://127.0.0.1:8080 to use your application"
15+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
16+
{{- end }}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "traefik-errors.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "traefik-errors.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "traefik-errors.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "traefik-errors.labels" -}}
37+
helm.sh/chart: {{ include "traefik-errors.chart" . }}
38+
{{ include "traefik-errors.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "traefik-errors.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "traefik-errors.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "traefik-errors.serviceAccountName" -}}
57+
{{- default "default" .Values.serviceAccount.name }}
58+
{{- end }}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{{- if .Values.deployment.enabled -}}
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: {{ include "traefik-errors.fullname" . }}
6+
labels:
7+
{{- include "traefik-errors.labels" . | nindent 4 }}
8+
{{- with .Values.deployment.labels }}
9+
{{ toYaml . | indent 4 }}
10+
{{- end }}
11+
spec:
12+
{{- if .Values.deployment.replicas }}
13+
replicas: {{ .Values.deployment.replicas }}
14+
{{- end }}
15+
selector:
16+
matchLabels:
17+
{{- include "traefik-errors.selectorLabels" . | nindent 6 }}
18+
template:
19+
metadata:
20+
{{- with .Values.deployment.annotations }}
21+
annotations:
22+
{{- toYaml . | nindent 8 }}
23+
{{- end }}
24+
labels:
25+
{{- include "traefik-errors.selectorLabels" . | nindent 8 }}
26+
spec:
27+
serviceAccountName: {{ include "traefik-errors.serviceAccountName" . }}
28+
containers:
29+
- name: {{ .Chart.Name }}
30+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
31+
imagePullPolicy: {{ .Values.image.pullPolicy }}
32+
ports:
33+
{{- if .Values.ports.http.enabled }}
34+
- name: http
35+
containerPort: {{ .Values.ports.http.port }}
36+
protocol: TCP
37+
{{- end }}
38+
env:
39+
{{- range $i, $val := .Values.env }}
40+
- name: {{ $val.name | quote }}
41+
value: {{ $val.value | quote }}
42+
{{- end }}
43+
livenessProbe:
44+
httpGet:
45+
path: /
46+
port: http
47+
readinessProbe:
48+
httpGet:
49+
path: /
50+
port: http
51+
resources: {{ if not .Values.resources -}}{}{{- end }}
52+
{{- if .Values.resources }}
53+
{{- toYaml .Values.resources | nindent 12 }}
54+
{{- end }}
55+
{{- end }}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{{- if .Values.service.enabled -}}
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: {{ include "traefik-errors.fullname" . }}
6+
labels:
7+
{{- include "traefik-errors.labels" . | nindent 4 }}
8+
{{- with .Values.service.labels }}
9+
{{ toYaml . | indent 4 }}
10+
{{- end }}
11+
{{- with .Values.deployment.annotations }}
12+
annotations:
13+
{{- toYaml . | nindent 4 }}
14+
{{- end }}
15+
spec:
16+
type: {{ .Values.service.type }}
17+
ports:
18+
{{- if .Values.ports.http.enabled }}
19+
- port: {{ .Values.ports.http.port }}
20+
targetPort: http
21+
protocol: TCP
22+
name: http
23+
{{- end }}
24+
selector:
25+
{{- include "traefik-errors.selectorLabels" . | nindent 4 }}
26+
{{- end }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: "{{ include "traefik-errors.fullname" . }}-test-connection"
5+
labels:
6+
{{- include "traefik-errors.labels" . | nindent 4 }}
7+
annotations:
8+
"helm.sh/hook": test
9+
spec:
10+
containers:
11+
- name: wget
12+
image: busybox
13+
command: ['wget']
14+
args: ['{{ include "traefik-errors.fullname" . }}:{{ .Values.ports.http.port }}']
15+
restartPolicy: Never

charts/traefik-errors/values.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
image:
2+
repository: pascaliske/traefik-errors
3+
tag: latest
4+
pullPolicy: IfNotPresent
5+
6+
nameOverride: ''
7+
fullnameOverride: ''
8+
9+
deployment:
10+
enabled: true
11+
kind: Deployment
12+
replicas: 1
13+
annotations: {}
14+
labels: {}
15+
16+
service:
17+
enabled: true
18+
type: ClusterIP
19+
annotations: {}
20+
labels: {}
21+
22+
env:
23+
- name: TZ
24+
value: UTC
25+
26+
ports:
27+
http:
28+
enabled: true
29+
port: 8080
30+
protocol: TCP
31+
32+
serviceAccount:
33+
name: ''
34+
35+
resources: {}
36+
# requests:
37+
# cpu: 100m
38+
# memory: 128Mi
39+
# limits:
40+
# cpu: 100m
41+
# memory: 128Mi

0 commit comments

Comments
 (0)