Skip to content
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
0bd63b0
[WIP] discourse helm chart
paulczar Mar 17, 2020
07b28bc
Udpate readme following bitnami best-practices
LucaPrete Mar 30, 2020
5096618
Remove .gitignore
LucaPrete Mar 30, 2020
88cf599
Use requirements.yaml to support helm2
LucaPrete Apr 6, 2020
06e61a1
Merge pull request #6 from LucaPrete/use-requirements-yaml
paulczar Apr 6, 2020
d38d7da
Merge pull request #4 from LucaPrete/remove-gitignore
paulczar Apr 6, 2020
66384b7
Merge pull request #1 from LucaPrete/refactor-readme
paulczar Apr 6, 2020
affa7a5
Update LICENSE
paulczar Apr 6, 2020
566dbdc
Update bitnami/discourse/Chart.yaml
paulczar May 1, 2020
b45ce01
Update bitnami/discourse/Chart.yaml
paulczar May 1, 2020
b8526ad
Update bitnami/discourse/Chart.yaml
paulczar May 1, 2020
7a02b72
Update bitnami/discourse/Chart.yaml
paulczar May 1, 2020
8e69d2e
Update bitnami/discourse/values.yaml
paulczar May 1, 2020
eff7d00
Update bitnami/discourse/templates/deployment-sidekiq.yaml
paulczar May 1, 2020
41add92
Work on latest bitnami change requests
LucaPrete May 3, 2020
3fcf31b
Merge pull request #8 from LucaPrete/suggested-bitnami-changes
paulczar May 13, 2020
dbf3831
Fix email indent and add Luca as maintainer
LucaPrete May 16, 2020
fb13e17
Fix: put back original wordpress chart content
LucaPrete May 25, 2020
da0c441
Merge pull request #9 from LucaPrete/fix-email-indent-add-luca
paulczar May 25, 2020
ecc9e70
Merge pull request #10 from LucaPrete/fix-put-back-wordpress-content
paulczar May 25, 2020
c733658
Update bitnami/discourse/Chart.yaml
javsalgar Jun 1, 2020
d55d263
Merge branch 'master' into discourse
javsalgar Jun 1, 2020
08494e5
Update bitnami/discourse/values.yaml
javsalgar Jun 1, 2020
550b6dc
Major lint fixes and intro of external DB and notes
LucaPrete Jun 3, 2020
acd449b
Merge pull request #11 from LucaPrete/fix-lint-issue
paulczar Jun 4, 2020
5168653
Delete wordpress file
Jun 5, 2020
289a88f
Restore original wordpress deployment file
Jun 5, 2020
d1f4bfd
Fix linter identation issues in requirements
Jun 5, 2020
55e9224
Integration of Sidekiq as sidecar
Jun 16, 2020
4411675
Fix linter issues
Jun 16, 2020
1c0c972
Chart api version downgraded to v1
Jun 17, 2020
93e430d
Added special values for CI testing purposes
Jun 17, 2020
13a4ec4
Fix identation issues
Jun 17, 2020
8c2588d
Fix sidekiq liveness probe + increase time
Jun 17, 2020
48de8e2
Remove CT targeted files
Jun 17, 2020
32ba718
Add Ingress TLS support
Jun 18, 2020
774348f
Set LoadBalancer service as default one
Jun 18, 2020
1672509
Add minor improvements to templates I
Jun 21, 2020
568f855
Add improvements II
Jun 22, 2020
e57186e
Add improvements III
Jun 23, 2020
d94a7a5
Add warning comments in NOTES.txt
Jun 23, 2020
3fdae96
Apply formatting to both values files
Jun 23, 2020
4b825da
Update licesing
Jun 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Copyright (c) 2020 Paul Czarkowski <username.taken@gmail.com>
Copyright (c) 2019 Bitnami

Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
23 changes: 23 additions & 0 deletions bitnami/discourse/.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/
19 changes: 19 additions & 0 deletions bitnami/discourse/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v2
name: discourse
description: A Helm chart for deploying Discourse to Kubernetes
type: application
version: 0.1.0
appVersion: 2.4.1
Comment thread
paulczar marked this conversation as resolved.
engine: gotpl
home: https://www.discourse.org/
Comment thread
paulczar marked this conversation as resolved.
icon: https://bitnami.com/assets/stacks/discourse/img/discourse-stack-220x234.png
sources:
- https://github.com/bitnami/bitnami-docker-discourse
- https://github.com/spinnaker
maintainers:
- name: Bitnami
email: containers@bitnami.com
- name: paulczar
email: username.taken@gmail.com
- name: lucaprete
email: preteluca@gmail.com
13 changes: 13 additions & 0 deletions bitnami/discourse/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2020 Paul Czarkowski <username.taken@gmail.com>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
111 changes: 111 additions & 0 deletions bitnami/discourse/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Discourse

