Skip to content

Commit 468774f

Browse files
committed
Merge branch 'dev'
2 parents 9e856a2 + 1208a64 commit 468774f

17 files changed

+318
-44
lines changed

.github/workflows/dev.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ jobs:
2020
run: |
2121
cd ./charts
2222
helm package ./bunkerweb/
23-
helm repo index . --url https://repo.bunkerweb.io/charts-dev
2423
2524
- name: Upload files via SSH
2625
env:
@@ -32,5 +31,9 @@ jobs:
3231
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
3332
chmod 600 ~/.ssh/id_ed25519
3433
ssh-keyscan $SSH_HOST >> ~/.ssh/known_hosts
35-
scp -r ./charts/bunkerweb-*.tgz $SSH_USERNAME@$SSH_HOST:/var/www/html/charts-dev
36-
scp ./charts/index.yaml $SSH_USERNAME@$SSH_HOST:/var/www/html/charts-dev
34+
cd charts
35+
scp *.tgz $SSH_USERNAME@$SSH_HOST:/var/www/html/charts-dev
36+
scp $SSH_USERNAME@$SSH_HOST:/var/www/html/charts-dev/* .
37+
helm repo index . --url https://repo.bunkerweb.io/charts-dev
38+
scp *.tgz $SSH_USERNAME@$SSH_HOST:/var/www/html/charts-dev
39+
scp index.yaml $SSH_USERNAME@$SSH_HOST:/var/www/html/charts-dev

.github/workflows/prod.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Deploy helm chart to prod
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v2
15+
16+
- uses: azure/setup-helm@v4.2.0
17+
id: install
18+
19+
- name: Package chart
20+
run: |
21+
cd ./charts
22+
helm package ./bunkerweb/
23+
24+
- name: Upload files via SSH
25+
env:
26+
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
27+
SSH_HOST: ${{ secrets.SSH_HOST }}
28+
SSH_USERNAME: ${{ secrets.SSH_USERNAME }}
29+
run: |
30+
mkdir -p ~/.ssh
31+
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
32+
chmod 600 ~/.ssh/id_ed25519
33+
ssh-keyscan $SSH_HOST >> ~/.ssh/known_hosts
34+
cd charts
35+
scp *.tgz $SSH_USERNAME@$SSH_HOST:/var/www/html/charts
36+
scp $SSH_USERNAME@$SSH_HOST:/var/www/html/charts/* .
37+
helm repo index . --url https://repo.bunkerweb.io/charts
38+
scp *.tgz $SSH_USERNAME@$SSH_HOST:/var/www/html/charts
39+
scp index.yaml $SSH_USERNAME@$SSH_HOST:/var/www/html/charts

README.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,23 @@
1-
# bunkerweb-helm
2-
BunkerWeb Kubernetes helm charts.
1+
# BunkerWeb Kubernetes Helm chart
2+
3+
Official [Helm chart](https://helm.sh/docs/) to deploy [BunkerWeb](https://www.bunkerweb.io/?utm_campaign=self&utm_source=github) on Kubernetes.
4+
5+
## Prerequisites
6+
7+
Please first refer to the [BunkerWeb documentation](https://docs.bunkerweb.io/latest/?utm_campaign=self&utm_source=github), particularly the [Kubernetes integration](https://docs.bunkerweb.io/latest/integrations/?utm_campaign=self&utm_source=bunkerwebio#kubernetes) section.
8+
9+
## Helm repository
10+
11+
The BunkerWeb Helm chart repository is available at `https://repo.bunkerweb.io/charts` :
12+
```bash
13+
helm repo add bunkerweb https://repo.bunkerweb.io/charts
14+
```
15+
16+
You can then use the `bunkerweb` helm chart from that repository :
17+
```bash
18+
helm install -f myvalues.yaml mybunkerweb bunkerweb/bunkerweb
19+
```
20+
21+
## Values
22+
23+
The full list of values are listed in the `charts/bunkerweb/values.yaml` file.

charts/bunkerweb/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.0.2
18+
version: 0.0.1
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to
2222
# follow Semantic Versioning. They should reflect the version the application is using.
2323
# It is recommended to use it with quotes.
24-
appVersion: "1.6.0"
24+
appVersion: "1.6.0-rc2"

charts/bunkerweb/templates/_helpers.tpl

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ Allows overriding it for multi-namespace deployments in combined charts.
5858
{{- default .Release.Namespace .Values.namespaceOverride | trunc 63 | trimSuffix "-" -}}
5959
{{- end -}}
6060

61+
{{/*
62+
UI_HOST setting
63+
*/}}
64+
{{- define "bunkerweb.uiHost" -}}
65+
{{- printf "http://ui-%s.%s.svc.%s:7000" (include "bunkerweb.fullname" .) (include "bunkerweb.namespace" .) .Values.settings.kubernetes.domainName -}}
66+
{{- end -}}
6167

