From 753e183b60e13b01f9ebf58701c43f2268c79f5e Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Sun, 6 Dec 2020 23:55:26 +0500 Subject: [PATCH 01/21] Add upstream plex chart --- test/plex/.helmignore | 24 ++ test/plex/Chart.yaml | 15 + test/plex/OWNERS | 4 + test/plex/README.md | 48 +++ test/plex/configs/41-plex-preferences | 64 ++++ test/plex/configs/42-pkcs-mangler | 53 +++ test/plex/templates/NOTES.txt | 19 ++ test/plex/templates/_helpers.tpl | 81 +++++ test/plex/templates/configmap.yaml | 42 +++ test/plex/templates/deployment.yaml | 357 ++++++++++++++++++++ test/plex/templates/ingress.yaml | 40 +++ test/plex/templates/promtail-configmap.yaml | 36 ++ test/plex/templates/secrets.yaml | 18 + test/plex/templates/service-tcp.yaml | 57 ++++ test/plex/templates/service-udp.yaml | 61 ++++ test/plex/templates/volumes.yaml | 57 ++++ test/plex/values.yaml | 349 +++++++++++++++++++ 17 files changed, 1325 insertions(+) create mode 100644 test/plex/.helmignore create mode 100644 test/plex/Chart.yaml create mode 100644 test/plex/OWNERS create mode 100644 test/plex/README.md create mode 100644 test/plex/configs/41-plex-preferences create mode 100644 test/plex/configs/42-pkcs-mangler create mode 100644 test/plex/templates/NOTES.txt create mode 100644 test/plex/templates/_helpers.tpl create mode 100644 test/plex/templates/configmap.yaml create mode 100644 test/plex/templates/deployment.yaml create mode 100644 test/plex/templates/ingress.yaml create mode 100644 test/plex/templates/promtail-configmap.yaml create mode 100644 test/plex/templates/secrets.yaml create mode 100644 test/plex/templates/service-tcp.yaml create mode 100644 test/plex/templates/service-udp.yaml create mode 100644 test/plex/templates/volumes.yaml create mode 100644 test/plex/values.yaml diff --git a/test/plex/.helmignore b/test/plex/.helmignore new file mode 100644 index 00000000000..e559de0a012 --- /dev/null +++ b/test/plex/.helmignore @@ -0,0 +1,24 @@ +# 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 +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ +# OWNERS file for Kubernetes +OWNERS diff --git a/test/plex/Chart.yaml b/test/plex/Chart.yaml new file mode 100644 index 00000000000..32815d2bef1 --- /dev/null +++ b/test/plex/Chart.yaml @@ -0,0 +1,15 @@ +apiVersion: v2 +appVersion: 1.20.2.3402 +description: Plex Media Server +name: plex +version: 2.1.0 +keywords: + - plex +home: https://plex.tv/ +icon: https://www.plex.tv/wp-content/uploads/2018/01/pmp-icon-1.png +sources: + - https://github.com/k8s-at-home/charts/tree/master/charts/plex + - https://hub.docker.com/r/plexinc/pms-docker/ +maintainers: + - name: billimek + email: jeff@billimek.com diff --git a/test/plex/OWNERS b/test/plex/OWNERS new file mode 100644 index 00000000000..51f8865259a --- /dev/null +++ b/test/plex/OWNERS @@ -0,0 +1,4 @@ +approvers: +- billimek +reviewers: +- billimek \ No newline at end of file diff --git a/test/plex/README.md b/test/plex/README.md new file mode 100644 index 00000000000..d086f384aae --- /dev/null +++ b/test/plex/README.md @@ -0,0 +1,48 @@ +# Plex Media Server helm chart + +This is an opinionated helm chart for Plex Media Center based on the [official container image](https://hub.docker.com/r/plexinc/pms-docker/). + +This chart is 'forked' from the excellent [munnerz/kube-plex](https://github.com/munnerz/kube-plex) repo in order to allow for more timely updates and publishing to a helm registry. **NOTE:** This chart is not compatible as an upgrade from the `kube-plex` chart. + +## TL;DR + +```shell +helm repo add k8s-at-home https://k8s-at-home.com/charts/ +helm install k8s-at-home/plex +``` + +## Installing the Chart + +To install the chart with the release name `plex`: + +```console +helm install plex k8s-at-home/plex +``` + +## Uninstalling the Chart + +To uninstall/delete the `plex` deployment: + +```console +helm delete plex +``` + +The command removes all the Kubernetes components associated with the chart and deletes the release. + +## Configuration + +Read through the [values.yaml](https://github.com/k8s-at-home/charts/blob/master/charts/plex/values.yaml) file. It has several commented out suggested values. + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, + +```console +helm install plex \ + --set timezone="America/New York" \ + k8s-at-home/plex +``` + +Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example, + +```console +helm install plex -f values.yaml k8s-at-home/plex +``` diff --git a/test/plex/configs/41-plex-preferences b/test/plex/configs/41-plex-preferences new file mode 100644 index 00000000000..5f13bd2abba --- /dev/null +++ b/test/plex/configs/41-plex-preferences @@ -0,0 +1,64 @@ +#!/usr/bin/with-contenv bash + +# This file is based off of the official 40-plex-first-run +# Here: https://github.com/plexinc/pms-docker/blob/master/root/etc/cont-init.d/40-plex-first-run +# It should live in /etc/cont-init.d/ + +# If we are debugging, enable trace +if [ "${DEBUG,,}" = "true" ]; then + set -x +fi + +function getPref { + local key="$1" + + xmlstarlet sel -T -t -m "/Preferences" -v "@${key}" -n "${prefFile}" +} + +function setPref { + local key="$1" + local value="$2" + + count="$(xmlstarlet sel -t -v "count(/Preferences/@${key})" "${prefFile}")" + count=$(($count + 0)) + if [[ $count > 0 ]]; then + xmlstarlet ed --inplace --update "/Preferences/@${key}" -v "${value}" "${prefFile}" + else + xmlstarlet ed --inplace --insert "/Preferences" --type attr -n "${key}" -v "${value}" "${prefFile}" + fi +} + +home="$(echo ~plex)" +pmsApplicationSupportDir="${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR:-${home}/Library/Application Support}" +prefFile="${pmsApplicationSupportDir}/Plex Media Server/Preferences.xml" + +if [ ! -z "${ADVERTISE_IP}" ]; then + setPref "customConnections" "${ADVERTISE_IP}" +fi + +if [ ! -z "${ALLOWED_NETWORKS}" ]; then + setPref "allowedNetworks" "${ALLOWED_NETWORKS}" +fi + +# Set transcoder temp if not yet set +if [ -z "$(getPref "TranscoderTempDirectory")" ]; then + setPref "TranscoderTempDirectory" "/transcode" +fi + +# Parse list of all exported variables that start with PLEX_PREFERENCE_ +# The format of which is PLEX_PREFERENCE_="Key=Value" +# Where Key is the EXACT key to use in the Plex Preference file +# And Value is the EXACT value to use in the Plex Preference file for that key. +# Please note it looks like many of the key's are camelCase in some fashion. +# Additionally there are likely some preferences where environment variable injection +# doesn't really work for. +for var in "${!PLEX_PREFERENCE_@}"; do + value=${!var} + PreferenceValue=${value#*=} + PreferenceKey=${value%=*} + setPref $PreferenceKey $PreferenceValue +done + +# touch /.firstRunComplete +# echo "Plex Media Server first run setup complete" +echo "Plex Media Server preferences update run complete" \ No newline at end of file diff --git a/test/plex/configs/42-pkcs-mangler b/test/plex/configs/42-pkcs-mangler new file mode 100644 index 00000000000..8a4fb1e2aa3 --- /dev/null +++ b/test/plex/configs/42-pkcs-mangler @@ -0,0 +1,53 @@ +#!/usr/bin/with-contenv bash + +# This file contains part of the official PLEX 40-plex-first-run +# Here: https://github.com/plexinc/pms-docker/blob/master/root/etc/cont-init.d/40-plex-first-run +# It should live in /etc/cont-init.d/ + +# If we are debugging, enable trace +if [ "${DEBUG,,}" = "true" ]; then + set -x +fi + +function setPref { + local key="$1" + local value="$2" + + count="$(xmlstarlet sel -t -v "count(/Preferences/@${key})" "${prefFile}")" + count=$(($count + 0)) + if [[ $count > 0 ]]; then + xmlstarlet ed --inplace --update "/Preferences/@${key}" -v "${value}" "${prefFile}" + else + xmlstarlet ed --inplace --insert "/Preferences" --type attr -n "${key}" -v "${value}" "${prefFile}" + fi +} + +home="$(echo ~plex)" +pmsApplicationSupportDir="${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR:-${home}/Library/Application Support}" +prefFile="${pmsApplicationSupportDir}/Plex Media Server/Preferences.xml" + +# If PKCSMANGLER__PFXINCONTAINERPATH is set, then assume we want to move the PFX Cert to that location +if [ ! -z "${PKCSMANGLER_PFXINCONTAINERPATH}" ]; then + # If it ends up a problem, we may need to set some kind of "don't replace existing PFX cert" + cp -f /shared/cert.pfx "${PKCSMANGLER_PFXINCONTAINERPATH}" + # If PKCSMANGLER__CUSTOMCERTDOMAIN is set, then assume we want to set the PLEX Preference customCertificatePath because we enabled setting PLEX Preferences + if [ ! -z "${PKCSMANGLER_CUSTOMCERTDOMAIN}" ]; then + setPref "customCertificatePath" "${PKCSMANGLER_PFXINCONTAINERPATH}" + fi +fi + +# If PKCSMANGLER_PFXPASSWORD is set, then assume we want to set the PLEX Preference customCertificateKey +if [ ! -z "${PKCSMANGLER_PFXPASSWORD}" ]; then + setPref "customCertificateKey" "${PKCSMANGLER_PFXPASSWORD}" +fi + +# If PKCSMANGLER__CUSTOMCERTDOMAIN is set, then assume we want to set the PLEX Preference customCertificateDomain +if [ ! -z "${PKCSMANGLER_CUSTOMCERTDOMAIN}" ]; then + PreferenceValue=${PKCSMANGLER_CUSTOMCERTDOMAIN#*=} + PreferenceKey=${PKCSMANGLER_CUSTOMCERTDOMAIN%=*} + setPref $PreferenceKey $PreferenceValue +fi + +# touch /.firstRunComplete +# echo "Plex Media Server first run setup complete" +echo "PKCS Mangler run complete" \ No newline at end of file diff --git a/test/plex/templates/NOTES.txt b/test/plex/templates/NOTES.txt new file mode 100644 index 00000000000..a4119425744 --- /dev/null +++ b/test/plex/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }} +{{- end }} +{{- else if contains "NodePort" .Values.serviceTCP.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "plex.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.serviceTCP.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "plex.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "plex.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.serviceTCP.port }} +{{- else if contains "ClusterIP" .Values.serviceTCP.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "plex.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/test/plex/templates/_helpers.tpl b/test/plex/templates/_helpers.tpl new file mode 100644 index 00000000000..18ddff7f7e6 --- /dev/null +++ b/test/plex/templates/_helpers.tpl @@ -0,0 +1,81 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "plex.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 "plex.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 "plex.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "plex.labels" -}} +helm.sh/chart: {{ include "plex.chart" . }} +{{ include "plex.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "plex.selectorLabels" -}} +app.kubernetes.io/name: {{ include "plex.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "plex.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "plex.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} + +{{/* +abstract: | + Joins a list of values into a comma separated string +values: | + test: + - foo + - bar +usage: | + {{ include "joinListWithComma" .Values.test }} +return: | + foo,bar +*/}} + +{{- define "joinListWithComma" -}} +{{- $local := dict "first" true -}} +{{- range $k, $v := . -}}{{- if not $local.first -}},{{- end -}}{{- $v -}}{{- $_ := set $local "first" false -}}{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/test/plex/templates/configmap.yaml b/test/plex/templates/configmap.yaml new file mode 100644 index 00000000000..ff5b183c755 --- /dev/null +++ b/test/plex/templates/configmap.yaml @@ -0,0 +1,42 @@ +{{- if .Values.plexPreferences.enabled -}} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Values.plexPreferences.configmap.name }} + labels: + {{- include "plex.labels" . | nindent 4 }} +{{- if .Values.plexPreferences.configmap.labels }} +{{ toYaml .Values.plexPreferences.configmap.labels | indent 4 }} +{{- end }} +{{- with .Values.plexPreferences.configmap.annotations }} + annotations: +{{ toYaml . | indent 4 }} +{{- end }} + +data: +# At some point figure out how to use a value/Variable here to be able to specify +# a different file or something. +{{ (tpl (.Files.Glob "configs/41-plex-preferences").AsConfig . ) | indent 2 }} +{{- end -}} + +{{- if .Values.certificate.pkcsMangler.enabled }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Values.certificate.pkcsMangler.configmap.name }} + labels: + {{- include "plex.labels" . | nindent 4 }} +{{- if .Values.certificate.pkcsMangler.configmap.labels }} +{{ toYaml .Values.certificate.pkcsMangler.configmap.labels | indent 4 }} +{{- end }} +{{- with .Values.certificate.pkcsMangler.configmap.annotations }} + annotations: +{{ toYaml . | indent 4 }} +{{- end }} + +data: +# At some point figure out how to use a value/Variable here to be able to specify +# a different file or something. +{{ (tpl (.Files.Glob "configs/42-pkcs-mangler").AsConfig . ) | indent 2 }} +{{- end -}} \ No newline at end of file diff --git a/test/plex/templates/deployment.yaml b/test/plex/templates/deployment.yaml new file mode 100644 index 00000000000..3fcabb00045 --- /dev/null +++ b/test/plex/templates/deployment.yaml @@ -0,0 +1,357 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "plex.fullname" . }} + labels: + {{- include "plex.labels" . | nindent 4 }} + {{- if .Values.deploymentAnnotations }} + annotations: + {{- range $key, $value := .Values.deploymentAnnotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} + {{- end }} +spec: + replicas: 1 + revisionHistoryLimit: 3 + strategy: + type: {{ .Values.strategyType }} + selector: + matchLabels: + {{- include "plex.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "plex.selectorLabels" . | nindent 8 }} + {{- if .Values.podAnnotations }} + annotations: + {{- range $key, $value := .Values.podAnnotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- if .Values.hostNetwork }} + hostNetwork: {{ .Values.hostNetwork }} + dnsPolicy: ClusterFirstWithHostNet + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- if .Values.certificate.pkcsMangler.enabled }} + initContainers: + # This is ugly, but it does work to create a pks file that will work with PLEX from the tls.crt and tls.key that cert-manager normally creates + {{- if .Values.certificate.pkcsMangler.enabled }} + - name: pkcsmangler-init-container + image: "{{ .Values.certificate.pkcsMangler.image.repository }}:{{ .Values.certificate.pkcsMangler.image.tag }}" + imagePullPolicy: Always + command: ["/bin/sh"] + args: ["-c", "openssl pkcs12 -export -passout pass:$(PKCSMANGLER_PFXPASSWORD) -out /shared/cert.pfx -inkey {{ .Values.certificate.pkcsMangler.certificateSecret.volume.mountPath }}/{{ .Values.certificate.pkcsMangler.certificateSecret.keyName }} -in {{ .Values.certificate.pkcsMangler.certificateSecret.volume.mountPath }}/{{ .Values.certificate.pkcsMangler.certificateSecret.crtName }}; chmod 0444 /shared/cert.pfx"] + env: + - name: "PKCSMANGLER_PFXPASSWORD" + valueFrom: + secretKeyRef: + name: {{ .Values.certificate.pkcsMangler.pfxPassword.secretName }} + key: {{ .Values.certificate.pkcsMangler.pfxPassword.passwordKey }} + volumeMounts: + - name: shared + mountPath: /shared + - name: {{ .Values.certificate.pkcsMangler.certificateSecret.volume.name }} + mountPath: {{ .Values.certificate.pkcsMangler.certificateSecret.volume.mountPath }} + {{- end }} + {{- end }} + containers: + {{- if .Values.logging.promtail.enabled }} + - name: {{ .Chart.Name }}-promtail + image: "{{ .Values.logging.promtail.image.repository }}:{{ .Values.logging.promtail.image.tag }}" + imagePullPolicy: {{ .Values.logging.promtail.image.pullPolicy }} + args: + - -config.file=/etc/promtail/promtail.yaml + volumeMounts: + - name: promtail-config + mountPath: /etc/promtail/promtail.yaml + subPath: promtail.yaml + readOnly: true + - name: shared-logs + mountPath: /plex-logs + {{- end }} + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: pms + protocol: TCP + containerPort: 32400 + - name: plex-dlna + protocol: TCP + containerPort: 32469 + - name: plex-dlna-udp + protocol: UDP + containerPort: 1900 + - name: plex-gdm1 + protocol: UDP + containerPort: 32410 + - name: plex-gdm2 + protocol: UDP + containerPort: 32412 + - name: plex-gdm3 + protocol: UDP + containerPort: 32413 + - name: plex-gdm4 + protocol: UDP + containerPort: 32414 + env: + - name: TZ + value: "{{ .Values.timezone }}" + # TODO: move this to a secret? + - name: PLEX_CLAIM + value: "{{ .Values.claimToken }}" + # plex env vars + - name: PMS_INTERNAL_ADDRESS + value: http://{{ template "plex.fullname" . }}:32400 + - name: PMS_IMAGE + value: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + - name: KUBE_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: TRANSCODE_PVC + {{- if .Values.persistence.transcode.claimName }} + value: "{{ .Values.persistence.transcode.claimName }}" + {{- else }} + value: "{{ template "plex.fullname" . }}-transcode" + {{- end }} + {{- if .Values.persistence.data.enabled }} + - name: DATA_PVC + {{- if .Values.persistence.data.claimName }} + value: "{{ .Values.persistence.data.claimName }}" + {{- else }} + value: "{{ template "plex.fullname" . }}-data" + {{- end }} + {{- end }} + - name: CONFIG_PVC + {{- if .Values.persistence.config.claimName }} + value: "{{ .Values.persistence.config.claimName }}" + {{- else }} + value: "{{ template "plex.fullname" . }}-config" + {{- end }} + {{- if .Values.proxy.enabled }} + {{- if .Values.proxy.http }} + - name: "HTTP_PROXY" + value: "{{.Values.proxy.http}}" + {{- end }} + {{- if .Values.proxy.https }} + - name: "HTTPS_PROXY" + value: "{{.Values.proxy.https}}" + {{- end }} + {{- if .Values.proxy.noproxy }} + - name: "NO_PROXY" + value: "{{.Values.proxy.noproxy}}" + {{- end }} + {{- end }} + {{- if .Values.advertiseIp }} + - name: "ADVERTISE_IP" + value: "{{.Values.advertiseIp}}" +{{- end }} +{{- if .Values.changeConfigDirOwnership }} + - name: "CHANGE_CONFIG_DIR_OWNERSHIP" + value: "{{.Values.changeConfigDirOwnership}}" +{{- end }} +{{- if .Values.allowedNetworks }} + - name: "ALLOWED_NETWORKS" + value: "{{include "joinListWithComma" .Values.allowedNetworks}}" +{{- end }} +{{- if .Values.plexUid }} + - name: "PLEX_UID" + value: "{{.Values.plexUid}}" +{{- end }} +{{- if .Values.plexGid }} + - name: "PLEX_GID" + value: "{{.Values.plexGid}}" +{{- end }} +# Extra ENV Values supplied by user +{{- range $key, $value := .Values.extraEnv }} + - name: {{ $key }} + value: {{ $value }} +{{- end }} +# This is part of pkcsMangler +{{- if .Values.certificate.pkcsMangler.enabled }} + - name: "PKCSMANGLER_PFXINCONTAINERPATH" + value: "{{.Values.certificate.pkcsMangler.pfxInContainerPath}}" +{{- if .Values.certificate.pkcsMangler.setPlexPreferences.enabled }} + - name: "PKCSMANGLER_PFXPASSWORD" + valueFrom: + secretKeyRef: + name: {{ .Values.certificate.pkcsMangler.pfxPassword.secretName }} + key: {{ .Values.certificate.pkcsMangler.pfxPassword.passwordKey }} + - name: "PKCSMANGLER_CUSTOMCERTDOMAIN" + value: "customCertificateDomain={{.Values.certificate.pkcsMangler.setPlexPreferences.customCertificateDomain}}" +{{- end }} +{{- end }} + readinessProbe: + httpGet: + path: /identity + port: 32400 + failureThreshold: {{ .Values.probes.readiness.failureThreshold }} + periodSeconds: {{ .Values.probes.readiness.periodSeconds }} + livenessProbe: + httpGet: + path: /identity + port: 32400 + failureThreshold: {{ .Values.probes.liveness.failureThreshold }} + periodSeconds: {{ .Values.probes.liveness.periodSeconds }} + startupProbe: + httpGet: + path: /identity + port: 32400 + initialDelaySeconds: {{ .Values.probes.startup.initialDelaySeconds }} + failureThreshold: {{ .Values.probes.startup.failureThreshold }} + periodSeconds: {{ .Values.probes.startup.periodSeconds }} + volumeMounts: + {{- if .Values.persistence.data.enabled }} + - name: data + mountPath: /data + {{- if .Values.persistence.data.subPath }} + subPath: {{ .Values.persistence.data.subPath }} + {{ end }} + {{ end }} + - name: config + mountPath: /config + {{- if .Values.persistence.config.subPath }} + subPath: {{ .Values.persistence.config.subPath }} + {{ end }} + - name: transcode + mountPath: /transcode + {{- if .Values.persistence.transcode.subPath }} + subPath: {{ .Values.persistence.transcode.subPath }} + {{ end }} + {{- range .Values.persistence.extraData }} + - mountPath: "/data-{{ .name }}" + {{- if .subPath }} + subPath: {{ .subPath }} + {{ end }} + name: "extradata-{{ .name }}" + {{- end }} + {{- range .Values.persistence.extraMounts }} + {{- if .mountPath }} + - mountPath: /{{ .mountPath }} + {{- else }} + - mountPath: /{{ .name }} + {{- end }} + {{- if .subPath }} + subPath: {{ .subPath }} + {{ end }} + name: {{ .name }} + {{- end }} + - name: shared + mountPath: /shared + - name: shared-logs + mountPath: "/config/Library/Application Support/Plex Media Server/Logs" + {{- if .Values.plexPreferences.enabled }} + - name: {{ .Values.plexPreferences.volume.name }} + mountPath: {{ .Values.plexPreferences.volume.mountPath }} + subPath: {{ .Values.plexPreferences.volume.subPath }} + {{- end }} + {{- if .Values.certificate.pkcsMangler.enabled }} + - name: {{ .Values.certificate.pkcsMangler.volume.name }} + mountPath: {{ .Values.certificate.pkcsMangler.volume.mountPath }} + subPath: {{ .Values.certificate.pkcsMangler.volume.subPath }} + {{- end }} + resources: + {{- toYaml .Values.resources | nindent 12 }} +##### VOLUMES START ##### + volumes: +{{- if .Values.persistence.data.enabled }} + - name: data + persistentVolumeClaim: + {{- if .Values.persistence.data.claimName }} + claimName: "{{ .Values.persistence.data.claimName }}" + {{- else }} + claimName: "{{ template "plex.fullname" . }}-data" + {{- end }} +{{- end }} + - name: config + persistentVolumeClaim: +{{- if .Values.persistence.config.claimName }} + claimName: "{{ .Values.persistence.config.claimName }}" +{{- else }} + claimName: "{{ template "plex.fullname" . }}-config" +{{- end }} + - name: transcode +{{- if .Values.persistence.transcode.enabled }} + persistentVolumeClaim: +{{- if .Values.persistence.transcode.claimName }} + claimName: "{{ .Values.persistence.transcode.claimName }}" +{{- else }} + claimName: "{{ template "plex.fullname" . }}-transcode" +{{- end }} +{{- else }} +{{- if .Values.persistence.transcode.emptyDir.medium }} + emptyDir: + medium: "{{ .Values.persistence.transcode.emptyDir.medium }}" +{{- else }} + emptyDir: {} +{{- end }} +{{- end }} +{{- range .Values.persistence.extraData }} + - name: "extradata-{{ .name }}" + persistentVolumeClaim: +{{- if .claimName }} + claimName: "{{ .claimName }}" +{{- else }} + claimName: "extradata-{{ .name }}" +{{- end }} +{{- end }} +{{- range .Values.persistence.extraMounts }} + {{- if .claimName }} + - name: {{ .name }} + persistentVolumeClaim: + claimName: {{ .claimName }} + {{- end }} +{{- end }} + - name: shared + emptyDir: {} + - name: shared-logs + emptyDir: {} + {{- if .Values.plexPreferences.enabled }} + - name: {{ .Values.plexPreferences.volume.name }} + configMap: + name: {{ .Values.plexPreferences.configmap.name }} + defaultMode: {{ .Values.plexPreferences.volume.defaultMode }} + {{- end }} + {{- if .Values.certificate.pkcsMangler.enabled }} + - name: {{ .Values.certificate.pkcsMangler.volume.name }} + configMap: + name: {{ .Values.certificate.pkcsMangler.configmap.name }} + defaultMode: {{ .Values.certificate.pkcsMangler.volume.defaultMode }} + - name: {{ .Values.certificate.pkcsMangler.certificateSecret.volume.name }} + secret: + secretName: {{ .Values.certificate.pkcsMangler.certificateSecret.name }} + {{- end }} + {{- if .Values.logging.promtail.enabled }} + - name: promtail-config + projected: + defaultMode: 0444 + sources: + - configMap: + name: {{ template "plex.fullname" . }}-promtail + items: + - key: promtail.yaml + path: promtail.yaml + {{- end }} +##### VOLUMES END ##### + {{- 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/test/plex/templates/ingress.yaml b/test/plex/templates/ingress.yaml new file mode 100644 index 00000000000..b151840237a --- /dev/null +++ b/test/plex/templates/ingress.yaml @@ -0,0 +1,40 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "plex.fullname" . -}} +{{- $svcPort := .Values.serviceTCP.port -}} +{{- $ingressPath := .Values.ingress.path -}} +{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "plex.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ . | quote }} + http: + paths: + - path: {{ $ingressPath }} + backend: + serviceName: {{ $fullName }}-tcp + servicePort: {{ $svcPort }} + {{- end }} +{{- end }} diff --git a/test/plex/templates/promtail-configmap.yaml b/test/plex/templates/promtail-configmap.yaml new file mode 100644 index 00000000000..c64e102bcfa --- /dev/null +++ b/test/plex/templates/promtail-configmap.yaml @@ -0,0 +1,36 @@ +{{- if .Values.logging.promtail.enabled }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "plex.fullname" . }}-promtail + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/name: {{ include "plex.name" . }} + helm.sh/chart: {{ include "plex.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +data: + promtail.yaml: | + server: + http_listen_port: 9080 + grpc_listen_port: 0 + positions: + filename: /tmp/positions.yaml + clients: + - url: {{ .Values.logging.promtail.loki.url }} + scrape_configs: + - job_name: plex-logs + static_configs: + - targets: + - localhost + labels: + job: plex-logs + __path__: "/plex-logs/*.log" + - job_name: plex-plugin-logs + static_configs: + - targets: + - localhost + labels: + job: plex-plugin-logs + __path__: "/plex-logs/PMS Plugin Logs/*.log" +{{- end }} diff --git a/test/plex/templates/secrets.yaml b/test/plex/templates/secrets.yaml new file mode 100644 index 00000000000..6f838fcde54 --- /dev/null +++ b/test/plex/templates/secrets.yaml @@ -0,0 +1,18 @@ +{{- if .Values.certificate.pkcsMangler.enabled -}} +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Values.certificate.pkcsMangler.pfxPassword.secretName }} + labels: + {{- include "plex.labels" . | nindent 4 }} +{{- if .Values.certificate.pkcsMangler.pfxPassword.labels }} +{{ toYaml .Values.certificate.pkcsMangler.pfxPassword.labels | indent 4 }} +{{- end }} +{{- with .Values.certificate.pkcsMangler.pfxPassword.annotations }} + annotations: +{{ toYaml . | indent 4 }} +{{- end }} +type: Opaque +stringData: + {{ .Values.certificate.pkcsMangler.pfxPassword.passwordKey }}: {{ .Values.certificate.pkcsMangler.pfxPassword.value }} +{{- end -}} \ No newline at end of file diff --git a/test/plex/templates/service-tcp.yaml b/test/plex/templates/service-tcp.yaml new file mode 100644 index 00000000000..f8e1be4b433 --- /dev/null +++ b/test/plex/templates/service-tcp.yaml @@ -0,0 +1,57 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "plex.fullname" . }}-tcp + labels: + {{- include "plex.labels" . | nindent 4 }} +{{- if .Values.serviceTCP.labels }} +{{ toYaml .Values.serviceTCP.labels | indent 4 }} +{{- end }} +{{- with .Values.serviceTCP.annotations }} + annotations: +{{ toYaml . | indent 4 }} +{{- end }} +spec: +{{- if (or (eq .Values.serviceTCP.type "ClusterIP") (empty .Values.serviceTCP.type)) }} + type: ClusterIP + {{- if .Values.serviceTCP.clusterIP }} + clusterIP: {{ .Values.serviceTCP.clusterIP }} + {{end}} +{{- else if eq .Values.serviceTCP.type "LoadBalancer" }} + type: {{ .Values.serviceTCP.type }} + {{- if .Values.serviceTCP.loadBalancerIP }} + loadBalancerIP: {{ .Values.serviceTCP.loadBalancerIP }} + {{- end }} + {{- if .Values.serviceTCP.loadBalancerSourceRanges }} + loadBalancerSourceRanges: +{{ toYaml .Values.serviceTCP.loadBalancerSourceRanges | indent 4 }} + {{- end -}} +{{- else }} + type: {{ .Values.serviceTCP.type }} +{{- end }} +{{- if .Values.serviceTCP.externalIPs }} + externalIPs: +{{ toYaml .Values.serviceTCP.externalIPs | indent 4 }} +{{- end }} + {{- if .Values.serviceTCP.externalTrafficPolicy }} + externalTrafficPolicy: {{ .Values.serviceTCP.externalTrafficPolicy }} + {{- end }} + ports: + - name: pms + port: {{ .Values.serviceTCP.port }} + protocol: TCP + targetPort: pms +{{ if (and (eq .Values.serviceTCP.type "NodePort") (not (empty .Values.serviceTCP.nodePort))) }} + nodePort: {{.Values.serviceTCP.nodePort}} +{{ end }} + - name: http + port: 80 + targetPort: pms + - name: https + port: 443 + targetPort: pms + - name: plex-dlna + port: 1900 + targetPort: plex-dlna + selector: + {{- include "plex.selectorLabels" . | nindent 4 }} diff --git a/test/plex/templates/service-udp.yaml b/test/plex/templates/service-udp.yaml new file mode 100644 index 00000000000..c4f07ab9be8 --- /dev/null +++ b/test/plex/templates/service-udp.yaml @@ -0,0 +1,61 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "plex.fullname" . }}-udp + labels: + {{- include "plex.labels" . | nindent 4 }} +{{- if .Values.serviceUDP.labels }} +{{ toYaml .Values.serviceUDP.labels | indent 4 }} +{{- end }} +{{- with .Values.serviceUDP.annotations }} + annotations: +{{ toYaml . | indent 4 }} +{{- end }} +spec: +{{- if (or (eq .Values.serviceUDP.type "ClusterIP") (empty .Values.serviceUDP.type)) }} + type: ClusterIP + {{- if .Values.serviceUDP.clusterIP }} + clusterIP: {{ .Values.serviceUDP.clusterIP }} + {{end}} +{{- else if eq .Values.serviceUDP.type "LoadBalancer" }} + type: {{ .Values.serviceUDP.type }} + {{- if .Values.serviceUDP.loadBalancerIP }} + loadBalancerIP: {{ .Values.serviceUDP.loadBalancerIP }} + {{- end }} + {{- if .Values.serviceUDP.loadBalancerSourceRanges }} + loadBalancerSourceRanges: +{{ toYaml .Values.serviceUDP.loadBalancerSourceRanges | indent 4 }} + {{- end -}} +{{- else }} + type: {{ .Values.serviceUDP.type }} +{{- end }} +{{- if .Values.serviceUDP.externalIPs }} + externalIPs: +{{ toYaml .Values.serviceUDP.externalIPs | indent 4 }} +{{- end }} + {{- if .Values.serviceUDP.externalTrafficPolicy }} + externalTrafficPolicy: {{ .Values.serviceUDP.externalTrafficPolicy }} + {{- end }} + ports: + - name: plex-dlna-udp + port: 1900 + protocol: UDP + targetPort: plex-dlna-udp + - name: plex-gdm1 + port: 32410 + protocol: UDP + targetPort: plex-gdm1 + - name: plex-gdm2 + port: 32412 + protocol: UDP + targetPort: plex-gdm2 + - name: plex-gdm3 + port: 32413 + protocol: UDP + targetPort: plex-gdm3 + - name: plex-gdm4 + port: 32414 + protocol: UDP + targetPort: plex-gdm4 + selector: + {{- include "plex.selectorLabels" . | nindent 4 }} diff --git a/test/plex/templates/volumes.yaml b/test/plex/templates/volumes.yaml new file mode 100644 index 00000000000..58c16dd9979 --- /dev/null +++ b/test/plex/templates/volumes.yaml @@ -0,0 +1,57 @@ +{{- if and (not .Values.persistence.transcode.claimName) .Values.persistence.transcode.enabled }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ template "plex.fullname" . }}-transcode + labels: + {{- include "plex.labels" . | nindent 4 }} + component: transcode +spec: + accessModes: + - {{ .Values.persistence.config.accessMode | quote }} + resources: + requests: + storage: {{ .Values.persistence.transcode.size | quote }} +{{- if .Values.persistence.transcode.storageClass }} + storageClassName: {{ .Values.persistence.transcode.storageClass | quote }} +{{- end }} +--- +{{- end }} +{{- if not .Values.persistence.config.claimName }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ template "plex.fullname" . }}-config + labels: + {{- include "plex.labels" . | nindent 4 }} + component: config +spec: + accessModes: + - {{ .Values.persistence.config.accessMode | quote }} + resources: + requests: + storage: {{ .Values.persistence.config.size | quote }} +{{- if .Values.persistence.config.storageClass }} + storageClassName: {{ .Values.persistence.config.storageClass | quote }} +{{- end }} +--- +{{- end }} +{{- if and (not .Values.persistence.data.claimName) .Values.persistence.data.enabled }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ template "plex.fullname" . }}-data + labels: + {{- include "plex.labels" . | nindent 4 }} + component: data +spec: + accessModes: + - {{ .Values.persistence.data.accessMode | quote }} + resources: + requests: + storage: {{ .Values.persistence.data.size | quote }} +{{- if .Values.persistence.data.storageClass }} + storageClassName: {{ .Values.persistence.data.storageClass | quote }} +{{- end }} +--- +{{- end }} diff --git a/test/plex/values.yaml b/test/plex/values.yaml new file mode 100644 index 00000000000..1a7ecdffb53 --- /dev/null +++ b/test/plex/values.yaml @@ -0,0 +1,349 @@ +# Default values +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +# The Image to use for PLEX + +image: + repository: plexinc/pms-docker + tag: 1.20.2.3402-0fec14d92 + pullPolicy: IfNotPresent + +##### START --> Official PLEX container environment variables +# Override this with the plex claim token from plex.tv/claim +claimToken: "" + +# Set the timezone of the plex server +timezone: "UTC" + +# add your pod network subnet to the `List of IP addresses and networks that are allowed without auth` +# This will override the manual settings, so only use this if you will not need to change it manually. +# This list will be automatically converted to a command seperated string when passed to the container. +# You would specify this when using helm CLI with --set allowedNetworks="{127.0.0.1,10.54.2.0/24}" +# allowedNetworks: +# - 127.0.0.1 +# - 10.54.2.0/24 + +# Instruct the Plex Media Server Container to Change the Configuration Directory Ownership +# Default is true, you would only need to set this if you want to disable it. +# changeConfigDirOwnership: true + +# advertiseIp This variable defines the additional IPs on which the server may be be found. +# For example: http://10.1.1.23:32400. +# This adds to the list where the server advertises that it can be found. +# See https://hub.docker.com/r/plexinc/pms-docker/ for details +# advertiseIp: "http://10.1.1.23:32400" + +# Set The user id of the plex user created inside the container. +# See https://hub.docker.com/r/plexinc/pms-docker/ for details +# plexUid: 1000 + +# Set The group id of the plex group created inside the container +# See https://hub.docker.com/r/plexinc/pms-docker/ for details +# plexGid: 1000 + +##### END --> Official PLEX container environment variables + +# You can add as many Additional ENV variables here +# The following is the same as --set extraEnv.TMPDIR="/transcode" +# extraEnv: +# TMPDIR: /transcode + +# upgrade strategy type (e.g. Recreate or RollingUpdate) +strategyType: Recreate + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +serviceTCP: + type: ClusterIP + port: 32400 + ## Specify the nodePort value for the LoadBalancer and NodePort service types. + ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport + ## + # nodePort: + ## Provide any additional annotations which may be required. This can be used to + ## set the LoadBalancer service type to internal only. + ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer + ## + annotations: {} + # metallb.universe.tf/allow-shared-ip: plex-svc + labels: {} + ## Use loadBalancerIP to request a specific static IP, + ## otherwise leave blank + ## + loadBalancerIP: + # loadBalancerSourceRanges: [] + ## Set the externalTrafficPolicy in the Service to either Cluster or Local + # externalTrafficPolicy: Cluster + +serviceUDP: + type: ClusterIP + ## Provide any additional annotations which may be required. This can be used to + ## set the LoadBalancer service type to internal only. + ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer + ## + annotations: {} + # metallb.universe.tf/allow-shared-ip: plex-svc + labels: {} + ## Use loadBalancerIP to request a specific static IP, + ## otherwise leave blank + ## + loadBalancerIP: + # loadBalancerSourceRanges: [] + ## Set the externalTrafficPolicy in the Service to either Cluster or Local + # externalTrafficPolicy: Cluster + +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + path: / + hosts: + - chart-example.local + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +plexPreferences: + # Enable init script that will read all environment variables starting with PLEX_PREFERENCE_ + # and take the value (of PLEX_PREFERENCE_) as the Key:Value option to set in Plex Preference.xml + # You can use extraEnv to add the addtional ENV's to the container. + # NOTE: Plex preference options are camelCase and CASE SENSITIVE! + # You can do horrible things to your PLEX configuration if you are not careful. + # --set extraEnv.PLEX_PREFERENCE_1="FriendlyName=plex-kubeernetes-test1" ` + # --set extraEnv.PLEX_PREFERENCE_2="EnableIPv6=0" ` + # --set extraEnv.PLEX_PREFERENCE_3="logDebug=0" ` + # --set extraEnv.PLEX_PREFERENCE_4="DisableTLSv1_0=1" ` + # --set extraEnv.PLEX_PREFERENCE_5="LanNetworksBandwidth=xxx.xxx.xxx.0/18\,xxx.xxx.xxx.0/24\,xxx.xxx.xxx.0/24" ` + # --set extraEnv.PLEX_PREFERENCE_6="TranscoderQuality=2" ` + # --set extraEnv.PLEX_PREFERENCE_7="TreatWanIpAsLocal=0" ` + # --set extraEnv.PLEX_PREFERENCE_8="TranscoderH264BackgroundPreset=fast" + # Why not use a single ENV? + # I thought using multiple environment variables would be less confusing + # It should work easily with CLI and value.yaml usage + # There is only minimal parsing required on the ENV value, as the only deliminator is = + # From what I can see, all the PLEX preferences that are NOT currently supported by the OFFICIAL + # Container are simple enough to work with this. + enabled: false + configmap: + labels: {} + annotations: {} + # Right now you can't really change this, additionally the configmap data is + # not configurable. + name: 41-plex-preferences + volume: + name: 41-plex-preferences + defaultMode: 493 # 0755 in octal permission notation + # Using mountPath & SubPath allow you to volume mount a configMap AS A FILE + # Unfortunately this also means that updates to the configMap are not automtically + # propagated to the file contents. But it's better then replacing the entire + # /etc/cont-init.d/ directory which is the "normal" behavior when doing volume + # mounts. + mountPath: /etc/cont-init.d/41-plex-preferences + subPath: 41-plex-preferences + +hostNetwork: false + +persistence: + transcode: + # We want to enable a transcode pvc + enabled: false + # Optionally specify claimName to manually override the PVC to be used for + # the transcode directory. If claimName is specified, storageClass and size + # are ignored. + ## claimName: "plex-transcode-pvc" + # Optionally specify a storage class to be used for the transcode directory. + # If not specified and claimName is not specified, the default storage + # class will be used. + storageClass: "" + # subPath: some-subpath + # The requested size of the volume to be used when creating a + # PersistentVolumeClaim. + size: 20Gi + # Access mode for this volume + accessMode: ReadWriteOnce + # If not using a transcode PVC, specify emptyDir.medium="Memory" to use a tmpfs (in-memory) + # Volume for /transcode. Warning! this will greatly increase the amount of memory the plex pod is using + # AND it will count toward any ram pod/namespace limits. Additionally all data will be lost if/when the + # pod is moved to another node. --set persistence.transcode.emptyDir.medium="Memory" ` + emptyDir: + medium: "" + # medium: "Memory" + + + data: + # We want to enable a data pvc + enabled: true + # Optionally specify claimName to manually override the PVC to be used for + # the data directory. If claimName is specified, storageClass and size are + # ignored. + ## claimName: "plex-data-pvc" + # Optionally specify a storage class to be used for the data directory. + # If not specified and claimName is not specified, the default storage + # class will be used. + storageClass: "" + # subPath: some-subpath + # The requested size of the volume to be used when creating a + # PersistentVolumeClaim. + size: 40Gi + # Access mode for this volume + accessMode: ReadWriteOnce + + extraData: [] + # Optionally specifify additional Data mounts. These will be mounted as + # /data-${name}. This should be in the same format as the above 'data', + # with the additional field 'name' + # - claimName: "special-tv" + # name: 'foo' + # subPath: optional/sub/path + + extraMounts: [] + ## Include additional claims that can be mounted inside the + ## pod. This is useful if you wish to use different paths with categories + ## Claim will me mounted as /{mountPath} if specified. If no {mountPath} is given, + ## mountPath will default to {name} + # - name: video + # # if claimName is specified the a new volume will mounted, if omitted the mount will be considered to be associated with one of the standard volumes (e.g data, config, transcode). + # # This useful to mount data to a different subPath + # claimName: optional-claim + # mountPath: /mnt/path/in/pod + # subPath: optional/sub/path + + config: + # Optionally specify claimName to manually override the PVC to be used for + # the config directory. If claimName is specified, storageClass and size + # are ignored. + ## claimName: "plex-config-pvc" + # Optionally specify a storage class to be used for the config directory. + # If not specified and claimName is not specified, the default storage + # class will be used. + # subPath: some-subpath + storageClass: "" + # The requested size of the volume to be used when creating a + # PersistentVolumeClaim. + size: 20Gi + # Access mode for this volume + accessMode: ReadWriteOnce + +# Certificate(s) in Plex +certificate: + # Assuming you have a kubernetes certificate secret (say from cert-manager) that has a tls.crt and tls.key but NO PFX! + # pkcsMangler to the rescue. The pkcsMangler part will add the supplied pfxPassword to a kubernetes secret + # This is so it's not in the clear in the YAML of the deployment in the kubernetes api. + # We will then use an OpenSSL init container to create a pfx file using the supplied secret (only available in container) + # Then we will use an init script (via configMap) to move the pfx file out of /shared (it's temporary storage) to + # the location specified in pfxInContainerPath. + pkcsMangler: + enabled: false + # The Image to use for pkcsMangler + image: + repository: tlsprint/openssl + tag: 1.1.1f + configmap: + labels: {} + annotations: {} + # Right now you can't really change this, additionally the configmap data is + # not configurable. + name: 42-pkcs-mangler + volume: + name: 42-pkcs-mangler + defaultMode: 493 # 0755 in octal permission notation + # Using mountPath & SubPath allow you to volume mount a configMap AS A FILE + # Unfortunately this also means that updates to the configMap are not automtically + # propagated to the file contents. But it's better then replacing the entire + # /etc/cont-init.d/ directory which is the "normal" behavior when doing volume + # mounts. + mountPath: /etc/cont-init.d/42-pkcs-mangler + subPath: 42-pkcs-mangler + setPlexPreferences: + enabled: true # Set Plex Preferences related to Certificates + customCertificateDomain: "" # If not empty, Set the Plex Preference customCertificateDomain + # Use spec.certificate.pkcsMangler.pfxPassword.value to Set the Plex Preference customCertificateKey + # Use spec.certificate.pkcsMangler.pfxInContainerPath to Set the Plex Preference customCertificatePath + pfxPassword: + value: "setpassword" + # We wlll create a Kubernetes Secret for spec.certificate.pkcsMangler.pfxPassword.value + # These are your options. + secretName: "plex-media-server-pfx-password" + passwordKey: "pfx-password" + labels: {} + annotations: {} + pfxInContainerPath: "/config/plex.pfx" # This is full path in the container pkcsMangler will copy the pfx file to + # This is the SSL Certificate Secret that will provide our crt and key file. If you used cert-manager to create + # the certificate, these defaults should work for you. This Secret (and volume details) are only used by the + # pkcsMangler Init Container. + certificateSecret: + name: "" + keyName: "tls.key" + crtName: "tls.crt" + volume: + name: plex-certs + mountPath: /etc/plex-certs + +# Logging configuration +logging: + promtail: + enabled: false + image: + repository: grafana/promtail + tag: 1.6.0 + pullPolicy: IfNotPresent + loki: + url: http://loki.logs.svc.cluster.local:3100/loki/api/v1/push + +# Probes configuration +probes: + liveness: + failureThreshold: 5 + periodSeconds: 10 + readiness: + failureThreshold: 5 + periodSeconds: 10 + startup: + initialDelaySeconds: 5 + failureThreshold: 30 + periodSeconds: 10 + +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: {} + +podAnnotations: {} + +deploymentAnnotations: {} + +proxy: + # This allows to set a proxy environment variable, which PMS uses to fetch the token and assets like movie cover + enabled: false + # http: "http://proxy:8080" + # https: "https://proxy:8080" + # noproxy: "localhost,127.0.0.1,10.96.0.0/12,10.244.0.0/12" From 3dcebe81c88d88fce6622740d4fa461876f9ba8c Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Sun, 6 Dec 2020 23:56:33 +0500 Subject: [PATCH 02/21] Remove owners file --- test/plex/OWNERS | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 test/plex/OWNERS diff --git a/test/plex/OWNERS b/test/plex/OWNERS deleted file mode 100644 index 51f8865259a..00000000000 --- a/test/plex/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -approvers: -- billimek -reviewers: -- billimek \ No newline at end of file From ac0caeb11e9af07fd7b59995ab499d3a82215d70 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Sun, 6 Dec 2020 23:57:39 +0500 Subject: [PATCH 03/21] Move plex to 2.1.0 version dir --- test/plex/{ => 2.1.0}/.helmignore | 0 test/plex/{ => 2.1.0}/Chart.yaml | 0 test/plex/{ => 2.1.0}/README.md | 0 test/plex/{ => 2.1.0}/configs/41-plex-preferences | 0 test/plex/{ => 2.1.0}/configs/42-pkcs-mangler | 0 test/plex/{ => 2.1.0}/templates/NOTES.txt | 0 test/plex/{ => 2.1.0}/templates/_helpers.tpl | 0 test/plex/{ => 2.1.0}/templates/configmap.yaml | 0 test/plex/{ => 2.1.0}/templates/deployment.yaml | 0 test/plex/{ => 2.1.0}/templates/ingress.yaml | 0 test/plex/{ => 2.1.0}/templates/promtail-configmap.yaml | 0 test/plex/{ => 2.1.0}/templates/secrets.yaml | 0 test/plex/{ => 2.1.0}/templates/service-tcp.yaml | 0 test/plex/{ => 2.1.0}/templates/service-udp.yaml | 0 test/plex/{ => 2.1.0}/templates/volumes.yaml | 0 test/plex/{ => 2.1.0}/values.yaml | 0 16 files changed, 0 insertions(+), 0 deletions(-) rename test/plex/{ => 2.1.0}/.helmignore (100%) rename test/plex/{ => 2.1.0}/Chart.yaml (100%) rename test/plex/{ => 2.1.0}/README.md (100%) rename test/plex/{ => 2.1.0}/configs/41-plex-preferences (100%) rename test/plex/{ => 2.1.0}/configs/42-pkcs-mangler (100%) rename test/plex/{ => 2.1.0}/templates/NOTES.txt (100%) rename test/plex/{ => 2.1.0}/templates/_helpers.tpl (100%) rename test/plex/{ => 2.1.0}/templates/configmap.yaml (100%) rename test/plex/{ => 2.1.0}/templates/deployment.yaml (100%) rename test/plex/{ => 2.1.0}/templates/ingress.yaml (100%) rename test/plex/{ => 2.1.0}/templates/promtail-configmap.yaml (100%) rename test/plex/{ => 2.1.0}/templates/secrets.yaml (100%) rename test/plex/{ => 2.1.0}/templates/service-tcp.yaml (100%) rename test/plex/{ => 2.1.0}/templates/service-udp.yaml (100%) rename test/plex/{ => 2.1.0}/templates/volumes.yaml (100%) rename test/plex/{ => 2.1.0}/values.yaml (100%) diff --git a/test/plex/.helmignore b/test/plex/2.1.0/.helmignore similarity index 100% rename from test/plex/.helmignore rename to test/plex/2.1.0/.helmignore diff --git a/test/plex/Chart.yaml b/test/plex/2.1.0/Chart.yaml similarity index 100% rename from test/plex/Chart.yaml rename to test/plex/2.1.0/Chart.yaml diff --git a/test/plex/README.md b/test/plex/2.1.0/README.md similarity index 100% rename from test/plex/README.md rename to test/plex/2.1.0/README.md diff --git a/test/plex/configs/41-plex-preferences b/test/plex/2.1.0/configs/41-plex-preferences similarity index 100% rename from test/plex/configs/41-plex-preferences rename to test/plex/2.1.0/configs/41-plex-preferences diff --git a/test/plex/configs/42-pkcs-mangler b/test/plex/2.1.0/configs/42-pkcs-mangler similarity index 100% rename from test/plex/configs/42-pkcs-mangler rename to test/plex/2.1.0/configs/42-pkcs-mangler diff --git a/test/plex/templates/NOTES.txt b/test/plex/2.1.0/templates/NOTES.txt similarity index 100% rename from test/plex/templates/NOTES.txt rename to test/plex/2.1.0/templates/NOTES.txt diff --git a/test/plex/templates/_helpers.tpl b/test/plex/2.1.0/templates/_helpers.tpl similarity index 100% rename from test/plex/templates/_helpers.tpl rename to test/plex/2.1.0/templates/_helpers.tpl diff --git a/test/plex/templates/configmap.yaml b/test/plex/2.1.0/templates/configmap.yaml similarity index 100% rename from test/plex/templates/configmap.yaml rename to test/plex/2.1.0/templates/configmap.yaml diff --git a/test/plex/templates/deployment.yaml b/test/plex/2.1.0/templates/deployment.yaml similarity index 100% rename from test/plex/templates/deployment.yaml rename to test/plex/2.1.0/templates/deployment.yaml diff --git a/test/plex/templates/ingress.yaml b/test/plex/2.1.0/templates/ingress.yaml similarity index 100% rename from test/plex/templates/ingress.yaml rename to test/plex/2.1.0/templates/ingress.yaml diff --git a/test/plex/templates/promtail-configmap.yaml b/test/plex/2.1.0/templates/promtail-configmap.yaml similarity index 100% rename from test/plex/templates/promtail-configmap.yaml rename to test/plex/2.1.0/templates/promtail-configmap.yaml diff --git a/test/plex/templates/secrets.yaml b/test/plex/2.1.0/templates/secrets.yaml similarity index 100% rename from test/plex/templates/secrets.yaml rename to test/plex/2.1.0/templates/secrets.yaml diff --git a/test/plex/templates/service-tcp.yaml b/test/plex/2.1.0/templates/service-tcp.yaml similarity index 100% rename from test/plex/templates/service-tcp.yaml rename to test/plex/2.1.0/templates/service-tcp.yaml diff --git a/test/plex/templates/service-udp.yaml b/test/plex/2.1.0/templates/service-udp.yaml similarity index 100% rename from test/plex/templates/service-udp.yaml rename to test/plex/2.1.0/templates/service-udp.yaml diff --git a/test/plex/templates/volumes.yaml b/test/plex/2.1.0/templates/volumes.yaml similarity index 100% rename from test/plex/templates/volumes.yaml rename to test/plex/2.1.0/templates/volumes.yaml diff --git a/test/plex/values.yaml b/test/plex/2.1.0/values.yaml similarity index 100% rename from test/plex/values.yaml rename to test/plex/2.1.0/values.yaml From 0f4dd3179070a4b2346821d6f0cc52b983fc1893 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Mon, 7 Dec 2020 00:09:39 +0500 Subject: [PATCH 04/21] Add item configuration file --- test/plex/item.yaml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 test/plex/item.yaml diff --git a/test/plex/item.yaml b/test/plex/item.yaml new file mode 100644 index 00000000000..697769c647e --- /dev/null +++ b/test/plex/item.yaml @@ -0,0 +1,2 @@ +categories: + - entertainment From 4983896378831b4ce2a8fea6e26a28c7414ea259 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Mon, 7 Dec 2020 00:18:28 +0500 Subject: [PATCH 05/21] Remove ingress config --- test/plex/2.1.0/templates/ingress.yaml | 40 -------------------------- 1 file changed, 40 deletions(-) delete mode 100644 test/plex/2.1.0/templates/ingress.yaml diff --git a/test/plex/2.1.0/templates/ingress.yaml b/test/plex/2.1.0/templates/ingress.yaml deleted file mode 100644 index b151840237a..00000000000 --- a/test/plex/2.1.0/templates/ingress.yaml +++ /dev/null @@ -1,40 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "plex.fullname" . -}} -{{- $svcPort := .Values.serviceTCP.port -}} -{{- $ingressPath := .Values.ingress.path -}} -{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} -apiVersion: networking.k8s.io/v1beta1 -{{- else -}} -apiVersion: extensions/v1beta1 -{{- end }} -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - {{- include "plex.labels" . | nindent 4 }} - {{- with .Values.ingress.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -spec: -{{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . | quote }} - {{- end }} - secretName: {{ .secretName }} - {{- end }} -{{- end }} - rules: - {{- range .Values.ingress.hosts }} - - host: {{ . | quote }} - http: - paths: - - path: {{ $ingressPath }} - backend: - serviceName: {{ $fullName }}-tcp - servicePort: {{ $svcPort }} - {{- end }} -{{- end }} From 4524d88bf68cf328d902293cd07476a4676607ae Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Mon, 7 Dec 2020 01:02:39 +0500 Subject: [PATCH 06/21] Add basic questions yaml --- test/plex/2.1.0/app-readme.md | 3 + test/plex/2.1.0/questions.yaml | 122 +++++++++++++++++++++++++++++++++ test/plex/2.1.0/values.yaml | 23 +------ 3 files changed, 127 insertions(+), 21 deletions(-) create mode 100644 test/plex/2.1.0/app-readme.md create mode 100644 test/plex/2.1.0/questions.yaml diff --git a/test/plex/2.1.0/app-readme.md b/test/plex/2.1.0/app-readme.md new file mode 100644 index 00000000000..f6fd499552a --- /dev/null +++ b/test/plex/2.1.0/app-readme.md @@ -0,0 +1,3 @@ +# Plex + +Plex is a chart designed to deploy plex in a TrueNAS SCALE kubernetes cluster. diff --git a/test/plex/2.1.0/questions.yaml b/test/plex/2.1.0/questions.yaml new file mode 100644 index 00000000000..112adaf709f --- /dev/null +++ b/test/plex/2.1.0/questions.yaml @@ -0,0 +1,122 @@ +groups: + - name: "Container Images" + description: "Image to be used for container" + - name: "Container Entrypoint" + description: "Configuration of the executable that will be run when the container is started" + - name: "Container Environment Variables" + description: "Set the environment that will be visible to the container" + - name: "Networking" + description: "Configure networking for container" + - name: "Storage" + description: "Persist and share data that is separate from the lifecycle of the container" + - name: "Plex Configuration" + description: "Configure plex deployment" + - name: "Workload Details" + description: "Configure how workload should be deployed" + - name: "Scaling/Upgrade Policy" + description: "Configure how pods are replaced when configuration is upgraded" + - name: "Restart Policy" + description: "Configure when pod should be restarted in case of failure" + - name: "Resource Reservation" + description: "Specify resources to be allocated to workload" + +questions: + # Image related + - variable: image + description: "Docker Image Details" + label: "Docker Image" + group: "Container Images" + schema: + type: dict + required: true + attrs: + - variable: repository + description: "Docker image repository" + label: "Image repository" + schema: + type: string + required: true + default: "plexinc/pms-docker" + - variable: tag + description: "Tag to use for specified image" + label: "Image Tag" + schema: + type: string + default: "1.20.2.3402-0fec14d92" + - variable: pullPolicy + description: "Docker Image Pull Policy" + label: "Image Pull Policy" + schema: + type: string + default: "IfNotPresent" + enum: + - value: "IfNotPresent" + description: "Only pull image if not present on host" + - value: "Always" + description: "Always pull image even if present on host" + - value: "Never" + description: "Never pull image even if it's not present on host" + + - variable: claimToken + label: "Plex Claim Token" + group: "Plex Configuration" + schema: + type: string + default: "" + + - variable: advertiseIp + label: "Plex Advertise IP" + group: "Plex Configuration" + schema: + type: string + + - variable: extraEnv + label: "Environment variables for plex" + group: "Plex Configuration" + schema: + type: dict + additional_attrs: true + + - variable: proxy + label: "Configure Proxy environment variable" + group: "Plex Configuration" + schema: + type: dict + attrs: + - variable: http + label: "HTTP Proxy" + schema: + type: string + - variable: https + label: "HTTPS Proxy" + schema: + type: string + + - variable: hostNetwork + label: "Configure Host Network" + group: "Networking" + schema: + type: boolean + default: false + + # TODO: Add timezone validation $ref + - variable: timezone + label: "Plex container timezone" + group: "Plex Configuration" + schema: + type: string + default: "UTC" + + # Update strategy + - variable: strategyType + description: "Upgrade Policy" + label: "Update Strategy" + group: "Scaling/Upgrade Policy" + schema: + type: string + default: "Recreate" + enum: + - value: "RollingUpdate" + description: "Create new pods and then kill old ones" + - value: "Recreate" + description: "Kill existing pods before creating new ones" diff --git a/test/plex/2.1.0/values.yaml b/test/plex/2.1.0/values.yaml index 1a7ecdffb53..088bbfd106e 100644 --- a/test/plex/2.1.0/values.yaml +++ b/test/plex/2.1.0/values.yaml @@ -68,7 +68,8 @@ securityContext: {} # runAsUser: 1000 serviceTCP: - type: ClusterIP + enabled: true + type: NodePort port: 32400 ## Specify the nodePort value for the LoadBalancer and NodePort service types. ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport @@ -81,13 +82,6 @@ serviceTCP: annotations: {} # metallb.universe.tf/allow-shared-ip: plex-svc labels: {} - ## Use loadBalancerIP to request a specific static IP, - ## otherwise leave blank - ## - loadBalancerIP: - # loadBalancerSourceRanges: [] - ## Set the externalTrafficPolicy in the Service to either Cluster or Local - # externalTrafficPolicy: Cluster serviceUDP: type: ClusterIP @@ -106,19 +100,6 @@ serviceUDP: ## Set the externalTrafficPolicy in the Service to either Cluster or Local # externalTrafficPolicy: Cluster -ingress: - enabled: false - annotations: {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" - path: / - hosts: - - chart-example.local - tls: [] - # - secretName: chart-example-tls - # hosts: - # - chart-example.local - plexPreferences: # Enable init script that will read all environment variables starting with PLEX_PREFERENCE_ # and take the value (of PLEX_PREFERENCE_) as the Key:Value option to set in Plex Preference.xml From db0ffe9d78da5f136064661b95894946b9595217 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Mon, 7 Dec 2020 01:49:22 +0500 Subject: [PATCH 07/21] Allow using host network for plex --- test/plex/2.1.0/templates/deployment.yaml | 3 +++ test/plex/2.1.0/templates/service-tcp.yaml | 29 +++------------------- test/plex/2.1.0/values.yaml | 1 - 3 files changed, 6 insertions(+), 27 deletions(-) diff --git a/test/plex/2.1.0/templates/deployment.yaml b/test/plex/2.1.0/templates/deployment.yaml index 3fcabb00045..ff563fc72b1 100644 --- a/test/plex/2.1.0/templates/deployment.yaml +++ b/test/plex/2.1.0/templates/deployment.yaml @@ -85,6 +85,9 @@ spec: - name: pms protocol: TCP containerPort: 32400 + {{- if .Values.hostNetwork }} + hostPort: {{ .Values.serviceTCP.port }} + {{- end }} - name: plex-dlna protocol: TCP containerPort: 32469 diff --git a/test/plex/2.1.0/templates/service-tcp.yaml b/test/plex/2.1.0/templates/service-tcp.yaml index f8e1be4b433..97dde110aa6 100644 --- a/test/plex/2.1.0/templates/service-tcp.yaml +++ b/test/plex/2.1.0/templates/service-tcp.yaml @@ -1,3 +1,4 @@ +{{- if eq .Values.hostNetwork false }} apiVersion: v1 kind: Service metadata: @@ -12,38 +13,13 @@ metadata: {{ toYaml . | indent 4 }} {{- end }} spec: -{{- if (or (eq .Values.serviceTCP.type "ClusterIP") (empty .Values.serviceTCP.type)) }} - type: ClusterIP - {{- if .Values.serviceTCP.clusterIP }} - clusterIP: {{ .Values.serviceTCP.clusterIP }} - {{end}} -{{- else if eq .Values.serviceTCP.type "LoadBalancer" }} - type: {{ .Values.serviceTCP.type }} - {{- if .Values.serviceTCP.loadBalancerIP }} - loadBalancerIP: {{ .Values.serviceTCP.loadBalancerIP }} - {{- end }} - {{- if .Values.serviceTCP.loadBalancerSourceRanges }} - loadBalancerSourceRanges: -{{ toYaml .Values.serviceTCP.loadBalancerSourceRanges | indent 4 }} - {{- end -}} -{{- else }} - type: {{ .Values.serviceTCP.type }} -{{- end }} -{{- if .Values.serviceTCP.externalIPs }} - externalIPs: -{{ toYaml .Values.serviceTCP.externalIPs | indent 4 }} -{{- end }} - {{- if .Values.serviceTCP.externalTrafficPolicy }} - externalTrafficPolicy: {{ .Values.serviceTCP.externalTrafficPolicy }} - {{- end }} + type: NodePort ports: - name: pms port: {{ .Values.serviceTCP.port }} protocol: TCP targetPort: pms -{{ if (and (eq .Values.serviceTCP.type "NodePort") (not (empty .Values.serviceTCP.nodePort))) }} nodePort: {{.Values.serviceTCP.nodePort}} -{{ end }} - name: http port: 80 targetPort: pms @@ -55,3 +31,4 @@ spec: targetPort: plex-dlna selector: {{- include "plex.selectorLabels" . | nindent 4 }} +{{- end }} diff --git a/test/plex/2.1.0/values.yaml b/test/plex/2.1.0/values.yaml index 088bbfd106e..3b08f896063 100644 --- a/test/plex/2.1.0/values.yaml +++ b/test/plex/2.1.0/values.yaml @@ -68,7 +68,6 @@ securityContext: {} # runAsUser: 1000 serviceTCP: - enabled: true type: NodePort port: 32400 ## Specify the nodePort value for the LoadBalancer and NodePort service types. From 769b45d4a43ee77b938edc3ca97ce3d98574de27 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Mon, 7 Dec 2020 01:54:40 +0500 Subject: [PATCH 08/21] Clean deployment and always roll pod in case of configuration change --- test/plex/2.1.0/templates/deployment.yaml | 82 +---------------------- test/plex/2.1.0/values.yaml | 11 --- 2 files changed, 1 insertion(+), 92 deletions(-) diff --git a/test/plex/2.1.0/templates/deployment.yaml b/test/plex/2.1.0/templates/deployment.yaml index ff563fc72b1..dc12830f552 100644 --- a/test/plex/2.1.0/templates/deployment.yaml +++ b/test/plex/2.1.0/templates/deployment.yaml @@ -4,12 +4,6 @@ metadata: name: {{ include "plex.fullname" . }} labels: {{- include "plex.labels" . | nindent 4 }} - {{- if .Values.deploymentAnnotations }} - annotations: - {{- range $key, $value := .Values.deploymentAnnotations }} - {{ $key }}: {{ $value | quote }} - {{- end }} - {{- end }} spec: replicas: 1 revisionHistoryLimit: 3 @@ -22,63 +16,15 @@ spec: metadata: labels: {{- include "plex.selectorLabels" . | nindent 8 }} - {{- if .Values.podAnnotations }} annotations: - {{- range $key, $value := .Values.podAnnotations }} - {{ $key }}: {{ $value | quote }} - {{- end }} - {{- end }} + rollme: {{ randAlphaNum 5 | quote }} spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} {{- if .Values.hostNetwork }} hostNetwork: {{ .Values.hostNetwork }} dnsPolicy: ClusterFirstWithHostNet {{- end }} - securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} - {{- if .Values.certificate.pkcsMangler.enabled }} - initContainers: - # This is ugly, but it does work to create a pks file that will work with PLEX from the tls.crt and tls.key that cert-manager normally creates - {{- if .Values.certificate.pkcsMangler.enabled }} - - name: pkcsmangler-init-container - image: "{{ .Values.certificate.pkcsMangler.image.repository }}:{{ .Values.certificate.pkcsMangler.image.tag }}" - imagePullPolicy: Always - command: ["/bin/sh"] - args: ["-c", "openssl pkcs12 -export -passout pass:$(PKCSMANGLER_PFXPASSWORD) -out /shared/cert.pfx -inkey {{ .Values.certificate.pkcsMangler.certificateSecret.volume.mountPath }}/{{ .Values.certificate.pkcsMangler.certificateSecret.keyName }} -in {{ .Values.certificate.pkcsMangler.certificateSecret.volume.mountPath }}/{{ .Values.certificate.pkcsMangler.certificateSecret.crtName }}; chmod 0444 /shared/cert.pfx"] - env: - - name: "PKCSMANGLER_PFXPASSWORD" - valueFrom: - secretKeyRef: - name: {{ .Values.certificate.pkcsMangler.pfxPassword.secretName }} - key: {{ .Values.certificate.pkcsMangler.pfxPassword.passwordKey }} - volumeMounts: - - name: shared - mountPath: /shared - - name: {{ .Values.certificate.pkcsMangler.certificateSecret.volume.name }} - mountPath: {{ .Values.certificate.pkcsMangler.certificateSecret.volume.mountPath }} - {{- end }} - {{- end }} containers: - {{- if .Values.logging.promtail.enabled }} - - name: {{ .Chart.Name }}-promtail - image: "{{ .Values.logging.promtail.image.repository }}:{{ .Values.logging.promtail.image.tag }}" - imagePullPolicy: {{ .Values.logging.promtail.image.pullPolicy }} - args: - - -config.file=/etc/promtail/promtail.yaml - volumeMounts: - - name: promtail-config - mountPath: /etc/promtail/promtail.yaml - subPath: promtail.yaml - readOnly: true - - name: shared-logs - mountPath: /plex-logs - {{- end }} - name: {{ .Chart.Name }} - securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} ports: @@ -179,20 +125,6 @@ spec: {{- range $key, $value := .Values.extraEnv }} - name: {{ $key }} value: {{ $value }} -{{- end }} -# This is part of pkcsMangler -{{- if .Values.certificate.pkcsMangler.enabled }} - - name: "PKCSMANGLER_PFXINCONTAINERPATH" - value: "{{.Values.certificate.pkcsMangler.pfxInContainerPath}}" -{{- if .Values.certificate.pkcsMangler.setPlexPreferences.enabled }} - - name: "PKCSMANGLER_PFXPASSWORD" - valueFrom: - secretKeyRef: - name: {{ .Values.certificate.pkcsMangler.pfxPassword.secretName }} - key: {{ .Values.certificate.pkcsMangler.pfxPassword.passwordKey }} - - name: "PKCSMANGLER_CUSTOMCERTDOMAIN" - value: "customCertificateDomain={{.Values.certificate.pkcsMangler.setPlexPreferences.customCertificateDomain}}" -{{- end }} {{- end }} readinessProbe: httpGet: @@ -346,15 +278,3 @@ spec: path: promtail.yaml {{- end }} ##### VOLUMES END ##### - {{- 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/test/plex/2.1.0/values.yaml b/test/plex/2.1.0/values.yaml index 3b08f896063..dc0b05b92f3 100644 --- a/test/plex/2.1.0/values.yaml +++ b/test/plex/2.1.0/values.yaml @@ -275,17 +275,6 @@ certificate: name: plex-certs mountPath: /etc/plex-certs -# Logging configuration -logging: - promtail: - enabled: false - image: - repository: grafana/promtail - tag: 1.6.0 - pullPolicy: IfNotPresent - loki: - url: http://loki.logs.svc.cluster.local:3100/loki/api/v1/push - # Probes configuration probes: liveness: From 0cf46c640059dd147dcace7a725f96fe7b679cc7 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Mon, 7 Dec 2020 01:57:13 +0500 Subject: [PATCH 09/21] Remove pkcs configuration from plex chart --- test/plex/2.1.0/configs/42-pkcs-mangler | 53 ------------- test/plex/2.1.0/templates/configmap.yaml | 42 ---------- test/plex/2.1.0/templates/deployment.yaml | 20 ----- .../2.1.0/templates/promtail-configmap.yaml | 36 --------- test/plex/2.1.0/templates/secrets.yaml | 18 ----- test/plex/2.1.0/values.yaml | 77 ------------------- 6 files changed, 246 deletions(-) delete mode 100644 test/plex/2.1.0/configs/42-pkcs-mangler delete mode 100644 test/plex/2.1.0/templates/configmap.yaml delete mode 100644 test/plex/2.1.0/templates/promtail-configmap.yaml delete mode 100644 test/plex/2.1.0/templates/secrets.yaml diff --git a/test/plex/2.1.0/configs/42-pkcs-mangler b/test/plex/2.1.0/configs/42-pkcs-mangler deleted file mode 100644 index 8a4fb1e2aa3..00000000000 --- a/test/plex/2.1.0/configs/42-pkcs-mangler +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/with-contenv bash - -# This file contains part of the official PLEX 40-plex-first-run -# Here: https://github.com/plexinc/pms-docker/blob/master/root/etc/cont-init.d/40-plex-first-run -# It should live in /etc/cont-init.d/ - -# If we are debugging, enable trace -if [ "${DEBUG,,}" = "true" ]; then - set -x -fi - -function setPref { - local key="$1" - local value="$2" - - count="$(xmlstarlet sel -t -v "count(/Preferences/@${key})" "${prefFile}")" - count=$(($count + 0)) - if [[ $count > 0 ]]; then - xmlstarlet ed --inplace --update "/Preferences/@${key}" -v "${value}" "${prefFile}" - else - xmlstarlet ed --inplace --insert "/Preferences" --type attr -n "${key}" -v "${value}" "${prefFile}" - fi -} - -home="$(echo ~plex)" -pmsApplicationSupportDir="${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR:-${home}/Library/Application Support}" -prefFile="${pmsApplicationSupportDir}/Plex Media Server/Preferences.xml" - -# If PKCSMANGLER__PFXINCONTAINERPATH is set, then assume we want to move the PFX Cert to that location -if [ ! -z "${PKCSMANGLER_PFXINCONTAINERPATH}" ]; then - # If it ends up a problem, we may need to set some kind of "don't replace existing PFX cert" - cp -f /shared/cert.pfx "${PKCSMANGLER_PFXINCONTAINERPATH}" - # If PKCSMANGLER__CUSTOMCERTDOMAIN is set, then assume we want to set the PLEX Preference customCertificatePath because we enabled setting PLEX Preferences - if [ ! -z "${PKCSMANGLER_CUSTOMCERTDOMAIN}" ]; then - setPref "customCertificatePath" "${PKCSMANGLER_PFXINCONTAINERPATH}" - fi -fi - -# If PKCSMANGLER_PFXPASSWORD is set, then assume we want to set the PLEX Preference customCertificateKey -if [ ! -z "${PKCSMANGLER_PFXPASSWORD}" ]; then - setPref "customCertificateKey" "${PKCSMANGLER_PFXPASSWORD}" -fi - -# If PKCSMANGLER__CUSTOMCERTDOMAIN is set, then assume we want to set the PLEX Preference customCertificateDomain -if [ ! -z "${PKCSMANGLER_CUSTOMCERTDOMAIN}" ]; then - PreferenceValue=${PKCSMANGLER_CUSTOMCERTDOMAIN#*=} - PreferenceKey=${PKCSMANGLER_CUSTOMCERTDOMAIN%=*} - setPref $PreferenceKey $PreferenceValue -fi - -# touch /.firstRunComplete -# echo "Plex Media Server first run setup complete" -echo "PKCS Mangler run complete" \ No newline at end of file diff --git a/test/plex/2.1.0/templates/configmap.yaml b/test/plex/2.1.0/templates/configmap.yaml deleted file mode 100644 index ff5b183c755..00000000000 --- a/test/plex/2.1.0/templates/configmap.yaml +++ /dev/null @@ -1,42 +0,0 @@ -{{- if .Values.plexPreferences.enabled -}} -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ .Values.plexPreferences.configmap.name }} - labels: - {{- include "plex.labels" . | nindent 4 }} -{{- if .Values.plexPreferences.configmap.labels }} -{{ toYaml .Values.plexPreferences.configmap.labels | indent 4 }} -{{- end }} -{{- with .Values.plexPreferences.configmap.annotations }} - annotations: -{{ toYaml . | indent 4 }} -{{- end }} - -data: -# At some point figure out how to use a value/Variable here to be able to specify -# a different file or something. -{{ (tpl (.Files.Glob "configs/41-plex-preferences").AsConfig . ) | indent 2 }} -{{- end -}} - -{{- if .Values.certificate.pkcsMangler.enabled }} ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ .Values.certificate.pkcsMangler.configmap.name }} - labels: - {{- include "plex.labels" . | nindent 4 }} -{{- if .Values.certificate.pkcsMangler.configmap.labels }} -{{ toYaml .Values.certificate.pkcsMangler.configmap.labels | indent 4 }} -{{- end }} -{{- with .Values.certificate.pkcsMangler.configmap.annotations }} - annotations: -{{ toYaml . | indent 4 }} -{{- end }} - -data: -# At some point figure out how to use a value/Variable here to be able to specify -# a different file or something. -{{ (tpl (.Files.Glob "configs/42-pkcs-mangler").AsConfig . ) | indent 2 }} -{{- end -}} \ No newline at end of file diff --git a/test/plex/2.1.0/templates/deployment.yaml b/test/plex/2.1.0/templates/deployment.yaml index dc12830f552..3e5c29a4f8e 100644 --- a/test/plex/2.1.0/templates/deployment.yaml +++ b/test/plex/2.1.0/templates/deployment.yaml @@ -257,24 +257,4 @@ spec: name: {{ .Values.plexPreferences.configmap.name }} defaultMode: {{ .Values.plexPreferences.volume.defaultMode }} {{- end }} - {{- if .Values.certificate.pkcsMangler.enabled }} - - name: {{ .Values.certificate.pkcsMangler.volume.name }} - configMap: - name: {{ .Values.certificate.pkcsMangler.configmap.name }} - defaultMode: {{ .Values.certificate.pkcsMangler.volume.defaultMode }} - - name: {{ .Values.certificate.pkcsMangler.certificateSecret.volume.name }} - secret: - secretName: {{ .Values.certificate.pkcsMangler.certificateSecret.name }} - {{- end }} - {{- if .Values.logging.promtail.enabled }} - - name: promtail-config - projected: - defaultMode: 0444 - sources: - - configMap: - name: {{ template "plex.fullname" . }}-promtail - items: - - key: promtail.yaml - path: promtail.yaml - {{- end }} ##### VOLUMES END ##### diff --git a/test/plex/2.1.0/templates/promtail-configmap.yaml b/test/plex/2.1.0/templates/promtail-configmap.yaml deleted file mode 100644 index c64e102bcfa..00000000000 --- a/test/plex/2.1.0/templates/promtail-configmap.yaml +++ /dev/null @@ -1,36 +0,0 @@ -{{- if .Values.logging.promtail.enabled }} -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ template "plex.fullname" . }}-promtail - namespace: {{ .Release.Namespace }} - labels: - app.kubernetes.io/name: {{ include "plex.name" . }} - helm.sh/chart: {{ include "plex.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} -data: - promtail.yaml: | - server: - http_listen_port: 9080 - grpc_listen_port: 0 - positions: - filename: /tmp/positions.yaml - clients: - - url: {{ .Values.logging.promtail.loki.url }} - scrape_configs: - - job_name: plex-logs - static_configs: - - targets: - - localhost - labels: - job: plex-logs - __path__: "/plex-logs/*.log" - - job_name: plex-plugin-logs - static_configs: - - targets: - - localhost - labels: - job: plex-plugin-logs - __path__: "/plex-logs/PMS Plugin Logs/*.log" -{{- end }} diff --git a/test/plex/2.1.0/templates/secrets.yaml b/test/plex/2.1.0/templates/secrets.yaml deleted file mode 100644 index 6f838fcde54..00000000000 --- a/test/plex/2.1.0/templates/secrets.yaml +++ /dev/null @@ -1,18 +0,0 @@ -{{- if .Values.certificate.pkcsMangler.enabled -}} -apiVersion: v1 -kind: Secret -metadata: - name: {{ .Values.certificate.pkcsMangler.pfxPassword.secretName }} - labels: - {{- include "plex.labels" . | nindent 4 }} -{{- if .Values.certificate.pkcsMangler.pfxPassword.labels }} -{{ toYaml .Values.certificate.pkcsMangler.pfxPassword.labels | indent 4 }} -{{- end }} -{{- with .Values.certificate.pkcsMangler.pfxPassword.annotations }} - annotations: -{{ toYaml . | indent 4 }} -{{- end }} -type: Opaque -stringData: - {{ .Values.certificate.pkcsMangler.pfxPassword.passwordKey }}: {{ .Values.certificate.pkcsMangler.pfxPassword.value }} -{{- end -}} \ No newline at end of file diff --git a/test/plex/2.1.0/values.yaml b/test/plex/2.1.0/values.yaml index dc0b05b92f3..d73d2db23c8 100644 --- a/test/plex/2.1.0/values.yaml +++ b/test/plex/2.1.0/values.yaml @@ -220,61 +220,6 @@ persistence: # Access mode for this volume accessMode: ReadWriteOnce -# Certificate(s) in Plex -certificate: - # Assuming you have a kubernetes certificate secret (say from cert-manager) that has a tls.crt and tls.key but NO PFX! - # pkcsMangler to the rescue. The pkcsMangler part will add the supplied pfxPassword to a kubernetes secret - # This is so it's not in the clear in the YAML of the deployment in the kubernetes api. - # We will then use an OpenSSL init container to create a pfx file using the supplied secret (only available in container) - # Then we will use an init script (via configMap) to move the pfx file out of /shared (it's temporary storage) to - # the location specified in pfxInContainerPath. - pkcsMangler: - enabled: false - # The Image to use for pkcsMangler - image: - repository: tlsprint/openssl - tag: 1.1.1f - configmap: - labels: {} - annotations: {} - # Right now you can't really change this, additionally the configmap data is - # not configurable. - name: 42-pkcs-mangler - volume: - name: 42-pkcs-mangler - defaultMode: 493 # 0755 in octal permission notation - # Using mountPath & SubPath allow you to volume mount a configMap AS A FILE - # Unfortunately this also means that updates to the configMap are not automtically - # propagated to the file contents. But it's better then replacing the entire - # /etc/cont-init.d/ directory which is the "normal" behavior when doing volume - # mounts. - mountPath: /etc/cont-init.d/42-pkcs-mangler - subPath: 42-pkcs-mangler - setPlexPreferences: - enabled: true # Set Plex Preferences related to Certificates - customCertificateDomain: "" # If not empty, Set the Plex Preference customCertificateDomain - # Use spec.certificate.pkcsMangler.pfxPassword.value to Set the Plex Preference customCertificateKey - # Use spec.certificate.pkcsMangler.pfxInContainerPath to Set the Plex Preference customCertificatePath - pfxPassword: - value: "setpassword" - # We wlll create a Kubernetes Secret for spec.certificate.pkcsMangler.pfxPassword.value - # These are your options. - secretName: "plex-media-server-pfx-password" - passwordKey: "pfx-password" - labels: {} - annotations: {} - pfxInContainerPath: "/config/plex.pfx" # This is full path in the container pkcsMangler will copy the pfx file to - # This is the SSL Certificate Secret that will provide our crt and key file. If you used cert-manager to create - # the certificate, these defaults should work for you. This Secret (and volume details) are only used by the - # pkcsMangler Init Container. - certificateSecret: - name: "" - keyName: "tls.key" - crtName: "tls.crt" - volume: - name: plex-certs - mountPath: /etc/plex-certs - # Probes configuration probes: liveness: @@ -288,28 +233,6 @@ probes: failureThreshold: 30 periodSeconds: 10 -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: {} - -podAnnotations: {} - -deploymentAnnotations: {} - proxy: # This allows to set a proxy environment variable, which PMS uses to fetch the token and assets like movie cover enabled: false From 883fb239bd64a0b2a53cc7011a644e64a4ad4ca6 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Mon, 7 Dec 2020 02:03:04 +0500 Subject: [PATCH 10/21] Clean udp service --- test/plex/2.1.0/templates/service-udp.yaml | 30 ---------------- test/plex/2.1.0/values.yaml | 41 ---------------------- 2 files changed, 71 deletions(-) diff --git a/test/plex/2.1.0/templates/service-udp.yaml b/test/plex/2.1.0/templates/service-udp.yaml index c4f07ab9be8..e13ae5658a8 100644 --- a/test/plex/2.1.0/templates/service-udp.yaml +++ b/test/plex/2.1.0/templates/service-udp.yaml @@ -4,38 +4,8 @@ metadata: name: {{ include "plex.fullname" . }}-udp labels: {{- include "plex.labels" . | nindent 4 }} -{{- if .Values.serviceUDP.labels }} -{{ toYaml .Values.serviceUDP.labels | indent 4 }} -{{- end }} -{{- with .Values.serviceUDP.annotations }} - annotations: -{{ toYaml . | indent 4 }} -{{- end }} spec: -{{- if (or (eq .Values.serviceUDP.type "ClusterIP") (empty .Values.serviceUDP.type)) }} type: ClusterIP - {{- if .Values.serviceUDP.clusterIP }} - clusterIP: {{ .Values.serviceUDP.clusterIP }} - {{end}} -{{- else if eq .Values.serviceUDP.type "LoadBalancer" }} - type: {{ .Values.serviceUDP.type }} - {{- if .Values.serviceUDP.loadBalancerIP }} - loadBalancerIP: {{ .Values.serviceUDP.loadBalancerIP }} - {{- end }} - {{- if .Values.serviceUDP.loadBalancerSourceRanges }} - loadBalancerSourceRanges: -{{ toYaml .Values.serviceUDP.loadBalancerSourceRanges | indent 4 }} - {{- end -}} -{{- else }} - type: {{ .Values.serviceUDP.type }} -{{- end }} -{{- if .Values.serviceUDP.externalIPs }} - externalIPs: -{{ toYaml .Values.serviceUDP.externalIPs | indent 4 }} -{{- end }} - {{- if .Values.serviceUDP.externalTrafficPolicy }} - externalTrafficPolicy: {{ .Values.serviceUDP.externalTrafficPolicy }} - {{- end }} ports: - name: plex-dlna-udp port: 1900 diff --git a/test/plex/2.1.0/values.yaml b/test/plex/2.1.0/values.yaml index d73d2db23c8..b47c1d67cd7 100644 --- a/test/plex/2.1.0/values.yaml +++ b/test/plex/2.1.0/values.yaml @@ -52,52 +52,11 @@ timezone: "UTC" # upgrade strategy type (e.g. Recreate or RollingUpdate) strategyType: Recreate -imagePullSecrets: [] nameOverride: "" fullnameOverride: "" -podSecurityContext: {} - # fsGroup: 2000 - -securityContext: {} - # capabilities: - # drop: - # - ALL - # readOnlyRootFilesystem: true - # runAsNonRoot: true - # runAsUser: 1000 - serviceTCP: - type: NodePort port: 32400 - ## Specify the nodePort value for the LoadBalancer and NodePort service types. - ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport - ## - # nodePort: - ## Provide any additional annotations which may be required. This can be used to - ## set the LoadBalancer service type to internal only. - ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer - ## - annotations: {} - # metallb.universe.tf/allow-shared-ip: plex-svc - labels: {} - -serviceUDP: - type: ClusterIP - ## Provide any additional annotations which may be required. This can be used to - ## set the LoadBalancer service type to internal only. - ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer - ## - annotations: {} - # metallb.universe.tf/allow-shared-ip: plex-svc - labels: {} - ## Use loadBalancerIP to request a specific static IP, - ## otherwise leave blank - ## - loadBalancerIP: - # loadBalancerSourceRanges: [] - ## Set the externalTrafficPolicy in the Service to either Cluster or Local - # externalTrafficPolicy: Cluster plexPreferences: # Enable init script that will read all environment variables starting with PLEX_PREFERENCE_ From a78da65326d3837d4c3d1754d551b1378a5c0fa5 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Mon, 7 Dec 2020 03:01:28 +0500 Subject: [PATCH 11/21] Setup persistent storage for plex chart --- test/plex/2.1.0/questions.yaml | 122 ++++++++++++++++++++++ test/plex/2.1.0/templates/_storage.tpl | 50 +++++++++ test/plex/2.1.0/templates/deployment.yaml | 107 ++----------------- test/plex/2.1.0/templates/volumes.yaml | 57 ---------- test/plex/2.1.0/values.yaml | 79 +------------- 5 files changed, 181 insertions(+), 234 deletions(-) create mode 100644 test/plex/2.1.0/templates/_storage.tpl delete mode 100644 test/plex/2.1.0/templates/volumes.yaml diff --git a/test/plex/2.1.0/questions.yaml b/test/plex/2.1.0/questions.yaml index 112adaf709f..a3e856473af 100644 --- a/test/plex/2.1.0/questions.yaml +++ b/test/plex/2.1.0/questions.yaml @@ -120,3 +120,125 @@ questions: description: "Create new pods and then kill old ones" - value: "Recreate" description: "Kill existing pods before creating new ones" + + # Persistence + - variable: persistence + label: "Configure Persistent Storage" + group: "Storage" + schema: + type: dict + attrs: + - variable: transcode + label: "Configure Transcode Storage" + schema: + type: dict + attrs: + - variable: hostPathEnabled + label: "Configure Host Path for Transcode" + schema: + type: boolean + default: false + show_subquestions_if: true + subquestions: + - variable: hostPath + label: "Specify HostPath for Transcode" + schema: + type: hostPath + required: true + - variable: volume + label: "Configure iXVolume" + schema: + type: dict + show_if: [["hostPathEnabled", "=", false]] + $ref: + - "normalize/ixVolume" + attrs: + - variable: mountPath + label: "Mount Path" + description: "Path where the volume will be mounted inside the pod" + schema: + type: path + editable: false + default: "/transcode" + - variable: datasetName + label: "Dataset Name" + schema: + type: string + default: "ix-plex_transcode" + editable: false + - variable: data + label: "Configure Data Storage" + schema: + type: dict + attrs: + - variable: hostPathEnabled + label: "Configure Host Path for Data" + schema: + type: boolean + default: false + show_subquestions_if: true + subquestions: + - variable: hostPath + label: "Specify HostPath for Data" + schema: + type: hostPath + required: true + - variable: volume + label: "Configure iXVolume" + schema: + type: dict + show_if: [["hostPathEnabled", "=", false]] + $ref: + - "normalize/ixVolume" + attrs: + - variable: mountPath + label: "Mount Path" + description: "Path where the volume will be mounted inside the pod" + schema: + type: path + editable: false + default: "/data" + - variable: datasetName + label: "Dataset Name" + schema: + type: string + default: "ix-plex_data" + editable: false + - variable: config + label: "Configure Config Storage" + schema: + type: dict + attrs: + - variable: hostPathEnabled + label: "Configure Host Path for Config" + schema: + type: boolean + default: false + show_subquestions_if: true + subquestions: + - variable: hostPath + label: "Specify HostPath for Config" + schema: + type: hostPath + required: true + - variable: volume + label: "Configure iXVolume" + schema: + type: dict + show_if: [["hostPathEnabled", "=", false]] + $ref: + - "normalize/ixVolume" + attrs: + - variable: mountPath + label: "Mount Path" + description: "Path where the volume will be mounted inside the pod" + schema: + type: path + editable: false + default: "/config" + - variable: datasetName + label: "Dataset Name" + schema: + type: string + default: "ix-plex_config" + editable: false diff --git a/test/plex/2.1.0/templates/_storage.tpl b/test/plex/2.1.0/templates/_storage.tpl new file mode 100644 index 00000000000..31cbc6eb571 --- /dev/null +++ b/test/plex/2.1.0/templates/_storage.tpl @@ -0,0 +1,50 @@ +{{/* +Retrieve host path from ix volumes based on dataset name +*/}} +{{- define "retrieveHostPathFromiXVolume" -}} +{{- range $index, $hostPathConfiguration := $.ixVolumes }} +{{- $dsName := base $hostPathConfiguration.hostPath -}} +{{- if eq $.datasetName $dsName -}} +{{- $hostPathConfiguration.hostPath -}} +{{- end -}} +{{- end }} +{{- end -}} + +{{/* +Retrieve host path for transcode +Let's please remove the redundancy +*/}} +{{- define "configuredHostPathTranscode" -}} +{{- if .Values.persistence.transcode.hostPathEnabled -}} +{{- .Values.persistence.transcode.hostPath -}} +{{- else -}} +{{- $volDict := dict "datasetName" $.Values.persistence.transcode.volume.datasetName "ixVolumes" $.Values.ixVolumes -}} +{{- include "retrieveHostPathFromiXVolume" $volDict -}} +{{- end -}} +{{- end -}} + +{{/* +Retrieve host path for data +Let's please remove the redundancy +*/}} +{{- define "configuredHostPathData" -}} +{{- if .Values.persistence.data.hostPathEnabled -}} +{{- .Values.persistence.data.hostPath -}} +{{- else -}} +{{- $volDict := dict "datasetName" $.Values.persistence.data.volume.datasetName "ixVolumes" $.Values.ixVolumes -}} +{{- include "retrieveHostPathFromiXVolume" $volDict -}} +{{- end -}} +{{- end -}} + +{{/* +Retrieve host path for transcode +Let's please remove the redundancy +*/}} +{{- define "configuredHostPathConfig" -}} +{{- if .Values.persistence.config.hostPathEnabled -}} +{{- .Values.persistence.config.hostPath -}} +{{- else -}} +{{- $volDict := dict "datasetName" $.Values.persistence.config.volume.datasetName "ixVolumes" $.Values.ixVolumes -}} +{{- include "retrieveHostPathFromiXVolume" $volDict -}} +{{- end -}} +{{- end -}} diff --git a/test/plex/2.1.0/templates/deployment.yaml b/test/plex/2.1.0/templates/deployment.yaml index 3e5c29a4f8e..abcff76d586 100644 --- a/test/plex/2.1.0/templates/deployment.yaml +++ b/test/plex/2.1.0/templates/deployment.yaml @@ -67,26 +67,6 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - - name: TRANSCODE_PVC - {{- if .Values.persistence.transcode.claimName }} - value: "{{ .Values.persistence.transcode.claimName }}" - {{- else }} - value: "{{ template "plex.fullname" . }}-transcode" - {{- end }} - {{- if .Values.persistence.data.enabled }} - - name: DATA_PVC - {{- if .Values.persistence.data.claimName }} - value: "{{ .Values.persistence.data.claimName }}" - {{- else }} - value: "{{ template "plex.fullname" . }}-data" - {{- end }} - {{- end }} - - name: CONFIG_PVC - {{- if .Values.persistence.config.claimName }} - value: "{{ .Values.persistence.config.claimName }}" - {{- else }} - value: "{{ template "plex.fullname" . }}-config" - {{- end }} {{- if .Values.proxy.enabled }} {{- if .Values.proxy.http }} - name: "HTTP_PROXY" @@ -146,41 +126,12 @@ spec: failureThreshold: {{ .Values.probes.startup.failureThreshold }} periodSeconds: {{ .Values.probes.startup.periodSeconds }} volumeMounts: - {{- if .Values.persistence.data.enabled }} - name: data mountPath: /data - {{- if .Values.persistence.data.subPath }} - subPath: {{ .Values.persistence.data.subPath }} - {{ end }} - {{ end }} - name: config mountPath: /config - {{- if .Values.persistence.config.subPath }} - subPath: {{ .Values.persistence.config.subPath }} - {{ end }} - name: transcode mountPath: /transcode - {{- if .Values.persistence.transcode.subPath }} - subPath: {{ .Values.persistence.transcode.subPath }} - {{ end }} - {{- range .Values.persistence.extraData }} - - mountPath: "/data-{{ .name }}" - {{- if .subPath }} - subPath: {{ .subPath }} - {{ end }} - name: "extradata-{{ .name }}" - {{- end }} - {{- range .Values.persistence.extraMounts }} - {{- if .mountPath }} - - mountPath: /{{ .mountPath }} - {{- else }} - - mountPath: /{{ .name }} - {{- end }} - {{- if .subPath }} - subPath: {{ .subPath }} - {{ end }} - name: {{ .name }} - {{- end }} - name: shared mountPath: /shared - name: shared-logs @@ -190,63 +141,17 @@ spec: mountPath: {{ .Values.plexPreferences.volume.mountPath }} subPath: {{ .Values.plexPreferences.volume.subPath }} {{- end }} - {{- if .Values.certificate.pkcsMangler.enabled }} - - name: {{ .Values.certificate.pkcsMangler.volume.name }} - mountPath: {{ .Values.certificate.pkcsMangler.volume.mountPath }} - subPath: {{ .Values.certificate.pkcsMangler.volume.subPath }} - {{- end }} - resources: - {{- toYaml .Values.resources | nindent 12 }} ##### VOLUMES START ##### volumes: -{{- if .Values.persistence.data.enabled }} - name: data - persistentVolumeClaim: - {{- if .Values.persistence.data.claimName }} - claimName: "{{ .Values.persistence.data.claimName }}" - {{- else }} - claimName: "{{ template "plex.fullname" . }}-data" - {{- end }} -{{- end }} + hostPath: + path: {{ template "configuredHostPathData" }} - name: config - persistentVolumeClaim: -{{- if .Values.persistence.config.claimName }} - claimName: "{{ .Values.persistence.config.claimName }}" -{{- else }} - claimName: "{{ template "plex.fullname" . }}-config" -{{- end }} + hostPath: + path: {{ template "configuredHostPathConfig" }} - name: transcode -{{- if .Values.persistence.transcode.enabled }} - persistentVolumeClaim: -{{- if .Values.persistence.transcode.claimName }} - claimName: "{{ .Values.persistence.transcode.claimName }}" -{{- else }} - claimName: "{{ template "plex.fullname" . }}-transcode" -{{- end }} -{{- else }} -{{- if .Values.persistence.transcode.emptyDir.medium }} - emptyDir: - medium: "{{ .Values.persistence.transcode.emptyDir.medium }}" -{{- else }} - emptyDir: {} -{{- end }} -{{- end }} -{{- range .Values.persistence.extraData }} - - name: "extradata-{{ .name }}" - persistentVolumeClaim: -{{- if .claimName }} - claimName: "{{ .claimName }}" -{{- else }} - claimName: "extradata-{{ .name }}" -{{- end }} -{{- end }} -{{- range .Values.persistence.extraMounts }} - {{- if .claimName }} - - name: {{ .name }} - persistentVolumeClaim: - claimName: {{ .claimName }} - {{- end }} -{{- end }} + hostPath: + path: {{ template "configuredHostPathTranscode" }} - name: shared emptyDir: {} - name: shared-logs diff --git a/test/plex/2.1.0/templates/volumes.yaml b/test/plex/2.1.0/templates/volumes.yaml deleted file mode 100644 index 58c16dd9979..00000000000 --- a/test/plex/2.1.0/templates/volumes.yaml +++ /dev/null @@ -1,57 +0,0 @@ -{{- if and (not .Values.persistence.transcode.claimName) .Values.persistence.transcode.enabled }} -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: {{ template "plex.fullname" . }}-transcode - labels: - {{- include "plex.labels" . | nindent 4 }} - component: transcode -spec: - accessModes: - - {{ .Values.persistence.config.accessMode | quote }} - resources: - requests: - storage: {{ .Values.persistence.transcode.size | quote }} -{{- if .Values.persistence.transcode.storageClass }} - storageClassName: {{ .Values.persistence.transcode.storageClass | quote }} -{{- end }} ---- -{{- end }} -{{- if not .Values.persistence.config.claimName }} -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: {{ template "plex.fullname" . }}-config - labels: - {{- include "plex.labels" . | nindent 4 }} - component: config -spec: - accessModes: - - {{ .Values.persistence.config.accessMode | quote }} - resources: - requests: - storage: {{ .Values.persistence.config.size | quote }} -{{- if .Values.persistence.config.storageClass }} - storageClassName: {{ .Values.persistence.config.storageClass | quote }} -{{- end }} ---- -{{- end }} -{{- if and (not .Values.persistence.data.claimName) .Values.persistence.data.enabled }} -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: {{ template "plex.fullname" . }}-data - labels: - {{- include "plex.labels" . | nindent 4 }} - component: data -spec: - accessModes: - - {{ .Values.persistence.data.accessMode | quote }} - resources: - requests: - storage: {{ .Values.persistence.data.size | quote }} -{{- if .Values.persistence.data.storageClass }} - storageClassName: {{ .Values.persistence.data.storageClass | quote }} -{{- end }} ---- -{{- end }} diff --git a/test/plex/2.1.0/values.yaml b/test/plex/2.1.0/values.yaml index b47c1d67cd7..a95ae2b0eab 100644 --- a/test/plex/2.1.0/values.yaml +++ b/test/plex/2.1.0/values.yaml @@ -100,84 +100,11 @@ hostNetwork: false persistence: transcode: - # We want to enable a transcode pvc - enabled: false - # Optionally specify claimName to manually override the PVC to be used for - # the transcode directory. If claimName is specified, storageClass and size - # are ignored. - ## claimName: "plex-transcode-pvc" - # Optionally specify a storage class to be used for the transcode directory. - # If not specified and claimName is not specified, the default storage - # class will be used. - storageClass: "" - # subPath: some-subpath - # The requested size of the volume to be used when creating a - # PersistentVolumeClaim. - size: 20Gi - # Access mode for this volume - accessMode: ReadWriteOnce - # If not using a transcode PVC, specify emptyDir.medium="Memory" to use a tmpfs (in-memory) - # Volume for /transcode. Warning! this will greatly increase the amount of memory the plex pod is using - # AND it will count toward any ram pod/namespace limits. Additionally all data will be lost if/when the - # pod is moved to another node. --set persistence.transcode.emptyDir.medium="Memory" ` - emptyDir: - medium: "" - # medium: "Memory" - - + hostPathEnabled: false data: - # We want to enable a data pvc - enabled: true - # Optionally specify claimName to manually override the PVC to be used for - # the data directory. If claimName is specified, storageClass and size are - # ignored. - ## claimName: "plex-data-pvc" - # Optionally specify a storage class to be used for the data directory. - # If not specified and claimName is not specified, the default storage - # class will be used. - storageClass: "" - # subPath: some-subpath - # The requested size of the volume to be used when creating a - # PersistentVolumeClaim. - size: 40Gi - # Access mode for this volume - accessMode: ReadWriteOnce - - extraData: [] - # Optionally specifify additional Data mounts. These will be mounted as - # /data-${name}. This should be in the same format as the above 'data', - # with the additional field 'name' - # - claimName: "special-tv" - # name: 'foo' - # subPath: optional/sub/path - - extraMounts: [] - ## Include additional claims that can be mounted inside the - ## pod. This is useful if you wish to use different paths with categories - ## Claim will me mounted as /{mountPath} if specified. If no {mountPath} is given, - ## mountPath will default to {name} - # - name: video - # # if claimName is specified the a new volume will mounted, if omitted the mount will be considered to be associated with one of the standard volumes (e.g data, config, transcode). - # # This useful to mount data to a different subPath - # claimName: optional-claim - # mountPath: /mnt/path/in/pod - # subPath: optional/sub/path - + hostPathEnabled: false config: - # Optionally specify claimName to manually override the PVC to be used for - # the config directory. If claimName is specified, storageClass and size - # are ignored. - ## claimName: "plex-config-pvc" - # Optionally specify a storage class to be used for the config directory. - # If not specified and claimName is not specified, the default storage - # class will be used. - # subPath: some-subpath - storageClass: "" - # The requested size of the volume to be used when creating a - # PersistentVolumeClaim. - size: 20Gi - # Access mode for this volume - accessMode: ReadWriteOnce + hostPathEnabled: false # Probes configuration probes: From 8da36972d822d794c039e92bf5d485a556d86928 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Mon, 7 Dec 2020 03:44:03 +0500 Subject: [PATCH 12/21] Clean post install notes --- test/plex/2.1.0/questions.yaml | 15 ++++++++++++--- test/plex/2.1.0/templates/NOTES.txt | 18 ------------------ test/plex/2.1.0/templates/deployment.yaml | 6 +++--- test/plex/2.1.0/values.yaml | 3 +++ 4 files changed, 18 insertions(+), 24 deletions(-) diff --git a/test/plex/2.1.0/questions.yaml b/test/plex/2.1.0/questions.yaml index a3e856473af..cb75533f095 100644 --- a/test/plex/2.1.0/questions.yaml +++ b/test/plex/2.1.0/questions.yaml @@ -76,6 +76,7 @@ questions: schema: type: dict additional_attrs: true + attrs: [] - variable: proxy label: "Configure Proxy environment variable" @@ -83,6 +84,11 @@ questions: schema: type: dict attrs: + - variable: enabled + label: "Enable Proxy" + schema: + type: boolean + default: false - variable: http label: "HTTP Proxy" schema: @@ -143,8 +149,9 @@ questions: - variable: hostPath label: "Specify HostPath for Transcode" schema: - type: hostPath + type: hostpath required: true + default: "" - variable: volume label: "Configure iXVolume" schema: @@ -181,8 +188,9 @@ questions: - variable: hostPath label: "Specify HostPath for Data" schema: - type: hostPath + type: hostpath required: true + default: "" - variable: volume label: "Configure iXVolume" schema: @@ -219,8 +227,9 @@ questions: - variable: hostPath label: "Specify HostPath for Config" schema: - type: hostPath + type: hostpath required: true + default: "" - variable: volume label: "Configure iXVolume" schema: diff --git a/test/plex/2.1.0/templates/NOTES.txt b/test/plex/2.1.0/templates/NOTES.txt index a4119425744..7d790da089b 100644 --- a/test/plex/2.1.0/templates/NOTES.txt +++ b/test/plex/2.1.0/templates/NOTES.txt @@ -1,19 +1 @@ 1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range $host := .Values.ingress.hosts }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }} -{{- end }} -{{- else if contains "NodePort" .Values.serviceTCP.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "plex.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.serviceTCP.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "plex.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "plex.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") - echo http://$SERVICE_IP:{{ .Values.serviceTCP.port }} -{{- else if contains "ClusterIP" .Values.serviceTCP.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "plex.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 -{{- end }} diff --git a/test/plex/2.1.0/templates/deployment.yaml b/test/plex/2.1.0/templates/deployment.yaml index abcff76d586..b00cc3c967a 100644 --- a/test/plex/2.1.0/templates/deployment.yaml +++ b/test/plex/2.1.0/templates/deployment.yaml @@ -145,13 +145,13 @@ spec: volumes: - name: data hostPath: - path: {{ template "configuredHostPathData" }} + path: {{ template "configuredHostPathData" . }} - name: config hostPath: - path: {{ template "configuredHostPathConfig" }} + path: {{ template "configuredHostPathConfig" . }} - name: transcode hostPath: - path: {{ template "configuredHostPathTranscode" }} + path: {{ template "configuredHostPathTranscode" . }} - name: shared emptyDir: {} - name: shared-logs diff --git a/test/plex/2.1.0/values.yaml b/test/plex/2.1.0/values.yaml index a95ae2b0eab..2ecb6fec8a6 100644 --- a/test/plex/2.1.0/values.yaml +++ b/test/plex/2.1.0/values.yaml @@ -101,10 +101,13 @@ hostNetwork: false persistence: transcode: hostPathEnabled: false + hostPath: "" data: hostPathEnabled: false + hostPath: "" config: hostPathEnabled: false + hostPath: "" # Probes configuration probes: From 36eee5eccbcff4f6b498114d0044db8d8376f72b Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Mon, 7 Dec 2020 20:07:30 +0500 Subject: [PATCH 13/21] Properly use host network when configured --- test/plex/2.1.0/questions.yaml | 18 +++++-- test/plex/2.1.0/templates/deployment.yaml | 29 +++-------- test/plex/2.1.0/templates/service-tcp.yaml | 23 +++++---- test/plex/2.1.0/values.yaml | 59 +--------------------- 4 files changed, 36 insertions(+), 93 deletions(-) diff --git a/test/plex/2.1.0/questions.yaml b/test/plex/2.1.0/questions.yaml index cb75533f095..3be8e1a419c 100644 --- a/test/plex/2.1.0/questions.yaml +++ b/test/plex/2.1.0/questions.yaml @@ -127,6 +127,21 @@ questions: - value: "Recreate" description: "Kill existing pods before creating new ones" + # Port configuration + - variable: plexServiceTCP + label: "Configure Plex TCP Service" + group: "Networking" + schema: + type: dict + attrs: + - variable: port + label: "Port to expose for Plex UI" + schema: + type: int + min: 9000 + max: 65535 + default: 32400 + # Persistence - variable: persistence label: "Configure Persistent Storage" @@ -151,7 +166,6 @@ questions: schema: type: hostpath required: true - default: "" - variable: volume label: "Configure iXVolume" schema: @@ -190,7 +204,6 @@ questions: schema: type: hostpath required: true - default: "" - variable: volume label: "Configure iXVolume" schema: @@ -229,7 +242,6 @@ questions: schema: type: hostpath required: true - default: "" - variable: volume label: "Configure iXVolume" schema: diff --git a/test/plex/2.1.0/templates/deployment.yaml b/test/plex/2.1.0/templates/deployment.yaml index b00cc3c967a..2a83f538407 100644 --- a/test/plex/2.1.0/templates/deployment.yaml +++ b/test/plex/2.1.0/templates/deployment.yaml @@ -32,7 +32,7 @@ spec: protocol: TCP containerPort: 32400 {{- if .Values.hostNetwork }} - hostPort: {{ .Values.serviceTCP.port }} + hostPort: {{ .Values.plexServiceTCP.port }} {{- end }} - name: plex-dlna protocol: TCP @@ -110,21 +110,21 @@ spec: httpGet: path: /identity port: 32400 - failureThreshold: {{ .Values.probes.readiness.failureThreshold }} - periodSeconds: {{ .Values.probes.readiness.periodSeconds }} + failureThreshold: 5 + periodSeconds: 15 livenessProbe: httpGet: path: /identity port: 32400 - failureThreshold: {{ .Values.probes.liveness.failureThreshold }} - periodSeconds: {{ .Values.probes.liveness.periodSeconds }} + failureThreshold: 5 + periodSeconds: 15 startupProbe: httpGet: path: /identity port: 32400 - initialDelaySeconds: {{ .Values.probes.startup.initialDelaySeconds }} - failureThreshold: {{ .Values.probes.startup.failureThreshold }} - periodSeconds: {{ .Values.probes.startup.periodSeconds }} + initialDelaySeconds: 5 + failureThreshold: 40 + periodSeconds: 15 volumeMounts: - name: data mountPath: /data @@ -136,12 +136,6 @@ spec: mountPath: /shared - name: shared-logs mountPath: "/config/Library/Application Support/Plex Media Server/Logs" - {{- if .Values.plexPreferences.enabled }} - - name: {{ .Values.plexPreferences.volume.name }} - mountPath: {{ .Values.plexPreferences.volume.mountPath }} - subPath: {{ .Values.plexPreferences.volume.subPath }} - {{- end }} -##### VOLUMES START ##### volumes: - name: data hostPath: @@ -156,10 +150,3 @@ spec: emptyDir: {} - name: shared-logs emptyDir: {} - {{- if .Values.plexPreferences.enabled }} - - name: {{ .Values.plexPreferences.volume.name }} - configMap: - name: {{ .Values.plexPreferences.configmap.name }} - defaultMode: {{ .Values.plexPreferences.volume.defaultMode }} - {{- end }} -##### VOLUMES END ##### diff --git a/test/plex/2.1.0/templates/service-tcp.yaml b/test/plex/2.1.0/templates/service-tcp.yaml index 97dde110aa6..48a69eef184 100644 --- a/test/plex/2.1.0/templates/service-tcp.yaml +++ b/test/plex/2.1.0/templates/service-tcp.yaml @@ -1,25 +1,27 @@ -{{- if eq .Values.hostNetwork false }} apiVersion: v1 kind: Service metadata: + {{- if .Values.hostNetwork }} + name: {{ include "plex.fullname" . }}-tcp-cluster-ip + {{- else }} name: {{ include "plex.fullname" . }}-tcp + {{- end }} labels: {{- include "plex.labels" . | nindent 4 }} -{{- if .Values.serviceTCP.labels }} -{{ toYaml .Values.serviceTCP.labels | indent 4 }} -{{- end }} -{{- with .Values.serviceTCP.annotations }} - annotations: -{{ toYaml . | indent 4 }} -{{- end }} spec: + {{- if .Values.hostNetwork }} + type: ClusterIP + {{- else }} type: NodePort + {{- end }} ports: - name: pms - port: {{ .Values.serviceTCP.port }} + port: {{ .Values.plexServiceTCP.port }} protocol: TCP targetPort: pms - nodePort: {{.Values.serviceTCP.nodePort}} + {{- if eq .Values.hostNetwork false }} + nodePort: {{.Values.plexServiceTCP.port}} + {{- end }} - name: http port: 80 targetPort: pms @@ -31,4 +33,3 @@ spec: targetPort: plex-dlna selector: {{- include "plex.selectorLabels" . | nindent 4 }} -{{- end }} diff --git a/test/plex/2.1.0/values.yaml b/test/plex/2.1.0/values.yaml index 2ecb6fec8a6..0daf7fe4554 100644 --- a/test/plex/2.1.0/values.yaml +++ b/test/plex/2.1.0/values.yaml @@ -52,75 +52,18 @@ timezone: "UTC" # upgrade strategy type (e.g. Recreate or RollingUpdate) strategyType: Recreate -nameOverride: "" -fullnameOverride: "" - -serviceTCP: +plexServiceTCP: port: 32400 -plexPreferences: - # Enable init script that will read all environment variables starting with PLEX_PREFERENCE_ - # and take the value (of PLEX_PREFERENCE_) as the Key:Value option to set in Plex Preference.xml - # You can use extraEnv to add the addtional ENV's to the container. - # NOTE: Plex preference options are camelCase and CASE SENSITIVE! - # You can do horrible things to your PLEX configuration if you are not careful. - # --set extraEnv.PLEX_PREFERENCE_1="FriendlyName=plex-kubeernetes-test1" ` - # --set extraEnv.PLEX_PREFERENCE_2="EnableIPv6=0" ` - # --set extraEnv.PLEX_PREFERENCE_3="logDebug=0" ` - # --set extraEnv.PLEX_PREFERENCE_4="DisableTLSv1_0=1" ` - # --set extraEnv.PLEX_PREFERENCE_5="LanNetworksBandwidth=xxx.xxx.xxx.0/18\,xxx.xxx.xxx.0/24\,xxx.xxx.xxx.0/24" ` - # --set extraEnv.PLEX_PREFERENCE_6="TranscoderQuality=2" ` - # --set extraEnv.PLEX_PREFERENCE_7="TreatWanIpAsLocal=0" ` - # --set extraEnv.PLEX_PREFERENCE_8="TranscoderH264BackgroundPreset=fast" - # Why not use a single ENV? - # I thought using multiple environment variables would be less confusing - # It should work easily with CLI and value.yaml usage - # There is only minimal parsing required on the ENV value, as the only deliminator is = - # From what I can see, all the PLEX preferences that are NOT currently supported by the OFFICIAL - # Container are simple enough to work with this. - enabled: false - configmap: - labels: {} - annotations: {} - # Right now you can't really change this, additionally the configmap data is - # not configurable. - name: 41-plex-preferences - volume: - name: 41-plex-preferences - defaultMode: 493 # 0755 in octal permission notation - # Using mountPath & SubPath allow you to volume mount a configMap AS A FILE - # Unfortunately this also means that updates to the configMap are not automtically - # propagated to the file contents. But it's better then replacing the entire - # /etc/cont-init.d/ directory which is the "normal" behavior when doing volume - # mounts. - mountPath: /etc/cont-init.d/41-plex-preferences - subPath: 41-plex-preferences - hostNetwork: false persistence: transcode: hostPathEnabled: false - hostPath: "" data: hostPathEnabled: false - hostPath: "" config: hostPathEnabled: false - hostPath: "" - -# Probes configuration -probes: - liveness: - failureThreshold: 5 - periodSeconds: 10 - readiness: - failureThreshold: 5 - periodSeconds: 10 - startup: - initialDelaySeconds: 5 - failureThreshold: 30 - periodSeconds: 10 proxy: # This allows to set a proxy environment variable, which PMS uses to fetch the token and assets like movie cover From aa72e525dff698f5c7091c4c9e2b95fb3aa4302b Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Mon, 7 Dec 2020 20:17:02 +0500 Subject: [PATCH 14/21] Add GPU support --- test/plex/2.1.0/questions.yaml | 9 +++++++++ test/plex/2.1.0/templates/deployment.yaml | 5 +++++ test/plex/2.1.0/values.yaml | 2 ++ 3 files changed, 16 insertions(+) diff --git a/test/plex/2.1.0/questions.yaml b/test/plex/2.1.0/questions.yaml index 3be8e1a419c..e2328f9e339 100644 --- a/test/plex/2.1.0/questions.yaml +++ b/test/plex/2.1.0/questions.yaml @@ -263,3 +263,12 @@ questions: type: string default: "ix-plex_config" editable: false + + # Specify GPU configuration + - variable: gpuConfiguration + label: "GPU Configuration" + group: "Resource Reservation" + schema: + type: dict + $ref: + - "definitions/gpuConfiguration" diff --git a/test/plex/2.1.0/templates/deployment.yaml b/test/plex/2.1.0/templates/deployment.yaml index 2a83f538407..acbc425aced 100644 --- a/test/plex/2.1.0/templates/deployment.yaml +++ b/test/plex/2.1.0/templates/deployment.yaml @@ -136,6 +136,11 @@ spec: mountPath: /shared - name: shared-logs mountPath: "/config/Library/Application Support/Plex Media Server/Logs" + {{- if .Values.gpuConfiguration }} + resources: + limits: + {{- toYaml .Values.gpuConfiguration | nindent 14 }} + {{- end }} volumes: - name: data hostPath: diff --git a/test/plex/2.1.0/values.yaml b/test/plex/2.1.0/values.yaml index 0daf7fe4554..668423ea8ea 100644 --- a/test/plex/2.1.0/values.yaml +++ b/test/plex/2.1.0/values.yaml @@ -71,3 +71,5 @@ proxy: # http: "http://proxy:8080" # https: "https://proxy:8080" # noproxy: "localhost,127.0.0.1,10.96.0.0/12,10.244.0.0/12" + +gpuConfiguration: {} From 2fc1d74043b7b556a043fe98eeedc05474bcb281 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Mon, 7 Dec 2020 20:49:46 +0500 Subject: [PATCH 15/21] Add timezone support --- features_capability.json | 4 ++++ test/plex/2.1.0/questions.yaml | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/features_capability.json b/features_capability.json index 96526c85a08..af1d4709aca 100644 --- a/features_capability.json +++ b/features_capability.json @@ -14,5 +14,9 @@ "definitions/gpuConfiguration": { "stable": {"min": "20.12-ALPHA"}, "nightlies": {"min": "20.10-MASTER-somever"} + }, + "definitions/timezone": { + "stable": {"min": "20.12-ALPHA"}, + "nightlies": {"min": "20.12-MASTER"} } } \ No newline at end of file diff --git a/test/plex/2.1.0/questions.yaml b/test/plex/2.1.0/questions.yaml index e2328f9e339..a21fd9adc96 100644 --- a/test/plex/2.1.0/questions.yaml +++ b/test/plex/2.1.0/questions.yaml @@ -111,7 +111,9 @@ questions: group: "Plex Configuration" schema: type: string - default: "UTC" + default: "Etc/UTC" + $ref: + - "definitions/timezone" # Update strategy - variable: strategyType From 725ee078dd4cbd32d39d440ff04aba3de2aa58e2 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Mon, 7 Dec 2020 21:09:23 +0500 Subject: [PATCH 16/21] Add icon url --- test/plex/2.1.0/README.md | 45 +---------------------------------- test/plex/2.1.0/app-readme.md | 2 +- test/plex/item.yaml | 1 + 3 files changed, 3 insertions(+), 45 deletions(-) diff --git a/test/plex/2.1.0/README.md b/test/plex/2.1.0/README.md index d086f384aae..7a3bb510dc9 100644 --- a/test/plex/2.1.0/README.md +++ b/test/plex/2.1.0/README.md @@ -1,48 +1,5 @@ # Plex Media Server helm chart -This is an opinionated helm chart for Plex Media Center based on the [official container image](https://hub.docker.com/r/plexinc/pms-docker/). - -This chart is 'forked' from the excellent [munnerz/kube-plex](https://github.com/munnerz/kube-plex) repo in order to allow for more timely updates and publishing to a helm registry. **NOTE:** This chart is not compatible as an upgrade from the `kube-plex` chart. - -## TL;DR - -```shell -helm repo add k8s-at-home https://k8s-at-home.com/charts/ -helm install k8s-at-home/plex -``` - -## Installing the Chart - -To install the chart with the release name `plex`: - -```console -helm install plex k8s-at-home/plex -``` - -## Uninstalling the Chart - -To uninstall/delete the `plex` deployment: - -```console -helm delete plex -``` - -The command removes all the Kubernetes components associated with the chart and deletes the release. - ## Configuration -Read through the [values.yaml](https://github.com/k8s-at-home/charts/blob/master/charts/plex/values.yaml) file. It has several commented out suggested values. - -Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, - -```console -helm install plex \ - --set timezone="America/New York" \ - k8s-at-home/plex -``` - -Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example, - -```console -helm install plex -f values.yaml k8s-at-home/plex -``` +Please refer to questions.yaml for a detailed overview on supported configurable items. diff --git a/test/plex/2.1.0/app-readme.md b/test/plex/2.1.0/app-readme.md index f6fd499552a..cb657a2f0e8 100644 --- a/test/plex/2.1.0/app-readme.md +++ b/test/plex/2.1.0/app-readme.md @@ -1,3 +1,3 @@ # Plex -Plex is a chart designed to deploy plex in a TrueNAS SCALE kubernetes cluster. +Plex chart is a chart designed to deploy plex in a TrueNAS SCALE kubernetes cluster. diff --git a/test/plex/item.yaml b/test/plex/item.yaml index 697769c647e..8d014b680de 100644 --- a/test/plex/item.yaml +++ b/test/plex/item.yaml @@ -1,2 +1,3 @@ categories: - entertainment +icon_url: https://www.plex.tv/wp-content/uploads/2018/01/pmp-icon-1.png From bd0a06c0173e8ebb3cbf3d36979c8c3e279dd9d4 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Tue, 8 Dec 2020 03:33:53 +0500 Subject: [PATCH 17/21] Properly setup persistence values --- test/plex/2.1.0/questions.yaml | 220 +++++++++++----------- test/plex/2.1.0/templates/_storage.tpl | 18 +- test/plex/2.1.0/templates/deployment.yaml | 12 ++ test/plex/2.1.0/values.yaml | 10 +- 4 files changed, 130 insertions(+), 130 deletions(-) diff --git a/test/plex/2.1.0/questions.yaml b/test/plex/2.1.0/questions.yaml index a21fd9adc96..52e778e8522 100644 --- a/test/plex/2.1.0/questions.yaml +++ b/test/plex/2.1.0/questions.yaml @@ -144,127 +144,119 @@ questions: max: 65535 default: 32400 - # Persistence - - variable: persistence - label: "Configure Persistent Storage" + - variable: transcodeHostPathEnabled + label: "Configure Host Path for Transcode" + group: "Storage" + schema: + type: boolean + default: false + show_subquestions_if: true + subquestions: + - variable: transcodeHostpath + label: "Specify HostPath for Transcode" + group: "Storage" + schema: + type: hostpath + required: true + + - variable: transcodeVolume + label: "Configure iXVolume" group: "Storage" schema: type: dict + show_if: [["transcodeHostPathEnabled", "=", false]] + $ref: + - "normalize/ixVolume" attrs: - - variable: transcode - label: "Configure Transcode Storage" + - variable: mountPath + label: "Mount Path" + description: "Path where the volume will be mounted inside the pod" schema: - type: dict - attrs: - - variable: hostPathEnabled - label: "Configure Host Path for Transcode" - schema: - type: boolean - default: false - show_subquestions_if: true - subquestions: - - variable: hostPath - label: "Specify HostPath for Transcode" - schema: - type: hostpath - required: true - - variable: volume - label: "Configure iXVolume" - schema: - type: dict - show_if: [["hostPathEnabled", "=", false]] - $ref: - - "normalize/ixVolume" - attrs: - - variable: mountPath - label: "Mount Path" - description: "Path where the volume will be mounted inside the pod" - schema: - type: path - editable: false - default: "/transcode" - - variable: datasetName - label: "Dataset Name" - schema: - type: string - default: "ix-plex_transcode" - editable: false - - variable: data - label: "Configure Data Storage" + type: path + editable: false + default: "/transcode" + - variable: datasetName + label: "Dataset Name" schema: - type: dict - attrs: - - variable: hostPathEnabled - label: "Configure Host Path for Data" - schema: - type: boolean - default: false - show_subquestions_if: true - subquestions: - - variable: hostPath - label: "Specify HostPath for Data" - schema: - type: hostpath - required: true - - variable: volume - label: "Configure iXVolume" - schema: - type: dict - show_if: [["hostPathEnabled", "=", false]] - $ref: - - "normalize/ixVolume" - attrs: - - variable: mountPath - label: "Mount Path" - description: "Path where the volume will be mounted inside the pod" - schema: - type: path - editable: false - default: "/data" - - variable: datasetName - label: "Dataset Name" - schema: - type: string - default: "ix-plex_data" - editable: false - - variable: config - label: "Configure Config Storage" + type: string + default: "ix-plex_transcode" + editable: false + + - variable: dataHostPathEnabled + label: "Configure Host Path for Data" + group: "Storage" + schema: + type: boolean + default: false + show_subquestions_if: true + group: "Storage" + subquestions: + - variable: dataHostPath + label: "Specify HostPath for Data" schema: - type: dict - attrs: - - variable: hostPathEnabled - label: "Configure Host Path for Config" - schema: - type: boolean - default: false - show_subquestions_if: true - subquestions: - - variable: hostPath - label: "Specify HostPath for Config" - schema: - type: hostpath - required: true - - variable: volume - label: "Configure iXVolume" - schema: - type: dict - show_if: [["hostPathEnabled", "=", false]] - $ref: - - "normalize/ixVolume" - attrs: - - variable: mountPath - label: "Mount Path" - description: "Path where the volume will be mounted inside the pod" - schema: - type: path - editable: false - default: "/config" - - variable: datasetName - label: "Dataset Name" - schema: - type: string - default: "ix-plex_config" - editable: false + type: hostpath + required: true + + - variable: dataVolume + label: "Configure data iXVolume" + group: "Storage" + schema: + type: dict + show_if: [["dataHostPathEnabled", "=", false]] + $ref: + - "normalize/ixVolume" + attrs: + - variable: mountPath + label: "Mount Path" + description: "Path where the volume will be mounted inside the pod" + schema: + type: path + editable: false + default: "/data" + - variable: datasetName + label: "Dataset Name" + schema: + type: string + default: "ix-plex_data" + editable: false + + - variable: configHostPathEnabled + label: "Configure Host Path for Config" + group: "Storage" + schema: + type: boolean + default: false + show_subquestions_if: true + subquestions: + - variable: configHostPath + label: "Specify HostPath for Config" + group: "Storage" + schema: + type: hostpath + required: true + + - variable: configVolume + label: "Configure iXVolume" + group: "Storage" + schema: + type: dict + show_if: [["configHostPathEnabled", "=", false]] + $ref: + - "normalize/ixVolume" + attrs: + - variable: mountPath + label: "Mount Path" + description: "Path where the volume will be mounted inside the pod" + schema: + type: path + editable: false + default: "/config" + - variable: datasetName + label: "Dataset Name" + schema: + type: string + default: "ix-plex_config" + editable: false # Specify GPU configuration - variable: gpuConfiguration diff --git a/test/plex/2.1.0/templates/_storage.tpl b/test/plex/2.1.0/templates/_storage.tpl index 31cbc6eb571..ef34fcb041e 100644 --- a/test/plex/2.1.0/templates/_storage.tpl +++ b/test/plex/2.1.0/templates/_storage.tpl @@ -15,10 +15,10 @@ Retrieve host path for transcode Let's please remove the redundancy */}} {{- define "configuredHostPathTranscode" -}} -{{- if .Values.persistence.transcode.hostPathEnabled -}} -{{- .Values.persistence.transcode.hostPath -}} +{{- if .Values.transcodeHostPathEnabled -}} +{{- .Values.transcodeHostPath -}} {{- else -}} -{{- $volDict := dict "datasetName" $.Values.persistence.transcode.volume.datasetName "ixVolumes" $.Values.ixVolumes -}} +{{- $volDict := dict "datasetName" $.Values.transcodeVolume.datasetName "ixVolumes" $.Values.ixVolumes -}} {{- include "retrieveHostPathFromiXVolume" $volDict -}} {{- end -}} {{- end -}} @@ -28,10 +28,10 @@ Retrieve host path for data Let's please remove the redundancy */}} {{- define "configuredHostPathData" -}} -{{- if .Values.persistence.data.hostPathEnabled -}} -{{- .Values.persistence.data.hostPath -}} +{{- if .Values.dataHostPathEnabled -}} +{{- .Values.dataHostPath -}} {{- else -}} -{{- $volDict := dict "datasetName" $.Values.persistence.data.volume.datasetName "ixVolumes" $.Values.ixVolumes -}} +{{- $volDict := dict "datasetName" $.Values.dataVolume.datasetName "ixVolumes" $.Values.ixVolumes -}} {{- include "retrieveHostPathFromiXVolume" $volDict -}} {{- end -}} {{- end -}} @@ -41,10 +41,10 @@ Retrieve host path for transcode Let's please remove the redundancy */}} {{- define "configuredHostPathConfig" -}} -{{- if .Values.persistence.config.hostPathEnabled -}} -{{- .Values.persistence.config.hostPath -}} +{{- if .Values.configHostPathEnabled -}} +{{- .Values.configHostPath -}} {{- else -}} -{{- $volDict := dict "datasetName" $.Values.persistence.config.volume.datasetName "ixVolumes" $.Values.ixVolumes -}} +{{- $volDict := dict "datasetName" $.Values.configVolume.datasetName "ixVolumes" $.Values.ixVolumes -}} {{- include "retrieveHostPathFromiXVolume" $volDict -}} {{- end -}} {{- end -}} diff --git a/test/plex/2.1.0/templates/deployment.yaml b/test/plex/2.1.0/templates/deployment.yaml index acbc425aced..714fcfae761 100644 --- a/test/plex/2.1.0/templates/deployment.yaml +++ b/test/plex/2.1.0/templates/deployment.yaml @@ -143,14 +143,26 @@ spec: {{- end }} volumes: - name: data + {{- if .Values.emptyDirVolumes }} + emptyDir: {} + {{- else }} hostPath: path: {{ template "configuredHostPathData" . }} + {{- end }} - name: config + {{- if .Values.emptyDirVolumes }} + emptyDir: {} + {{- else }} hostPath: path: {{ template "configuredHostPathConfig" . }} + {{- end }} - name: transcode + {{- if .Values.emptyDirVolumes }} + emptyDir: {} + {{- else }} hostPath: path: {{ template "configuredHostPathTranscode" . }} + {{- end }} - name: shared emptyDir: {} - name: shared-logs diff --git a/test/plex/2.1.0/values.yaml b/test/plex/2.1.0/values.yaml index 668423ea8ea..53379d62a92 100644 --- a/test/plex/2.1.0/values.yaml +++ b/test/plex/2.1.0/values.yaml @@ -57,13 +57,9 @@ plexServiceTCP: hostNetwork: false -persistence: - transcode: - hostPathEnabled: false - data: - hostPathEnabled: false - config: - hostPathEnabled: false +transcodeHostPathEnabled: false +dataHostPathEnabled: false +configHostPathEnabled: false proxy: # This allows to set a proxy environment variable, which PMS uses to fetch the token and assets like movie cover From 868900c84f87cd8a657c818adde44a179d865e44 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Tue, 8 Dec 2020 03:37:18 +0500 Subject: [PATCH 18/21] Add test values yaml file --- test/plex/2.1.0/questions.yaml | 4 +- test/plex/2.1.0/test_values.yaml | 72 ++++++++++++++++++++++++++++++++ test/plex/2.1.0/values.yaml | 2 +- 3 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 test/plex/2.1.0/test_values.yaml diff --git a/test/plex/2.1.0/questions.yaml b/test/plex/2.1.0/questions.yaml index 52e778e8522..042dbdfcbdb 100644 --- a/test/plex/2.1.0/questions.yaml +++ b/test/plex/2.1.0/questions.yaml @@ -152,9 +152,8 @@ questions: default: false show_subquestions_if: true subquestions: - - variable: transcodeHostpath + - variable: transcodeHostPath label: "Specify HostPath for Transcode" - group: "Storage" schema: type: hostpath required: true @@ -230,7 +229,6 @@ questions: subquestions: - variable: configHostPath label: "Specify HostPath for Config" - group: "Storage" schema: type: hostpath required: true diff --git a/test/plex/2.1.0/test_values.yaml b/test/plex/2.1.0/test_values.yaml new file mode 100644 index 00000000000..e87d30077c8 --- /dev/null +++ b/test/plex/2.1.0/test_values.yaml @@ -0,0 +1,72 @@ +# Default values +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +# The Image to use for PLEX + +image: + repository: plexinc/pms-docker + tag: 1.20.2.3402-0fec14d92 + pullPolicy: IfNotPresent + +##### START --> Official PLEX container environment variables +# Override this with the plex claim token from plex.tv/claim +claimToken: "" + +# Set the timezone of the plex server +timezone: "Etc/UTC" + +# add your pod network subnet to the `List of IP addresses and networks that are allowed without auth` +# This will override the manual settings, so only use this if you will not need to change it manually. +# This list will be automatically converted to a command seperated string when passed to the container. +# You would specify this when using helm CLI with --set allowedNetworks="{127.0.0.1,10.54.2.0/24}" +# allowedNetworks: +# - 127.0.0.1 +# - 10.54.2.0/24 + +# Instruct the Plex Media Server Container to Change the Configuration Directory Ownership +# Default is true, you would only need to set this if you want to disable it. +# changeConfigDirOwnership: true + +# advertiseIp This variable defines the additional IPs on which the server may be be found. +# For example: http://10.1.1.23:32400. +# This adds to the list where the server advertises that it can be found. +# See https://hub.docker.com/r/plexinc/pms-docker/ for details +# advertiseIp: "http://10.1.1.23:32400" + +# Set The user id of the plex user created inside the container. +# See https://hub.docker.com/r/plexinc/pms-docker/ for details +# plexUid: 1000 + +# Set The group id of the plex group created inside the container +# See https://hub.docker.com/r/plexinc/pms-docker/ for details +# plexGid: 1000 + +##### END --> Official PLEX container environment variables + +# You can add as many Additional ENV variables here +# The following is the same as --set extraEnv.TMPDIR="/transcode" +# extraEnv: +# TMPDIR: /transcode + +# upgrade strategy type (e.g. Recreate or RollingUpdate) +strategyType: Recreate + +plexServiceTCP: + port: 32400 + +hostNetwork: false + +transcodeHostPathEnabled: false +dataHostPathEnabled: false +configHostPathEnabled: false + +proxy: + # This allows to set a proxy environment variable, which PMS uses to fetch the token and assets like movie cover + enabled: false + # http: "http://proxy:8080" + # https: "https://proxy:8080" + # noproxy: "localhost,127.0.0.1,10.96.0.0/12,10.244.0.0/12" + +gpuConfiguration: {} +emptyDirVolumes: true diff --git a/test/plex/2.1.0/values.yaml b/test/plex/2.1.0/values.yaml index 53379d62a92..f1a1754a549 100644 --- a/test/plex/2.1.0/values.yaml +++ b/test/plex/2.1.0/values.yaml @@ -14,7 +14,7 @@ image: claimToken: "" # Set the timezone of the plex server -timezone: "UTC" +timezone: "Etc/UTC" # add your pod network subnet to the `List of IP addresses and networks that are allowed without auth` # This will override the manual settings, so only use this if you will not need to change it manually. From 6c8cc0b29c95873bd2bf119ac1dddc96d5ef0c74 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Tue, 8 Dec 2020 03:48:37 +0500 Subject: [PATCH 19/21] Remove plex-preferences file --- test/plex/2.1.0/configs/41-plex-preferences | 64 --------------------- test/plex/2.1.0/templates/NOTES.txt | 2 + 2 files changed, 2 insertions(+), 64 deletions(-) delete mode 100644 test/plex/2.1.0/configs/41-plex-preferences diff --git a/test/plex/2.1.0/configs/41-plex-preferences b/test/plex/2.1.0/configs/41-plex-preferences deleted file mode 100644 index 5f13bd2abba..00000000000 --- a/test/plex/2.1.0/configs/41-plex-preferences +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/with-contenv bash - -# This file is based off of the official 40-plex-first-run -# Here: https://github.com/plexinc/pms-docker/blob/master/root/etc/cont-init.d/40-plex-first-run -# It should live in /etc/cont-init.d/ - -# If we are debugging, enable trace -if [ "${DEBUG,,}" = "true" ]; then - set -x -fi - -function getPref { - local key="$1" - - xmlstarlet sel -T -t -m "/Preferences" -v "@${key}" -n "${prefFile}" -} - -function setPref { - local key="$1" - local value="$2" - - count="$(xmlstarlet sel -t -v "count(/Preferences/@${key})" "${prefFile}")" - count=$(($count + 0)) - if [[ $count > 0 ]]; then - xmlstarlet ed --inplace --update "/Preferences/@${key}" -v "${value}" "${prefFile}" - else - xmlstarlet ed --inplace --insert "/Preferences" --type attr -n "${key}" -v "${value}" "${prefFile}" - fi -} - -home="$(echo ~plex)" -pmsApplicationSupportDir="${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR:-${home}/Library/Application Support}" -prefFile="${pmsApplicationSupportDir}/Plex Media Server/Preferences.xml" - -if [ ! -z "${ADVERTISE_IP}" ]; then - setPref "customConnections" "${ADVERTISE_IP}" -fi - -if [ ! -z "${ALLOWED_NETWORKS}" ]; then - setPref "allowedNetworks" "${ALLOWED_NETWORKS}" -fi - -# Set transcoder temp if not yet set -if [ -z "$(getPref "TranscoderTempDirectory")" ]; then - setPref "TranscoderTempDirectory" "/transcode" -fi - -# Parse list of all exported variables that start with PLEX_PREFERENCE_ -# The format of which is PLEX_PREFERENCE_="Key=Value" -# Where Key is the EXACT key to use in the Plex Preference file -# And Value is the EXACT value to use in the Plex Preference file for that key. -# Please note it looks like many of the key's are camelCase in some fashion. -# Additionally there are likely some preferences where environment variable injection -# doesn't really work for. -for var in "${!PLEX_PREFERENCE_@}"; do - value=${!var} - PreferenceValue=${value#*=} - PreferenceKey=${value%=*} - setPref $PreferenceKey $PreferenceValue -done - -# touch /.firstRunComplete -# echo "Plex Media Server first run setup complete" -echo "Plex Media Server preferences update run complete" \ No newline at end of file diff --git a/test/plex/2.1.0/templates/NOTES.txt b/test/plex/2.1.0/templates/NOTES.txt index 7d790da089b..66f71247be2 100644 --- a/test/plex/2.1.0/templates/NOTES.txt +++ b/test/plex/2.1.0/templates/NOTES.txt @@ -1 +1,3 @@ 1. Get the application URL by running these commands: + +https:node_ip:{{ .Values.plexServiceTCP.port }}/ From 1133d2ff01db529d68e07b58dab6c89da22cbcd9 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Tue, 8 Dec 2020 03:58:28 +0500 Subject: [PATCH 20/21] Specify web portal for plex --- test/plex/2.1.0/questions.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/plex/2.1.0/questions.yaml b/test/plex/2.1.0/questions.yaml index 042dbdfcbdb..043da8e5eaf 100644 --- a/test/plex/2.1.0/questions.yaml +++ b/test/plex/2.1.0/questions.yaml @@ -20,6 +20,15 @@ groups: - name: "Resource Reservation" description: "Specify resources to be allocated to workload" +portals: + web_portal: + protocols: + - "http" + host: + - "$node_ip" + ports: + - "$variable-plexServiceTCP.port" + questions: # Image related - variable: image @@ -188,7 +197,6 @@ questions: type: boolean default: false show_subquestions_if: true - group: "Storage" subquestions: - variable: dataHostPath label: "Specify HostPath for Data" From 37c8493270d0f8009535fb9067e2294b60861680 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Tue, 8 Dec 2020 04:46:01 +0500 Subject: [PATCH 21/21] Clean chart configuration --- test/plex/2.1.0/Chart.yaml | 4 ---- test/plex/2.1.0/questions.yaml | 1 - test/plex/2.1.0/templates/NOTES.txt | 2 +- test/plex/2.1.0/templates/deployment.yaml | 16 ---------------- 4 files changed, 1 insertion(+), 22 deletions(-) diff --git a/test/plex/2.1.0/Chart.yaml b/test/plex/2.1.0/Chart.yaml index 32815d2bef1..09ad0662cb9 100644 --- a/test/plex/2.1.0/Chart.yaml +++ b/test/plex/2.1.0/Chart.yaml @@ -8,8 +8,4 @@ keywords: home: https://plex.tv/ icon: https://www.plex.tv/wp-content/uploads/2018/01/pmp-icon-1.png sources: - - https://github.com/k8s-at-home/charts/tree/master/charts/plex - https://hub.docker.com/r/plexinc/pms-docker/ -maintainers: - - name: billimek - email: jeff@billimek.com diff --git a/test/plex/2.1.0/questions.yaml b/test/plex/2.1.0/questions.yaml index 043da8e5eaf..62e748adcd7 100644 --- a/test/plex/2.1.0/questions.yaml +++ b/test/plex/2.1.0/questions.yaml @@ -114,7 +114,6 @@ questions: type: boolean default: false - # TODO: Add timezone validation $ref - variable: timezone label: "Plex container timezone" group: "Plex Configuration" diff --git a/test/plex/2.1.0/templates/NOTES.txt b/test/plex/2.1.0/templates/NOTES.txt index 66f71247be2..f3d1e07cb14 100644 --- a/test/plex/2.1.0/templates/NOTES.txt +++ b/test/plex/2.1.0/templates/NOTES.txt @@ -1,3 +1,3 @@ 1. Get the application URL by running these commands: -https:node_ip:{{ .Values.plexServiceTCP.port }}/ +http://$node_ip:{{ .Values.plexServiceTCP.port }}/ diff --git a/test/plex/2.1.0/templates/deployment.yaml b/test/plex/2.1.0/templates/deployment.yaml index 714fcfae761..059ecbef276 100644 --- a/test/plex/2.1.0/templates/deployment.yaml +++ b/test/plex/2.1.0/templates/deployment.yaml @@ -76,31 +76,15 @@ spec: - name: "HTTPS_PROXY" value: "{{.Values.proxy.https}}" {{- end }} - {{- if .Values.proxy.noproxy }} - - name: "NO_PROXY" - value: "{{.Values.proxy.noproxy}}" - {{- end }} {{- end }} {{- if .Values.advertiseIp }} - name: "ADVERTISE_IP" value: "{{.Values.advertiseIp}}" {{- end }} -{{- if .Values.changeConfigDirOwnership }} - - name: "CHANGE_CONFIG_DIR_OWNERSHIP" - value: "{{.Values.changeConfigDirOwnership}}" -{{- end }} {{- if .Values.allowedNetworks }} - name: "ALLOWED_NETWORKS" value: "{{include "joinListWithComma" .Values.allowedNetworks}}" {{- end }} -{{- if .Values.plexUid }} - - name: "PLEX_UID" - value: "{{.Values.plexUid}}" -{{- end }} -{{- if .Values.plexGid }} - - name: "PLEX_GID" - value: "{{.Values.plexGid}}" -{{- end }} # Extra ENV Values supplied by user {{- range $key, $value := .Values.extraEnv }} - name: {{ $key }}