[Discourse](https://www.discourse.org/) is an open source discussion platform. It can be used as a mailing list, discussion forum, long-form chat room, and more.

## TL;DR;

```console
$ helm repo add bitnami https://charts.bitnami.com/bitnami
$ helm install my-release bitnami/discourse
```

## Introduction

This chart bootstraps a [Discourse](https://www.discourse.org/) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.

It also packages [Bitnami Postgresql](https://github.com/bitnami/charts/tree/master/bitnami/postgresql) and [Bitnami Redis](https://github.com/bitnami/charts/tree/master/bitnami/redis) which are required as a database for the Discourse application.

Bitnami charts can be used with [Kubeapps](https://kubeapps.com/) for deployment and management of Helm Charts in clusters. This chart has been tested to work with NGINX Ingress, cert-manager, fluentd and Prometheus on top of the [BKPR](https://kubeprod.io/).

## Prerequisites

- Kubernetes 1.12+
- Helm 2.11+ or Helm 3.0-beta3+
- PV provisioner support in the underlying infrastructure
- ReadWriteMany volumes for deployment scaling

## Installing the Chart

To install the chart with the release name `my-release`:

```console
$ helm install my-release bitnami/discourse
```

The command deploys Discourse on the Kubernetes cluster in the default configuration. The [Parameters](#parameters) section lists the parameters that can be configured during installation.

> **Tip**: List all releases using `helm list`

## Uninstalling the Chart

To uninstall/delete the `my-release` deployment:

```console
$ helm delete my-release
```

The command removes all the Kubernetes components associated with the chart and deletes the release.

## Parameters

The following table lists the configurable parameters of the Discourse chart and their default values.

| Parameter | Description | Default |
| ---------------------------------- | ----------------------------------------------------- | ------------------------------------------------------------ |
**TBD after other patches get merged**

The above parameters map to the env variables defined in [bitnami/discourse](https://github.com/bitnami/bitnami-docker-discourse). For more information please refer to the [bitnami/discourse](https://github.com/bitnami/bitnami-docker-discourse) image documentation.

Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,

```console
$ helm install my-release \
--set discourseUsername=admin,discoursePassword=password,mariadb.mariadbRootPassword=secretpassword \
bitnami/discourse
```

The above command sets the Discourse administrator account username and password to `admin` and `password` respectively. Additionally, it sets the MariaDB `root` user password to `secretpassword`.

Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example,

```console
$ helm install my-release -f values.yaml bitnami/discourse
```

> **Tip**: You can use the default [values.yaml](values.yaml)

## Configuration and installation details

### [Rolling VS Immutable tags](https://docs.bitnami.com/containers/how-to/understand-rolling-tags-containers/)

It is strongly recommended to use immutable tags in a production environment. This ensures your deployment does not change automatically if the same tag is updated with a different image.

Bitnami will release a new chart updating its containers if a new version of the main container, significant changes, or critical vulnerabilities exist.

### Local development and binding to port 80

Discourse is pretty insistent on giving access via port 80 or 443.
This is fine if you're hosting it on a public cluster, but it's not while testing the chart locally.
The easiest [but horribly insecure] way to do it is to simply allow kubectl to bind to privileged ports and then use a `port-forward`:

```console
sudo setcap CAP_NET_BIND_SERVICE=+eip $(which kubectl)
kubectl portforward svc/discourse 80:3000
```

### Image

The `image` parameter allows specifying which image will be pulled for the chart.

#### Private registry

If you configure the `image` value to one in a private registry, you will need to [specify an image pull secret](https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod).

1. Manually create image pull secret(s) in the namespace. See [this YAML example reference](https://kubernetes.io/docs/concepts/containers/images/#creating-a-secret-with-a-docker-config). Consult your image registry's documentation about getting the appropriate secret.
2. Note that the `imagePullSecrets` configuration value cannot currently be passed to helm using the `--set` parameter, so you must supply these using a `values.yaml` file, such as:

```yaml
imagePullSecrets:
- name: SECRET_NAME
```
3. Install the chart
9 changes: 9 additions & 0 deletions bitnami/discourse/requirements.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencies:
- name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 8.6.4
- name: redis
repository: https://charts.bitnami.com/bitnami
version: 10.5.11
digest: sha256:a8c674729c5c688f9e3799891d47e04606888c6ab54d2fc2159b03644c322bd0
generated: "2020-03-14T10:12:55.307197087-05:00"
9 changes: 9 additions & 0 deletions bitnami/discourse/requirements.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencies:
- name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 8.6.4
condition: postgresql.enabled
- name: redis
repository: https://charts.bitnami.com/bitnami
version: 10.5.11
condition: redis.enabled
21 changes: 21 additions & 0 deletions bitnami/discourse/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
1. Get the application URL by running these commands:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the Magento notes and add something similar here. We want to warn the users that they should upgrade their deployments if they didn't set the hostname. It makes sense to deploy it in two steps so they get the LoadBalancer IPs from the cloud provider.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping on this one

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in my latest patch (still needs to be approved) here: paulczar#11

{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "discourse.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "discourse.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "discourse.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "discourse.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:80 to use your application"
sudo kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 80:3000
{{- end }}
137 changes: 137 additions & 0 deletions bitnami/discourse/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "discourse.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 "discourse.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 "discourse.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add these helpers

Suggested change
{{/*
Renders a value that contains template.
Usage:
{{ include "discourse.tplValue" ( dict "value" .Values.path.to.the.Value "context" $) }}
*/}}
{{- define "discourse.tplValue" -}}
{{- if typeIs "string" .value }}
{{- tpl .value .context }}
{{- else }}
{{- tpl (.value | toYaml) .context }}
{{- end }}
{{- end -}}
{{/*
Return the proper Docker Image Registry Secret Names
*/}}
{{- define "discourse.imagePullSecrets" -}}
{{/*
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
but Helm 2.9 and 2.10 does not support it, so we need to implement this if-else logic.
Also, we can not use a single if because lazy evaluation is not an option
*/}}
{{- if .Values.global }}
{{- if .Values.global.imagePullSecrets }}
imagePullSecrets:
{{- range .Values.global.imagePullSecrets }}
- name: {{ . }}
{{- end }}
{{- else if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end -}}
{{- else if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end -}}
{{- end -}}
{{/*
Return the proper WordPress image name
*/}}
{{- define "discourse.image" -}}
{{- $registryName := .Values.image.registry -}}
{{- $repositoryName := .Values.image.repository -}}
{{- $tag := .Values.image.tag | toString -}}
{{/*
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic.
Also, we can't use a single if because lazy evaluation is not an option
*/}}
{{- if .Values.global }}
{{- if .Values.global.imageRegistry }}
{{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}}
{{- else -}}
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
{{- end -}}
{{- else -}}
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
{{- end -}}
{{- end -}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

{{/*
Create the name of the service account to use
*/}}
{{- define "discourse.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "discourse.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}

{{/*
Renders a value that contains template.
Usage:
{{ include "discourse.tplValue" ( dict "value" .Values.path.to.the.Value "context" $) }}
*/}}
{{- define "discourse.tplValue" -}}
{{- if typeIs "string" .value }}
{{- tpl .value .context }}
{{- else }}
{{- tpl (.value | toYaml) .context }}
{{- end }}
{{- end -}}

{{/*
Return the proper Docker Image Registry Secret Names
*/}}
{{- define "discourse.imagePullSecrets" -}}
{{/*
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
but Helm 2.9 and 2.10 does not support it, so we need to implement this if-else logic.
Also, we can not use a single if because lazy evaluation is not an option
*/}}
{{- if .Values.global }}
{{- if .Values.global.imagePullSecrets }}
imagePullSecrets:
{{- range .Values.global.imagePullSecrets }}
- name: {{ . }}
{{- end }}
{{- else if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end -}}
{{- else if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end -}}
{{- end -}}

{{/*
Gets the host to be used for this application.
If not using ClusterIP, or if a host or LoadBalancerIP is not defined, the value will be empty.
*/}}
{{- define "discourse.host" -}}
{{- $host := index .Values (printf "%sHost" .Chart.Name) | default "" -}}
{{- default (include "discourse.serviceIP" .) $host -}}
{{- end -}}

{{/*
Return the proper Discourse image name
*/}}
{{- define "discourse.image" -}}
{{- $registryName := .Values.image.registry -}}
{{- $repositoryName := .Values.image.repository -}}
{{- $tag := .Values.image.tag | toString -}}
{{/*
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic.
Also, we can't use a single if because lazy evaluation is not an option
*/}}
{{- if .Values.global }}
{{- if .Values.global.imageRegistry }}
{{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}}
{{- else -}}
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
{{- end -}}
{{- else -}}
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
{{- end -}}
{{- end -}}
21 changes: 21 additions & 0 deletions bitnami/discourse/templates/configmaps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "discourse.fullname" . }}
labels: {{- include "discourse.labels" . | nindent 4 }}
data:
DISCOURSE_HOSTNAME: {{ .Values.discourseHost }}
DISCOURSE_USERNAME: {{ .Values.admin.username }}
DISCOURSE_EMAIL: {{ .Values.admin.email }}
DISCOURSE_SITENAME: {{ .Values.sitename }}
POSTGRESQL_HOST: {{ include "discourse.fullname" . }}-postgresql
DISCOURSE_POSTGRESQL_NAME: "{{ .Values.postgresql.postgresqlDatabase }}"

@javsalgar javsalgar May 21, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
DISCOURSE_POSTGRESQL_NAME: "{{ .Values.postgresql.postgresqlDatabase }}"
DISCOURSE_POSTGRESQL_NAME: {{ .Values.postgresql.postgresqlDatabase | quote }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would do the same with the rest for consistency

DISCOURSE_POSTGRESQL_USERNAME: "{{ .Values.postgresql.postgresqlUsername }}"
POSTGRESQL_ROOT_USER: "postgres"
POSTGRESQL_CLIENT_CREATE_DATABASE_NAME: "{{ .Values.postgresql.postgresqlDatabase }}"
POSTGRESQL_CLIENT_CREATE_DATABASE_USERNAME: "{{ .Values.postgresql.postgresqlUsername }}"
REDIS_HOST: {{ include "discourse.fullname" . }}-redis-master
REDIS_PORT_NUMBER: "6379"
{{- if .Release.IsUpgrade }}
DISCOURSE_SKIP_INSTALL: "yes"
{{- end }}
Loading