Skip to content

Commit b9411f6

Browse files
committed
Adding wg-easy starting point, not functional yet
Signed-off-by: Tim Beermann <[email protected]>
1 parent 5f1fa3d commit b9411f6

14 files changed

+530
-0
lines changed

wg-easy/.helmignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

wg-easy/Chart.yaml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: wg-easy
3+
description: A Helm chart for wg-easy
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "14"

wg-easy/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# wg-easy
2+
3+
not working yet.

wg-easy/templates/NOTES.txt

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.ingress.enabled }}
3+
{{- range $host := .Values.ingress.hosts }}
4+
{{- range .paths }}
5+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
6+
{{- end }}
7+
{{- end }}
8+
{{- else if contains "NodePort" .Values.service.web.type }}
9+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "wg-easy.fullname" . }})
10+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
11+
echo http://$NODE_IP:$NODE_PORT
12+
{{- else if contains "LoadBalancer" .Values.service.web.type }}
13+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
14+
You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "wg-easy.fullname" . }}'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "wg-easy.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
16+
echo http://$SERVICE_IP:{{ .Values.service.web.port }}
17+
{{- else if contains "ClusterIP" .Values.service.web.type }}
18+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "wg-easy.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
20+
echo "Visit http://127.0.0.1:8080 to use your application"
21+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
22+
{{- end }}

wg-easy/templates/_helpers.tpl

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "wg-easy.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 "wg-easy.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 "wg-easy.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "wg-easy.labels" -}}
37+
helm.sh/chart: {{ include "wg-easy.chart" . }}
38+
{{ include "wg-easy.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 "wg-easy.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "wg-easy.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 "wg-easy.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "wg-easy.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}

wg-easy/templates/deployment.yaml

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "wg-easy.fullname" . }}
5+
labels:
6+
{{- include "wg-easy.labels" . | nindent 4 }}
7+
spec:
8+
{{- if not .Values.autoscaling.enabled }}
9+
replicas: {{ .Values.replicaCount }}
10+
{{- end }}
11+
selector:
12+
matchLabels:
13+
{{- include "wg-easy.selectorLabels" . | nindent 6 }}
14+
template:
15+
metadata:
16+
annotations:
17+
checksum/config: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
18+
{{- with .Values.podAnnotations }}
19+
{{- toYaml . | nindent 8 }}
20+
{{- end }}
21+
labels:
22+
{{- include "wg-easy.labels" . | nindent 8 }}
23+
{{- with .Values.podLabels }}
24+
{{- toYaml . | nindent 8 }}
25+
{{- end }}
26+
spec:
27+
{{- with .Values.imagePullSecrets }}
28+
imagePullSecrets:
29+
{{- toYaml . | nindent 8 }}
30+
{{- end }}
31+
serviceAccountName: {{ include "wg-easy.serviceAccountName" . }}
32+
{{- with .Values.podSecurityContext }}
33+
securityContext:
34+
{{- toYaml . | nindent 8 }}
35+
{{- end }}
36+
containers:
37+
- name: {{ .Chart.Name }}
38+
{{- with .Values.securityContext }}
39+
securityContext:
40+
{{- toYaml . | nindent 12 }}
41+
{{- end }}
42+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
43+
imagePullPolicy: {{ .Values.image.pullPolicy }}
44+
ports:
45+
- name: http
46+
containerPort: {{ .Values.service.web.port }}
47+
protocol: TCP
48+
- name: wireguard
49+
containerPort: {{ .Values.service.wireguard.port }}
50+
protocol: UDP
51+
{{- with .Values.livenessProbe }}
52+
livenessProbe:
53+
{{- toYaml . | nindent 12 }}
54+
{{- end }}
55+
{{- with .Values.readinessProbe }}
56+
readinessProbe:
57+
{{- toYaml . | nindent 12 }}
58+
{{- end }}
59+
{{- with .Values.resources }}
60+
resources:
61+
{{- toYaml . | nindent 12 }}
62+
{{- end }}
63+
volumeMounts:
64+
- name: tun
65+
mountPath: /dev/net/tun
66+
- name: config
67+
mountPath: /etc/wireguard
68+
{{- with .Values.volumeMounts }}
69+
{{- toYaml . | nindent 12 }}
70+
{{- end }}
71+
envFrom:
72+
- secretRef:
73+
name: {{ include "wg-easy.fullname" . }}
74+
volumes:
75+
- name: tun
76+
hostPath:
77+
type: 'CharDevice'
78+
path: /dev/net/tun
79+
- name: config
80+
persistentVolumeClaim:
81+
claimName: {{ include "wg-easy.fullname" . }}
82+
{{- with .Values.volumes }}
83+
{{- toYaml . | nindent 8 }}
84+
{{- end }}
85+
{{- with .Values.nodeSelector }}
86+
nodeSelector:
87+
{{- toYaml . | nindent 8 }}
88+
{{- end }}
89+
{{- with .Values.affinity }}
90+
affinity:
91+
{{- toYaml . | nindent 8 }}
92+
{{- end }}
93+
{{- with .Values.tolerations }}
94+
tolerations:
95+
{{- toYaml . | nindent 8 }}
96+
{{- end }}

