From 780c0f804b2715e85989d937932c021dfeb37171 Mon Sep 17 00:00:00 2001 From: baxtree Date: Tue, 26 Sep 2023 12:39:17 +0100 Subject: [PATCH] add the initial chart --- .github/workflows/dockerhub.yml | 19 ++--- .github/workflows/lint-charts.yml | 29 ++++++++ charts/subaligner/.helmignore | 23 ++++++ charts/subaligner/Chart.yaml | 7 ++ charts/subaligner/templates/NOTES.txt | 1 + charts/subaligner/templates/_helpers.tpl | 62 ++++++++++++++++ charts/subaligner/templates/configmap.yaml | 7 ++ charts/subaligner/templates/job.yaml | 70 +++++++++++++++++++ charts/subaligner/templates/secret.yaml | 7 ++ .../subaligner/templates/serviceaccount.yaml | 12 ++++ charts/subaligner/values.yaml | 34 +++++++++ 11 files changed, 256 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/lint-charts.yml create mode 100644 charts/subaligner/.helmignore create mode 100644 charts/subaligner/Chart.yaml create mode 100644 charts/subaligner/templates/NOTES.txt create mode 100644 charts/subaligner/templates/_helpers.tpl create mode 100644 charts/subaligner/templates/configmap.yaml create mode 100644 charts/subaligner/templates/job.yaml create mode 100644 charts/subaligner/templates/secret.yaml create mode 100644 charts/subaligner/templates/serviceaccount.yaml create mode 100644 charts/subaligner/values.yaml diff --git a/.github/workflows/dockerhub.yml b/.github/workflows/dockerhub.yml index a8081a8..24cacff 100644 --- a/.github/workflows/dockerhub.yml +++ b/.github/workflows/dockerhub.yml @@ -39,21 +39,10 @@ jobs: platforms: linux/amd64,linux/arm64 allow: network.host github-token: ${{ github.token }} - tags: baxtree/subaligner:latest - push: true - - - name: Build and push the Ubuntu 20 image - id: docker_build_u20 - uses: docker/build-push-action@v4 - with: - context: ./docker - file: "./docker/Dockerfile-Ubuntu20" - build-args: | - "RELEASE_VERSION=${{ steps.tag.outputs.TAG }}" - platforms: linux/amd64,linux/arm64 - allow: network.host - github-token: ${{ github.token }} - tags: baxtree/subaligner:${{ steps.tag.outputs.TAG }}.u20 + tags: | + baxtree/subaligner:latest + baxtree/subaligner:${{ steps.tag.outputs.TAG }} + baxtree/subaligner:${{ steps.tag.outputs.TAG }}.u20 push: true - name: Build and push the Ubuntu 22 image diff --git a/.github/workflows/lint-charts.yml b/.github/workflows/lint-charts.yml new file mode 100644 index 0000000..f869e50 --- /dev/null +++ b/.github/workflows/lint-charts.yml @@ -0,0 +1,29 @@ +name: Lint Helm charts + +on: + push: + paths: + - "charts/**" + + workflow_dispatch: + +env: + HELM_VERSION: 3.11.2 + +jobs: + lint-helm-charts: + runs-on: ubuntu-20.04 + + steps: + - name: Checkout sources + uses: actions/checkout@v3 + + - name: Setup Helm + uses: mamezou-tech/setup-helmfile@v1.2.0 + with: + helm-version: "v${{ env.HELM_VERSION }}" + + - name: Lint Helm Charts + run: | + helm lint charts/* + working-directory: ${{ github.workspace }} diff --git a/charts/subaligner/.helmignore b/charts/subaligner/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/subaligner/.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/subaligner/Chart.yaml b/charts/subaligner/Chart.yaml new file mode 100644 index 0000000..625ae57 --- /dev/null +++ b/charts/subaligner/Chart.yaml @@ -0,0 +1,7 @@ +apiVersion: v2 +name: subaligner +description: A Helm chart for subaligner CLIs +icon: https://raw.githubusercontent.com/baxtree/subaligner/master/figures/subaligner.png +type: application +version: 0.1.0 +appVersion: "0.3.6" diff --git a/charts/subaligner/templates/NOTES.txt b/charts/subaligner/templates/NOTES.txt new file mode 100644 index 0000000..2946877 --- /dev/null +++ b/charts/subaligner/templates/NOTES.txt @@ -0,0 +1 @@ +{{ .Release.Name }} is deployed to {{ .Release.Namespace }} namespace. \ No newline at end of file diff --git a/charts/subaligner/templates/_helpers.tpl b/charts/subaligner/templates/_helpers.tpl new file mode 100644 index 0000000..c814c05 --- /dev/null +++ b/charts/subaligner/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "subaligner.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 "subaligner.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 "subaligner.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "subaligner.labels" -}} +helm.sh/chart: {{ include "subaligner.chart" . }} +{{ include "subaligner.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "subaligner.selectorLabels" -}} +app.kubernetes.io/name: {{ include "subaligner.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "subaligner.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "subaligner.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/subaligner/templates/configmap.yaml b/charts/subaligner/templates/configmap.yaml new file mode 100644 index 0000000..f3fc60d --- /dev/null +++ b/charts/subaligner/templates/configmap.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "subaligner.fullname" . }} + labels: + {{- include "subaligner.labels" . | nindent 4 }} +data: \ No newline at end of file diff --git a/charts/subaligner/templates/job.yaml b/charts/subaligner/templates/job.yaml new file mode 100644 index 0000000..1afd889 --- /dev/null +++ b/charts/subaligner/templates/job.yaml @@ -0,0 +1,70 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: {{.Release.Name}}-{{ randAlphaNum 5 | lower }} + labels: + {{- include "subaligner.labels" . | nindent 4 }} +spec: + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "subaligner.selectorLabels" . | nindent 8 }} + spec: + restartPolicy: Never + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "subaligner.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + command: ['/usr/local/bin/subaligner_batch', '-m', '{{ .Values.alignmentMode }}', '-vd', '/subaligner-media/videos', '-sd', '/subaligner-media/subtitles', '-od', '/subaligner-media/output'] + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + volumeMounts: + - name: videos + mountPath: /subaligner-media/videos + - name: subtitles + mountPath: /subaligner-media/subtitles + - name: output + mountPath: /subaligner-media/output + resources: + {{- toYaml .Values.resources | nindent 12 }} + envFrom: + - secretRef: + name: {{ include "subaligner.fullname" . }} + - configMapRef: + name: {{ include "subaligner.fullname" . }} + volumes: + - name: videos + hostPath: + path: {{ .Values.pathToTheVideoDirectory }} + type: Directory + - name: subtitles + hostPath: + path: {{ .Values.pathToTheSubtitleDirectory }} + type: Directory + - name: output + hostPath: + path: {{ .Values.pathToTheOutputDirectory }} + type: Directory + {{- 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/charts/subaligner/templates/secret.yaml b/charts/subaligner/templates/secret.yaml new file mode 100644 index 0000000..d2e0921 --- /dev/null +++ b/charts/subaligner/templates/secret.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "subaligner.fullname" . }} + labels: + {{- include "subaligner.labels" . | nindent 4 }} +data: \ No newline at end of file diff --git a/charts/subaligner/templates/serviceaccount.yaml b/charts/subaligner/templates/serviceaccount.yaml new file mode 100644 index 0000000..bd006fb --- /dev/null +++ b/charts/subaligner/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "subaligner.serviceAccountName" . }} + labels: + {{- include "subaligner.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/subaligner/values.yaml b/charts/subaligner/values.yaml new file mode 100644 index 0000000..68b70d8 --- /dev/null +++ b/charts/subaligner/values.yaml @@ -0,0 +1,34 @@ +replicaCount: 1 + +image: + repository: baxtree/subaligner + pullPolicy: IfNotPresent + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + create: true + annotations: {} + name: "" + +podAnnotations: {} + +podSecurityContext: {} + +securityContext: {} + +resources: {} + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +alignmentMode: "dual" +pathToTheVideoDirectory: "" +pathToTheSubtitleDirectory: "" +pathToTheOutputDirectory: ""