From 726a6b21328eba1682de6f72c36fbaa702fecd1e Mon Sep 17 00:00:00 2001 From: Tommy Date: Sat, 8 Jun 2024 08:12:51 +0200 Subject: [PATCH] feat: add linkding --- charts/linkding/Chart.yaml | 17 ++++ charts/linkding/README.md | 99 +++++++++++++++++++ charts/linkding/templates/_helpers.tpl | 69 +++++++++++++ charts/linkding/templates/db-init.yaml | 20 ++++ charts/linkding/templates/deployment.yaml | 45 +++++++++ charts/linkding/templates/service.yaml | 16 +++ charts/linkding/templates/serviceaccount.yaml | 6 ++ charts/linkding/values.yaml | 48 +++++++++ 8 files changed, 320 insertions(+) create mode 100644 charts/linkding/Chart.yaml create mode 100644 charts/linkding/README.md create mode 100644 charts/linkding/templates/_helpers.tpl create mode 100644 charts/linkding/templates/db-init.yaml create mode 100644 charts/linkding/templates/deployment.yaml create mode 100644 charts/linkding/templates/service.yaml create mode 100644 charts/linkding/templates/serviceaccount.yaml create mode 100644 charts/linkding/values.yaml diff --git a/charts/linkding/Chart.yaml b/charts/linkding/Chart.yaml new file mode 100644 index 0000000..e5b106b --- /dev/null +++ b/charts/linkding/Chart.yaml @@ -0,0 +1,17 @@ +# yaml-language-server: $schema=https://json.schemastore.org/chart.json +apiVersion: v2 +type: application +name: linkding +description: A Helm chart for linkding +version: 2.0.0 +# renovate: image=sissbruecker/linkding +appVersion: "1.30.0" +sources: +- https://code.252.no/tommy/helm-charts +- https://github.com/sissbruecker/linkding +keywords: +- linkding +- bookmarks +maintainers: +- name: Tommy Skaug + email: tommy@skaug.me diff --git a/charts/linkding/README.md b/charts/linkding/README.md new file mode 100644 index 0000000..6ab381e --- /dev/null +++ b/charts/linkding/README.md @@ -0,0 +1,99 @@ +# [`linkding`](https://charts.pascaliske.dev/charts/linkding/) + +> A Helm chart for linkding + +[![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ](https://charts.pascaliske.dev/charts/linkding/)[![Version: 2.0.0](https://img.shields.io/badge/Version-2.0.0-informational?style=flat-square) ](https://charts.pascaliske.dev/charts/linkding/)[![AppVersion: 1.22.1](https://img.shields.io/badge/AppVersion-1.22.1-informational?style=flat-square) ](https://charts.pascaliske.dev/charts/linkding/) + +* +* + +## Requirements + +- [`helm`](https://helm.sh) - Refer to their [docs](https://helm.sh/docs) to get started. + +## Usage + +To use this chart add the repo as follows: + +```sh +helm repo add pascaliske https://charts.pascaliske.dev +``` + +If you had already added this repo earlier, run `helm repo update` to retrieve the latest versions of the packages. + +To install this chart simply run the following command: + +```sh +helm install linkding pascaliske/linkding +``` + +To uninstall this chart simply run the following command: + +```sh +helm delete linkding +``` + +## Values + +The following values can be used to adjust the helm chart. + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| additionalContainers | object | `{}` | Specify any additional containers here as dictionary items - each should have it's own key. | +| affinity | object | `{}` | Pod-level affinity. More info [here](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#scheduling). | +| certificate.annotations | object | `{}` | Additional annotations for the certificate object. | +| certificate.create | bool | `false` | Create an Certificate object for the exposed chart. | +| certificate.dnsNames | list | `[]` | List of subject alternative names for the certificate. | +| certificate.issuerRef.kind | string | `"ClusterIssuer"` | Type of the referenced certificate issuer. Can be "Issuer" or "ClusterIssuer". | +| certificate.issuerRef.name | string | `""` | Name of the referenced certificate issuer. | +| certificate.labels | object | `{}` | Additional labels for the certificate object. | +| certificate.secretName | string | `""` | Name of the secret in which the certificate will be stored. Defaults to the first item in dnsNames. | +| controller.annotations | object | `{}` | Additional annotations for the controller object. | +| controller.enabled | bool | `true` | Create a workload for this chart. | +| controller.kind | string | `"Deployment"` | Type of the workload object. | +| controller.labels | object | `{}` | Additional labels for the controller object. | +| controller.replicas | int | `1` | The number of replicas. | +| env[0] | object | `{"name":"TZ","value":"UTC"}` | Timezone for the container. | +| fullnameOverride | string | `""` | | +| image.pullPolicy | string | `"IfNotPresent"` | The pull policy for the controller. | +| image.repository | string | `"sissbruecker/linkding"` | The repository to pull the image from. | +| image.tag | string | `.Chart.AppVersion` | The docker tag, if left empty chart's appVersion will be used. | +| ingressRoute.annotations | object | `{}` | Additional annotations for the ingress route object. | +| ingressRoute.create | bool | `false` | Create an IngressRoute object for exposing this chart. | +| ingressRoute.entryPoints | list | `[]` | List of [entry points](https://doc.traefik.io/traefik/routing/routers/#entrypoints) on which the ingress route will be available. | +| ingressRoute.labels | object | `{}` | Additional labels for the ingress route object. | +| ingressRoute.middlewares | list | `[]` | List of [middleware objects](https://doc.traefik.io/traefik/routing/providers/kubernetes-crd/#kind-middleware) for the ingress route. | +| ingressRoute.rule | string | `""` | [Matching rule](https://doc.traefik.io/traefik/routing/routers/#rule) for the underlying router. | +| ingressRoute.tlsSecretName | string | `""` | Use an existing secret containing the TLS certificate. | +| nameOverride | string | `""` | | +| persistentVolumeClaim.accessMode | string | `"ReadWriteOnce"` | Access mode of the persistent volume claim object. | +| persistentVolumeClaim.annotations | object | `{}` | Additional annotations for the persistent volume claim object. | +| persistentVolumeClaim.create | bool | `true` | Create a new persistent volume claim object. | +| persistentVolumeClaim.existingPersistentVolumeClaim | string | `""` | Use an existing persistent volume claim object. | +| persistentVolumeClaim.labels | object | `{}` | Additional labels for the persistent volume claim object. | +| persistentVolumeClaim.mountPath | string | `"/etc/linkding/data"` | Mount path of the persistent volume claim object. | +| persistentVolumeClaim.size | string | `"1Gi"` | Storage request size for the persistent volume claim object. | +| persistentVolumeClaim.storageClassName | string | `""` | Storage class name for the persistent volume claim object. | +| persistentVolumeClaim.volumeMode | string | `"Filesystem"` | Volume mode of the persistent volume claim object. | +| ports.http.enabled | bool | `true` | Enable the port inside the `controller` and `Service` objects. | +| ports.http.nodePort | string | `nil` | The external port used if `.service.type` == `NodePort`. | +| ports.http.port | int | `9090` | The port used as internal port and cluster-wide port if `.service.type` == `ClusterIP`. | +| ports.http.protocol | string | `"TCP"` | The protocol used for the service. | +| resources | object | `{}` | Compute resources used by the container. More info [here](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/). | +| securityContext | object | `{}` | Pod-level security attributes. More info [here](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#security-context). | +| service.annotations | object | `{}` | Additional annotations for the service object. | +| service.enabled | bool | `true` | Create a service for exposing this chart. | +| service.labels | object | `{}` | Additional labels for the service object. | +| service.type | string | `"ClusterIP"` | The service type used. | +| serviceAccount.name | string | `""` | Specify the service account used for the controller. | +| tolerations | list | `[]` | Pod-level tolerations. More info [here](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#scheduling). | + +## Maintainers + +| Name | Email | Url | +| ---- | ------ | --- | +| pascaliske | | | + +## License + +[MIT](../LICENSE.md) – © 2023 [Pascal Iske](https://pascaliske.dev) \ No newline at end of file diff --git a/charts/linkding/templates/_helpers.tpl b/charts/linkding/templates/_helpers.tpl new file mode 100644 index 0000000..42edc36 --- /dev/null +++ b/charts/linkding/templates/_helpers.tpl @@ -0,0 +1,69 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "linkding.name" -}} +{{- .Values.nameOverride | default .Chart.Name | 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 "linkding.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := .Values.nameOverride | default .Chart.Name -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Get the correct image tag name +*/}} +{{- define "linkding.imageTag" -}} +{{- .Values.image.tag | default (printf "%s" .Chart.AppVersion) -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "linkding.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "linkding.labels" -}} +helm.sh/chart: {{ include "linkding.chart" . }} +{{ include "linkding.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "linkding.selectorLabels" -}} +app.kubernetes.io/name: {{ include "linkding.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "linkding.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "linkding.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/linkding/templates/db-init.yaml b/charts/linkding/templates/db-init.yaml new file mode 100644 index 0000000..cf801c1 --- /dev/null +++ b/charts/linkding/templates/db-init.yaml @@ -0,0 +1,20 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ include "linkding.fullname" . }}-db-init + labels: + {{- include "linkding.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": pre-install + "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded +spec: + template: + spec: + restartPolicy: Never + containers: + - name: general-db-init + image: "{{ .Values.initContainers.dbInit.image.repository }}:{{ .Values.initContainers.dbInit.image.tag }}" + envFrom: + - secretRef: + name: {{ .Values.postgres.secretName }} + backoffLimit: 3 diff --git a/charts/linkding/templates/deployment.yaml b/charts/linkding/templates/deployment.yaml new file mode 100644 index 0000000..6fe9870 --- /dev/null +++ b/charts/linkding/templates/deployment.yaml @@ -0,0 +1,45 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "linkding.fullname" . }} + labels: + {{- include "linkding.labels" . | nindent 4 }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ include "linkding.fullname" . }} + template: + metadata: + labels: + app: {{ include "linkding.fullname" . }} + spec: + serviceAccountName: {{ include "linkding.fullname" . }} + containers: + - name: {{ include "linkding.fullname" . }} + image: {{ .Values.image.repository }}:{{ include "linkding.imageTag" . }} + env: + {{- range $i, $val := .Values.env }} + {{- if $val.value }} + - name: {{ $val.name | quote }} + value: {{ $val.value | quote }} + {{- end }} + {{- end }} + - name: LD_SERVER_PORT + value: "80" + envFrom: + - secretRef: + name: {{ .Values.envFromSecret }} + resources: + {{- toYaml .Values.resources | nindent 10 }} + ports: + - containerPort: 80 + name: http + volumeMounts: + - name: {{ include "linkding.fullname" . }}-data + mountPath: "/data" + readOnly: false + volumes: + - name: {{ include "linkding.fullname" . }}-data + persistentVolumeClaim: + claimName: {{ .Values.persistence.existingClaim }} diff --git a/charts/linkding/templates/service.yaml b/charts/linkding/templates/service.yaml new file mode 100644 index 0000000..8b79034 --- /dev/null +++ b/charts/linkding/templates/service.yaml @@ -0,0 +1,16 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "linkding.fullname" . }} + labels: + {{- include "linkding.labels" . | nindent 4 }} +spec: + type: "ClusterIP" + ports: + - port: 80 + targetPort: http + protocol: TCP + name: http + selector: + app: {{ include "linkding.fullname" . }} \ No newline at end of file diff --git a/charts/linkding/templates/serviceaccount.yaml b/charts/linkding/templates/serviceaccount.yaml new file mode 100644 index 0000000..a985baa --- /dev/null +++ b/charts/linkding/templates/serviceaccount.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "linkding.fullname" . }} + labels: + {{- include "linkding.labels" . | nindent 4 }} \ No newline at end of file diff --git a/charts/linkding/values.yaml b/charts/linkding/values.yaml new file mode 100644 index 0000000..1327819 --- /dev/null +++ b/charts/linkding/values.yaml @@ -0,0 +1,48 @@ +image: + repository: sissbruecker/linkding + pullPolicy: IfNotPresent + +initContainers: + dbInit: + image: + repository: ghcr.io/onedr0p/postgres-init + tag: "16" + envFrom: + - secretRef: + name: linkding-secret + +env: +- name: TZ + value: Europe/Oslo + +envFromSecret: linkding-env-secret +postgres: + secretName: linkding-secret + +persistence: + existingClaim: linkding + +securityContext: {} + +resources: {} +# limits: +# cpu: 100m +# memory: 128Mi +# requests: +# cpu: 100m +# memory: 128Mi + +affinity: {} +# nodeAffinity: +# requiredDuringSchedulingIgnoredDuringExecution: +# nodeSelectorTerms: +# - matchExpressions: +# - key: kubernetes.io/hostname +# operator: In +# values: +# - my-node-xyz + +tolerations: [] +# - key: node-role.kubernetes.io/control-plane +# operator: Exists +# effect: NoSchedule