6268
{{/*
6369
DATABASE_URI setting
@@ -66,8 +72,8 @@ DATABASE_URI setting
6672
{{- if .Values.mariadb.enabled -}}
6773
{{- $user := .Values.mariadb.config.user -}}
6874
{{- $password := .Values.mariadb.config.password -}}
69-
{{- $host := printf "mariadb-%s" (include "bunkerweb.fullname" .) -}}
70-
{{- $db := .Values.mariadb.config.db -}}
75+
{{- $host := printf "mariadb-%s.%s.svc.%s" (include "bunkerweb.fullname" .) (include "bunkerweb.namespace" .) .Values.settings.kubernetes.domainName -}}
76+
{{- $db := .Values.mariadb.config.database -}}
7177
{{- printf "mariadb+pymysql://%s:%s@%s:3306/%s" $user $password $host $db -}}
7278
{{- else -}}
7379
{{- .Values.settings.misc.databaseUri -}}
@@ -84,13 +90,34 @@ REDIS settings
8490
- name: REDIS_USERNAME
8591
value: ""
8692
- name: REDIS_PASSWORD
93+
{{- if not (empty .Values.settings.existingSecret) }}
94+
valueFrom:
95+
secretKeyRef:
96+
name: "{{ .Values.settings.existingSecret }}"
97+
key: redis-password
98+
{{- else }}
8799
value: "{{ .Values.redis.config.password }}"
100+
{{- end }}
88101
{{- else }}
89102
- name: REDIS_HOST
90103
value: "{{ .Values.settings.redis.redisHost }}"
91104
- name: REDIS_USERNAME
105+
{{- if not (empty .Values.settings.existingSecret) }}
106+
valueFrom:
107+
secretKeyRef:
108+
name: "{{ .Values.settings.existingSecret }}"
109+
key: redis-username
110+
{{- else }}
92111
value: "{{ .Values.settings.redis.redisUsername }}"
112+
{{- end }}
93113
- name: REDIS_PASSWORD
114+
{{- if not (empty .Values.settings.existingSecret) }}
115+
valueFrom:
116+
secretKeyRef:
117+
name: "{{ .Values.settings.existingSecret }}"
118+
key: redis-password
119+
{{- else }}
94120
value: "{{ .Values.settings.redis.redisPassword }}"
121+
{{- end }}
95122
{{- end }}
96123
{{- end }}

charts/bunkerweb/templates/bunkerweb-daemonset.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ spec:
1111
{{- include "bunkerweb.selectorLabels" . | nindent 6 }}
1212
template:
1313
metadata:
14-
{{- with .Values.bunkerweb.podAnnotations }}
1514
annotations:
1615
# mandatory annotation
1716
bunkerweb.io/INSTANCE: "yes"
17+
{{- with .Values.bunkerweb.podAnnotations }}
1818
{{- toYaml . | nindent 8 }}
1919
{{- end }}
2020
labels:
@@ -58,4 +58,9 @@ spec:
5858
{{- with .Values.bunkerweb.readinessProbe }}
5959
readinessProbe:
6060
{{- toYaml . | nindent 12}}
61-
{{- end }}
61+
{{- end }}
62+
{{- with .Values.nodeSelector }}
63+
nodeSelector:
64+
{{- toYaml . | nindent 8 }}
65+
{{- end }}
66+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
{{- if .Values.service.enabled -}}
3+
apiVersion: v1
4+
kind: Service
5+
metadata:
6+
name: {{ include "bunkerweb.fullname" . }}-external
7+
namespace: {{ include "bunkerweb.namespace" . }}
8+
labels:
9+
{{- include "bunkerweb.labels" . | nindent 4 }}
10+
annotations:
11+
{{- toYaml .Values.service.annotations | nindent 4 }}
12+
spec:
13+
type: {{ .Values.service.type }}
14+
externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy }}
15+
selector:
16+
bunkerweb.io/component: "bunkerweb"
17+
ports:
18+
- port: 80
19+
targetPort: 8080
20+
protocol: TCP
21+
name: http
22+
- port: 443
23+
targetPort: 8443
24+
protocol: TCP
25+
name: https
26+
{{- end }}

charts/bunkerweb/templates/bunkerweb-service.yaml renamed to charts/bunkerweb/templates/bunkerweb-service-internal.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v1
22
kind: Service
33
metadata:
4-
name: {{ include "bunkerweb.fullname" . }}
4+
name: {{ include "bunkerweb.fullname" . }}-internal
55
namespace: {{ include "bunkerweb.namespace" . }}
66
labels:
77
{{- include "bunkerweb.labels" . | nindent 4 }}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: controller-{{ include "bunkerweb.fullname" . }}
5+
namespace: {{ include "bunkerweb.namespace" . }}
6+
labels:
7+
{{- include "bunkerweb.labels" . | nindent 4 }}
8+
spec:
9+
strategy:
10+
type: Recreate
11+
replicas: 1
12+
selector:
13+
matchLabels:
14+
{{- include "bunkerweb.selectorLabels" . | nindent 6 }}
15+
template:
16+
metadata:
17+
labels:
18+
{{- include "bunkerweb.labels" . | nindent 8 }}
19+
{{- with .Values.controller.podLabels }}
20+
{{- toYaml . | nindent 8 }}
21+
{{- end }}
22+
bunkerweb.io/component: "controller"
23+
spec:
24+
serviceAccountName: {{ include "bunkerweb.fullname" . }}
25+
containers:
26+
- name: bunkerweb-controller
27+
image: {{ .Values.controller.repository }}:{{ .Values.controller.tag }}
28+
imagePullPolicy: {{ .Values.controller.pullPolicy }}
29+
{{- with .Values.controller.securityContext }}
30+
securityContext:
31+
{{- toYaml . | nindent 12}}
32+
{{- end }}
33+
env:
34+
# Mandatory for k8s integration
35+
- name: KUBERNETES_MODE
36+
value: "yes"
37+
- name: DATABASE_URI
38+
{{- if not (empty .Values.settings.existingSecret) }}
39+
valueFrom:
40+
secretKeyRef:
41+
name: {{ .Values.settings.existingSecret }}
42+
key: database-uri
43+
{{- else }}
44+
value: "{{ include "bunkerweb.databaseUri" . }}"
45+
{{- end }}
46+
- name: NAMESPACES
47+
value: "{{ .Values.settings.kubernetes.namespaces }}"
48+
- name: KUBERNETES_INGRESS_CLASS
49+
value: "{{ .Values.settings.kubernetes.ingressClass }}"
50+
- name: KUBERNETES_DOMAIN_NAME
51+
value: "{{ .Values.settings.kubernetes.domainName }}"
52+
{{- with .Values.nodeSelector }}
53+
nodeSelector:
54+
{{- toYaml . | nindent 8 }}
55+
{{- end }}

charts/bunkerweb/templates/mariadb-deployment.yaml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,37 @@ spec:
2121
image: mariadb:11
2222
imagePullPolicy: Always
2323
env:
24-
- name: MYSQL_RANDOM_ROOT_PASSWORD
24+
- name: MARIADB_RANDOM_ROOT_PASSWORD
2525
value: "{{ .Values.mariadb.config.randomRootPassword }}"
26-
- name: MYSQL_DATABASE
27-
value: "{{ .Values.mariadb.config.db }}"
28-
- name: MYSQL_USER
26+
- name: MARIADB_DATABASE
27+
value: "{{ .Values.mariadb.config.database }}"
28+
- name: MARIADB_USER
29+
{{- if not (empty .Values.settings.existingSecret) }}
30+
valueFrom:
31+
secretKeyRef:
32+
name: "{{ .Values.settings.existingSecret }}"
33+
key: mariadb-user
34+
{{- else }}
2935
value: "{{ .Values.mariadb.config.user }}"
30-
- name: MYSQL_PASSWORD
36+
{{- end }}
37+
- name: MARIADB_PASSWORD
38+
{{- if not (empty .Values.settings.existingSecret) }}
39+
valueFrom:
40+
secretKeyRef:
41+
name: "{{ .Values.settings.existingSecret }}"
42+
key: mariadb-password
43+
{{- else }}
3144
value: "{{ .Values.mariadb.config.password }}"
45+
{{- end }}
3246
volumeMounts:
3347
- mountPath: "/var/lib/mysql"
3448
name: vol-db
3549
volumes:
3650
- name: vol-db
3751
persistentVolumeClaim:
3852
claimName: mariadb-{{ include "bunkerweb.fullname" . }}
53+
{{- with .Values.nodeSelector }}
54+
nodeSelector:
55+
{{- toYaml . | nindent 8 }}
56+
{{- end }}
3957
{{- end }}

0 commit comments

Comments
 (0)