Skip to content

Commit

Permalink
Add helm chart (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
hollanbm authored May 12, 2024
1 parent e2481b4 commit 131b60f
Show file tree
Hide file tree
Showing 9 changed files with 318 additions and 1 deletion.
34 changes: 34 additions & 0 deletions .github/workflows/publish-helm-chart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release Charts

on:
push:
branches:
- master

jobs:
release:
# depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions
# see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/[email protected]

- name: Run chart-releaser
uses: helm/[email protected]
with:
charts_dir: Helm
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
1 change: 0 additions & 1 deletion Docker/PlexAniSync/run/runsync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ else
echo "Using custom config: "${SETTINGS_FILE}
run
fi

9 changes: 9 additions & 0 deletions Helm/plexanisync/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v2
name: plexanisync
version: 0.1.0
description: Plex AniSync helm chart
type: "application"
maintainers:
- name: Brad Holland
email: [email protected]
url: https://www.github.com/hollanbm
57 changes: 57 additions & 0 deletions Helm/plexanisync/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# plexanisync helm chart

## Values

| Name | Description | Default Value | Example |
| -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `nameOverride` | String to partially override plexanisync.fullname template (will maintain the release name) | `""` | |
| `fullnameOverride` | String to fully override plexanisync.fullname template | `""` | |
| `namespaceOverride` | String to fully override common.names.namespace | `""` | |
| `custom_mappings` | Contents of custom_mappings.yaml recomended multiline yaml string. | `""` | <pre>custom_mappings: \|<br>&nbsp;&nbsp;&nbsp;&nbsp;remote-urls:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- https://raw.githubusercontent.com/RickDB/PlexAniSync-Custom-Mappings/main/series-tvdb.en.yaml<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- https://raw.githubusercontent.com/RickDB/PlexAniSync-Custom-Mappings/main/movies-tmdb.en.yaml</pre> |
| `envVars` | Additional EnvVars to define in the plexanisync container | `[]` | <pre>EnvVars:<br>&nbsp;&nbsp;- name: KEY<br>&nbsp;&nbsp;&nbsp;&nbsp;value: "VALUE"</pre> |
| `image` | container image to use | `ghcr.io/rickdb/plexanisync:latest` | |
| `resources` | plexanisync container resource requests/limits | <pre>resources:<br>&nbsp;&nbsp;limits:<br>&nbsp;&nbsp;&nbsp;&nbsp;cpu: '1'<br>&nbsp;&nbsp;&nbsp;&nbsp;memory: 1Gi<br>&nbsp;&nbsp;requests:<br>&nbsp;&nbsp;&nbsp;&nbsp;cpu: '100m'<br>&nbsp;&nbsp;&nbsp;&nbsp;memory: 256Mi | |
| `settings` | [plexanisync environment variable settings](https://github.com/RickDB/PlexAniSync/tree/master/Docker/PlexAniSync#environment-variables) | <pre>settings:<br>&nbsp;&nbsp;plex_section:&nbsp;Anime\|Anime&nbsp;Movies<br>&nbsp;&nbsp;plex_url:<br>&nbsp;&nbsp;ani_username:<br>&nbsp;&nbsp;plex_episode_count_priority:<br>&nbsp;&nbsp;sync_ratings:<br>&nbsp;&nbsp;skip_list_update:&nbsp;&nbsp;<br>&nbsp;&nbsp;schedule:</pre> | <pre>settings:<br>&nbsp;&nbsp;plex_section:&nbsp;Anime\|Anime&nbsp;Movies<br>&nbsp;&nbsp;plex_url:&nbsp;https://plex.tld.org<br>&nbsp;&nbsp;ani_username:&nbsp;username<br>&nbsp;&nbsp;plex_episode_count_priority:&nbsp;true<br>&nbsp;&nbsp;sync_ratings:&nbsp;false<br>&nbsp;&nbsp;skip_list_update:&nbsp;true<br>&nbsp;&nbsp;schedule:&nbsp;"* */1 * * *"</pre> |
| `settings.schedule` | Cron schedule, see [crontab.guru](https://crontab.guru/#*_*/1_*_*_*) for more information | `'* */1 * * *'` |
| `tokens` | plex and anilist tokens | <pre>tokens:<br>&nbsp;&nbsp;ani:<br>&nbsp;&nbsp;plex:</pre> | <pre>tokens:<br>&nbsp;&nbsp;ani: ani-token<br>&nbsp;&nbsp;plex: plex-token</pre> |
| `podSecurityContext` | [pod security context](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#securitycontext-v1-core) | `{}` | |
| `containerSecurityContext` | [container security context](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#securitycontext-v1-core) | `{}` | |
| `volumes` | Additional [volumes](https://kubernetes.io/docs/concepts/storage/volumes/) to define in the pod | `[]` | |
| `volumeMounts` | volumeMounts for additional volumes | `[]` | |
| `cronjob` | CronJob configuration, most users will most likely omit these, as the defaults should be sufficient | <pre>cronjob:<br>&nbsp;&nbsp;concurrencyPolicy:&nbsp;Forbid<br>&nbsp;&nbsp;failedJobsHistoryLimit:&nbsp;2<br>&nbsp;&nbsp;startingDeadlineSeconds:&nbsp;300<br>&nbsp;&nbsp;successfulJobsHistoryLimit:&nbsp;1</pre> |
### Settings

* If an optional setting is not defined, the environment variable will not be set. This will then use the plexanisync container image default for that particular setting

* This chart does not provide *native* support for the following plexanisync settings.
* SETTINGS_FILE
* LOG_FAILED_MATCHES

* It is possible to enable these features using a combination of the envVars, volumes, and volumeMounts

#### Example values.yaml

```yaml
custom_mappings: |
remote-urls:
- https://raw.githubusercontent.com/RickDB/PlexAniSync-Custom-Mappings/main/series-tvdb.en.yaml
entries:
- title: The Rising of the Shield Hero
seasons:
- season: 1
anilist-id: 99263
settings:
plex_section: Anime|Anime Movies
plex_url: https://plex.tld.org
ani_username: UserName
plex_episode_count_priority: true
sync_ratings: false
skip_list_update: true
schedule: "* */1 * * *"

tokens:
ani: ani-token
plex: plex-token

```
62 changes: 62 additions & 0 deletions Helm/plexanisync/templates/_commom.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Not using enough of the bitnami common library chart, to warrant a full chart dependency
https://github.dev/bitnami/charts/blob/main/bitnami/common
*/}}

{{/*
Expand the name of the chart.
*/}}
{{- define "common.names.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "common.names.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | 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 "common.names.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 -}}

{{/*
Allow the release namespace to be overridden for multi-namespace deployments in combined charts.
*/}}
{{- define "common.names.namespace" -}}
{{- default .Release.Namespace .Values.namespaceOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Kubernetes standard labels
{{ include "common.labels.standard" (dict "customLabels" .Values.commonLabels "context" $) -}}
*/}}
{{- define "common.labels.standard" -}}
app.kubernetes.io/name: {{ include "common.names.name" . | quote }}
helm.sh/chart: {{ include "common.names.chart" . | quote }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
{{- end -}}

{{/*
Labels used on immutable fields such as deploy.spec.selector.matchLabels or svc.spec.selector
*/}}
{{- define "common.labels.matchLabels" -}}
app.kubernetes.io/name: {{ include "common.names.name" . | quote }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
{{- end -}}
11 changes: 11 additions & 0 deletions Helm/plexanisync/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- if .Values.custom_mappings }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "common.names.fullname" . }}
namespace: {{ include "common.names.namespace" . }}
labels: {{- include "common.labels.standard" . | nindent 4}}
data:
custom_mappings.yaml: |
{{- .Values.custom_mappings | nindent 4 }}
{{- end }}
Loading

0 comments on commit 131b60f

Please sign in to comment.