wg-easy/templates/hpa.yaml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{{- if .Values.autoscaling.enabled }}
2+
apiVersion: autoscaling/v2
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
name: {{ include "wg-easy.fullname" . }}
6+
labels:
7+
{{- include "wg-easy.labels" . | nindent 4 }}
8+
spec:
9+
scaleTargetRef:
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
name: {{ include "wg-easy.fullname" . }}
13+
minReplicas: {{ .Values.autoscaling.minReplicas }}
14+
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
15+
metrics:
16+
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
17+
- type: Resource
18+
resource:
19+
name: cpu
20+
target:
21+
type: Utilization
22+
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
23+
{{- end }}
24+
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
25+
- type: Resource
26+
resource:
27+
name: memory
28+
target:
29+
type: Utilization
30+
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
31+
{{- end }}
32+
{{- end }}

wg-easy/templates/ingress.yaml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{{- if .Values.ingress.enabled -}}
2+
apiVersion: networking.k8s.io/v1
3+
kind: Ingress
4+
metadata:
5+
name: {{ include "wg-easy.fullname" . }}
6+
labels:
7+
{{- include "wg-easy.labels" . | nindent 4 }}
8+
{{- with .Values.ingress.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
spec:
13+
{{- with .Values.ingress.className }}
14+
ingressClassName: {{ . }}
15+
{{- end }}
16+
{{- if .Values.ingress.tls }}
17+
tls:
18+
{{- range .Values.ingress.tls }}
19+
- hosts:
20+
{{- range .hosts }}
21+
- {{ . | quote }}
22+
{{- end }}
23+
secretName: {{ .secretName }}
24+
{{- end }}
25+
{{- end }}
26+
rules:
27+
{{- range .Values.ingress.hosts }}
28+
- host: {{ .host | quote }}
29+
http:
30+
paths:
31+
{{- range .paths }}
32+
- path: {{ .path }}
33+
{{- with .pathType }}
34+
pathType: {{ . }}
35+
{{- end }}
36+
backend:
37+
service:
38+
name: {{ include "wg-easy.fullname" $ }}
39+
port:
40+
number: {{ $.Values.service.web.port }}
41+
{{- end }}
42+
{{- end }}
43+
{{- end }}

wg-easy/templates/pvc.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
kind: PersistentVolumeClaim
2+
apiVersion: v1
3+
metadata:
4+
name: {{ include "wg-easy.fullname" . }}
5+
labels:
6+
app.kubernetes.io/name: {{ include "wg-easy.name" . }}
7+
app.kubernetes.io/instance: {{ .Release.Name }}
8+
app.kubernetes.io/managed-by: {{ .Release.Service }}
9+
helm.sh/chart: {{ include "wg-easy.chart" . }}
10+
annotations:
11+
{{- range $key, $value := .Values.persistence.annotations }}
12+
{{ $key }}: {{ $value | quote }}
13+
{{- end }}
14+
spec:
15+
accessModes:
16+
- {{ .Values.persistence.accessMode | quote }}
17+
resources:
18+
requests:
19+
storage: {{ .Values.persistence.size | quote }}
20+
{{- if .Values.persistence.storageClass }}
21+
{{- if (eq "-" .Values.persistence.storageClass) }}
22+
storageClassName: ""
23+
{{- else }}
24+
storageClassName: "{{ .Values.persistence.storageClass }}"
25+
{{- end }}
26+
{{- end }}

wg-easy/templates/secret.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: {{ include "wg-easy.fullname" . }}
5+
labels:
6+
{{- include "wg-easy.labels" . | nindent 4 }}
7+
type: Opaque
8+
stringData:
9+
PASSWORD_HASH: {{ bcrypt .Values.PASSWORD }}
10+
{{- with .Values.env }}
11+
{{- toYaml . | nindent 2 }}
12+
{{- end }}

wg-easy/templates/service.yaml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "wg-easy.fullname" . }}
5+
labels:
6+
{{- include "wg-easy.labels" . | nindent 4 }}
7+
spec:
8+
type: {{ .Values.service.web.type }}
9+
ports:
10+
- port: {{ .Values.service.web.port }}
11+
targetPort: http
12+
protocol: TCP
13+
name: http
14+
- port: {{ .Values.service.wireguard.port }}
15+
targetPort: wireguard
16+
protocol: UDP
17+
name: wireguard
18+
selector:
19+
{{- include "wg-easy.selectorLabels" . | nindent 4 }}

wg-easy/templates/serviceaccount.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{- if .Values.serviceAccount.create -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ include "wg-easy.serviceAccountName" . }}
6+
labels:
7+
{{- include "wg-easy.labels" . | nindent 4 }}
8+
{{- with .Values.serviceAccount.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
13+
{{- end }}

0 commit comments

Comments
 (0)