1
0
Fork 0

chore: wip
Some checks are pending
Release Docs / Release Docs (push) Waiting to run
Release / Build and publish a Docker image / build-and-push-image (push) Waiting to run

This commit is contained in:
Vojtěch Mareš 2024-05-01 07:47:42 +02:00
parent 491a9cc294
commit eeada0e25d
Signed by: vojtech.mares
GPG key ID: C6827B976F17240D
17 changed files with 674 additions and 0 deletions

View file

@ -0,0 +1,23 @@
# 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
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

View file

@ -0,0 +1,7 @@
apiVersion: v2
name: pterodactyl-panel
description: Pterodactyl Panel Helm chart
kubeVersion: ">=1.24.0"
type: application
version: 0.1.0
appVersion: "1.10.1"

View file

@ -0,0 +1,22 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "pterodactyl-panel.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.service.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 "pterodactyl-panel.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "pterodactyl-panel.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "pterodactyl-panel.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}

View file

@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "pterodactyl-panel.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 "pterodactyl-panel.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 "pterodactyl-panel.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "pterodactyl-panel.labels" -}}
helm.sh/chart: {{ include "pterodactyl-panel.chart" . }}
{{ include "pterodactyl-panel.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "pterodactyl-panel.selectorLabels" -}}
app.kubernetes.io/name: {{ include "pterodactyl-panel.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "pterodactyl-panel.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "pterodactyl-panel.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

View file

@ -0,0 +1,44 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "pterodactyl-panel.fullname" . }}
labels:
app.kubernetes.io/name: php-cli
app.kubernetes.io/version: "{{ .Values.phpfpm.image.tag | default .Chart.AppVersion }}"
app.kubernetes.io/component: backend-cronjob
app.kubernetes.io/part-of: pterodactyl-panel
spec:
schedule: "* * * * *"
jobTemplate:
spec:
backoffLimit: 4
activeDeadlineSeconds: 60
ttlSecondsAfterFinished: 900
template:
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "pterodactyl-panel.serviceAccountName" . }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
resources:
{{- toYaml .Values.cron.resources | nindent 14 }}
command: ["php"]
args:
- /var/www/pterodactyl/artisan
- schedule:run
envFrom:
- configMapRef:
name: {{ include "pterodactyl-panel.fullname" . }}-config
- secretRef:
name: {{ include "pterodactyl-panel.fullname" . }}-credentials
restartPolicy: OnFailure

View file

@ -0,0 +1,41 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "pterodactyl-panel.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "pterodactyl-panel.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
ingressClassName: {{ .Values.ingress.className }}
{{- 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: {{ .path }}
pathType: {{ .pathType }}
backend:
service:
name: {{ $fullName }}--nginx
port:
number: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}

View file

@ -0,0 +1,43 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-conf
data:
nginx.conf: |
user nginx;
worker_processes 1;
error_log /dev/stdout warn;
events {
worker_connections 1024;
}
http {
log_format json_combined escape=json
'{'
'"time_local":"$time_local",'
'"remote_addr":"$remote_addr",'
'"remote_user":"$remote_user",'
'"request":"$request",'
'"status": "$status",'
'"body_bytes_sent":"$body_bytes_sent",'
'"request_time":"$request_time",'
'"http_referrer":"$http_referer",'
'"http_user_agent":"$http_user_agent"'
'}';
access_log /dev/stdout main;
server {
listen 80;
server_name _;
location / {
root html;
index index.html index.htm;
}
}
include /etc/nginx/virtualhost/virtualhost.conf;
}

View file

@ -0,0 +1,108 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "pterodactyl-panel.fullname" . }}--nginx
labels:
app.kubernetes.io/name: nginx
app.kubernetes.io/version: "{{ .Values.nginx.image.tag }}"
app.kubernetes.io/component: reverse-proxy
app.kubernetes.io/part-of: pterodactyl-panel
{{- include "pterodactyl-panel.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.nginx.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "pterodactyl-panel.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.nginx.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "pterodactyl-panel.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.nginx.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "pterodactyl-panel.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.nginx.podSecurityContext | nindent 8 }}
terminationGracePeriodSeconds: 30
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.nginx.securityContext | nindent 12 }}
image: "{{ .Values.nginx.image.repository }}:{{ .Values.nginx.image.tag }}"
imagePullPolicy: {{ .Values.nginx.image.pullPolicy }}
args:
- /bin/sh
- -c
- |
nginx -g "daemon off";
lifecycle:
preStop:
exec:
command:
- /bin/sh
- -c
- sleep 5 && /usr/sbin/nginx
- -s
- quit
ports:
- name: http
containerPort: 8080
protocol: TCP
livenessProbe:
exec:
command:
- /bin/sh
- -c
- "[ -f /var/run/nginx.pid ] && ps -A | grep nginx"
initialDelaySeconds: 10
periodSeconds: 5
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.nginx.resources | nindent 12 }}
volumeMounts:
- mountPath: /var/cache/nginx
name: cache
- mountPath: /var/run
name: pid
volumes:
- name: cache
emptyDir: {}
- name: pid
emptyDir: {}
{{- with .Values.nginx.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nginx.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nginx.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View file

@ -0,0 +1,28 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "pterodactyl-panel.fullname" . }}--nginx
labels:
{{- include "pterodactyl-panel.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "pterodactyl-panel.fullname" . }}--nginx
minReplicas: {{ .Values.nginx.autoscaling.minReplicas }}
maxReplicas: {{ .Values.nginx.autoscaling.maxReplicas }}
metrics:
{{- if .Values.nginx.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.nginx.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.nginx.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.nginx.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}

View file

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

View file

@ -0,0 +1,85 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "pterodactyl-panel.fullname" . }}--php-fpm
labels:
app.kubernetes.io/name: php-fpm
app.kubernetes.io/version: "{{ .Values.phpfpm.image.tag | default .Chart.AppVersion }}"
app.kubernetes.io/component: backend
app.kubernetes.io/part-of: pterodactyl-panel
{{- include "pterodactyl-panel.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.phpFpm.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "pterodactyl-panel.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.phpFpm.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "pterodactyl-panel.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.phpFpm.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "pterodactyl-panel.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.phpFpm.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.phpFpm.securityContext | nindent 12 }}
image: "{{ .Values.phpFpm.image.repository }}:{{ .Values.phpFpm.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.phpFpm.image.pullPolicy }}
lifecycle:
preStop:
exec:
command:
- /bin/sh
- '-c'
- sleep 5 && kill -SIGQUIT 1
ports:
- name: fastcgi
containerPort: 9000
protocol: TCP
livenessProbe:
tcpSocket:
port: 9000
initialDelaySeconds: 5
periodSeconds: 10
readinessProbe:
tcpSocket:
port: 9000
initialDelaySeconds: 5
periodSeconds: 10
resources:
{{- toYaml .Values.phpFpm.resources | nindent 12 }}
{{- with .Values.phpFpm.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.phpFpm.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.phpFpm.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View file

@ -0,0 +1,28 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "pterodactyl-panel.fullname" . }}--php-fpm
labels:
{{- include "pterodactyl-panel.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "pterodactyl-panel.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}

View file

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

View file

@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "pterodactyl-panel.serviceAccountName" . }}
labels:
{{- include "pterodactyl-panel.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}

View file

@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "pterodactyl-panel.fullname" . }}-test-connection"
labels:
{{- include "pterodactyl-panel.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "pterodactyl-panel.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never

View file

@ -0,0 +1,126 @@
nameOverride: ""
fullnameOverride: ""
autoscaling:
enabled: false
nginx:
imagePullSecrets: []
image:
repository: nginx
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "1.23.1"
replicaCount: 1
autoscaling:
minReplicas: 2
maxReplicas: 10
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
service:
type: ClusterIP
port: 8080
resources:
limits:
cpu: 250m
memory: 512Mi
requests:
cpu: 100m
memory: 256Mi
podAnnotations: {}
podSecurityContext:
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
- NET_RAW
securityContext:
runAsNonRoot: true
runAsUser: 10014
runAsGroup: 10014
nodeSelector: {}
tolerations: []
affinity: {}
phpFpm:
imagePullSecrets: []
image:
repository: ghcr.io/acaslab/pterodactyl-panel
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""
replicaCount: 1
autoscaling:
minReplicas: 2
maxReplicas: 10
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
service:
type: ClusterIP
port: 9000
resources:
limits:
cpu: 400m
memory: 256Mi
requests:
cpu: 600m
memory: 512Mi
podAnnotations: {}
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
nodeSelector: {}
tolerations: []
affinity: {}
serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""
ingress:
enabled: false
className: ""
annotations: {}
hosts:
- host: example.com
paths:
- path: /
pathType: Prefix
tls: []
# - secretName: example-tls
# hosts:
# - example.com