diff --git a/documentation/kubernetes.md b/documentation/kubernetes.md new file mode 100644 index 0000000..5b68d63 --- /dev/null +++ b/documentation/kubernetes.md @@ -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: + files: + # Location of .env file + env: + # Location of storage folder + storage: + +ingress: + url: + #optional + annotations: + cert-manager.io/issuer: "" +```` +if no cert-manager is used, the appropriate certificate must be stored under -secret-tls as secret + +Once this has been done, you can install the helm chart as follows: `helm install ./helm --values ` + +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 diff --git a/helm/Chart.yaml b/helm/Chart.yaml new file mode 100644 index 0000000..c73b734 --- /dev/null +++ b/helm/Chart.yaml @@ -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 diff --git a/helm/templates/Deployment.yml b/helm/templates/Deployment.yml new file mode 100644 index 0000000..3bbfce2 --- /dev/null +++ b/helm/templates/Deployment.yml @@ -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 }} diff --git a/helm/templates/Ingress.yml b/helm/templates/Ingress.yml new file mode 100644 index 0000000..4a9afe1 --- /dev/null +++ b/helm/templates/Ingress.yml @@ -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 diff --git a/helm/templates/Service.yml b/helm/templates/Service.yml new file mode 100644 index 0000000..64e0247 --- /dev/null +++ b/helm/templates/Service.yml @@ -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 diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl new file mode 100644 index 0000000..a16c83f --- /dev/null +++ b/helm/templates/_helpers.tpl @@ -0,0 +1,7 @@ +{{/* +Expand the name of the chart. +*/}} + +{{- define "Shaark.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} diff --git a/helm/values.yaml b/helm/values.yaml new file mode 100644 index 0000000..65fb8b1 --- /dev/null +++ b/helm/values.yaml @@ -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: