Merge pull request #1 from zerotier/ingress

initial config
This commit is contained in:
Grant Limberg
2024-01-17 15:23:09 -05:00
committed by GitHub
11 changed files with 359 additions and 0 deletions
+23
View File
@@ -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/
+24
View File
@@ -0,0 +1,24 @@
apiVersion: v2
name: zerotier-ingress-helm
description: A Helm chart for Kubernetes
# 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
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
@@ -0,0 +1,6 @@
FROM nginx:1.25.3-bookworm
COPY ./entrypoint-ztnginx.sh /entrypoint-ztnginx.sh
COPY ./default.conf.template /default.conf.template
ENTRYPOINT ["/entrypoint-ztnginx.sh"]
@@ -0,0 +1,11 @@
server {
listen $NGINX_LISTEN_PORT;
location / {
proxy_pass $NGINX_PROXY_ADDRESS;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
+14
View File
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
NGINX_LISTEN_PORT="${NGINX_LISTEN_PORT:-8000}"
if [ -z "$NGINX_PROXY_ADDRESS" ]; then
echo "Error: NGINX_PROXY_ADDRESS environment variable is not set"
exit 1
fi
envsubst '$NGINX_LISTEN_PORT,$NGINX_PROXY_ADDRESS' < /default.conf.template > /etc/nginx/conf.d/default.conf
cat /etc/nginx/conf.d/default.conf
exec /docker-entrypoint.sh nginx -g "daemon off;"
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "zerotier-ingress-helm.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 "zerotier-ingress-helm.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 "zerotier-ingress-helm.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "zerotier-ingress-helm.labels" -}}
helm.sh/chart: {{ include "zerotier-ingress-helm.chart" . }}
{{ include "zerotier-ingress-helm.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "zerotier-ingress-helm.selectorLabels" -}}
app.kubernetes.io/name: {{ include "zerotier-ingress-helm.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "zerotier-ingress-helm.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "zerotier-ingress-helm.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
@@ -0,0 +1,97 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "zerotier-ingress-helm.fullname" . }}
labels:
{{- include "zerotier-ingress-helm.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "zerotier-ingress-helm.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "zerotier-ingress-helm.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "zerotier-ingress-helm.serviceAccountName" . }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.zerotier.image.repository }}:{{ .Values.zerotier.image.tag | default "1.12.2" }}"
imagePullPolicy: {{ .Values.zerotier.image.pullPolicy }}
args:
- "{{ .Values.zerotier.networkID }}"
env:
- name: ZEROTIER_IDENTITY_PUBLIC
valueFrom:
secretKeyRef:
name: {{ include "zerotier-ingress-helm.fullname" . }}-ztidentity
key: identity.public
- name: ZEROTIER_IDENTITY_SECRET
valueFrom:
secretKeyRef:
name: {{ include "zerotier-ingress-helm.fullname" . }}-ztidentity
key: identity.secret
securityContext:
privileged: true
volumeMounts:
- mountPath: /dev/net
name: dev-net
{{- with .Values.zerotier.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
- name: {{ .Chart.Name }}-nginx
image: "{{ .Values.nginx.image.repository }}:{{ .Values.nginx.image.tag | default "1.25.3-bookworm-zt" }}"
imagePullPolicy: {{ .Values.nginx.image.pullPolicy }}
env:
- name: NGINX_LISTEN_PORT
value: "{{ .Values.nginx.listenPort | default 8000 }}"
- name: NGINX_PROXY_ADDRESS
value: {{ .Values.nginx.proxyAddress }}
ports:
- name: http
containerPort: {{ .Values.nginx.listenPort }}
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.nginx.resources | nindent 12 }}
{{- with .Values.nginx.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
volumes:
- name: dev-net
hostPath:
path: /dev/net
{{- with .Values.volumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ include "zerotier-ingress-helm.fullname" . }}-ztidentity
labels:
{{- include "zerotier-ingress-helm.labels" . | nindent 4 }}
type: Opaque
data:
identity.public: {{ .Values.zerotier.identity.public | b64enc }}
identity.secret: {{ .Values.zerotier.identity.secret | b64enc }}
@@ -0,0 +1,13 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "zerotier-ingress-helm.serviceAccountName" . }}
labels:
{{- include "zerotier-ingress-helm.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}
+99
View File
@@ -0,0 +1,99 @@
# Default values for zerotier-ingress-helm.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
nginx:
image:
repository: zerotier/ztnginx
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""
listenPort: 8080
# Set the proxy address
# this should be the full host/port combination: http://someservice.mynamespace.svc.cluster.local:1234
proxyAddress: ""
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
volumeMounts:
[]
# - name: foo
# mountPath: "/etc/foo"
# readOnly: true
zerotier:
image:
repository: zerotier/zerotier
pullPolicy: IfNotPresent
tag: "1.12.2"
# ZeroTier Identity
# Create these values with `zerotier-idtool`
identity:
public: ""
secret: ""
# NetworkID to join
networkID: ""
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
volumeMounts:
[]
# - name: foo
# mountPath: "/etc/foo"
# readOnly: true
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
serviceAccount:
# Specifies whether a service account should be created
create: true
# Automatically mount a ServiceAccount's API credentials?
automount: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""
podAnnotations: {}
podLabels: {}
# Additional volumes on the output Deployment definition.
volumes: []
# - name: foo
# secret:
# secretName: mysecret
# optional: false
nodeSelector: {}
tolerations: []
affinity: {}