[plex] add promtail to ship logs to loki (#337)

* add startup probe to plex

* bump version

* add promtail sidecar

* fix up probes

* fix up logging paths in templates

* add new line to configmap
This commit is contained in:
Devin Buhl 2020-08-28 09:19:24 -04:00 committed by GitHub
parent 4c79130198
commit 83d76d5abe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 104 additions and 15 deletions

View File

@ -1,8 +1,8 @@
apiVersion: v1
appVersion: 1.19.1.2645-ccb6eb67e
appVersion: 1.19.5.3112-b23ab3896
description: Plex Media Server
name: plex
version: 1.7.2
version: 1.8.0
keywords:
- plex
home: https://plex.tv/

View File

@ -62,6 +62,20 @@ spec:
{{- 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 }}
@ -181,16 +195,21 @@ spec:
httpGet:
path: /identity
port: 32400
initialDelaySeconds: {{ .Values.probes.readiness.initialDelaySeconds }}
failureThreshold: {{ .Values.probes.readiness.failureThreshold }}
timeoutSeconds: {{ .Values.probes.readiness.timeoutSeconds }}
periodSeconds: {{ .Values.probes.readiness.periodSeconds }}
livenessProbe:
httpGet:
path: /identity
port: 32400
initialDelaySeconds: {{ .Values.probes.liveness.initialDelaySeconds }}
failureThreshold: {{ .Values.probes.liveness.failureThreshold }}
timeoutSeconds: {{ .Values.probes.liveness.timeoutSeconds }}
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
@ -223,6 +242,8 @@ spec:
{{- 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 }}
@ -235,10 +256,7 @@ spec:
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
##### VOLUMES START #####
volumes:
{{- if .Values.persistence.data.enabled }}
- name: data
@ -288,6 +306,8 @@ spec:
{{- end }}
- name: shared
emptyDir: {}
- name: shared-logs
emptyDir: {}
{{- if .Values.plexPreferences.enabled }}
- name: {{ .Values.plexPreferences.volume.name }}
configMap:
@ -303,7 +323,22 @@ spec:
secret:
secretName: {{ .Values.certificate.pkcsMangler.certificateSecret.name }}
{{- end }}
##### VOLUMES 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 }}

View File

@ -0,0 +1,18 @@
{{- 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:
{{- if .Values.logging.promtail.config }}
{{ $root := . }}
promtail.yaml: |
{{ tpl (toYaml .Values.logging.promtail.config | indent 4) $root }}
{{- end }}
{{- end }}

View File

@ -291,16 +291,52 @@ certificate:
name: plex-certs
mountPath: /etc/plex-certs
# Logging configuration
# Standard Plex log paths:
# - /config/Library/Application\ Support/Plex\ Media\ Server/Logs/*.log
# - /config/Library/Application\ Support/Plex\ Media\ Server/Logs/PMS Plugin Logs/*.log
logging:
promtail:
enabled: false
image:
repository: grafana/promtail
tag: 1.6.0
pullPolicy: IfNotPresent
config:
server:
disable: true
positions:
filename: /tmp/positions.yaml
clients:
- url: http://loki.logs.svc.cluster.local:3100/loki/api/v1/push
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"
# Probes configuration
probes:
liveness:
initialDelaySeconds: 15
failureThreshold: 5
timeoutSeconds: 5
periodSeconds: 10
readiness:
initialDelaySeconds: 15
failureThreshold: 5
timeoutSeconds: 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