Skip to content

Commit

Permalink
add wireguard chart
Browse files Browse the repository at this point in the history
  • Loading branch information
mihma committed Jul 20, 2023
1 parent 0f9a724 commit d6a96b3
Show file tree
Hide file tree
Showing 9 changed files with 277 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/wireguard/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
18 changes: 18 additions & 0 deletions charts/wireguard/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v2
name: wireguard
description: Helm chart for wireguard server

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
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.0
62 changes: 62 additions & 0 deletions charts/wireguard/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "wireguard.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "wireguard.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "wireguard.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "wireguard.labels" -}}
helm.sh/chart: {{ include "wireguard.chart" . }}
{{ include "wireguard.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "wireguard.selectorLabels" -}}
app.kubernetes.io/name: {{ include "wireguard.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "wireguard.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "wireguard.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
16 changes: 16 additions & 0 deletions charts/wireguard/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "wireguard.fullname" . }}
labels:
{{- include "wireguard.labels" . | nindent 4 }}
data:
PUID: "1000"
PGID: "1000"
TZ: {{ .Values.config.timeZone }}
SERVERURL: {{ .Values.config.serverUrl }}
SERVERPORT: "51820"
PEERS: {{ .Values.config.peers | quote }}
ALLOWEDIPS: {{ .Values.config.allowedIPs | quote }}
INTERNAL_SUBNET: {{ .Values.config.internalSubnet | quote }}
LOG_CONFS: {{ .Values.config.logConfs | quote }}
63 changes: 63 additions & 0 deletions charts/wireguard/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "wireguard.fullname" . }}
labels:
{{- include "wireguard.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "wireguard.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "wireguard.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "wireguard.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.registry }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: IfNotPresent
ports:
- name: wg-server
containerPort: 51820
protocol: UDP
volumeMounts:
- name: wg-config
mountPath: /config
envFrom:
- configMapRef:
name: {{ include "wireguard.fullname" . }}
env:
{{- toYaml .Values.env | nindent 12 }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
- name: wg-config
persistentVolumeClaim:
claimName: {{ include "wireguard.fullname" . }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
13 changes: 13 additions & 0 deletions charts/wireguard/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "wireguard.fullname" . }}
labels:
{{- include "wireguard.labels" . | nindent 4 }}
spec:
storageClassName: {{ .Values.persistence.storageClassName }}
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.persistence.storageSize }}
15 changes: 15 additions & 0 deletions charts/wireguard/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "wireguard.fullname" . }}
labels:
{{- include "wireguard.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: 51820
protocol: UDP
name: wg-server
selector:
{{- include "wireguard.selectorLabels" . | nindent 4 }}
12 changes: 12 additions & 0 deletions charts/wireguard/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "wireguard.serviceAccountName" . }}
labels:
{{- include "wireguard.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
55 changes: 55 additions & 0 deletions charts/wireguard/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
replicaCount: 1

config:
timeZone: Europe/Helsinki
serverUrl: "vpn.example.com"
peers: "1"
allowedIPs: "10.0.0.0/8"
internalSubnet: "10.13.13.0/24"
logConfs: "false"

image:
registry: linuxserver/wireguard
pullPolicy: IfNotPresent
tag: "1.0.20210914"

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

serviceAccount:
create: true
annotations: {}

podAnnotations: {}

podSecurityContext: {}

securityContext:
capabilities:
add:
- NET_ADMIN

persistence:
storageClassName: standard-rwo
storageSize: 10M

service:
type: LoadBalancer
port: 51820

env: []

resources:
requests:
memory: 64Mi
cpu: 100m
limits:
memory: 512Mi
cpu: 500m

nodeSelector: {}

tolerations: []

affinity: {}

0 comments on commit d6a96b3

Please sign in to comment.