From eafdbff4d5db77c9b8667f34197dd2657cf19a98 Mon Sep 17 00:00:00 2001 From: Aram Peres <6775216+aramperes@users.noreply.github.com> Date: Fri, 21 Jul 2023 21:25:18 -0400 Subject: [PATCH] Add Helm chart --- .github/workflows/release.yml | 19 ++++++ helm/ts-activity/.helmignore | 23 +++++++ helm/ts-activity/Chart.yaml | 8 +++ helm/ts-activity/templates/_helpers.tpl | 62 +++++++++++++++++++ helm/ts-activity/templates/deployment.yaml | 61 ++++++++++++++++++ .../ts-activity/templates/serviceaccount.yaml | 12 ++++ helm/ts-activity/values.yaml | 53 ++++++++++++++++ 7 files changed, 238 insertions(+) create mode 100644 helm/ts-activity/.helmignore create mode 100644 helm/ts-activity/Chart.yaml create mode 100644 helm/ts-activity/templates/_helpers.tpl create mode 100644 helm/ts-activity/templates/deployment.yaml create mode 100644 helm/ts-activity/templates/serviceaccount.yaml create mode 100644 helm/ts-activity/values.yaml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3d979d5..75aafdc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,3 +32,22 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + + - name: Get the release version from the tag + if: env.VERSION == '' + run: | + echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + echo "version is: ${{ env.VERSION }}" + + - name: Update Helm chart version + shell: bash + run: sed -i 's/0\.0\.0/${{ env.VERSION }}/g' helm/ts-activity/Chart.yaml + + - name: Build and push Helm chart + uses: goodsmileduck/helm-push-action@ec9f29cbf16a4773438b3ea98790aa5b5ca3e749 + env: + SOURCE_DIR: './helm' + CHART_FOLDER: 'ts-activity' + CHARTMUSEUM_URL: 'https://charts.momoperes.ca' + CHARTMUSEUM_USER: '${{ secrets.CHARTMUSEUM_USER }}' + CHARTMUSEUM_PASSWORD: ${{ secrets.CHARTMUSEUM_PASSWORD }} diff --git a/helm/ts-activity/.helmignore b/helm/ts-activity/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm/ts-activity/.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/helm/ts-activity/Chart.yaml b/helm/ts-activity/Chart.yaml new file mode 100644 index 0000000..07bc879 --- /dev/null +++ b/helm/ts-activity/Chart.yaml @@ -0,0 +1,8 @@ +apiVersion: v2 +name: ts-activity +description: Post TeamSpeak events to Discord + +type: application + +version: "0.0.0" +appVersion: "0.0.0" diff --git a/helm/ts-activity/templates/_helpers.tpl b/helm/ts-activity/templates/_helpers.tpl new file mode 100644 index 0000000..9665e88 --- /dev/null +++ b/helm/ts-activity/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "ts-activity.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 "ts-activity.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 "ts-activity.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "ts-activity.labels" -}} +helm.sh/chart: {{ include "ts-activity.chart" . }} +{{ include "ts-activity.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "ts-activity.selectorLabels" -}} +app.kubernetes.io/name: {{ include "ts-activity.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "ts-activity.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "ts-activity.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/helm/ts-activity/templates/deployment.yaml b/helm/ts-activity/templates/deployment.yaml new file mode 100644 index 0000000..9667033 --- /dev/null +++ b/helm/ts-activity/templates/deployment.yaml @@ -0,0 +1,61 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "ts-activity.fullname" . }} + labels: + {{- include "ts-activity.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: 1 + {{- end }} + selector: + matchLabels: + {{- include "ts-activity.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "ts-activity.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "ts-activity.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default "latest" }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + 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 }} + {{- 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/ts-activity/templates/serviceaccount.yaml b/helm/ts-activity/templates/serviceaccount.yaml new file mode 100644 index 0000000..f102664 --- /dev/null +++ b/helm/ts-activity/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "ts-activity.serviceAccountName" . }} + labels: + {{- include "ts-activity.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/helm/ts-activity/values.yaml b/helm/ts-activity/values.yaml new file mode 100644 index 0000000..332054c --- /dev/null +++ b/helm/ts-activity/values.yaml @@ -0,0 +1,53 @@ +# Default values for ts-activity. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +image: + repository: aramperes/ts-activity + pullPolicy: IfNotPresent + # Overrides the image tag whose default is latest. + tag: "" + +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 + +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: {}