Skip to content

Commit 32741b1

Browse files
authored
Add tailscale sidecar (#112)
* add tailscale sidecar * update doc table * add new line
1 parent a443aac commit 32741b1

File tree

5 files changed

+87
-2
lines changed

5 files changed

+87
-2
lines changed

charts/k8s-dev-pod/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: k8s-dev-pod
33
description: A Helm chart for deploying a dev environment inside a K8S cluster that is compatible with Visual Studio Code remote targets
44
type: application
5-
version: 0.1.10
5+
version: 0.2.0
66
appVersion: "0.1.0"
77
maintainers:
88
- name: Bryopsida

charts/k8s-dev-pod/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# k8s-dev-pod
22

3-
![Version: 0.1.10](https://img.shields.io/badge/Version-0.1.10-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square)
3+
![Version: 0.2.0](https://img.shields.io/badge/Version-0.2.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square)
44

55
A Helm chart for deploying a dev environment inside a K8S cluster that is compatible with Visual Studio Code remote targets
66

@@ -21,6 +21,11 @@ A Helm chart for deploying a dev environment inside a K8S cluster that is compat
2121
| ingressEnabled | bool | `false` | |
2222
| ingressPort | int | `3022` | |
2323
| passwordLoginEnabled | bool | `true` | |
24+
| tailscale.authKey | string | `nil` | |
25+
| tailscale.enabled | bool | `false` | |
26+
| tailscale.image.pullPolicy | string | `"Always"` | |
27+
| tailscale.image.repo | string | `"ghcr.io/tailscale/tailscale"` | |
28+
| tailscale.image.tag | string | `"latest"` | |
2429

2530
----------------------------------------------
2631
Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0)

charts/k8s-dev-pod/templates/deployment.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ spec:
3434
{{- if .Values.volumes }}
3535
{{- toYaml .Values.volumes | nindent 8 }}
3636
{{- end }}
37+
{{- if .Values.tailscale.enabled }}
38+
serviceAccountName: "tailscale-sa"
39+
{{- end }}
3740
containers:
3841
- name: {{ .Chart.Name }}
3942
securityContext:
@@ -62,6 +65,26 @@ spec:
6265
{{- if .Values.volumeMounts }}
6366
{{- toYaml .Values.volumeMounts | nindent 12 }}
6467
{{- end }}
68+
{{- if .Values.tailscale.enabled }}
69+
- name: tailscale
70+
image: "{{ .Values.tailscale.image.repo }}:{{ .Values.tailscale.image.tag }}"
71+
imagePullPolicy: "{{ .Values.tailscale.image.pullPolicy }}"
72+
securityContext:
73+
runAsUser: 1000
74+
runAsGroup: 1000
75+
env:
76+
# Store the state in a k8s secret
77+
- name: TS_KUBE_SECRET
78+
value: "tailscale-state"
79+
- name: TS_USERSPACE
80+
value: "true"
81+
- name: TS_AUTHKEY
82+
valueFrom:
83+
secretKeyRef:
84+
name: tailscale-auth
85+
key: TS_AUTHKEY
86+
optional: true
87+
{{- end }}
6588
{{- with .Values.nodeSelector }}
6689
nodeSelector:
6790
{{- toYaml . | nindent 8 }}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{{- if .Values.tailscale.enabled }}
2+
---
3+
apiVersion: v1
4+
kind: ServiceAccount
5+
metadata:
6+
name: tailscale-sa
7+
namespace: {{ .Release.Namespace }}
8+
---
9+
apiVersion: rbac.authorization.k8s.io/v1
10+
kind: RoleBinding
11+
metadata:
12+
name: tailscale
13+
subjects:
14+
- kind: ServiceAccount
15+
name: "tailscale-sa"
16+
roleRef:
17+
kind: Role
18+
name: tailscale
19+
apiGroup: rbac.authorization.k8s.io
20+
---
21+
apiVersion: rbac.authorization.k8s.io/v1
22+
kind: Role
23+
metadata:
24+
name: tailscale
25+
namespace: {{ .Release.Namespace }}
26+
rules:
27+
- apiGroups: [""] # "" indicates the core API group
28+
resources: ["secrets"]
29+
# Create can not be restricted to a resource name.
30+
verbs: ["create"]
31+
- apiGroups: [""] # "" indicates the core API group
32+
resourceNames: ["tailscale-state"]
33+
resources: ["secrets"]
34+
verbs: ["get", "update", "patch"]
35+
---
36+
apiVersion: v1
37+
kind: Secret
38+
metadata:
39+
name: tailscale-state
40+
namespace: {{ .Release.Namespace}}
41+
data:
42+
---
43+
apiVersion: v1
44+
kind: Secret
45+
metadata:
46+
name: tailscale-auth
47+
namespace: {{ .Release.Namespace}}
48+
data:
49+
TS_AUTHKEY: {{ (required "When tailscale.enabled is true, a value must be provided for tailscale.authKey!" .Values.tailscale.authKey) | b64enc }}
50+
{{- end }}

charts/k8s-dev-pod/values.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,10 @@ homeSize: 20
66
ingressEnabled: false
77
ingressPort: 3022
88
passwordLoginEnabled: true
9+
tailscale:
10+
enabled: false
11+
image:
12+
repo: ghcr.io/tailscale/tailscale
13+
tag: latest
14+
pullPolicy: Always
15+
authKey: ~

0 commit comments

Comments
 (0)