Skip to content

Commit

Permalink
just add a helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
romer8 committed Jul 27, 2023
1 parent c28f058 commit 548e6fe
Show file tree
Hide file tree
Showing 13 changed files with 376 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/chart-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: release
on:
push:
branches:
- main

release:
types: [published, created]

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Publish Helm charts
uses: stefanprodan/helm-gh-pages@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
charts_dir: charts
23 changes: 23 additions & 0 deletions charts/.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/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: postgis
repository: oci://ghcr.io/romer8
version: 0.2.2
digest: sha256:04b2dfdfa289445f609e73be801ed34a58f95a1a88bc3d90ec33cc115e3149c3
generated: "2023-06-14T13:56:00.462532683-06:00"
11 changes: 11 additions & 0 deletions charts/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v2
name: djangocms
description: django-cms helm chart for the django-cms quickstart demo
type: application
version: 0.1.0
appVersion: '1.16.0'
dependencies:
- name: 'postgis'
repository: 'oci://ghcr.io/romer8'
version: '*'
condition: postgis.enabled
Binary file added charts/charts/postgis-0.2.2.tgz
Binary file not shown.
1 change: 1 addition & 0 deletions charts/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

62 changes: 62 additions & 0 deletions charts/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "djangocms.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 "djangocms.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 "djangocms.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "djangocms.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "djangocms.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
61 changes: 61 additions & 0 deletions charts/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "djangocms.fullname" . }}
labels:
{{- include "djangocms.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "djangocms.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
app.kubernetes.io/name: {{ include "djangocms.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- with .Values.env }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- containerPort: {{ .Values.service.internalPort }}
name: main-node
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: djangocms-data
mountPath: /app/data/media
subPath: media
volumes:
- name: djangocms-data
persistentVolumeClaim:
claimName: "djangocms-persist-pvc"
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
41 changes: 41 additions & 0 deletions charts/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "djangocms.fullname" . -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: "{{ $fullName }}-ingress"
labels:
{{- include "djangocms.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
ingress.kubernetes.io/rewrite-target: /
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
ingressClassName: {{ .Values.ingress.className }}
{{- 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 }}
- pathType: Prefix
path: {{ . }}
backend:
service:
name: {{ $fullName }}
port:
number: {{ $.Values.service.externalPort }}
{{- end }}
{{- end }}
{{- end }}
17 changes: 17 additions & 0 deletions charts/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: djangocms-persist-pvc
labels:
{{ include "djangocms.labels" . | indent 4 }}
spec:
accessModes:
{{- range .Values.persistentVolumeClaim.accessModes }}
- {{ . }}
{{- end }}
{{- if .Values.storageClass.storageClassName }}
storageClassName: {{ .Values.storageClass.storageClassName | quote }}
{{- end }}
resources:
requests:
storage: {{ .Values.storage_size | quote }}
15 changes: 15 additions & 0 deletions charts/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "djangocms.fullname" . }}
labels:
{{- include "djangocms.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.externalPort }}
targetPort: {{ .Values.service.internalPort }}
name: main-node
selector:
app.kubernetes.io/name: {{ include "djangocms.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
15 changes: 15 additions & 0 deletions charts/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 "djangocms.fullname" . }}-test-connection"
labels:
{{- include "djangocms.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "djangocms.fullname" . }}:{{ .Values.service.externalPort }}']
restartPolicy: Never
104 changes: 104 additions & 0 deletions charts/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Default values for djangocms.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

image:
repository: gioelkin/django-cms
pullPolicy: IfNotPresent
tag: 'v1.1'
postgis:
enabled: true
fullnameOverride: 'djangocms-db'
postgres_user: postgres
postgres_password: 'pass'
imagePullSecrets: []
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
podSecurityContext: {}
securityContext: {}

service:
type: ClusterIP
externalPort: 3000
internalPort: 80

env:
# - name: DATABASE_URL
# value: 'postgres://postgres:pass@djangocms-db:5432/postgres'
- name: DJANGOCMS_DB_NAME
value: 'djangocms'
- name: DJANGOCMS_DB_USER
value: 'djangocmsadmin'
- name: DJANGOCMS_DB_PWD
value: 'pass'
- name: DJANGOCMS_DB_HOST
value: 'djangocms-db'
- name: DJANGOCMS_DB_PORT
value: '5432'
- name: DJANGO_SUPERUSER_USERNAME
value: 'admin'
- name: DJANGO_SUPERUSER_EMAIL
value: '[email protected]'
- name: DJANGO_SUPERUSER_PASSWORD
value: 'pass'
- name: DJANGOCMS_ADMIN_DB_USER
value: 'postgres'
- name: DJANGOCMS_ADMIN_DB_PWD
value: 'pass'
- name: DEFAULT_STORAGE_DSN
value: '=file:///data/media/?url=%2Fmedia%2F'
- name: DEBUG
value: 'False'
- name: DOMAIN_ALIASES
value: 'localhost, 127.0.0.1'
- name: SECURE_SSL_REDIRECT
value: 'False'
- name: DOMAIN
value: 'localhost'
# - name: SKIP_CREATION_USER
# value: 'undone'

storage_size: 2Gi
persistentVolumeClaim:
name: 'djangocms-pv-claim'
accessModes:
- ReadWriteOnce
storageClass:
createClass: false
provisioner: ''
storageClassName: ''
parameters:
provisioningMode: ''
fileSystemId: ''
directoryPerms: ''
gidRangeStart: ''
gidRangeEnd: ''
basePath: ''
allowVolumeExpansion: true
volumeBindingMode: ''
mountOptions: []
annotations: {}

ingress:
enabled: true
className: ''
annotations: {}
hosts:
- host: localhost
paths:
- /

tls: []

resources:
requests:
memory: '2Gi'
cpu: '1'
limits:
memory: '4Gi'
nodeSelector: {}
tolerations: []
affinity: {}

0 comments on commit 548e6fe

Please sign in to comment.