Skip to content

Commit

Permalink
Add hotcrp chart
Browse files Browse the repository at this point in the history
  • Loading branch information
xcompass committed Aug 8, 2023
1 parent 9835096 commit 08425f7
Show file tree
Hide file tree
Showing 16 changed files with 790 additions and 0 deletions.
23 changes: 23 additions & 0 deletions hotcrp/.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/
9 changes: 9 additions & 0 deletions hotcrp/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencies:
- name: mariadb
repository: https://charts.bitnami.com/bitnami
version: 12.2.8
- name: common
repository: https://charts.bitnami.com/bitnami
version: 2.6.0
digest: sha256:a59fc1e92f2a69b92406af77a60f1d9f817493eb1d73d6a08a9bb42e0ce3107f
generated: "2023-07-17T23:15:07.234971-07:00"
48 changes: 48 additions & 0 deletions hotcrp/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
apiVersion: v2
name: hotcrp
description: A Helm chart for Hotcrp

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "3.0.0"

keywords:
- application
- http
- php
- web
- hotcrp
maintainers:
- name: Pan Luo
email: [email protected]
sources:
- https://github.com/ubc/charts/tree/master/hotcrp

dependencies:
- condition: db.enabled
name: mariadb
alias: db
repository: https://charts.bitnami.com/bitnami
version: 12.x.x
- name: common
repository: https://charts.bitnami.com/bitnami
tags:
- bitnami-common
version: 2.x.x
Binary file added hotcrp/charts/common-2.6.0.tgz
Binary file not shown.
Binary file added hotcrp/charts/mariadb-12.2.8.tgz
Binary file not shown.
23 changes: 23 additions & 0 deletions hotcrp/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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 "hotcrp.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 "hotcrp.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "hotcrp.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 "hotcrp.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 "Run 'apt update && apt install mariadb-client && mysql -u hotcrp -p$MYSQL_PASSWORD -h $MYSQL_HOST hotcrp < schema.sql' in the application container to initiate database for the first install."
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
136 changes: 136 additions & 0 deletions hotcrp/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "hotcrp.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 "hotcrp.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 a default fully qualified db name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "hotcrp.db.fullname" -}}
{{- include "common.names.dependency.fullname" (dict "chartName" "db" "chartValues" .Values.db "context" $) -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "hotcrp.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

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

{{/*
Return the MariaDB Hostname
*/}}
{{- define "hotcrp.databaseHost" -}}
{{- if .Values.db.enabled }}
{{- if eq .Values.db.architecture "replication" }}
{{- printf "%s-primary" (include "hotcrp.db.fullname" .) | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s" (include "hotcrp.db.fullname" .) -}}
{{- end -}}
{{- else -}}
{{- printf "%s" .Values.externalDatabase.host -}}
{{- end -}}
{{- end -}}

{{/*
Return the MariaDB Port
*/}}
{{- define "hotcrp.databasePort" -}}
{{- if .Values.db.enabled }}
{{- printf "3306" -}}
{{- else -}}
{{- printf "%d" (.Values.externalDatabase.port | int ) -}}
{{- end -}}
{{- end -}}

{{/*
Return the MariaDB Database Name
*/}}
{{- define "hotcrp.databaseName" -}}
{{- if .Values.db.enabled }}
{{- printf "%s" .Values.db.auth.database -}}
{{- else -}}
{{- printf "%s" .Values.externalDatabase.database -}}
{{- end -}}
{{- end -}}

{{/*
Return the MariaDB User
*/}}
{{- define "hotcrp.databaseUser" -}}
{{- if .Values.db.enabled }}
{{- printf "%s" .Values.db.auth.username -}}
{{- else -}}
{{- printf "%s" .Values.externalDatabase.user -}}
{{- end -}}
{{- end -}}

{{/*
Return the MariaDB Secret Name
*/}}
{{- define "hotcrp.databaseSecretName" -}}
{{- if .Values.db.enabled }}
{{- if .Values.db.auth.existingSecret -}}
{{- printf "%s" .Values.db.auth.existingSecret -}}
{{- else -}}
{{- printf "%s" (include "hotcrp.db.fullname" .) -}}
{{- end -}}
{{- else if .Values.externalDatabase.existingSecret -}}
{{- include "common.tplvalues.render" (dict "value" .Values.externalDatabase.existingSecret "context" $) -}}
{{- else -}}
{{- printf "%s-externaldb" (include "common.names.fullname" .) -}}
{{- end -}}
{{- end -}}

33 changes: 33 additions & 0 deletions hotcrp/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "hotcrp.fullname" . }}-msmtp
data:
msmtprc: |-
defaults
logfile /var/log/msmtp.log
account default
host {{ .Values.smtp.host }}
port {{ .Values.smtp.port }}
{{- if .Values.smtp.username }}
user {{ .Values.smtp.username }}
{{- end }}
{{- if .Values.smtp.password}}
password {{ .Values.smtp.password }}
{{- end }}
{{- if .Values.ingress.enabled }}
---
{{- $fullName := include "hotcrp.fullname" . -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $fullName }}-ingress-cm
data:
SCRIPT_FILENAME: "/var/www/html/index.php"
SCRIPT_NAME: "/index.php"
PATH_INFO: "$fastcgi_path_info"
{{- end }}
114 changes: 114 additions & 0 deletions hotcrp/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "hotcrp.fullname" . }}
labels:
{{- include "hotcrp.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "hotcrp.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "hotcrp.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.hotcrp.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "hotcrp.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.hotcrp.image.repository }}:{{ .Values.hotcrp.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.hotcrp.image.pullPolicy }}
env:
- name: HOTCRP_CONTACT_NAME
value: {{ .Values.hotcrp.contactName}}
- name: HOTCRP_EMAIL_CONTACT
value: {{ .Values.hotcrp.contactEmail}}
- name: HOTCRP_EMAIL_FROM
value: {{ .Values.hotcrp.emailFrom}}
- name: HOTCRP_PAPER_SITE
value: {{ .Values.hotcrp.paperSite}}
- name: MYSQL_HOST
value: {{ include "hotcrp.databaseHost" .}}
- name: MYSQL_DATABASE
value: {{ include "hotcrp.databaseName" .}}
- name: MYSQL_USER
value: {{ include "hotcrp.databaseUser" .}}
- name: MYSQL_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "hotcrp.databaseSecretName" . }}
key: mariadb-password
ports:
- containerPort: 9000
hostPort: 9000
protocol: TCP
# livenessProbe:
# httpGet:
# path: /
# port: http
# readinessProbe:
# httpGet:
# path: /
# port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- mountPath: /etc/msmtprc
name: msmtprc
subPath: msmtprc
- mountPath: /var/log
name: hotcrp-log
- name: shared-files
mountPath: /shared
- name: {{ .Chart.Name }}-web
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.web.image.repository }}:{{ .Values.web.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.web.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
volumeMounts:
- name: shared-files
mountPath: /usr/share/nginx/html
resources:
{{- toYaml .Values.resources | nindent 12 }}
restartPolicy: Always
volumes:
- name: msmtprc
configMap:
name: {{ include "hotcrp.fullname" . }}-msmtp
- name: hotcrp-log
persistentVolumeClaim:
claimName: {{ template "hotcrp.fullname" . }}-app-log
# Create the shared files volume to be used in both pods
- name: shared-files
emptyDir: {}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
Loading

0 comments on commit 08425f7

Please sign in to comment.