Add plexporter

This commit is contained in:
Jonny Ervine 2024-02-24 20:49:34 +08:00
parent 2ef910d236
commit cfb7a5621d
11 changed files with 95 additions and 177 deletions

View File

@ -1,41 +0,0 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "nzbhydra.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- 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 "nzbhydra.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: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ . }}
backend:
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}

View File

@ -1,15 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "nzbhydra.fullname" . }}
labels:
{{- include "nzbhydra.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: 5076
protocol: TCP
name: hydra
selector:
{{- include "nzbhydra.selectorLabels" . | nindent 4 }}

View File

@ -1,85 +0,0 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "nzbhydra.fullname" . }}
labels:
{{- include "nzbhydra.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
serviceName: {{ include "nzbhydra.fullname" . }}
selector:
matchLabels:
{{- include "nzbhydra.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "nzbhydra.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "nzbhydra.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: hydra
containerPort: 5076
protocol: TCP
livenessProbe:
tcpSocket:
port: 5076
readinessProbe:
tcpSocket:
port: 5076
startupProbe:
tcpSocket:
port: 5076
failureThreshold: 30
periodSeconds: 10
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: hydra-config
mountPath: /config
- name: hydra-tmp
mountPath: /tmp
volumes:
- name: hydra-tmp
emptyDir: {}
{{- if and .Values.config.persistence.enabled .Values.config.persistence.existingClaim }}
- name: hydra-config
persistentVolumeClaim:
{{- with .Values.config.persistence.existingClaim }}
claimName: {{ tpl . $ }}
{{- end }}
{{- 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 }}
{{- if and .Values.config.persistence.enabled (not .Values.config.persistence.existingClaim) }}
volumeClaimTemplates:
- metadata:
name: hydra-config
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: {{ .Values.config.persistence.storageClassName | quote }}
resources:
requests:
storage: {{ .Values.config.persistence.storageSize }}
{{- end -}}

View File

@ -1,5 +1,5 @@
apiVersion: v2 apiVersion: v2
name: nzbhydra name: plexporter
description: A Helm chart for Kubernetes description: A Helm chart for Kubernetes
# A chart can be either an 'application' or a 'library' chart. # A chart can be either an 'application' or a 'library' chart.
@ -14,10 +14,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes # This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version. # to the chart and its templates, including the app version.
version: 0.1.32 version: 0.1
# This is the version number of the application being deployed. This version number should be # This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. # incremented each time you make changes to the application.
appVersion: v3.13.0 appVersion: v0.1
icon: https://git.ervine.org/jonny/x86_64-alpine-nzbhydra/raw/branch/master/hydra.png icon: https://www.plex.tv/wp-content/uploads/2018/01/pmp-icon-1.png

View File

@ -6,16 +6,16 @@
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- else if contains "NodePort" .Values.service.type }} {{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "nzbhydra.fullname" . }}) export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "sonarr.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }} {{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available. 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 "nzbhydra.fullname" . }}' You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "sonarr.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "nzbhydra.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "sonarr.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }} echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }} {{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "nzbhydra.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "sonarr.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" echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
{{- end }} {{- end }}

View File

@ -2,7 +2,7 @@
{{/* {{/*
Expand the name of the chart. Expand the name of the chart.
*/}} */}}
{{- define "nzbhydra.name" -}} {{- define "sonarr.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}} {{- end -}}
@ -11,7 +11,7 @@ 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). 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. If release name contains chart name it will be used as a full name.
*/}} */}}
{{- define "nzbhydra.fullname" -}} {{- define "sonarr.fullname" -}}
{{- if .Values.fullnameOverride -}} {{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}} {{- else -}}
@ -27,16 +27,16 @@ If release name contains chart name it will be used as a full name.
{{/* {{/*
Create chart name and version as used by the chart label. Create chart name and version as used by the chart label.
*/}} */}}
{{- define "nzbhydra.chart" -}} {{- define "sonarr.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}} {{- end -}}
{{/* {{/*
Common labels Common labels
*/}} */}}
{{- define "nzbhydra.labels" -}} {{- define "sonarr.labels" -}}
helm.sh/chart: {{ include "nzbhydra.chart" . }} helm.sh/chart: {{ include "sonarr.chart" . }}
{{ include "nzbhydra.selectorLabels" . }} {{ include "sonarr.selectorLabels" . }}
{{- if .Chart.AppVersion }} {{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }} {{- end }}
@ -46,17 +46,17 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{/* {{/*
Selector labels Selector labels
*/}} */}}
{{- define "nzbhydra.selectorLabels" -}} {{- define "sonarr.selectorLabels" -}}
app.kubernetes.io/name: {{ include "nzbhydra.name" . }} app.kubernetes.io/name: {{ include "sonarr.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}} {{- end -}}
{{/* {{/*
Create the name of the service account to use Create the name of the service account to use
*/}} */}}
{{- define "nzbhydra.serviceAccountName" -}} {{- define "sonarr.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}} {{- if .Values.serviceAccount.create -}}
{{ default (include "nzbhydra.fullname" .) .Values.serviceAccount.name }} {{ default (include "sonarr.fullname" .) .Values.serviceAccount.name }}
{{- else -}} {{- else -}}
{{ default "default" .Values.serviceAccount.name }} {{ default "default" .Values.serviceAccount.name }}
{{- end -}} {{- end -}}

View File

@ -0,0 +1,60 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "plexporter.fullname" . }}
labels:
{{- include "plexporter.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "plexporter.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "plexporter.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "plexporter.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
env:
- name: PLEX_SERVER
value: {{ .Values.metrics.plex_server }}
- name: PLEX_TOKEN
value: {{ .Values.metrics.plex_token }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 9000
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View File

@ -2,7 +2,7 @@
apiVersion: v1 apiVersion: v1
kind: ServiceAccount kind: ServiceAccount
metadata: metadata:
name: {{ include "nzbhydra.serviceAccountName" . }} name: {{ include "sonarr.serviceAccountName" . }}
labels: labels:
{{ include "nzbhydra.labels" . | nindent 4 }} {{ include "sonarr.labels" . | nindent 4 }}
{{- end -}} {{- end -}}

View File

@ -1,9 +1,9 @@
apiVersion: v1 apiVersion: v1
kind: Pod kind: Pod
metadata: metadata:
name: "{{ include "nzbhydra.fullname" . }}-test-connection" name: "{{ include "sonarr.fullname" . }}-test-connection"
labels: labels:
{{ include "nzbhydra.labels" . | nindent 4 }} {{ include "sonarr.labels" . | nindent 4 }}
annotations: annotations:
"helm.sh/hook": test-success "helm.sh/hook": test-success
spec: spec:
@ -11,5 +11,5 @@ spec:
- name: wget - name: wget
image: busybox image: busybox
command: ['wget'] command: ['wget']
args: ['{{ include "nzbhydra.fullname" . }}:{{ .Values.service.port }}'] args: ['{{ include "sonarr.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never restartPolicy: Never

View File

@ -1,17 +1,22 @@
# Default values for nzbhydra. # Default values for sonarr.
# This is a YAML-formatted file. # This is a YAML-formatted file.
# Declare variables to be passed into your templates. # Declare variables to be passed into your templates.
replicaCount: 1 replicaCount: 1
image: image:
repository: harbor.ervine.dev/public/x86_64/alpine/nzbhydra repository: harbor.ervine.dev/public/x86_64/prometheus-plex-exporter
pullPolicy: Always tag: latest
pullPolicy: IfNotPresent
imagePullSecrets: [] imagePullSecrets: []
nameOverride: "" nameOverride: ""
fullnameOverride: "" fullnameOverride: ""
metrics:
plex_token: xwDKx3sL621esg8ELVHj
plex_server: "http://plex.ipa.champion:32400"
serviceAccount: serviceAccount:
# Specifies whether a service account should be created # Specifies whether a service account should be created
create: true create: true
@ -32,7 +37,7 @@ securityContext:
service: service:
type: ClusterIP type: ClusterIP
port: 5076 port: 9000
ingress: ingress:
enabled: false enabled: false
@ -56,8 +61,8 @@ resources:
# cpu: 100m # cpu: 100m
# memory: 128Mi # memory: 128Mi
requests: requests:
cpu: 300m cpu: 20m
memory: 256Mi memory: 64Mi
nodeSelector: nodeSelector:
location: livingRoom location: livingRoom
@ -66,9 +71,3 @@ tolerations: []
affinity: {} affinity: {}
config:
persistence:
enabled: true
existingClaim: media-nzbhydra-config
storageClassName: nfs-client-hermes
storageSize: 10Gi