From 0361226bde46d96922e0218993625810f1666f14 Mon Sep 17 00:00:00 2001 From: Richard Robert Reitz Date: Fri, 22 Nov 2024 13:01:46 +0100 Subject: [PATCH] Fixed forgejo-runner helm chart --- kind/forgejo-runner/.helmignore | 23 ++++++ kind/forgejo-runner/Chart.yaml | 24 ++++++ kind/forgejo-runner/templates/NOTES.txt | 7 ++ kind/forgejo-runner/templates/_helpers.tpl | 62 ++++++++++++++ kind/forgejo-runner/templates/deployment.yaml | 82 +++++++++++++++++++ kind/forgejo-runner/templates/secret.yaml | 13 +++ kind/forgejo-runner/values.yaml | 45 ++++++++++ kind/stacks/core/forgejo-runner.yaml | 2 +- kind/stacks/core/forgejo-runner/values.yaml | 2 - 9 files changed, 257 insertions(+), 3 deletions(-) create mode 100644 kind/forgejo-runner/.helmignore create mode 100644 kind/forgejo-runner/Chart.yaml create mode 100644 kind/forgejo-runner/templates/NOTES.txt create mode 100644 kind/forgejo-runner/templates/_helpers.tpl create mode 100644 kind/forgejo-runner/templates/deployment.yaml create mode 100644 kind/forgejo-runner/templates/secret.yaml create mode 100644 kind/forgejo-runner/values.yaml diff --git a/kind/forgejo-runner/.helmignore b/kind/forgejo-runner/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/kind/forgejo-runner/.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/kind/forgejo-runner/Chart.yaml b/kind/forgejo-runner/Chart.yaml new file mode 100644 index 0000000..49a663c --- /dev/null +++ b/kind/forgejo-runner/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: forgejo-runner +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.1.0 + +# 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: "1.16.0" diff --git a/kind/forgejo-runner/templates/NOTES.txt b/kind/forgejo-runner/templates/NOTES.txt new file mode 100644 index 0000000..e2dcc06 --- /dev/null +++ b/kind/forgejo-runner/templates/NOTES.txt @@ -0,0 +1,7 @@ +{{- if not .Values.registration.enabled}} +You will have to manually create a secret with the registration token, since you have not specified the registration token in the values.yaml file. + +To create a secret with the registration token, run the following command: + + kubectl create secret generic {{ include "forgejo-runner.fullname" . }}-token --from-literal=token= +{{- end}} diff --git a/kind/forgejo-runner/templates/_helpers.tpl b/kind/forgejo-runner/templates/_helpers.tpl new file mode 100644 index 0000000..7af352b --- /dev/null +++ b/kind/forgejo-runner/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "forgejo-runner.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 "forgejo-runner.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 "forgejo-runner.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "forgejo-runner.labels" -}} +helm.sh/chart: {{ include "forgejo-runner.chart" . }} +{{ include "forgejo-runner.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "forgejo-runner.selectorLabels" -}} +app.kubernetes.io/name: {{ include "forgejo-runner.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "forgejo-runner.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "forgejo-runner.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/kind/forgejo-runner/templates/deployment.yaml b/kind/forgejo-runner/templates/deployment.yaml new file mode 100644 index 0000000..0134e8f --- /dev/null +++ b/kind/forgejo-runner/templates/deployment.yaml @@ -0,0 +1,82 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + {{- include "forgejo-runner.labels" . | nindent 4 }} + name: {{ include "forgejo-runner.fullname" . }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "forgejo-runner.selectorLabels" . | nindent 6 }} + strategy: {} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "forgejo-runner.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + volumes: + - name: docker-certs + emptyDir: {} + - name: runner-data + emptyDir: {} + initContainers: + - name: runner-register + image: {{ .Values.image.repository }}:{{ .Values.image.tag }} + command: ["forgejo-runner", "register", "--no-interactive", "--token", $(RUNNER_SECRET), "--name", $(RUNNER_NAME), "--instance", $(FORGEJO_INSTANCE_URL)] + env: + - name: RUNNER_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: RUNNER_SECRET + valueFrom: + secretKeyRef: + name: {{ include "forgejo-runner.fullname" . }}-token + key: token + - name: FORGEJO_INSTANCE_URL + value: {{ .Values.forgejoUrl }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - name: runner-data + mountPath: /data + containers: + - name: runner + image: {{ .Values.image.repository }}:{{ .Values.image.tag }} + command: ["sh", "-c", "while ! nc -z localhost 2376