Skip to content

Commit

Permalink
Moved charts to dedicated repo.
Browse files Browse the repository at this point in the history
  • Loading branch information
XtremeOwnageDotCom committed Jun 30, 2024
1 parent 86f735c commit 4005d92
Show file tree
Hide file tree
Showing 19 changed files with 654 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/helm-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release Helm Chart

on:
push:
branches:
- main
- dev

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Install Helm
uses: azure/setup-helm@v4
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.6.0
with:
charts_dir: charts
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
6 changes: 6 additions & 0 deletions charts/warbot/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: warbot
description: A Helm chart for deploying WarBOT

version: 0.1.0
appVersion: "1.0"
35 changes: 35 additions & 0 deletions charts/warbot/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "warbot.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
*/}}
{{- define "warbot.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else }}
{{- include "warbot.name" . }}-{{ .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "warbot.labels" -}}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
{{ include "warbot.selectorLabels" . }}
{{- end -}}

{{/*
Selector labels
*/}}
{{- define "warbot.selectorLabels" -}}
app.kubernetes.io/name: {{ include "warbot.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
11 changes: 11 additions & 0 deletions charts/warbot/cm-common.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: common
namespace: {{ .Release.Namespace }}
labels:
{{- include "warbot.labels" . | nindent 4 }}
data:
DB_HOST: {{ .Values.database.host | quote }}
DB_PORT: {{ .Values.database.port | quote }}
PUBLIC_URL: {{ .Values.publicUrl | quote }}
11 changes: 11 additions & 0 deletions charts/warbot/cm-web.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- if .Values.ui.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: web-config
namespace: {{ .Release.Namespace }}
labels:
{{- include "warbot.labels" . | nindent 4 }}
data:
PUBLIC_URL: {{ .Values.publicUrl | quote }}
{{- end }}
78 changes: 78 additions & 0 deletions charts/warbot/deployment-bot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "warbot.fullname" . }}-bot
labels:
{{- include "warbot.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "warbot.selectorLabels" . | nindent 6 }}
role: bot
template:
metadata:
labels:
{{- include "warbot.selectorLabels" . | nindent 8 }}
role: bot
spec:
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: warbot
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: SUPERADMIN_USER_IDS
value: {{ .Values.env.SUPERADMIN_USER_IDS | quote }}
- name: ADMIN_GUILDS
value: {{ .Values.env.ADMIN_GUILDS | quote }}
- name: DB_HOST
value: {{ if .Values.database.enabled }}db{{ else }}{{ .Values.externalDatabase.host | quote }}{{ end }}
- name: DB_PORT
value: {{ if .Values.database.enabled }}3306{{ else }}{{ .Values.externalDatabase.port | quote }}{{ end }}
- name: DB_NAME
value: {{ if .Values.database.enabled }}warbot{{ else }}{{ .Values.externalDatabase.name | quote }}{{ end }}
- name: DB_USER
value: {{ if .Values.database.enabled }}warbot_user{{ else }}{{ .Values.externalDatabase.user | quote }}{{ end }}
- name: DB_PASS
value: {{ if .Values.database.enabled }}secret{{ else }}{{ .Values.externalDatabase.password | quote }}{{ end }}
- name: DISCORD_TOKEN
value: {{ .Values.discord.token | quote }}
- name: DISCORD_ID
value: {{ .Values.discord.id | quote }}
- name: DISCORD_SECRET
value: {{ .Values.discord.secret | quote }}
- name: PUBLIC_URL
value: {{ .Values.publicUrl | quote }}
ports:
- containerPort: 80
name: http
livenessProbe:
exec:
command:
- /bin/bash
- -c
- "end=$(date -u +%s);start=$(stat -c %Z /proc/1 | awk '{print int($1)}'); test $(($end-$start)) -lt 172800"
readinessProbe:
httpGet:
path: /health
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
52 changes: 52 additions & 0 deletions charts/warbot/deployment-ui.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{{- if .Values.ui.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "warbot.fullname" . }}-ui
labels:
{{- include "warbot.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "warbot.selectorLabels" . | nindent 6 }}
role: web
template:
metadata:
labels:
{{- include "warbot.selectorLabels" . | nindent 8 }}
role: web
spec:
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: web
image: "{{ .Values.ui.image.repository }}:{{ .Values.ui.image.tag }}"
imagePullPolicy: {{ .Values.ui.image.pullPolicy }}
env:
- name: DB_HOST
value: {{ if .Values.database.enabled }}db{{ else }}{{ .Values.externalDatabase.host | quote }}{{ end }}
- name: DB_PORT
value: {{ if .Values.database.enabled }}3306{{ else }}{{ .Values.externalDatabase.port | quote }}{{ end }}
- name: DB_NAME
value: {{ if .Values.database.enabled }}warbot{{ else }}{{ .Values.externalDatabase.name | quote }}{{ end }}
- name: DB_USER
value: {{ if .Values.database.enabled }}warbot_user{{ else }}{{ .Values.externalDatabase.user | quote }}{{ end }}
- name: DB_PASS
value: {{ if .Values.database.enabled }}secret{{ else }}{{ .Values.externalDatabase.password | quote }}{{ end }}
- name: PUBLIC_URL
value: {{ .Values.publicUrl | quote }}
ports:
- containerPort: 80
name: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
36 changes: 36 additions & 0 deletions charts/warbot/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{- if .Values.ingress.enabled -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "warbot.fullname" . }}
labels:
{{- include "warbot.labels" . | nindent 4 }}
annotations:
{{- toYaml .Values.ingress.annotations | nindent 4 }}
spec:
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ . }}
pathType: ImplementationSpecific
backend:
service:
name: {{ include "warbot.fullname" $. }}
port:
number: {{ $.Values.service.port }}
{{- end }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
{{- end }}
21 changes: 21 additions & 0 deletions charts/warbot/ingressroute.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- if .Values.ingressRoute.enabled -}}
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: {{ include "warbot.fullname" . }}
labels:
{{- include "warbot.labels" . | nindent 4 }}
spec:
entryPoints:
{{- toYaml .Values.ingressRoute.entryPoints | nindent 4 }}
routes:
{{- range .Values.ingressRoute.routes }}
- match: {{ .match | quote }}
kind: {{ .kind }}
services:
{{- range .services }}
- name: {{ .name }}
port: {{ .port }}
{{- end }}
{{- end }}
{{- end }}
37 changes: 37 additions & 0 deletions charts/warbot/networkpolicy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{{- if .Values.networkPolicies.enabled -}}
{{- range .Values.networkPolicies.policies }}
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ .name }}
namespace: {{ $.Release.Namespace }}
labels:
{{- include "warbot.labels" $ | nindent 4 }}
spec:
podSelector:
{{- toYaml .podSelector | nindent 4 }}
policyTypes:
{{- if .ingress }}
- Ingress
{{- end }}
{{- if .egress }}
- Egress
{{- end }}
{{- if .ingress }}
ingress:
{{- range .ingress }}
- from:
{{- toYaml .from | nindent 6 }}
{{- end }}
{{- end }}
{{- if .egress }}
egress:
{{- range .egress }}
- to:
{{- toYaml .to | nindent 6 }}
ports:
{{- toYaml .ports | nindent 6 }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions charts/warbot/pvc-db-data.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- if .Values.database.enabled }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: db-data
namespace: {{ .Release.Namespace }}
labels:
{{- include "warbot.labels" . | nindent 4 }}
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
{{- end }}
15 changes: 15 additions & 0 deletions charts/warbot/pvc-ui.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- if .Values.ui.enabled }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ui-data
namespace: {{ .Release.Namespace }}
labels:
{{- include "warbot.labels" . | nindent 4 }}
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
{{- end }}
14 changes: 14 additions & 0 deletions charts/warbot/secret-db.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Secret
metadata:
name: db-secrets
namespace: {{ .Release.Namespace }}
labels:
{{- include "warbot.labels" . | nindent 4 }}
stringData:
MYSQL_ROOT_PASSWORD: {{ .Values.database.password | quote }}
MYSQL_DATABASE: {{ .Values.database.name | quote }}
MYSQL_USER: {{ .Values.database.user | quote }}
MYSQL_PASSWORD: {{ .Values.database.password | quote }}
MARIADB_AUTO_UPGRADE: "1"
MARIADB_INITDB_SKIP_TZINFO: "1"
11 changes: 11 additions & 0 deletions charts/warbot/secret-discord.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Secret
metadata:
name: discord-secrets
namespace: {{ .Release.Namespace }}
labels:
{{- include "warbot.labels" . | nindent 4 }}
stringData:
DISCORD_ID: {{ .Values.discord.id | quote }}
DISCORD_TOKEN: {{ .Values.discord.token | quote }}
DISCORD_SECRET: {{ .Values.discord.secret | quote }}
Loading

0 comments on commit 4005d92

Please sign in to comment.