Skip to content
This repository was archived by the owner on Nov 25, 2024. It is now read-only.

Commit d579ddb

Browse files
S7evinKkegsay
andauthored
Add simplified helm chart (#2905)
As discussed yesterday, a simplified version of [my helm](https://github.com/S7evinK/dendrite-helm) which deploys a monolith with internal NATS and an optionally enabled PostgreSQL server. If the PostgreSQL dependency is not enabled, a user specified connection string is constructed. Co-authored-by: kegsay <[email protected]>
1 parent 2e1fe58 commit d579ddb

25 files changed

+1238
-2
lines changed

.github/workflows/gh-pages.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Sample workflow for building and deploying a Jekyll site to GitHub Pages
2+
name: Deploy GitHub Pages dependencies preinstalled
3+
4+
on:
5+
# Runs on pushes targeting the default branch
6+
push:
7+
branches: ["main"]
8+
paths:
9+
- 'docs/**' # only execute if we have docs changes
10+
11+
# Allows you to run this workflow manually from the Actions tab
12+
workflow_dispatch:
13+
14+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
15+
permissions:
16+
contents: read
17+
pages: write
18+
id-token: write
19+
20+
# Allow one concurrent deployment
21+
concurrency:
22+
group: "pages"
23+
cancel-in-progress: true
24+
25+
jobs:
26+
# Build job
27+
build:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v3
32+
- name: Setup Pages
33+
uses: actions/configure-pages@v2
34+
- name: Build with Jekyll
35+
uses: actions/jekyll-build-pages@v1
36+
with:
37+
source: ./docs
38+
destination: ./_site
39+
- name: Upload artifact
40+
uses: actions/upload-pages-artifact@v1
41+
42+
# Deployment job
43+
deploy:
44+
environment:
45+
name: github-pages
46+
url: ${{ steps.deployment.outputs.page_url }}
47+
runs-on: ubuntu-latest
48+
needs: build
49+
steps:
50+
- name: Deploy to GitHub Pages
51+
id: deployment
52+
uses: actions/deploy-pages@v1

.github/workflows/helm.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Release Charts
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'helm/**' # only execute if we have helm chart changes
9+
10+
jobs:
11+
release:
12+
# depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions
13+
# see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
14+
permissions:
15+
contents: write
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v2
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Configure Git
24+
run: |
25+
git config user.name "$GITHUB_ACTOR"
26+
git config user.email "[email protected]"
27+
28+
- name: Install Helm
29+
uses: azure/setup-helm@v3
30+
with:
31+
version: v3.10.0
32+
33+
- name: Run chart-releaser
34+
uses: helm/[email protected]
35+
env:
36+
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
37+
with:
38+
config: helm/cr.yaml
39+
charts_dir: helm/

.github/workflows/k8s.yml

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: k8s
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
paths:
7+
- 'helm/**' # only execute if we have helm chart changes
8+
pull_request:
9+
branches: ["main"]
10+
paths:
11+
- 'helm/**'
12+
13+
jobs:
14+
lint:
15+
name: Lint Helm chart
16+
runs-on: ubuntu-latest
17+
outputs:
18+
changed: ${{ steps.list-changed.outputs.changed }}
19+
steps:
20+
- uses: actions/checkout@v3
21+
with:
22+
fetch-depth: 0
23+
- uses: azure/setup-helm@v3
24+
with:
25+
version: v3.10.0
26+
- uses: actions/setup-python@v4
27+
with:
28+
python-version: 3.11
29+
check-latest: true
30+
- uses: helm/[email protected]
31+
- name: Get changed status
32+
id: list-changed
33+
run: |
34+
changed=$(ct list-changed --config helm/ct.yaml --target-branch ${{ github.event.repository.default_branch }})
35+
if [[ -n "$changed" ]]; then
36+
echo "::set-output name=changed::true"
37+
fi
38+
39+
- name: Run lint
40+
run: ct lint --config helm/ct.yaml
41+
42+
# only bother to run if lint step reports a change to the helm chart
43+
install:
44+
needs:
45+
- lint
46+
if: ${{ needs.lint.outputs.changed == 'true' }}
47+
name: Install Helm charts
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Checkout
51+
uses: actions/checkout@v3
52+
with:
53+
fetch-depth: 0
54+
ref: ${{ inputs.checkoutCommit }}
55+
- name: Install Kubernetes tools
56+
uses: yokawasa/[email protected]
57+
with:
58+
setup-tools: |
59+
helmv3
60+
helm: "3.10.3"
61+
- uses: actions/setup-python@v4
62+
with:
63+
python-version: "3.10"
64+
- name: Set up chart-testing
65+
uses: helm/[email protected]
66+
- name: Create k3d cluster
67+
uses: nolar/setup-k3d-k3s@v1
68+
with:
69+
version: v1.21
70+
- name: Remove node taints
71+
run: |
72+
kubectl taint --all=true nodes node.cloudprovider.kubernetes.io/uninitialized- || true
73+
- name: Run chart-testing (install)
74+
run: ct install --config helm/ct.yaml
75+
76+
# Install the chart using helm directly and test with create-account
77+
- name: Install chart
78+
run: |
79+
helm install --values helm/dendrite/ci/ct-postgres-sharedsecret-values.yaml dendrite helm/dendrite
80+
- name: Wait for Postgres and Dendrite to be up
81+
run: |
82+
kubectl wait --for=condition=ready --timeout=90s pod -l app.kubernetes.io/name=postgresql || kubectl get pods -A
83+
kubectl wait --for=condition=ready --timeout=90s pod -l app.kubernetes.io/name=dendrite || kubectl get pods -A
84+
kubectl get pods -A
85+
kubectl get services
86+
kubectl get ingress
87+
- name: Run create account
88+
run: |
89+
podName=$(kubectl get pods -l app.kubernetes.io/name=dendrite -o name)
90+
kubectl exec "${podName}" -- /usr/bin/create-account -username alice -password somerandompassword

helm/cr.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
release-name-template: "helm-{{ .Name }}-{{ .Version }}"

helm/ct.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
remote: origin
2+
target-branch: main
3+
chart-repos:
4+
- bitnami=https://charts.bitnami.com/bitnami
5+
chart-dirs:
6+
- helm
7+
validate-maintainers: false

helm/dendrite/.helm-docs/about.gotmpl

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{{ define "chart.about" }}
2+
## About
3+
4+
This chart creates a monolith deployment, including an optionally enabled PostgreSQL dependency to connect to.
5+
{{ end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{{ define "chart.appservices" }}
2+
## Usage with appservices
3+
4+
Create a folder `appservices` and place your configurations in there. The configurations will be read and placed in a secret `dendrite-appservices-conf`.
5+
{{ end }}
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{{ define "chart.dbCreation" }}
2+
## Manual database creation
3+
4+
(You can skip this, if you're deploying the PostgreSQL dependency)
5+
6+
You'll need to create the following database before starting Dendrite (see [installation](https://matrix-org.github.io/dendrite/installation/database#single-database-creation)):
7+
8+
```postgres
9+
create database dendrite
10+
```
11+
12+
or
13+
14+
```bash
15+
sudo -u postgres createdb -O dendrite -E UTF-8 dendrite
16+
```
17+
18+
{{ end }}

helm/dendrite/.helm-docs/state.gotmpl

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{ define "chart.state" }}
2+
Status: **NOT PRODUCTION READY**
3+
{{ end }}

helm/dendrite/Chart.yaml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: v2
2+
name: dendrite
3+
version: "0.10.8"
4+
appVersion: "0.10.8"
5+
description: Dendrite Matrix Homeserver
6+
type: application
7+
keywords:
8+
- matrix
9+
- chat
10+
- homeserver
11+
- dendrite
12+
home: https://github.com/matrix-org/dendrite
13+
sources:
14+
- https://github.com/matrix-org/dendrite
15+
dependencies:
16+
- name: postgresql
17+
version: 12.1.7
18+
repository: https://charts.bitnami.com/bitnami
19+
condition: postgresql.enabled

0 commit comments

Comments
 (0)