Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add helm chart #450

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions charts/banchopy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
charts/**.tgz
.template
23 changes: 23 additions & 0 deletions charts/banchopy/.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 charts/banchopy/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencies:
- name: redis
repository: https://charts.bitnami.com/bitnami
version: 17.10.3
- name: mariadb
repository: https://charts.bitnami.com/bitnami
version: 12.1.6
digest: sha256:83be4e5ad922a98b90882cf1237a2e6d06450ed5e687b33a249359b3b2a02102
generated: "2023-05-10T21:04:53.9343167+08:00"
34 changes: 34 additions & 0 deletions charts/banchopy/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: v2
name: banchopy
description: A Helm chart for Kubernetes

# 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.0.1

# 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: "4.7.2"

dependencies:
- name: redis
version: "17.10.3"
repository: "https://charts.bitnami.com/bitnami"
condition: global.redis.managed
- name: mariadb
version: "12.1.6"
repository: "https://charts.bitnami.com/bitnami"
condition: global.database.managed
20 changes: 20 additions & 0 deletions charts/banchopy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Bancho.py Helm Chart

TODO

## Generate template for reviewing

```sh
$ helm template test . --output-dir .template
```

## Testing in K8S

```sh
# Test local
$ kubectl apply -f .template --recursive --dry-run=client
# Test server-side
$ kubectl apply -f .template --recursive --dry-run=server
# Or helm install
$ helm install test . --debug --dry-run
```
Empty file.
20 changes: 20 additions & 0 deletions charts/banchopy/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host }}/
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "banchopy.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 "banchopy.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "banchopy.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 "banchopy.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 }}
130 changes: 130 additions & 0 deletions charts/banchopy/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "banchopy.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 "banchopy.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 "banchopy.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

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

{{- define "banchopy.baseConfig" -}}
# for nginx reverse proxy to work through the containers, the bancho
# server must expose itself on port 80 to be accessed on http://bancho.
SERVER_ADDR: "0.0.0.0"
SERVER_PORT: !!str 80

# Chimu: https://api.chimu.moe/cheesegull/search - https://api.chimu.moe/v1/download
# osu.direct: https://osu.direct/api/search - https://osu.direct/d
MIRROR_SEARCH_ENDPOINT: https://catboy.best/api/search
MIRROR_DOWNLOAD_ENDPOINT: https://catboy.best/d

# XXX: change your domain if applicable
DOMAIN: {{ .Values.global.domain }}

COMMAND_PREFIX: !

SEASONAL_BGS: https://akatsuki.pw/static/flower.png,https://i.cmyui.xyz/nrMT4V2RR3PR.jpeg

MENU_ICON_URL: https://akatsuki.pw/static/logos/logo_ingame.png
MENU_ONCLICK_URL: https://akatsuki.pw

DEBUG: 'False'

# redirect beatmaps, beatmapsets, and forum
# pages of maps to the official osu! website
REDIRECT_OSU_URLS: 'True'

PP_CACHED_ACCS: 90,95,98,99,100

DISALLOWED_NAMES: mrekk,vaxei,btmc,cookiezi
DISALLOWED_PASSWORDS: password,abc123
DISALLOW_OLD_CLIENTS: 'True'

DISCORD_AUDIT_LOG_WEBHOOK: ''

# automatically share information with the primary
# developer of bancho.py (https://github.com/cmyui)
# for debugging & development purposes.
AUTOMATICALLY_REPORT_PROBLEMS: 'False'

# advanced dev settings

## WARNING: only touch this once you've
## read through what it enables.
## you could put your server at risk.
DEVELOPER_MODE: 'False'
{{- end }}

{{- define "banchopy.basePvcConfig" -}}
{{- if .args.enabled -}}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ printf "%s-%s" (include "banchopy.fullname" .global) .suffix }}
labels:
{{- toYaml .args.labels | nindent 4 }}
annotations:
{{- toYaml .args.annotations | nindent 4 }}
spec:
storageClassName: {{ .args.storageClass }}
resources:
requests:
storage: {{ .args.size }}
accessModes: {{ .args.accessModes }}
---
{{- end -}}
{{- end }}
9 changes: 9 additions & 0 deletions charts/banchopy/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{- $baseConfig := include "banchopy.baseConfig" . | fromYaml -}}
{{- $mergedConfig := mustMergeOverwrite (dict) $baseConfig .Values.config -}}

kind: ConfigMap
apiVersion: v1
metadata:
name: {{ include "banchopy.fullname" . }}
data:
{{- toYaml $mergedConfig | nindent 2 }}
Loading