From 7f3ec8d2968186709fca55cf4c4a245daa29cccb Mon Sep 17 00:00:00 2001 From: Kovah Date: Fri, 17 Jan 2025 15:59:56 +0100 Subject: [PATCH] Provide a helm chart for kubernetes deployments (#870) --- .gitignore | 2 +- app/Http/Middleware/SetupCheckMiddleware.php | 4 + deploy/README.md | 87 +++++++++ deploy/linkace/.env.k8s | 25 +++ deploy/linkace/.helmignore | 23 +++ deploy/linkace/Chart.yaml | 24 +++ deploy/linkace/templates/NOTES.txt | 20 ++ deploy/linkace/templates/_helpers.tpl | 62 ++++++ deploy/linkace/templates/cronjob.yaml | 30 +++ deploy/linkace/templates/deployment.yaml | 178 ++++++++++++++++++ deploy/linkace/templates/hpa.yaml | 32 ++++ deploy/linkace/templates/ingress.yaml | 41 ++++ deploy/linkace/templates/pvc.yaml | 54 ++++++ deploy/linkace/templates/secret.yaml | 18 ++ deploy/linkace/templates/service.yaml | 53 ++++++ deploy/linkace/templates/serviceaccount.yaml | 13 ++ .../templates/tests/test-connection.yaml | 15 ++ deploy/linkace/values.yaml | 108 +++++++++++ lang/ca_ES/setup.php | 2 +- lang/de_DE/setup.php | 2 +- lang/en_US/setup.php | 2 +- lang/es_ES/setup.php | 2 +- lang/fr_FR/setup.php | 2 +- lang/hu_HU/setup.php | 2 +- lang/it_IT/setup.php | 2 +- lang/ja_JP/setup.php | 2 +- lang/no_NO/setup.php | 2 +- lang/pl_PL/setup.php | 2 +- lang/ro_RO/setup.php | 2 +- lang/vi_VN/setup.php | 2 +- lang/zh_CN/setup.php | 2 +- routes/web.php | 1 + 32 files changed, 802 insertions(+), 14 deletions(-) create mode 100644 deploy/README.md create mode 100644 deploy/linkace/.env.k8s create mode 100644 deploy/linkace/.helmignore create mode 100644 deploy/linkace/Chart.yaml create mode 100644 deploy/linkace/templates/NOTES.txt create mode 100644 deploy/linkace/templates/_helpers.tpl create mode 100644 deploy/linkace/templates/cronjob.yaml create mode 100644 deploy/linkace/templates/deployment.yaml create mode 100644 deploy/linkace/templates/hpa.yaml create mode 100644 deploy/linkace/templates/ingress.yaml create mode 100644 deploy/linkace/templates/pvc.yaml create mode 100644 deploy/linkace/templates/secret.yaml create mode 100644 deploy/linkace/templates/service.yaml create mode 100644 deploy/linkace/templates/serviceaccount.yaml create mode 100644 deploy/linkace/templates/tests/test-connection.yaml create mode 100644 deploy/linkace/values.yaml diff --git a/.gitignore b/.gitignore index d0ffadcb..af8bad72 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,7 @@ yarn-error.log !.env.docker.production !.env.sqlite.production !.env.example +!.env.k8s .phpunit.result.cache _ide_helper.php _ide_helper_models.php -linkace diff --git a/app/Http/Middleware/SetupCheckMiddleware.php b/app/Http/Middleware/SetupCheckMiddleware.php index 5753f79e..0e658d39 100644 --- a/app/Http/Middleware/SetupCheckMiddleware.php +++ b/app/Http/Middleware/SetupCheckMiddleware.php @@ -33,6 +33,10 @@ public function handle(Request $request, Closure $next): mixed $setupCompleted = setupCompleted(); + if ($request->is('_health')) { + return $next($request); + } + if ($request->is('setup/*')) { if ($setupCompleted) { // Do not allow access to the setup after it was completed diff --git a/deploy/README.md b/deploy/README.md new file mode 100644 index 00000000..be0293f7 --- /dev/null +++ b/deploy/README.md @@ -0,0 +1,87 @@ +# LinkAce Helm Chart (BETA) + +This Helm chart can be used to deploy LinkAce to your Kubernetes cluster. Please note that this chart deploys the +full application stack by default, including a MariaDB database and Redis for caching. It is possible to use an existing +database or Redis. Please see the values.yml file for details. + +This Helm Chart is currently a beta version. Please give feedback if you are using it. + + +## Overview + +The following resources will be created during the deployment of LinkAce: + +- Deployment for LinkAce itself including + - a Service + - an Ingress + - a Secret for the configuration and passwords + - PersistentVolumeClaim for both logs and backups + - a cronjob which runs every minute to properly execute scheduled commands + - if autoscaling is enabled + - a HorizontalPodAutoscaler for the LinkAce container +- if MariaDB and Redis + - an additional Deployment including MariaDB and Redis + - Services for both applications + - PersistentVolumeClaim for both applications + + +## Requirements + +- a working Kubernetes cluster +- `kubectl` installed and configured to access your cluster +- `helm` installed + + +## Deployment + +### Prepare the environment variables + +To be able to correctly use LinkAce you have to adjust some parts of the configuration **before** the deployment. +Please open the `.env.k8s` file and do the following adjustments: + +- Please run `docker run --rm linkace/linkace php artisan key:generate --show` and set the output as the `APP_KEY` variable. +- Change the database password at `DB_PASSWORD` from the current value to something unique and secure. +- Change the redis password at `REDIS_PASSWORD` from the current value to something unique and secure. +- Configure sending emails from LinkAce by adjusting the settings starting with `MAIL`. + +LinkAce stores the configuration from the .env.k8s file as a Secret in Kubernetes, as there is sensible data which should +not be exposed as regular environment variables. + +### Adjust the Kubernetes deployment configuration (optional) + +You may change certain settings of the deployment such as the allowed resources, volume sizes or database version used. +Depending on the type of changes you want to do, you may either +- pass specific options directly to helm with + ``` + helm upgrade linkace ./linkace --set database.volumeSize=2Gi + ``` +- or change the values directly in the `values.yml`. + +> Please be advised that enabling autoscaling must NOT be turned on if you have either the database or redis enabled! + +### Deploy the application for the first time + +```bash +cd deploy +helm install linkace ./linkace +``` + +To deploy LinkAce without a database and Redis, use this command: + +```bash +helm install linkace ./linkace --set database.enabled=false --set redis.enabled=false +``` + +### Update an existing LinkAce deployment + +```bash +cd deploy +helm upgrade linkace ./linkace +``` + +### Remove an existing LinkAce deployment + +```bash +cd deploy +helm uninstall linkace +``` diff --git a/deploy/linkace/.env.k8s b/deploy/linkace/.env.k8s new file mode 100644 index 00000000..01b61de4 --- /dev/null +++ b/deploy/linkace/.env.k8s @@ -0,0 +1,25 @@ +APP_KEY=someRandomStringWith32Characters + +DB_CONNECTION=mysql +DB_HOST=linkace-mariadb +DB_PORT=3306 +DB_DATABASE=linkace +DB_USERNAME=linkace +DB_PASSWORD=ChangeThisToASecurePassword! + +REDIS_HOST=linkace-redis +REDIS_PASSWORD=ChangeThisToASecurePassword! +REDIS_PORT=6379 + +MAIL_FROM_ADDRESS=your@email.com +MAIL_FROM_NAME=LinkAce +MAIL_DRIVER=smtp +MAIL_HOST=smtp.mailtrap.io +MAIL_PORT=2525 +MAIL_USERNAME=null +MAIL_PASSWORD=null +MAIL_ENCRYPTION=null + +BACKUP_ENABLED=true +SESSION_DRIVER=redis +CACHE_DRIVER=redis diff --git a/deploy/linkace/.helmignore b/deploy/linkace/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/deploy/linkace/.helmignore @@ -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/ diff --git a/deploy/linkace/Chart.yaml b/deploy/linkace/Chart.yaml new file mode 100644 index 00000000..05a3df7b --- /dev/null +++ b/deploy/linkace/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: linkace +description: A Helm chart for deploying LinkAce to Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +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: 1.0.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "2.0.0" diff --git a/deploy/linkace/templates/NOTES.txt b/deploy/linkace/templates/NOTES.txt new file mode 100644 index 00000000..e909b312 --- /dev/null +++ b/deploy/linkace/templates/NOTES.txt @@ -0,0 +1,20 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.paths }} +http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $.Values.ingress.host }}{{ .path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "linkace.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 its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "linkace.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "linkace.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 "linkace.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 }} diff --git a/deploy/linkace/templates/_helpers.tpl b/deploy/linkace/templates/_helpers.tpl new file mode 100644 index 00000000..43ca0f94 --- /dev/null +++ b/deploy/linkace/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "linkace.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 "linkace.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 "linkace.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "linkace.labels" -}} +helm.sh/chart: {{ include "linkace.chart" . }} +{{ include "linkace.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "linkace.selectorLabels" -}} +app.kubernetes.io/name: {{ include "linkace.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "linkace.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "linkace.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/deploy/linkace/templates/cronjob.yaml b/deploy/linkace/templates/cronjob.yaml new file mode 100644 index 00000000..4dddf793 --- /dev/null +++ b/deploy/linkace/templates/cronjob.yaml @@ -0,0 +1,30 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: {{ include "linkace.fullname" . }}-cronjob +spec: + schedule: "* * * * *" + jobTemplate: + spec: + template: + spec: + restartPolicy: OnFailure + volumes: + - name: {{ .Release.Name }}-app-logs + persistentVolumeClaim: + claimName: {{ .Release.Name }}-app-logs-pvc + - name: {{ .Release.Name }}-app-backups + persistentVolumeClaim: + claimName: {{ .Release.Name }}-app-backups-pvc + containers: + - name: {{ .Release.Name }}-cron + image: "{{ .Values.linkace.repository }}:{{ .Values.linkace.tag }}" + command: ["php", "artisan", "schedule:run"] + envFrom: + - secretRef: + name: {{ .Release.Name }}-env + volumeMounts: + - name: {{ .Release.Name }}-app-logs + mountPath: "/app/storage/logs" + - name: {{ .Release.Name }}-app-backups + mountPath: "/app/storage/app/backups/LinkAce" diff --git a/deploy/linkace/templates/deployment.yaml b/deploy/linkace/templates/deployment.yaml new file mode 100644 index 00000000..1bb2b003 --- /dev/null +++ b/deploy/linkace/templates/deployment.yaml @@ -0,0 +1,178 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "linkace.fullname" . }} + labels: + {{- include "linkace.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "linkace.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + deploymentRevisionId: "{{ .Release.Revision }}" + {{- include "linkace.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "linkace.serviceAccountName" . }} + {{- with .Values.podSecurityContext }} + securityContext: + {{- toYaml . | nindent 8 }} + {{- end }} + volumes: + - name: {{ .Release.Name }}-app-logs + persistentVolumeClaim: + claimName: {{ .Release.Name }}-app-logs-pvc + - name: {{ .Release.Name }}-app-backups + persistentVolumeClaim: + claimName: {{ .Release.Name }}-app-backups-pvc + + containers: + # LinkAce application container + - name: {{ .Chart.Name }} + image: "{{ .Values.linkace.repository }}:{{ .Values.linkace.tag }}" + imagePullPolicy: {{ .Values.linkace.pullPolicy }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + envFrom: + - secretRef: + name: {{ .Release.Name }}-env + livenessProbe: + httpGet: + path: /_health + port: http + readinessProbe: + httpGet: + path: /_health + port: http + {{- with .Values.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + volumeMounts: + - name: {{ .Release.Name }}-app-logs + mountPath: "/app/storage/logs" + - name: {{ .Release.Name }}-app-backups + mountPath: "/app/storage/app/backups/LinkAce" + +{{- if or .Values.database.enabled .Values.redis.enabled }} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "linkace.fullname" . }}-services + labels: + {{- include "linkace.labels" . | nindent 4 }} +spec: + replicas: 1 + selector: + matchLabels: + {{- include "linkace.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + deploymentRevisionId: "{{ .Release.Revision }}" + {{- include "linkace.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "linkace.serviceAccountName" . }} + {{- with .Values.podSecurityContext }} + securityContext: + {{- toYaml . | nindent 8 }} + {{- end }} + volumes: + {{- if .Values.database.enabled }} + - name: mariadb-data + persistentVolumeClaim: + claimName: {{ .Release.Name }}-mariadb-pvc + {{- end }} + {{- if .Values.redis.enabled }} + - name: redis-data + persistentVolumeClaim: + claimName: {{ .Release.Name }}-redis-pvc + {{- end }} + + containers: + {{- if .Values.database.enabled }} + # Database container + - name: mariadb + image: {{ .Values.database.repository }}:{{ .Values.database.tag }} + imagePullPolicy: {{ .Values.database.pullPolicy }} + ports: + - name: mariadb + containerPort: 3306 + env: + - name: MARIADB_DATABASE + valueFrom: + secretKeyRef: + name: {{ .Release.Name }}-env + key: DB_DATABASE + - name: MARIADB_USER + valueFrom: + secretKeyRef: + name: {{ .Release.Name }}-env + key: DB_USERNAME + - name: MARIADB_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Release.Name }}-env + key: DB_PASSWORD + - name: MARIADB_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Release.Name }}-env + key: DB_PASSWORD + volumeMounts: + - name: mariadb-data + mountPath: "/var/lib/mysql" + {{- end }} + + {{- if .Values.redis.enabled }} + # Redis container + - name: redis + image: {{ .Values.redis.repository }}:{{ .Values.redis.tag }} + ports: + - name: redis + containerPort: 6379 + command: + - "redis-server" + - "--requirepass" + - "$(REDIS_PASSWORD)" + env: + - name: REDIS_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Release.Name }}-env + key: REDIS_PASSWORD + volumeMounts: + - name: redis-data + mountPath: "/data" + {{- end }} + +{{- end }} + diff --git a/deploy/linkace/templates/hpa.yaml b/deploy/linkace/templates/hpa.yaml new file mode 100644 index 00000000..e788cd1f --- /dev/null +++ b/deploy/linkace/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "linkace.fullname" . }} + labels: + {{- include "linkace.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "linkace.fullname" . }} + 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 }} diff --git a/deploy/linkace/templates/ingress.yaml b/deploy/linkace/templates/ingress.yaml new file mode 100644 index 00000000..bfae4e57 --- /dev/null +++ b/deploy/linkace/templates/ingress.yaml @@ -0,0 +1,41 @@ +{{- if .Values.ingress.enabled -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "linkace.fullname" . }} + labels: + {{- include "linkace.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- with .Values.ingress.className }} + ingressClassName: {{ . }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + - host: {{ .Values.ingress.host | quote }} + http: + paths: + {{- range .Values.ingress.paths }} + - path: {{ .path }} + {{- with .pathType }} + pathType: {{ . }} + {{- end }} + backend: + service: + name: {{ include "linkace.fullname" $ }} + port: + number: {{ $.Values.service.port }} + {{- end }} +{{- end }} diff --git a/deploy/linkace/templates/pvc.yaml b/deploy/linkace/templates/pvc.yaml new file mode 100644 index 00000000..af3377cf --- /dev/null +++ b/deploy/linkace/templates/pvc.yaml @@ -0,0 +1,54 @@ +# LinkAce Logs volume +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Release.Name }}-app-backups-pvc +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: {{ .Values.linkace.logsVolumeSize }} +--- +# LinkAce Backups volume +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Release.Name }}-app-logs-pvc +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: {{ .Values.linkace.backupVolumeSize }} + + +{{- if .Values.database.enabled }} +--- +# MariaDB data volume +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Release.Name }}-mariadb-pvc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: {{ .Values.database.volumeSize }} +{{- end }} + +{{- if .Values.redis.enabled }} +--- +# Redis data volume +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Release.Name }}-redis-pvc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: {{ .Values.redis.volumeSize }} +{{- end }} diff --git a/deploy/linkace/templates/secret.yaml b/deploy/linkace/templates/secret.yaml new file mode 100644 index 00000000..d6ef1fcf --- /dev/null +++ b/deploy/linkace/templates/secret.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Release.Name }}-env +type: Opaque +data: +{{- $files := .Files }} +{{- with $files.Get ".env.k8s" }} +{{- range $line := splitList "\n" . }} +{{- $line := trim $line }} +{{- if and (ne (len $line) 0) (not (hasPrefix "#" $line)) }} +{{- $kv := splitList "=" $line }} +{{- if eq (len $kv) 2 }} + {{ index $kv 0 | trim | quote }}: {{ index $kv 1 | trim | b64enc | quote }} +{{- end }} +{{- end }} +{{- end }} +{{- end }} diff --git a/deploy/linkace/templates/service.yaml b/deploy/linkace/templates/service.yaml new file mode 100644 index 00000000..894422e8 --- /dev/null +++ b/deploy/linkace/templates/service.yaml @@ -0,0 +1,53 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "linkace.fullname" . }} + labels: + {{- include "linkace.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "linkace.selectorLabels" . | nindent 4 }} + +{{- if .Values.database.enabled }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "linkace.fullname" . }}-mariadb + labels: + {{- include "linkace.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.database.port }} + targetPort: mariadb + protocol: TCP + name: mariadb + selector: + {{- include "linkace.selectorLabels" . | nindent 4 }} +{{- end }} + +{{- if .Values.redis.enabled }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "linkace.fullname" . }}-redis + labels: + {{- include "linkace.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.redis.port }} + targetPort: redis + protocol: TCP + name: redis + selector: + {{- include "linkace.selectorLabels" . | nindent 4 }} +{{- end }} diff --git a/deploy/linkace/templates/serviceaccount.yaml b/deploy/linkace/templates/serviceaccount.yaml new file mode 100644 index 00000000..3280738e --- /dev/null +++ b/deploy/linkace/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "linkace.serviceAccountName" . }} + labels: + {{- include "linkace.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/deploy/linkace/templates/tests/test-connection.yaml b/deploy/linkace/templates/tests/test-connection.yaml new file mode 100644 index 00000000..684d5f56 --- /dev/null +++ b/deploy/linkace/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "linkace.fullname" . }}-test-connection" + labels: + {{- include "linkace.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "linkace.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/deploy/linkace/values.yaml b/deploy/linkace/values.yaml new file mode 100644 index 00000000..2fa113a5 --- /dev/null +++ b/deploy/linkace/values.yaml @@ -0,0 +1,108 @@ +# Default values for linkace. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +# This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/ +replicaCount: 1 + +# This sets the container images more information can be found here: https://kubernetes.io/docs/concepts/containers/images/ +linkace: + repository: linkace/linkace + tag: "2.x-php-8.4-test" + pullPolicy: Always + backupVolumeSize: 1Gi + logsVolumeSize: 500Mi + +database: + # if you have an existing database, set enabled: false + enabled: true + port: 3306 + repository: docker.io/library/mariadb + tag: "11.5" + pullPolicy: IfNotPresent + volumeSize: 1Gi + +redis: + # if you have an existing database, set enabled: false + enabled: true + port: 6379 + repository: docker.io/library/redis + tag: "7.2" + pullPolicy: IfNotPresent + volumeSize: 1Gi + +# This is for the secrets for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ +imagePullSecrets: [] +# This is to override the chart name. +nameOverride: "" +fullnameOverride: "" + +# This section builds out the service account more information can be found here: https://kubernetes.io/docs/concepts/security/service-accounts/ +serviceAccount: + # Specifies whether a service account should be created + create: false + # Automatically mount a ServiceAccount's API credentials? + automount: 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: "" + +# This is for setting Kubernetes Annotations to a Pod. +# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ +podAnnotations: {} +# This is for setting Kubernetes Labels to a Pod. +# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ +podLabels: {} + +podSecurityContext: {} +# fsGroup: 2000 + +# This is for setting up a service more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/ +service: + # This sets the service type more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types + type: ClusterIP + # This sets the ports more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports + port: 80 + +# This block is for setting up the ingress for more information can be found here: https://kubernetes.io/docs/concepts/services-networking/ingress/ +ingress: + enabled: true + className: "nginx" + annotations: + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + host: linkace-microk8s.test + paths: + - path: / + pathType: Prefix + backend: + service: + name: http + port: + number: 80 + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +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 + +# This section is for setting up autoscaling more information can be found here: https://kubernetes.io/docs/concepts/workloads/autoscaling/ +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 10 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 diff --git a/lang/ca_ES/setup.php b/lang/ca_ES/setup.php index 557dab30..96691c28 100644 --- a/lang/ca_ES/setup.php +++ b/lang/ca_ES/setup.php @@ -12,7 +12,7 @@ 'intro.step3' => 'Crea compte d\'usuari nou.', 'check_requirements' => 'Comprovar requeriments', - 'requirements.php_version' => 'Versió de PHP >= 7.4.0', + 'requirements.php_version' => 'Versió de PHP >= 8.1', 'requirements.extension_bcmath' => 'Extensió PHP: BCMath', 'requirements.extension_ctype' => 'Extensió PHP: Ctype', 'requirements.extension_json' => 'Extensió PHP: JSON', diff --git a/lang/de_DE/setup.php b/lang/de_DE/setup.php index e1abb11b..a7b89131 100644 --- a/lang/de_DE/setup.php +++ b/lang/de_DE/setup.php @@ -13,7 +13,7 @@ 'setup_requirements' => 'Setup-Anforderungen', 'check_requirements' => 'Anforderungen prüfen', - 'requirements.php_version' => 'PHP-Version >= 7.4.0', + 'requirements.php_version' => 'PHP-Version >= 8.1', 'requirements.extension_bcmath' => 'PHP Extension: BCMath', 'requirements.extension_ctype' => 'PHP Extension: Ctype', 'requirements.extension_json' => 'PHP Extension: JSON', diff --git a/lang/en_US/setup.php b/lang/en_US/setup.php index 9f061be5..0ea2461e 100644 --- a/lang/en_US/setup.php +++ b/lang/en_US/setup.php @@ -13,7 +13,7 @@ 'setup_requirements' => 'Setup Requirements', 'check_requirements' => 'Check Requirements', - 'requirements.php_version' => 'PHP version >= 7.4.0', + 'requirements.php_version' => 'PHP version >= 8.1', 'requirements.extension_bcmath' => 'PHP Extension: BCMath', 'requirements.extension_ctype' => 'PHP Extension: Ctype', 'requirements.extension_curl' => 'PHP Extension: Curl', diff --git a/lang/es_ES/setup.php b/lang/es_ES/setup.php index a368a6ca..6e19bba7 100644 --- a/lang/es_ES/setup.php +++ b/lang/es_ES/setup.php @@ -12,7 +12,7 @@ 'intro.step3' => 'Crea tu cuenta de usuario.', 'check_requirements' => 'Comprobar requisitos', - 'requirements.php_version' => 'Versión PHP >= 7.4.0', + 'requirements.php_version' => 'Versión PHP >= 8.1', 'requirements.extension_bcmath' => 'Extensión PHP: BCMath', 'requirements.extension_ctype' => 'Extensión PHP: Ctype', 'requirements.extension_json' => 'Extensión PHP: JSON', diff --git a/lang/fr_FR/setup.php b/lang/fr_FR/setup.php index f8633b3c..bd7d9948 100644 --- a/lang/fr_FR/setup.php +++ b/lang/fr_FR/setup.php @@ -13,7 +13,7 @@ 'setup_requirements' => 'Configuration requise', 'check_requirements' => 'Vérifier Prérequis', - 'requirements.php_version' => 'Version de PHP >= 7.4.0', + 'requirements.php_version' => 'Version de PHP >= 8.1', 'requirements.extension_bcmath' => 'Module PHP : BCMath', 'requirements.extension_ctype' => 'Module PHP : Ctype', 'requirements.extension_json' => 'Module PHP : JSON', diff --git a/lang/hu_HU/setup.php b/lang/hu_HU/setup.php index 489cdb6a..199eea08 100644 --- a/lang/hu_HU/setup.php +++ b/lang/hu_HU/setup.php @@ -12,7 +12,7 @@ 'intro.step3' => 'Hozzon létre felhasználói fiókot.', 'check_requirements' => 'Ellenőrizze a követelményeket', - 'requirements.php_version' => 'PHP-verzió >= 7.4.0', + 'requirements.php_version' => 'PHP-verzió >= 8.1', 'requirements.extension_bcmath' => 'PHP-bővítmény: BCMath', 'requirements.extension_ctype' => 'PHP-bővítmény: Ctype', 'requirements.extension_json' => 'PHP-bővítmény: JSON', diff --git a/lang/it_IT/setup.php b/lang/it_IT/setup.php index 8aafc740..007629fe 100644 --- a/lang/it_IT/setup.php +++ b/lang/it_IT/setup.php @@ -12,7 +12,7 @@ 'intro.step3' => 'Crea il tuo account utente.', 'check_requirements' => 'Verifica Requisiti', - 'requirements.php_version' => 'Versione di PHP >= 7.4.0', + 'requirements.php_version' => 'Versione di PHP >= 8.1', 'requirements.extension_bcmath' => 'Estensione PHP: BCMath', 'requirements.extension_ctype' => 'Estensione PHP: Ctype', 'requirements.extension_json' => 'Estensione PHP: JSON', diff --git a/lang/ja_JP/setup.php b/lang/ja_JP/setup.php index f903f482..29d6a7ac 100644 --- a/lang/ja_JP/setup.php +++ b/lang/ja_JP/setup.php @@ -13,7 +13,7 @@ 'setup_requirements' => 'セットアップ要件', 'check_requirements' => '要件の確認', - 'requirements.php_version' => 'PHPバージョン >= 7.4.0', + 'requirements.php_version' => 'PHPバージョン >= 8.1', 'requirements.extension_bcmath' => 'PHP拡張モジュール:BCMath', 'requirements.extension_ctype' => 'PHP拡張モジュール:Ctype', 'requirements.extension_json' => 'PHP拡張モジュール:JSON', diff --git a/lang/no_NO/setup.php b/lang/no_NO/setup.php index 4e752c03..f980eeb7 100644 --- a/lang/no_NO/setup.php +++ b/lang/no_NO/setup.php @@ -13,7 +13,7 @@ 'setup_requirements' => 'Oppsettskrav', 'check_requirements' => 'Kontroller kravene', - 'requirements.php_version' => 'PHP versjon >= 7.4.0', + 'requirements.php_version' => 'PHP versjon >= 8.1', 'requirements.extension_bcmath' => 'PHP utvidelse: BCMath', 'requirements.extension_ctype' => 'PHP utvidelse: Ctype', 'requirements.extension_json' => 'PHP utvidelse: JSON', diff --git a/lang/pl_PL/setup.php b/lang/pl_PL/setup.php index 2eabc5a4..2e66fc50 100644 --- a/lang/pl_PL/setup.php +++ b/lang/pl_PL/setup.php @@ -12,7 +12,7 @@ 'intro.step3' => 'Utwórz swoje konto użytkownika.', 'check_requirements' => 'Sprawdź wymagania', - 'requirements.php_version' => 'Wersja PHP >= 7.4.0', + 'requirements.php_version' => 'Wersja PHP >= 8.1', 'requirements.extension_bcmath' => 'Rozszerzenie PHP: BCMath', 'requirements.extension_ctype' => 'Rozszerzenie PHP: Ctype', 'requirements.extension_json' => 'Rozszerzenie PHP: JSON', diff --git a/lang/ro_RO/setup.php b/lang/ro_RO/setup.php index 872ef081..ac4a3880 100644 --- a/lang/ro_RO/setup.php +++ b/lang/ro_RO/setup.php @@ -13,7 +13,7 @@ 'setup_requirements' => 'Cerințe de configurare', 'check_requirements' => 'Verificare cerințe', - 'requirements.php_version' => 'Versiune PHP >= 7.4.0', + 'requirements.php_version' => 'Versiune PHP >= 8.1', 'requirements.extension_bcmath' => 'Extensie PHP: BCMath', 'requirements.extension_ctype' => 'Extensie PHP: Ctype', 'requirements.extension_json' => 'Extensie PHP: JSON', diff --git a/lang/vi_VN/setup.php b/lang/vi_VN/setup.php index a25dbf87..309045d1 100644 --- a/lang/vi_VN/setup.php +++ b/lang/vi_VN/setup.php @@ -12,7 +12,7 @@ 'intro.step3' => 'Tạo tài khoản của bạn.', 'check_requirements' => 'Kiểm tra tương thích', - 'requirements.php_version' => 'Phiên bản PHP >= 7.4.0', + 'requirements.php_version' => 'Phiên bản PHP >= 8.1', 'requirements.extension_bcmath' => 'PHP Extension: BCMath', 'requirements.extension_ctype' => 'PHP Extension: Ctype', 'requirements.extension_json' => 'PHP Extension: JSON', diff --git a/lang/zh_CN/setup.php b/lang/zh_CN/setup.php index b800a361..615db1d9 100644 --- a/lang/zh_CN/setup.php +++ b/lang/zh_CN/setup.php @@ -12,7 +12,7 @@ 'intro.step3' => '创建您的帐户。', 'check_requirements' => '检查要求', - 'requirements.php_version' => 'PHP 版本 >= 7.4.0', + 'requirements.php_version' => 'PHP 版本 >= 8.1', 'requirements.extension_bcmath' => 'PHP Extension: BCMath', 'requirements.extension_ctype' => 'PHP Extension: Ctype', 'requirements.extension_json' => 'PHP Extension: JSON', diff --git a/routes/web.php b/routes/web.php index fa77cfd0..dfb74fd8 100644 --- a/routes/web.php +++ b/routes/web.php @@ -39,6 +39,7 @@ // Frontpage Route::get('/', FrontController::class)->name('front'); +Route::get('/_health', fn() => 'Ok'); // Setup routes Route::prefix('setup')->group(function () {