Skip to content

Commit

Permalink
feat: Add initial Helm Chart with init container
Browse files Browse the repository at this point in the history
  • Loading branch information
B&R committed Mar 4, 2023
0 parents commit e8e2e25
Show file tree
Hide file tree
Showing 14 changed files with 451 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/humhub-chart.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
HumHub Helm Chart
=================

Unofficial Helm Chart for HumHub - an Open Source Social Network.
Maintained by Riotkit Tech Collective, which is a non-profit, grassroot, activist collective maintaining software for activists network.

What is HumHub?
---------------

HumHub is an open source social network platform with a wide variety of use cases as social intranet, community or collaboration platform. HumHub consists of a core application, which can be extended through additional modules and adjusted to your needs by many configuration options.

**Common use cases for HumHub are:**
- Activist networks
- Neighbourhood & family networks
- Public or private communities
- Enterprise Social Intranet
- Schools
- Agencies
- Municipality
- Associations

Support
-------

Each Helm release supports single HumHub version defined in `appVersion` of the [Chart.yaml](charts/humhub/Chart.yaml)
23 changes: 23 additions & 0 deletions charts/humhub/.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/
6 changes: 6 additions & 0 deletions charts/humhub/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: humhub
description: "HumHub is a free social network software and framework built to give you the tools to make communication and collaboration easy and successful."
type: application
version: 0.1.0
appVersion: "1.13.0"
33 changes: 33 additions & 0 deletions charts/humhub/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Riotkit's HumHub Helm Chart
===========================

Thanks for choosing, hope for a cooperation! Feel free to contribute, as our "manpower" is very limited.
We are an anarchist tech collective aiming to provide images, Helm Charts, Ansible playbooks for activist networks and not only.

With 161 greetings,
Riotkit

---

1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- 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 "humhub.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 "humhub.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "humhub.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 "humhub.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
55 changes: 55 additions & 0 deletions charts/humhub/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "humhub.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{- define "humhub.pvcName" -}}
{{- default .Values.pvc.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 "humhub.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 "humhub.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

{{/*
Selector labels
*/}}
{{- define "humhub.selectorLabels" -}}
app.kubernetes.io/name: {{ include "humhub.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
102 changes: 102 additions & 0 deletions charts/humhub/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "humhub.fullname" . }}
labels:
{{- include "humhub.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "humhub.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "humhub.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
automountServiceAccountToken: false
securityContext:
{{- if .Values.podSecurityContext }}
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{ else }}
{{- toYaml .Values.defaults.podSecurityContext | nindent 8 }}
{{- end }}
initContainers:
{{ if .Values.chownInitContainer.enabled }}
- name: set-volume-permissions
image: {{ .Values.chownInitContainer.image }}
command: ['sh', '-c', 'chown 100:101 {{- range $name, $path := .Values.defaults.mounts }}/mnt/{{ $path }} {{ end }}']
securityContext:
runAsNonRoot: false
runAsUser: 0
runAsGroup: 0
volumeMounts:
{{- range $name, $path := .Values.defaults.mounts }}
{{- if $path }}
- mountPath: /mnt/{{ $path }}
name: data
{{- end }}
{{- end }}
{{ end }}
volumes:
- name: data
persistentVolumeClaim:
claimName: {{ include "humhub.pvcName" . }}
readOnly: false
containers:
- name: humhub
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
volumeMounts:
{{- range $name, $path := .Values.defaults.mounts }}
{{- if $path }}
- mountPath: /mnt/{{ $path }}
name: data
{{- end }}
{{- end }}
startupProbe:
{{ toYaml .Values.health.startupProbe | nindent 14 }}
httpGet:
path: /
port: http
livenessProbe:
{{ toYaml .Values.health.livenessProbe | nindent 14 }}
httpGet:
path: /
port: http
readinessProbe:
{{ toYaml .Values.health.readinessProbe | nindent 14 }}
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
28 changes: 28 additions & 0 deletions charts/humhub/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "humhub.fullname" . }}
labels:
{{- include "humhub.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "humhub.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
37 changes: 37 additions & 0 deletions charts/humhub/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "humhub.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "humhub.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
backend:
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions charts/humhub/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "humhub.fullname" . }}
labels:
{{- include "humhub.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "humhub.selectorLabels" . | nindent 4 }}
15 changes: 15 additions & 0 deletions charts/humhub/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "humhub.fullname" . }}-test-connection"
labels:
{{- include "humhub.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "humhub.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never
Loading

0 comments on commit e8e2e25

Please sign in to comment.