Skip to content

Commit

Permalink
add helm chart to deploy on Kubernetes clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
Letsplaybar committed Dec 17, 2023
1 parent da133ca commit 386d017
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 0 deletions.
25 changes: 25 additions & 0 deletions documentation/kubernetes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Helm
This project has a helm chart, in order to use it, the Docker image must first be built and loaded into a repo.

After this is done, copy the file from `helm/values.yml` and fill it in. Here you can see a small example with fields that have to be filled in:

````yml
deployment:
image: <url to image>
files:
# Location of .env file
env: <path to .env file>
# Location of storage folder
storage: <path to storage folder>

ingress:
url: <url to reach shaark instance>
#optional
annotations:
cert-manager.io/issuer: "<issuer name when used cert-manager>"
````
if no cert-manager is used, the appropriate certificate must be stored under <name>-secret-tls as secret

Once this has been done, you can install the helm chart as follows: `helm install <name> ./helm --values <edit-values-file>`

The installation comes without mysql and redis if this is required, this must be installed externally by existing charts from the intenet and then the corresponding kubernetes-url must be stored in the .env as host
9 changes: 9 additions & 0 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v2

name: Shaark
description: "Shaark is a self-hosted platform to keep and share your content: web links, posts, passwords and pictures."

type: application
version: 2.0.0-alpha

appVersion: 2.0.0-alpha
34 changes: 34 additions & 0 deletions helm/templates/Deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "Shaark.name" . }}-deployment
namespace: {{ .Release.Namespace }}
spec:
replicas: 1
selector:
matchLabels:
app: {{ include "Shaark.name" . }}
template:
metadata:
labels:
app: {{ include "Shaark.name" . }}
spec:
containers:
- name: shaark
image: {{.Values.deployment.image}}
imagePullPolicy: Always
ports:
- containerPort: 80
volumeMounts:
- name: env
mountPath: /var/www/laravel/.env
subPath: .env
- name: storage
mountPath: /var/www/laravel/storage
volumes:
- name: env
hostPath:
path: {{ .Values.deployment.files.env }}
- name: storage
hostPath:
path: {{ .Values.deployment.files.storage }}
25 changes: 25 additions & 0 deletions helm/templates/Ingress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "Shaark.name" . }}-ingress
namespace: {{ .Release.Namespace }}
annotations:
nginx.ingress.kubernetes.io/proxy-body-size: 1G
nginx.org/client-max-body-size: 1G
{{- .Values.ingress.annotations | toYaml | indent 4}}
spec:
tls:
- hosts:
- {{ .Values.ingress.url }}
secretName: {{ include "Shaark.name" . }}-secret-tls
rules:
- host: {{ .Values.ingress.url }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: {{ include "Shaark.name" . }}-service
port:
number: 80
14 changes: 14 additions & 0 deletions helm/templates/Service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "Shaark.name" . }}-service
labels:
app: {{ include "Shaark.name" . }}
namespace: {{ .Release.Namespace }}
spec:
selector:
app: {{ include "Shaark.name" . }}
ports:
- protocol: TCP
port: 80
targetPort: 80
7 changes: 7 additions & 0 deletions helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{/*
Expand the name of the chart.
*/}}

{{- define "Shaark.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
17 changes: 17 additions & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
nameOverride:

deployment:
image:
files:
# Location of .env file
env:
# Location of storage folder
storage:

ingress:
url:
#Example
# annotations:
# cert-manager.io/issuer: "letsencrypt-prod"
# nginx.ingress.kubernetes.io/ssl-redirect: true
annotations:

0 comments on commit 386d017

Please sign in to comment.