Skip to content

Commit

Permalink
Merge pull request #6 from WyriHaximusNet/add-commento-chart
Browse files Browse the repository at this point in the history
Add commento chart
  • Loading branch information
WyriHaximus authored Nov 13, 2020
2 parents b583ccf + 5ce1243 commit e1cda63
Show file tree
Hide file tree
Showing 20 changed files with 391 additions and 5 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/helm-charts-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ jobs:

- name: Fetch history
run: git fetch --prune --unshallow

- run: |
echo -e " \"postgresql://postgres:postgres@postgres/postgres\"" >> charts/commento/ci/postgresql-values.yaml
- name: Lint charts
id: lint
uses: helm/[email protected]
with:
command: lint
config: ct.yaml


test:
runs-on: ubuntu-latest
needs: lint
Expand All @@ -33,17 +33,31 @@ jobs:
- name: Create kind cluster
uses: helm/[email protected]
with:
installLocalPathProvisioner: true
# Only build a kind cluster if there are chart changes to test.
installLocalPathProvisioner: true # Only build a kind cluster if there are chart changes to test.

- name: Install postgresql
uses: evryfs/[email protected]
with:
repo: https://charts.bitnami.com/bitnami
chart: postgresql
helm: 'helm' # optional, default value is 'helm'
args: '--wait --timeout 2m' #optional, default value is '--wait --timeout 2m' in order to wait for the chart-install to stabilize into ready state
- name: Get PG passowrd
id: postgresql_passowrd
run: |
echo ::set-output name=password::$(echo "$(kubectl get secret --namespace default postgresql-helm-charts-${{ github.run_number }} -o jsonpath="{.data.postgresql-password}" | base64 --decode)")
- name: Create postgresql URL
id: postgresql
run: |
echo ::set-output name=url::$(echo "postgresql://postgres:${{ steps.postgresql_passowrd.outputs.password }}@postgresql-helm-charts-${{ github.run_number }}.default/postgres")
- name: Prepare library charts
run: |
cp charts/cron-jobs/library-ci/*.yaml charts/cron-jobs/templates/
cp charts/horizontal-pod-autoscalers/library-ci/*.yaml charts/horizontal-pod-autoscalers/templates/
cp charts/pi-hole-exporter/library-ci/*.yaml charts/pi-hole-exporter/templates/
echo -e " \"${{ steps.postgresql.outputs.url }}\"" >> charts/commento/ci/postgresql-values.yaml
sed -i 's/library/application/g' charts/cron-jobs/Chart.yaml
sed -i 's/library/application/g' charts/horizontal-pod-autoscalers/Chart.yaml
- name: Test charts
uses: helm/[email protected]
with:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Opinionated helm chats for my personal projects, and OSS Projects that either do

### Application

* [`commento`](https://artifacthub.io/packages/helm/wyrihaximusnet/commento)
* [`default-backend`](https://artifacthub.io/packages/helm/wyrihaximusnet/default-backend)
* [`docker-hub-exporter`](https://artifacthub.io/packages/helm/wyrihaximusnet/docker-hub-exporter)
* [`pi-hole-exporter`](https://artifacthub.io/packages/helm/wyrihaximusnet/pi-hole-exporter)
Expand Down
24 changes: 24 additions & 0 deletions charts/commento/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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
*~
# Various IDEs
.project
.idea/
*.tmproj

# Example k8s files
secrets/
6 changes: 6 additions & 0 deletions charts/commento/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: horizontal-pod-autoscalers
repository: https://helm.wyrihaximus.net/
version: 0.2.0
digest: sha256:c24acf3aaf1d76d5b431e2d608ee5162acf6e5bb0ad764b2a3cf81e37bb499bf
generated: "2020-11-13T22:49:13.62060267+01:00"
14 changes: 14 additions & 0 deletions charts/commento/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v2
appVersion: "v1.8.0"
description: Helm chart to install commento on a kubernetes cluster
home: https://commento.io/
icon: https://cdn.commento.io/images/logo.svg
name: commento
version: 0.1.0
maintainers:
- name: WyriHaximus
email: [email protected]
dependencies:
- name: horizontal-pod-autoscalers
version: ^0.2
repository: https://helm.wyrihaximus.net/
14 changes: 14 additions & 0 deletions charts/commento/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Commento

<p align="center">
<img width="200" height="200" src="https://cdn.commento.io/images/logo.svg">
</p>

Opinionated helm chart for [`commento`](https://commento.io/).

## Opinionated decisions

* Port are hardcoded to `8967`.
* Ingress with HTTPS certificate is assumed.
* Comes with a pod.

8 changes: 8 additions & 0 deletions charts/commento/ci/postgresql-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
replicaCount: 1

hpa:
enable: true

database:
urlSuffix: "?sslmode=disable"
manual:
8 changes: 8 additions & 0 deletions charts/commento/secrets/github.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: auth-github
type: Opaque
data:
COMMENTO_GITHUB_KEY: COMMENTO_GITHUB_KEY_ENCRYPTED
COMMENTO_GITHUB_SECRET: COMMENTO_GITHUB_SECRET_ENCRYPTED
8 changes: 8 additions & 0 deletions charts/commento/secrets/twitter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: auth-twitter
type: Opaque
data:
COMMENTO_TWITTER_KEY: COMMENTO_TWITTER_KEY_ENCRYPTED
COMMENTO_TWITTER_SECRET: COMMENTO_TWITTER_SECRET_ENCRYPTED
8 changes: 8 additions & 0 deletions charts/commento/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Congratulations you can now reach you Commento installation at: https://{{ $.Values.ingress.host }}

{{- if eq (.Values.application.forbidNewOwners) false }}
It looks like you've set forbidNewOwners to "false". If you intend for anyone to sign up and add sites to your installations that is fine, but.
If you don't want anyone to be able to sign up and add sites, it is recommended to set forbidNewOwners to "true".
{{- end }}

For detail information how to configure Commento, visit: https://docs.commento.io/
32 changes: 32 additions & 0 deletions charts/commento/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "commento.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 "commento.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 "commento.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
94 changes: 94 additions & 0 deletions charts/commento/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "commento.fullname" . }}
labels:
app: {{ template "commento.name" . }}
chart: {{ template "commento.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicas }}
selector:
matchLabels:
app: {{ template "commento.name" . }}
release: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ template "commento.name" . }}
release: {{ .Release.Name }}
spec:
containers:
- name: commento
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: commento
containerPort: 8967
protocol: TCP
{{- if eq (empty .Values.secrets) false }}
envFrom:
{{- range .Values.secrets }}
- secretRef:
name: {{ . }}
{{- end }}
{{- end }}
env:
- name: "COMMENTO_ORIGIN_HOST"
value: {{ .Values.ingress.host | quote}}
- name: "COMMENTO_ORIGIN"
value: "https://$(COMMENTO_ORIGIN_HOST)"
- name: "COMMENTO_BIND_ADDRESS"
value: "0.0.0.0"
- name: "COMMENTO_PORT"
value: "8967"
{{- if .Values.database.movetokube.enable }}
- name: "COMMENTO_POSTGRES_BASE"
valueFrom:
secretKeyRef:
key: POSTGRES_URL
name: {{ .Values.database.movetokube.name }}-postgres-credentials-{{ .Values.database.movetokube.name }}-user
{{- else if .Values.database.secret.enable }}
- name: "COMMENTO_POSTGRES_BASE"
valueFrom:
secretKeyRef:
key: {{ .Values.database.secret.key }}
name: {{ .Values.database.secret.secret }}
{{- else }}
- name: "COMMENTO_POSTGRES_BASE"
value: {{ .Values.database.manual }}
{{- end }}
- name: "COMMENTO_POSTGRES_SUFFIX"
value: {{ .Values.database.urlSuffix | quote }}
- name: "COMMENTO_POSTGRES"
value: "$(COMMENTO_POSTGRES_BASE)$(COMMENTO_POSTGRES_SUFFIX)"
- name: "COMMENTO_FORBID_NEW_OWNERS"
value: {{ .Values.application.forbidNewOwners | quote }}
livenessProbe:
httpGet:
path: /login
port: commento
readinessProbe:
httpGet:
path: /login
port: commento
startupProbe:
failureThreshold: 120
httpGet:
path: /login
port: commento
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
3 changes: 3 additions & 0 deletions charts/commento/templates/horizontal-pod-autoscaler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{- if .Values.hpa.enable -}}
{{- include "horizontal-pod-autoscalers.hpa" (dict "name" (include "commento.fullname" .) "replicas" (dict "min" .Values.replicas "max" .Values.hpa.maxReplicas)) -}}
{{ end }}
30 changes: 30 additions & 0 deletions charts/commento/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{- if eq (eq .Values.ingress.host "comments.YOURDOMAIN.TLD") false }}
{{- $chartName := .Chart.Name -}}
{{- $fullName := include "commento.fullname" . -}}
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
app: {{ template "commento.name" . }}
chart: {{ template "commento.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.ingress.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
tls:
- hosts:
- {{ .Values.ingress.host }}
secretName: tls-{{ .Values.ingress.host | replace "." "-" }}
rules:
- host: {{ .Values.ingress.host }}
http:
paths:
- path: /
backend:
serviceName: {{ $fullName }}
servicePort: commento
{{- end }}
12 changes: 12 additions & 0 deletions charts/commento/templates/pod-disruption-budget.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if gt (.Values.replicas | int) 1 -}}
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: {{ template "commento.fullname" . }}-pdb
spec:
maxUnavailable: 1
selector:
matchLabels:
app: {{ include "commento.fullname" . }}
release: {{ include "commento.fullname" . }}
{{ end }}
13 changes: 13 additions & 0 deletions charts/commento/templates/postgres-database.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.database.movetokube.enable -}}
apiVersion: db.movetokube.com/v1alpha1
kind: Postgres
metadata:
name: {{ .Values.database.movetokube.name }}
namespace: {{ .Release.Namespace }}
spec:
database: {{ .Values.database.movetokube.name }}
dropOnDelete: {{ .Values.database.movetokube.dropOnDelete }}
masterRole: {{ .Values.database.movetokube.name }}-group
extensions:
- pgcrypto
{{ end }}
12 changes: 12 additions & 0 deletions charts/commento/templates/postgres-user.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.database.movetokube.enable -}}
apiVersion: db.movetokube.com/v1alpha1
kind: PostgresUser
metadata:
name: {{ .Values.database.movetokube.name }}-user
namespace: {{ .Release.Namespace }}
spec:
role: {{ .Values.database.movetokube.name }}-role
database: {{ .Values.database.movetokube.name }} # This references the Postgres CR
secretName: {{ .Values.database.movetokube.name }}-postgres-credentials
privileges: OWNER # Can be OWNER/READ/WRITE
{{ end }}
19 changes: 19 additions & 0 deletions charts/commento/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "commento.fullname" . }}
labels:
app: {{ template "commento.name" . }}
chart: {{ template "commento.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
type: ClusterIP
ports:
- port: 8967
targetPort: 8967
protocol: TCP
name: commento
selector:
app: {{ template "commento.name" . }}
release: {{ .Release.Name }}
Loading

0 comments on commit e1cda63

Please sign in to comment.