Skip to content

Commit

Permalink
Merge pull request #12 from cloudkite-io/add-tailscale-vpn
Browse files Browse the repository at this point in the history
publish tailscale vpn helm chart
  • Loading branch information
TeamoreA authored Apr 9, 2024
2 parents a488c7d + b19648e commit 1706b61
Show file tree
Hide file tree
Showing 10 changed files with 254 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/tailscale-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Publish Tailscale VPN Chart

env:
CHART_NAME: tailscale
GAR_LOCATION: us-central1
PROJECT_NAME: cloudkite-public
PROJECT_ID: 297731695546
REPOSITORY: public-helm-charts

on:
workflow_dispatch:
push:
branches: [main]
paths: [tailscale/**]

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Authenticate to Google Cloud
id: auth
uses: google-github-actions/auth@v0
with:
workload_identity_provider: projects/${{ env.PROJECT_ID }}/locations/global/workloadIdentityPools/github-actions/providers/github-oidc
service_account: github-actions@${{ env.PROJECT_NAME }}.iam.gserviceaccount.com
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0
- name: Docker configuration
run: gcloud auth configure-docker $GAR_LOCATION-docker.pkg.dev --quiet
- name: Update dependencies
working-directory: ${{ env.CHART_NAME }}
run: helm dependency update
- name: Package chart
run: helm package $CHART_NAME
- name: Push chart
run: helm push $CHART_NAME-*.tgz oci://$GAR_LOCATION-docker.pkg.dev/$PROJECT_NAME/$REPOSITORY
23 changes: 23 additions & 0 deletions tailscale/.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/
24 changes: 24 additions & 0 deletions tailscale/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: tailscale
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"
62 changes: 62 additions & 0 deletions tailscale/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "tailscale.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 "tailscale.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 "tailscale.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "tailscale.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "tailscale.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
55 changes: 55 additions & 0 deletions tailscale/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "tailscale.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "tailscale.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
{{- include "tailscale.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "tailscale.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "tailscale.fullname" . }}
securityContext:
runAsUser: 1000
runAsGroup: 1000
containers:
- name: tailscale
imagePullPolicy: Always
image: "ghcr.io/tailscale/tailscale:latest"
env:
# Store the state in a k8s secret
- name: TS_KUBE_SECRET
value: {{ include "tailscale.fullname" . }}
- name: TS_USERSPACE
value: "true"
- name: TS_ACCEPT_DNS
value: "true"
- name: TS_EXTRA_ARGS
value: "--advertise-tags={{ .Values.tags }} --hostname={{ include "tailscale.fullname" . }}-{{ .Values.env }}-cluster"
- name: TS_AUTH_KEY
valueFrom:
secretKeyRef:
name: {{ include "tailscale.fullname" . }}
key: TS_AUTH_KEY
optional: true
- name: TS_ROUTES
value: {{ .Values.TS_ROUTES }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
16 changes: 16 additions & 0 deletions tailscale/templates/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (c) Tailscale Inc & AUTHORS
# SPDX-License-Identifier: BSD-3-Clause
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "tailscale.fullname" . }}
namespace: {{ .Release.Namespace }}
rules:
- apiGroups: [""] # "" indicates the core API group
resources: ["secrets"]
# Create can not be restricted to a resource name.
verbs: ["create"]
- apiGroups: [""] # "" indicates the core API group
resourceNames: [{{ include "tailscale.fullname" . }}]
resources: ["secrets"]
verbs: ["get", "update", "patch"]
12 changes: 12 additions & 0 deletions tailscale/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "tailscale.fullname" . }}
namespace: {{ .Release.Namespace }}
subjects:
- kind: ServiceAccount
name: {{ include "tailscale.fullname" . }}
roleRef:
kind: Role
name: tailscale
apiGroup: rbac.authorization.k8s.io
9 changes: 9 additions & 0 deletions tailscale/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{- if .Values.authKey }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "tailscale.fullname" . }}
namespace: {{ .Release.Namespace }}
stringData:
TS_AUTH_KEY: {{ .Values.authKey }}
{{- end }}
5 changes: 5 additions & 0 deletions tailscale/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "tailscale.fullname" . }}
namespace: {{ .Release.Namespace }}
7 changes: 7 additions & 0 deletions tailscale/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
env: dev
# comma seperated routes to advertise example 0.0.0.1/24, 0.0.0.1/32
TS_ROUTES: ''
# auth key generated from tailscale admin console
authKey: tskey-auth-xxxxx
# comma separated ACL tags, example, tag:server,tag:development
tags: tag:server

0 comments on commit 1706b61

Please sign in to comment.