Skip to content

Commit

Permalink
added helm
Browse files Browse the repository at this point in the history
  • Loading branch information
Place1 committed Mar 10, 2020
1 parent 9d57280 commit 8e35e75
Show file tree
Hide file tree
Showing 9 changed files with 347 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
config.yaml
data/
wg-access-server
./wg-access-server
23 changes: 23 additions & 0 deletions deploy/helm/wg-access-server/.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/
5 changes: 5 additions & 0 deletions deploy/helm/wg-access-server/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v2
appVersion: 0.0.9
description: A Wireguard VPN Access Server
name: wg-access-server
version: 0.0.9
64 changes: 64 additions & 0 deletions deploy/helm/wg-access-server/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "wg-access-server.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 "wg-access-server.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 "wg-access-server.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "wg-access-server.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "wg-access-server.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
79 changes: 79 additions & 0 deletions deploy/helm/wg-access-server/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{{- $fullName := include "wg-access-server.fullname" . -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "wg-access-server.fullname" . }}
labels:
{{- include "wg-access-server.labels" . | nindent 4 }}
spec:
replicas: 1
strategy:
type: "{{ .Values.strategy.type }}"
selector:
matchLabels:
{{- include "wg-access-server.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "wg-access-server.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
securityContext:
capabilities:
add: ['NET_ADMIN']
image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 8000
protocol: TCP
- name: wireguard
containerPort: 51820
protocol: UDP
volumeMounts:
- name: tun
mountPath: /dev/net/tun
- name: data
mountPath: /data
- name: config
mountPath: /config.yaml
subPath: config.yaml
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
- name: tun
hostPath:
type: 'CharDevice'
path: /dev/net/tun
- name: data
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: "{{ $fullName }}"
{{- end }}
{{- if not .Values.persistence.enabled }}
emptyDir: {}
{{- end }}
- name: config
configMap:
name: "{{ $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 }}
36 changes: 36 additions & 0 deletions deploy/helm/wg-access-server/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "wg-access-server.fullname" . -}}
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "wg-access-server.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ . }}
backend:
serviceName: {{ $fullName }}
servicePort: 80
{{- end }}
{{- end }}
{{- end }}
29 changes: 29 additions & 0 deletions deploy/helm/wg-access-server/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{- if .Values.persistence.enabled -}}
{{- $fullName := include "wg-access-server.fullname" . -}}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: "{{ $fullName }}"
labels:
{{- include "wg-access-server.labels" . | nindent 4 }}
{{- with .Values.persistence.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
accessModes:
{{ toYaml .Values.persistence.accessModes | indent 4 }}
{{- if .Values.persistence.storageClass }}
{{- if (eq "-" .Values.persistence.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.persistence.storageClass }}"
{{- end }}
{{- end }}
{{- if .Values.persistence.volumeBindingMode }}
volumeBindingModeName: "{{ .Values.persistence.volumeBindingMode }}"
{{- end }}
resources:
requests:
storage: "{{ .Values.persistence.size }}"
{{- end -}}
34 changes: 34 additions & 0 deletions deploy/helm/wg-access-server/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{- $fullName := include "wg-access-server.fullname" . -}}
apiVersion: v1
kind: Service
metadata:
name: {{ $fullName }}-web
labels:
{{- include "wg-access-server.labels" . | nindent 4 }}
spec:
type: {{ .Values.web.service.type }}
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
{{- include "wg-access-server.selectorLabels" . | nindent 4 }}

---

apiVersion: v1
kind: Service
metadata:
name: {{ $fullName }}-wireguard
labels:
{{- include "wg-access-server.labels" . | nindent 4 }}
spec:
type: {{ .Values.wireguard.service.type }}
ports:
- port: 51820
targetPort: wireguard
protocol: UDP
name: wireguard
selector:
{{- include "wg-access-server.selectorLabels" . | nindent 4 }}
76 changes: 76 additions & 0 deletions deploy/helm/wg-access-server/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# wg-access-server config
config:
wireguard:
# The WireGuard PrivateKey
# You can generate this value using "$ wg genkey"
# If this value is empty then the server will use an in-memory
# generated key
privateKey: ""

web:
service:
type: ClusterIP

wireguard:
service:
type: ClusterIP

persistence:
enabled: false
## Persistent Volume Storage Class
## If defined, storageClassName: <storageClass>
## If set to "-", storageClassName: "", which disables dynamic provisioning
## If undefined (the default) or set to null, no storageClassName spec is
## set, choosing the default provisioner. (gp2 on AWS, standard on
## GKE, AWS & OpenStack)
##
# storageClass: "-"
size: 100Mi
annotations: {}
accessModes:
- ReadWriteOnce
subPath: ""


ingress:
enabled: false
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
# - www.example.com
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local

nameOverride: ""

fullnameOverride: ""

imagePullSecrets: []

image:
repository: place1/wg-access-server
pullPolicy: IfNotPresent

strategy:
type: Recreate

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

nodeSelector: {}

tolerations: []

affinity: {}

0 comments on commit 8e35e75

Please sign in to comment.