Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/pixelfed/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# 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.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.14.5
version: 0.15.0

# This is the version number of the application being deployed.
# renovate:image=ghcr.io/mattlqx/docker-pixelfed
Expand Down
4 changes: 3 additions & 1 deletion charts/pixelfed/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pixelfed

![Version: 0.14.5](https://img.shields.io/badge/Version-0.14.5-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.12.4-nginx](https://img.shields.io/badge/AppVersion-v0.12.4--nginx-informational?style=flat-square)
![Version: 0.15.0](https://img.shields.io/badge/Version-0.15.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.12.4-nginx](https://img.shields.io/badge/AppVersion-v0.12.4--nginx-informational?style=flat-square)

A Helm chart for deploying Pixelfed on Kubernetes

Expand Down Expand Up @@ -105,6 +105,8 @@ A Helm chart for deploying Pixelfed on Kubernetes
| pixelfed.force_https_urls | bool | `true` | Force https url generation |
| pixelfed.horizon.dark_mode | bool | `false` | darkmode for the web interface in the admin panel |
| pixelfed.horizon.prefix | string | `"horizon-"` | prefix will be used when storing all Horizon data in Redis |
| pixelfed.horizon.replicas | int | `1` | Number of replicas for the Horizon deployment when running separately. Ignored if autoscaling is enabled. |
| pixelfed.horizon.separate_deployment | bool | `false` | Enable running Laravel Horizon in a separate deployment. Allow to scale the backend queue workers independently. |
| pixelfed.image_driver | string | `"gd"` | library to process images. options: "gd" (default), "imagick" |
| pixelfed.image_quality | int | `80` | Set the image optimization quality, between 1-100. Lower uses less space, higher more quality |
| pixelfed.instance.contact_email | string | `""` | The public contact email for your server |
Expand Down
11 changes: 9 additions & 2 deletions charts/pixelfed/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ Common labels
*/}}
{{- define "pixelfed.labels" -}}
helm.sh/chart: {{ include "pixelfed.chart" . }}
{{ include "pixelfed.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
Expand All @@ -45,9 +44,17 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{/*
Selector labels
*/}}
{{- define "pixelfed.selectorLabels" -}}
{{- define "pixelfed.web.selectorLabels" -}}
app.kubernetes.io/name: {{ include "pixelfed.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: web
{{- end }}

{{/*
Horizon selector labels
*/}}
{{- define "pixelfed.horizon.selectorLabels" -}}
app.kubernetes.io/component: horizon
{{- end }}

{{/*
Expand Down
7 changes: 6 additions & 1 deletion charts/pixelfed/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
{{- end }}
selector:
matchLabels:
{{- include "pixelfed.selectorLabels" . | nindent 6 }}
{{- include "pixelfed.web.selectorLabels" . | nindent 6 }}
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
template:
metadata:
Expand All @@ -22,6 +22,7 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "pixelfed.web.selectorLabels" . | nindent 8 }}
{{- include "pixelfed.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
Expand Down Expand Up @@ -67,6 +68,10 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}

# Run horizon inside this pod dependent upon the separate_deployment flag
- name: ENABLE_HORIZON
value: "{{ not .Values.pixelfed.horizon.separate_deployment }}"

# pixelfed app key
- name: APP_KEY
valueFrom:
Expand Down
234 changes: 234 additions & 0 deletions charts/pixelfed/templates/deployment_backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
{{- if .Values.pixelfed.horizon.separate_deployment }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "pixelfed.fullname" . }}-backend
labels:
{{- include "pixelfed.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.pixelfed.horizon.replicas }}
{{- end }}
selector:
matchLabels:
{{- include "pixelfed.horizon.selectorLabels" . | nindent 6 }}
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
template:
metadata:
annotations:
# reload deployment if config files change
php-config-hash: {{ toJson .Values.phpConfigs | sha256sum }}
checksum/config: {{ include (print $.Template.BasePath "/configmap_env.yaml") . | sha256sum }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "pixelfed.horizon.selectorLabels" . | nindent 8 }}
{{- include "pixelfed.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "pixelfed.serviceAccountName" . }}
{{- with .Values.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.extraInitContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}-backend
{{- with .Values.securityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ["php"]
args: ["artisan", "horizon"]
envFrom:
{{- with .Values.extraEnvFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
- configMapRef:
name: {{ include "pixelfed.fullname" . }}-env
env:
{{- with .Values.extraEnv }}
{{- toYaml . | nindent 12 }}
{{- end }}

# pixelfed app key
- name: APP_KEY
valueFrom:
secretKeyRef:
{{- if and .Values.pixelfed.app.existingSecret .Values.pixelfed.app.existingSecretKey }}
name: {{ .Values.pixelfed.app.existingSecret }}
key: {{ .Values.pixelfed.app.existingSecretKey }}
{{- else }}
name: {{ include "pixelfed.fullname" . }}-app-key
key: key
{{- end }}

# valkey AKA redis
{{- if and .Values.externalValkey.enabled .Values.externalValkey.existingSecretKeys.host }}
- name: REDIS_HOST
valueFrom:
secretKeyRef:
{{- if and .Values.externalValkey.existingSecret .Values.externalValkey.existingSecretKeys.host }}
name: {{ .Values.externalValkey.existingSecret }}
key: {{ .Values.externalValkey.existingSecretKeys.host }}
{{- else }}
name: {{ include "pixelfed.fullname" . }}-valkey
key: host
{{- end }}
{{- end }}

{{- if and .Values.externalValkey.enabled .Values.externalValkey.existingSecret .Values.externalValkey.existingSecretKeys.port }}
- name: REDIS_PORT
valueFrom:
secretKeyRef:
{{- if and .Values.externalValkey.existingSecret .Values.externalValkey.existingSecretKeys.port }}
name: {{ .Values.externalValkey.existingSecret }}
key: {{ .Values.externalValkey.existingSecretKeys.port }}
{{- else }}
name: {{ include "pixelfed.fullname" . }}-valkey
key: port
{{- end }}
{{- end }}

- name: REDIS_PASSWORD
valueFrom:
secretKeyRef:
{{- if and .Values.externalValkey.enabled .Values.externalValkey.existingSecret }}
name: {{ .Values.externalValkey.existingSecret }}
key: {{ .Values.externalValkey.existingSecretKeys.password }}
{{- else if and .Values.externalValkey.enabled (not .Values.externalValkey.existingSecret) }}
name: {{ include "pixelfed.fullname" . }}-valkey
key: password
{{- else if .Values.valkey.auth.existingSecret }}
name: {{ .Values.valkey.auth.existingSecret }}
key: password
{{- else }}
name: {{ .Values.valkey.fullnameOverride }}
key: valkey-password
{{- end }}

# database configuration
{{- if .Values.externalDatabase.enabled }}
- name: DB_HOST
valueFrom:
secretKeyRef:
{{- if and .Values.externalDatabase.enabled .Values.externalDatabase.existingSecret .Values.externalDatabase.existingSecretKeys.host }}
name: {{ .Values.externalDatabase.existingSecret }}
key: {{ .Values.externalDatabase.existingSecretKeys.host }}
{{- else if and .Values.externalDatabase.enabled (not .Values.externalDatabase.existingSecretKeys.host) }}
name: {{ include "pixelfed.fullname" . }}-database
key: host
{{- end }}
{{- end }}

{{- if .Values.externalDatabase.enabled }}
- name: DB_USERNAME
valueFrom:
secretKeyRef:
{{- if and .Values.externalDatabase.enabled .Values.externalDatabase.existingSecret .Values.externalDatabase.existingSecretKeys.username }}
name: {{ .Values.externalDatabase.existingSecret }}
key: {{ .Values.externalDatabase.existingSecretKeys.username }}
{{- else if and .Values.externalDatabase.enabled (not .Values.externalDatabase.existingSecretKeys.username) }}
name: {{ include "pixelfed.fullname" . }}-database
key: username
{{- end }}
{{- end }}

{{- if .Values.externalDatabase.enabled }}
- name: DB_DATABASE
valueFrom:
secretKeyRef:
{{- if and .Values.externalDatabase.enabled .Values.externalDatabase.existingSecret .Values.externalDatabase.existingSecretKeys.database }}
name: {{ .Values.externalDatabase.existingSecret }}
key: {{ .Values.externalDatabase.existingSecretKeys.database }}
{{- else if and .Values.externalDatabase.enabled (not .Values.externalDatabase.existingSecretKeys.database) }}
name: {{ include "pixelfed.fullname" . }}-database
key: database
{{- end }}
{{- end }}

{{- if .Values.externalDatabase.enabled }}
- name: DB_PORT
valueFrom:
secretKeyRef:
{{- if and .Values.externalDatabase.enabled .Values.externalDatabase.existingSecret .Values.externalDatabase.existingSecretKeys.port }}
name: {{ .Values.externalDatabase.existingSecret }}
key: {{ .Values.externalDatabase.existingSecretKeys.port }}
{{- else if and .Values.externalDatabase.enabled (not .Values.externalDatabase.existingSecretKeys.port) }}
name: {{ include "pixelfed.fullname" . }}-database
key: port
{{- end }}
{{- end }}

- name: DB_PASSWORD
{{- if and .Values.externalDatabase.enabled (not .Values.externalDatabase.existingSecret) }}
value: {{ .Values.externalDatabase.password }}
{{- else }}
valueFrom:
secretKeyRef:
{{- if and .Values.externalDatabase.enabled .Values.externalDatabase.existingSecret }}
name: {{ .Values.externalDatabase.existingSecret }}
key: {{ .Values.externalDatabase.existingSecretKeys.password }}
{{- else if .Values.postgresql.auth.existingSecret }}
name: {{ .Values.postgresql.auth.existingSecret }}
key: postgres-password
{{- else }}
name: {{ .Values.postgresql.fullnameOverride }}
key: postgres-password
{{- end }}
{{- end }}

{{- with .Values.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}

{{- if or .Values.extraVolumeMounts .Values.phpConfigs }}
volumeMounts:
{{- with .Values.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- range $key, $value := .Values.phpConfigs }}
- name: phpconfig
mountPath: {{ print "/usr/local/etc/php-fpm.d/%s" $key | quote }}
subPath: {{ $key }}
{{- end }}
{{- end }}{{/* end volumeMounts */}}

{{- if or .Values.phpConfigs .Values.extraVolumes }}
volumes:
{{- with .Values.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.phpConfigs }}
- name: phpconfig
configMap:
name: {{ template "pixelfed.fullname" . }}-phpconfig
{{- 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 }}
{{- end }}
32 changes: 32 additions & 0 deletions charts/pixelfed/templates/hpa_backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- if and .Values.autoscaling.enabled .Values.pixelfed.horizon.separate_deployment }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "pixelfed.fullname" . }}-backend
labels:
{{- include "pixelfed.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "pixelfed.fullname" . }}-backend
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/pixelfed/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ spec:
protocol: TCP
name: http
selector:
{{- include "pixelfed.selectorLabels" . | nindent 4 }}
{{- include "pixelfed.web.selectorLabels" . | nindent 4 }}
4 changes: 4 additions & 0 deletions charts/pixelfed/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,10 @@ pixelfed:
prefix: "horizon-"
# -- darkmode for the web interface in the admin panel
dark_mode: false
# -- Enable running Laravel Horizon in a separate deployment. Allow to scale the backend queue workers independently.
separate_deployment: false
# -- Number of replicas for the Horizon deployment when running separately. Ignored if autoscaling is enabled.
replicas: 1

# app specific settings
app:
Expand Down
Loading