diff --git a/helm/am-bot/.helmignore b/helm/am-bot/.helmignore new file mode 100644 index 0000000..414bb6e --- /dev/null +++ b/helm/am-bot/.helmignore @@ -0,0 +1,18 @@ +# Patterns to ignore when building packages. +.DS_Store +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +*.swp +*.bak +*.tmp +*.orig +*~ +.project +.idea/ +*.tmproj +.vscode/ diff --git a/helm/am-bot/Chart.yaml b/helm/am-bot/Chart.yaml new file mode 100644 index 0000000..78350e9 --- /dev/null +++ b/helm/am-bot/Chart.yaml @@ -0,0 +1,10 @@ +apiVersion: v2 +name: am-bot +description: ARK Modding Discord Bot - Community management bot for ARK modding Discord server +type: application +version: 1.0.0 +appVersion: "0.0.6" + +maintainers: + - name: jslay + email: jslay@arkmodding.net diff --git a/helm/am-bot/templates/_helpers.tpl b/helm/am-bot/templates/_helpers.tpl new file mode 100644 index 0000000..dee3d65 --- /dev/null +++ b/helm/am-bot/templates/_helpers.tpl @@ -0,0 +1,85 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "am-bot.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +*/}} +{{- define "am-bot.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 "am-bot.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "am-bot.labels" -}} +helm.sh/chart: {{ include "am-bot.chart" . }} +{{ include "am-bot.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "am-bot.selectorLabels" -}} +app.kubernetes.io/name: {{ include "am-bot.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +app: {{ include "am-bot.name" . }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "am-bot.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "am-bot.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} + +{{/* +Bot secret name +*/}} +{{- define "am-bot.secretName" -}} +{{- if .Values.existingSecret }} +{{- .Values.existingSecret }} +{{- else }} +{{- printf "%s-secrets" (include "am-bot.fullname" .) }} +{{- end }} +{{- end }} + +{{/* +AWS secret name +*/}} +{{- define "am-bot.awsSecretName" -}} +{{- if .Values.aws.existingSecret }} +{{- .Values.aws.existingSecret }} +{{- else if .Values.existingSecret }} +{{- .Values.existingSecret }} +{{- else }} +{{- printf "%s-secrets" (include "am-bot.fullname" .) }} +{{- end }} +{{- end }} diff --git a/helm/am-bot/templates/deployment.yaml b/helm/am-bot/templates/deployment.yaml new file mode 100644 index 0000000..19cb4ba --- /dev/null +++ b/helm/am-bot/templates/deployment.yaml @@ -0,0 +1,77 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "am-bot.fullname" . }} + labels: + {{- include "am-bot.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "am-bot.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "am-bot.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- range . }} + - name: {{ . }} + {{- end }} + {{- end }} + {{- if .Values.serviceAccount.create }} + serviceAccountName: {{ include "am-bot.serviceAccountName" . }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + {{- /* Bot token */}} + - name: BOT_TOKEN + valueFrom: + secretKeyRef: + name: {{ include "am-bot.secretName" . }} + key: BOT_TOKEN + {{- /* AWS credentials for SES */}} + {{- if .Values.aws.enabled }} + - name: AWS_ACCESS_KEY_ID + valueFrom: + secretKeyRef: + name: {{ include "am-bot.awsSecretName" . }} + key: AWS_ACCESS_KEY_ID + - name: AWS_SECRET_ACCESS_KEY + valueFrom: + secretKeyRef: + name: {{ include "am-bot.awsSecretName" . }} + key: AWS_SECRET_ACCESS_KEY + - name: AWS_DEFAULT_REGION + valueFrom: + secretKeyRef: + name: {{ include "am-bot.awsSecretName" . }} + key: AWS_DEFAULT_REGION + {{- end }} + {{- /* Additional environment variables */}} + {{- range $key, $value := .Values.env }} + - name: {{ $key }} + value: {{ $value | quote }} + {{- end }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/helm/am-bot/templates/secrets.yaml b/helm/am-bot/templates/secrets.yaml new file mode 100644 index 0000000..710c848 --- /dev/null +++ b/helm/am-bot/templates/secrets.yaml @@ -0,0 +1,18 @@ +{{- if and (not .Values.existingSecret) (or .Values.secrets .Values.aws.secrets) }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "am-bot.fullname" . }}-secrets + labels: + {{- include "am-bot.labels" . | nindent 4 }} +type: Opaque +stringData: + {{- range $key, $value := .Values.secrets }} + {{ $key }}: {{ $value | quote }} + {{- end }} + {{- if and .Values.aws.enabled (not .Values.aws.existingSecret) }} + {{- range $key, $value := .Values.aws.secrets }} + {{ $key }}: {{ $value | quote }} + {{- end }} + {{- end }} +{{- end }} diff --git a/helm/am-bot/values.yaml b/helm/am-bot/values.yaml new file mode 100644 index 0000000..ca8b83f --- /dev/null +++ b/helm/am-bot/values.yaml @@ -0,0 +1,53 @@ +# Default values for am-bot + +replicaCount: 1 + +image: + registry: ghcr.io + repository: arkmodding/am_bot + tag: "0.0.6" + pullPolicy: IfNotPresent + +imagePullSecrets: [] + +# Use an existing secret for credentials +# The secret must contain: BOT_TOKEN +# If AWS SES is enabled, also needs: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_DEFAULT_REGION +existingSecret: "" + +# If not using existingSecret, provide secrets here (not recommended for production) +secrets: {} + # BOT_TOKEN: "" + +# AWS SES configuration for email notifications +aws: + enabled: true + # Use a separate existing secret for AWS credentials + # Must contain: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_DEFAULT_REGION + existingSecret: "" + # If not using existingSecret, provide values here + secrets: {} + # AWS_ACCESS_KEY_ID: "" + # AWS_SECRET_ACCESS_KEY: "" + # AWS_DEFAULT_REGION: "" + +# Additional environment variables +env: {} + +resources: + limits: + cpu: 200m + memory: 128Mi + requests: + cpu: 50m + memory: 64Mi + +nodeSelector: {} +tolerations: [] +affinity: {} + +podAnnotations: {} + +serviceAccount: + create: false + name: ""