From 0761dfb41754e694055370c1fefcce744b3ccb84 Mon Sep 17 00:00:00 2001 From: Stefan <29133953+stevefan1999-personal@users.noreply.github.com> Date: Mon, 19 Jun 2023 13:31:39 +0800 Subject: [PATCH] add helm chart --- charts/banchopy/.gitignore | 2 + charts/banchopy/.helmignore | 23 +++ charts/banchopy/Chart.lock | 9 + charts/banchopy/Chart.yaml | 34 ++++ charts/banchopy/README.md | 20 ++ charts/banchopy/charts/.gitkeep | 0 charts/banchopy/templates/NOTES.txt | 20 ++ charts/banchopy/templates/_helpers.tpl | 130 ++++++++++++ charts/banchopy/templates/configmap.yaml | 9 + charts/banchopy/templates/deployment.yaml | 186 +++++++++++++++++ charts/banchopy/templates/ingress.yaml | 114 +++++++++++ charts/banchopy/templates/pvc.yaml | 13 ++ charts/banchopy/templates/secret.yaml | 30 +++ charts/banchopy/templates/service.yaml | 23 +++ charts/banchopy/templates/serviceaccount.yaml | 12 ++ .../templates/tests/test-connection.yaml | 15 ++ charts/banchopy/values.yaml | 188 ++++++++++++++++++ 17 files changed, 828 insertions(+) create mode 100644 charts/banchopy/.gitignore create mode 100644 charts/banchopy/.helmignore create mode 100644 charts/banchopy/Chart.lock create mode 100644 charts/banchopy/Chart.yaml create mode 100644 charts/banchopy/README.md create mode 100644 charts/banchopy/charts/.gitkeep create mode 100644 charts/banchopy/templates/NOTES.txt create mode 100644 charts/banchopy/templates/_helpers.tpl create mode 100644 charts/banchopy/templates/configmap.yaml create mode 100644 charts/banchopy/templates/deployment.yaml create mode 100644 charts/banchopy/templates/ingress.yaml create mode 100644 charts/banchopy/templates/pvc.yaml create mode 100644 charts/banchopy/templates/secret.yaml create mode 100644 charts/banchopy/templates/service.yaml create mode 100644 charts/banchopy/templates/serviceaccount.yaml create mode 100644 charts/banchopy/templates/tests/test-connection.yaml create mode 100644 charts/banchopy/values.yaml diff --git a/charts/banchopy/.gitignore b/charts/banchopy/.gitignore new file mode 100644 index 000000000..f0dfd7ef3 --- /dev/null +++ b/charts/banchopy/.gitignore @@ -0,0 +1,2 @@ +charts/**.tgz +.template diff --git a/charts/banchopy/.helmignore b/charts/banchopy/.helmignore new file mode 100644 index 000000000..0e8a0eb36 --- /dev/null +++ b/charts/banchopy/.helmignore @@ -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/ diff --git a/charts/banchopy/Chart.lock b/charts/banchopy/Chart.lock new file mode 100644 index 000000000..4b0b18aa7 --- /dev/null +++ b/charts/banchopy/Chart.lock @@ -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" diff --git a/charts/banchopy/Chart.yaml b/charts/banchopy/Chart.yaml new file mode 100644 index 000000000..83c69b790 --- /dev/null +++ b/charts/banchopy/Chart.yaml @@ -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 diff --git a/charts/banchopy/README.md b/charts/banchopy/README.md new file mode 100644 index 000000000..5ff2d77e5 --- /dev/null +++ b/charts/banchopy/README.md @@ -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 +``` diff --git a/charts/banchopy/charts/.gitkeep b/charts/banchopy/charts/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/charts/banchopy/templates/NOTES.txt b/charts/banchopy/templates/NOTES.txt new file mode 100644 index 000000000..3832259e3 --- /dev/null +++ b/charts/banchopy/templates/NOTES.txt @@ -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 }} diff --git a/charts/banchopy/templates/_helpers.tpl b/charts/banchopy/templates/_helpers.tpl new file mode 100644 index 000000000..13570c937 --- /dev/null +++ b/charts/banchopy/templates/_helpers.tpl @@ -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 }} diff --git a/charts/banchopy/templates/configmap.yaml b/charts/banchopy/templates/configmap.yaml new file mode 100644 index 000000000..6e1de68b9 --- /dev/null +++ b/charts/banchopy/templates/configmap.yaml @@ -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 }} diff --git a/charts/banchopy/templates/deployment.yaml b/charts/banchopy/templates/deployment.yaml new file mode 100644 index 000000000..986bdffd2 --- /dev/null +++ b/charts/banchopy/templates/deployment.yaml @@ -0,0 +1,186 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "banchopy.fullname" . }} + labels: + {{- include "banchopy.labels" . | nindent 4 }} +spec: + selector: + matchLabels: + {{- include "banchopy.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "banchopy.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "banchopy.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ required "Image repository is required!" .Values.image.repository }}:{{ required "Image tag is required!" (.Values.image.tag | default .Chart.AppVersion) }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + workingDir: /home/bpyuser # Workaround for https://github.com/osuAkatsuki/bancho.py/blob/f5ace93da9f61fe0229b14fc229276808c9f9da1/app/api/v1/api.py#L34-L37 + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + envFrom: + - configMapRef: + name: {{ include "banchopy.fullname" . }} + - secretRef: + name: {{ include "banchopy.fullname" . }} + volumeMounts: + - name: base + mountPath: /home/bpyuser/.data + {{- if .Values.data.assets.persistence.enabled }} + - name: assets + mountPath: /home/bpyuser/.data/assets + {{- end -}} + {{- if .Values.data.avatars.persistence.enabled }} + - name: avatars + mountPath: /home/bpyuser/.data/avatars + {{- end -}} + {{- if .Values.data.beatmaps.persistence.enabled }} + - name: beatmaps + mountPath: /home/bpyuser/.data/osu + {{- end -}} + {{- if .Values.data.replays.persistence.enabled }} + - name: replays + mountPath: /home/bpyuser/.data/osr + {{- end -}} + {{- if .Values.data.screenshots.persistence.enabled }} + - name: screenshots + mountPath: /home/bpyuser/.data/ss + {{- end }} + - name: assets-serve + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: joseluisq/static-web-server:2 + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: SERVER_PORT + value: !!str 81 + - name: SERVER_ROOT + value: "/home/bpyuser/.data/assets" + ports: + - name: assets-http + containerPort: 81 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + {{- if .Values.data.assets.persistence.enabled }} + - name: assets + mountPath: /home/bpyuser/.data/assets + {{ else }} + - name: base + mountPath: /home/bpyuser/.data + subPath: assets + {{- end }} + - name: avatars-serve + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: joseluisq/static-web-server:2 + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: SERVER_PORT + value: !!str 82 + - name: SERVER_ROOT + value: "/home/bpyuser/.data/avatars" + ports: + - name: avatars-http + containerPort: 82 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + {{- if .Values.data.avatars.persistence.enabled }} + - name: avatars + mountPath: /home/bpyuser/.data/avatars + {{ else }} + - name: base + mountPath: /home/bpyuser/.data + subPath: avatars + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + volumes: + - name: base + {{- if .Values.data.base.persistence.enabled }} + persistentVolumeClaim: + claimName: {{ include "banchopy.fullname" . }}-base + {{ else }} + emptyDir: {} + {{- end -}} + {{- if .Values.data.assets.persistence.enabled }} + - name: assets + persistentVolumeClaim: + claimName: {{ include "banchopy.fullname" . }}-assets + {{- end -}} + {{- if .Values.data.avatars.persistence.enabled }} + - name: avatars + persistentVolumeClaim: + claimName: {{ include "banchopy.fullname" . }}-avatars + {{- end -}} + {{- if .Values.data.beatmaps.persistence.enabled }} + - name: beatmaps + persistentVolumeClaim: + claimName: {{ include "banchopy.fullname" . }}-beatmaps + {{- end -}} + {{- if .Values.data.replays.persistence.enabled }} + - name: replays + persistentVolumeClaim: + claimName: {{ include "banchopy.fullname" . }}-replays + {{- end -}} + {{- if .Values.data.screenshots.persistence.enabled }} + - name: screenshots + persistentVolumeClaim: + claimName: {{ include "banchopy.fullname" . }}-screenshots + {{- end -}} diff --git a/charts/banchopy/templates/ingress.yaml b/charts/banchopy/templates/ingress.yaml new file mode 100644 index 000000000..cc9d57616 --- /dev/null +++ b/charts/banchopy/templates/ingress.yaml @@ -0,0 +1,114 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "banchopy.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- $domain := .Values.global.domain -}} + +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "banchopy.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + - host: {{ $domain }} + http: + paths: + - path: / + {{- if (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: ImplementationSpecific + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + # assets "assets.foo.com" + - host: {{ printf "%s.%s" "assets" $domain }} + http: + paths: + - path: / + {{- if (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: ImplementationSpecific + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: 81 + {{- else }} + serviceName: {{ $fullName }} + servicePort: 81 + {{- end }} + # avatars "a.foo.com" + - host: {{ printf "%s.%s" "a" $domain }} + http: + paths: + - path: / + {{- if (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: ImplementationSpecific + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: 82 + {{- else }} + serviceName: {{ $fullName }} + servicePort: 82 + {{- end }} + {{- range .Values.ingress.hosts }} + - host: {{ printf "%s.%s" . $domain }} + http: + paths: + - path: / + {{- if (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: ImplementationSpecific + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/banchopy/templates/pvc.yaml b/charts/banchopy/templates/pvc.yaml new file mode 100644 index 000000000..71cc3afa2 --- /dev/null +++ b/charts/banchopy/templates/pvc.yaml @@ -0,0 +1,13 @@ +{{ $pvcs := dict + "base" .Values.data.base.persistence + "assets" .Values.data.assets.persistence + "avatars" .Values.data.avatars.persistence + "beatmaps" .Values.data.beatmaps.persistence + "replays" .Values.data.replays.persistence + "screenshots" .Values.data.screenshots.persistence +}} +{{ $global := . }} + +{{- range $name, $values := $pvcs }} +{{ include "banchopy.basePvcConfig" (dict "global" $global "suffix" $name "args" $values) }} +{{- end }} diff --git a/charts/banchopy/templates/secret.yaml b/charts/banchopy/templates/secret.yaml new file mode 100644 index 000000000..9e79da28a --- /dev/null +++ b/charts/banchopy/templates/secret.yaml @@ -0,0 +1,30 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "banchopy.fullname" . }} +type: Opaque +stringData: + DB_USER: {{ .Values.mariadb.auth.username }} + DB_PASS: {{ .Values.mariadb.auth.password }} + DB_NAME: {{ .Values.mariadb.auth.database }} + DB_PORT: {{ .Values.mariadb.auth.port | quote }} + {{- if .Values.global.database.managed }} + DB_HOST: {{ template "mariadb.primary.fullname" .Subcharts.mariadb }} + {{- else }} + DB_HOST: {{ .Values.mariadb.auth.host }} + {{- end }} + + REDIS_USER: {{ .Values.redis.auth.username }} + REDIS_PASS: {{ .Values.redis.auth.password }} + REDIS_PORT: {{ .Values.redis.auth.port | quote }} + REDIS_DB: {{ .Values.redis.auth.database | quote }} + {{- if .Values.global.redis.managed }} + REDIS_HOST: {{ template "common.names.fullname" .Subcharts.redis }}-master + {{- else }} + REDIS_HOST: {{ .Values.redis.auth.host }} + {{- end }} + + # XXX: change your db credentials + OSU_API_KEY: {{ .Values.osu.apiKey }} + DATADOG_API_KEY: {{ .Values.datadog.apiKey }} + DATADOG_APP_KEY: {{ .Values.datadog.appKey }} diff --git a/charts/banchopy/templates/service.yaml b/charts/banchopy/templates/service.yaml new file mode 100644 index 000000000..741cf3efb --- /dev/null +++ b/charts/banchopy/templates/service.yaml @@ -0,0 +1,23 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "banchopy.fullname" . }} + labels: + {{- include "banchopy.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + - port: 81 + targetPort: assets-http + protocol: TCP + name: assets-http + - port: 82 + targetPort: avatars-http + protocol: TCP + name: avatars-http + selector: + {{- include "banchopy.selectorLabels" . | nindent 4 }} diff --git a/charts/banchopy/templates/serviceaccount.yaml b/charts/banchopy/templates/serviceaccount.yaml new file mode 100644 index 000000000..f17592da0 --- /dev/null +++ b/charts/banchopy/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "banchopy.serviceAccountName" . }} + labels: + {{- include "banchopy.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/banchopy/templates/tests/test-connection.yaml b/charts/banchopy/templates/tests/test-connection.yaml new file mode 100644 index 000000000..5e8d798c5 --- /dev/null +++ b/charts/banchopy/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "banchopy.fullname" . }}-test-connection" + labels: + {{- include "banchopy.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "banchopy.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/charts/banchopy/values.yaml b/charts/banchopy/values.yaml new file mode 100644 index 000000000..1f11f3f01 --- /dev/null +++ b/charts/banchopy/values.yaml @@ -0,0 +1,188 @@ +# Default values for banchopy. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: "deez/nuts" # TODO + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" # TODO + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} +# fsGroup: 2000 + +securityContext: {} +# capabilities: +# drop: +# - ALL +# readOnlyRootFilesystem: true +# runAsNonRoot: true +# runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: true + className: "" + annotations: + nginx.ingress.kubernetes.io/use-regex: "true" + hosts: + - api + - c1 + - c2 + - c3 + - c4 + - c5 + - c6 + - ce + - cho + - c + - i + - map + - osu + - s + - web + + tls: [] + + +resources: {} +# We usually recommend not to specify default resources and to leave this as a conscious +# choice for the user. This also increases chances charts run on environments with little +# resources, such as Minikube. If you do want to specify resources, uncomment the following +# lines, adjust them as necessary, and remove the curly braces after 'resources:'. +# limits: +# cpu: 100m +# memory: 128Mi +# requests: +# cpu: 100m +# memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +global: + redis: + managed: true + database: + managed: true + domain: example.com + +redis: + architecture: standalone + auth: + host: '' + port: 6379 + username: 'default' + password: '' + database: 0 + +mariadb: + auth: + host: '' + port: 3306 + username: 'banchopy' + password: '4cf3b0bf1a415ea41f45d3bf27a205538d67b058' # SHA1('banchopy') + database: 'banchopy' + +osu: + apiKey: +datadog: + apiKey: + appKey: + +data: + # This is a fuck-all base/default persistence storage if you want it to just work™ + base: + persistence: + enabled: false + storageClass: "" + accessModes: + - ReadWriteOnce + size: 100Mi + annotations: {} + labels: {} + + # You can also choose different storage endpoint for different kinds of data, for example avatars to a custom S3 backend with FUSE (cough cough rclone) + + # maps to ".data/assets" + assets: + persistence: + enabled: true + storageClass: "" + accessModes: + - ReadWriteOnce + size: 100Mi + annotations: {} + labels: {} + # maps to ".data/avatars" + avatars: + persistence: + enabled: true + storageClass: "" + accessModes: + - ReadWriteOnce + size: 100Mi + annotations: {} + labels: {} + # maps to ".data/osu" + beatmaps: + persistence: + enabled: false + storageClass: "" + accessModes: + - ReadWriteOnce + size: 100Mi + annotations: {} + labels: {} + # maps to ".data/osr" + replays: + persistence: + enabled: false + storageClass: "" + accessModes: + - ReadWriteOnce + size: 100Mi + annotations: {} + labels: {} + # maps to ".data/ss" + screenshots: + persistence: + enabled: false + storageClass: "" + accessModes: + - ReadWriteOnce + size: 100Mi + annotations: {} + labels: {} + +config: {} + +# You are given a chance to override the config injected to the environment, example: +# config: +# MIRROR_SEARCH_ENDPOINT: https://cat.nyan/ +# +# N.B. This is not going to deep merge the key-value pairs/arrays, so if you override them, they are replaced with new values entirely, without the old ones +# Make sure you copy the old values in if you want to preserve them