From 10d35f069aac70f11f3de63281dc2c53041e503b Mon Sep 17 00:00:00 2001 From: jon4hz Date: Wed, 22 Jan 2025 02:31:21 +0100 Subject: [PATCH 1/7] feat: add charts for shlink and shlink-web --- README.md | 14 +++ charts/shlink-web/Chart.yaml | 18 ++++ charts/shlink-web/README.md | 60 ++++++++++++ charts/shlink-web/templates/_helpers.tpl | 63 ++++++++++++ charts/shlink-web/templates/deployment.yaml | 68 +++++++++++++ charts/shlink-web/templates/ingress.yaml | 49 ++++++++++ charts/shlink-web/templates/service.yaml | 15 +++ .../shlink-web/templates/serviceaccount.yaml | 12 +++ charts/shlink-web/values.yaml | 77 +++++++++++++++ charts/shlink/Chart.lock | 6 ++ charts/shlink/Chart.yaml | 23 +++++ charts/shlink/README.md | 71 ++++++++++++++ charts/shlink/templates/_helpers.tpl | 89 +++++++++++++++++ charts/shlink/templates/deployment.yaml | 98 +++++++++++++++++++ charts/shlink/templates/ingress.yaml | 49 ++++++++++ charts/shlink/templates/service.yaml | 15 +++ charts/shlink/templates/serviceaccount.yaml | 12 +++ charts/shlink/values.yaml | 89 +++++++++++++++++ 18 files changed, 828 insertions(+) create mode 100644 charts/shlink-web/Chart.yaml create mode 100644 charts/shlink-web/README.md create mode 100644 charts/shlink-web/templates/_helpers.tpl create mode 100644 charts/shlink-web/templates/deployment.yaml create mode 100644 charts/shlink-web/templates/ingress.yaml create mode 100644 charts/shlink-web/templates/service.yaml create mode 100644 charts/shlink-web/templates/serviceaccount.yaml create mode 100644 charts/shlink-web/values.yaml create mode 100644 charts/shlink/Chart.lock create mode 100644 charts/shlink/Chart.yaml create mode 100644 charts/shlink/README.md create mode 100644 charts/shlink/templates/_helpers.tpl create mode 100644 charts/shlink/templates/deployment.yaml create mode 100644 charts/shlink/templates/ingress.yaml create mode 100644 charts/shlink/templates/service.yaml create mode 100644 charts/shlink/templates/serviceaccount.yaml create mode 100644 charts/shlink/values.yaml diff --git a/README.md b/README.md index 5ddf061c..3814d398 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,20 @@ Deploy Keycloak Operator and Keycloak Deploy rbac-manager RBACDefinitions via Helm [rbac-definitions](charts/rbac-definitions) +#### [shlink](charts/shlink) chart + +![Version: 1.0.x](https://img.shields.io/badge/version-1.0.x-brightgreen) ![App version: 4.4.x](https://img.shields.io/badge/app%20version-4.4.x-brightgreen) + +A Helm chart to deploy shlink + +[shlink](charts/shlink) +#### [shlink-web](charts/shlink-web) chart + +![Version: 1.0.x](https://img.shields.io/badge/version-1.0.x-brightgreen) ![App version: 4.3.x](https://img.shields.io/badge/app%20version-4.3.x-brightgreen) + +A Helm chart to deploy shlink-web + +[shlink-web](charts/shlink-web) #### Argo CD app-of-apps charts diff --git a/charts/shlink-web/Chart.yaml b/charts/shlink-web/Chart.yaml new file mode 100644 index 00000000..23943d13 --- /dev/null +++ b/charts/shlink-web/Chart.yaml @@ -0,0 +1,18 @@ +apiVersion: v2 +name: shlink-web +description: A Helm chart to deploy shlink-web +icon: https://shlink.io/favicon.svg +type: application +version: 1.0.0 +appVersion: 4.3.0 +home: https://shlink.io +sources: + - https://github.com/adfinis/helm-charts/tree/main/charts/shlink-web +maintainers: + - name: adfinis + email: support@adfinis.com + url: https://adfinis.com +annotations: + artifacthub.io/changes: | + - kind: added + description: "Initial release" diff --git a/charts/shlink-web/README.md b/charts/shlink-web/README.md new file mode 100644 index 00000000..73b2fd8a --- /dev/null +++ b/charts/shlink-web/README.md @@ -0,0 +1,60 @@ +# shlink-web + +![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 4.3.0](https://img.shields.io/badge/AppVersion-4.3.0-informational?style=flat-square) + +A Helm chart to deploy shlink-web + +**Homepage:** + +## Maintainers +This chart is maintained by [Adfinis](https://adfinis.com/?pk_campaign=github&pk_kwd=helm-charts). + +## Source Code + +* + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| affinity | object | `{}` | | +| env.DOMAIN_NAME | string | `"shlink.io"` | Shlink Web domain | +| env.SHLINK_SERVER_API_KEY | string | `""` | Shlink API Key | +| env.SHLINK_SERVER_NAME | string | `"Shlink"` | Shlink Server Name | +| env.SHLINK_SERVER_URL | string | `"https://shlink.io"` | Shlink API URL | +| externalSecret.enabled | bool | `false` | Specifies whether an external secret should be used | +| externalSecret.key | string | `"shlink-api-key"` | Key in the secret containing the API key | +| externalSecret.name | string | `"shlink-api-key"` | Name of the secret containing the API key | +| image.pullPolicy | string | `"IfNotPresent"` | Shlink Web image pull policy | +| image.repository | string | `"ghcr.io/shlinkio/shlink-web-client"` | Shlink Web image name | +| ingress.annotations | object | `{}` | Ingress annotations | +| ingress.className | string | `"nginx"` | Ingress class name | +| ingress.enabled | bool | `false` | Enable ingress for shlink web | +| nodeSelector | object | `{}` | | +| podSecurityContext | object | `{}` | | +| replicaCount | int | `1` | | +| resources | object | `{}` | | +| securityContext | object | `{}` | | +| service.port | int | `80` | Shlink Web service port | +| service.type | string | `"ClusterIP"` | Shlink Web service type | +| serviceAccount.annotations | object | `{}` | Annotations to add to the service account | +| serviceAccount.create | bool | `false` | Specifies whether a service account should be created | +| serviceAccount.name | string | `nil` | Name of the service account | +| tolerations | list | `[]` | | + +## About this chart + +Adfinis fights for a software world that is more open, where the quality is +better and where software must be accessible to everyone. This chart +is part of the action behind this commitment. Feel free to +[contact](https://adfinis.com/kontakt/?pk_campaign=github&pk_kwd=helm-charts) +us if you have any questions. + +## License + +This Helm chart is free software: you can redistribute it and/or modify it under the terms +of the GNU Affero General Public License as published by the Free Software Foundation, +version 3 of the License. + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs](https://github.com/norwoodj/helm-docs/) diff --git a/charts/shlink-web/templates/_helpers.tpl b/charts/shlink-web/templates/_helpers.tpl new file mode 100644 index 00000000..64cb4a10 --- /dev/null +++ b/charts/shlink-web/templates/_helpers.tpl @@ -0,0 +1,63 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "shlink-web.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 "shlink-web.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 "shlink-web.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "shlink-web.labels" -}} +helm.sh/chart: {{ include "shlink-web.chart" . }} +{{ include "shlink-web.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "shlink-web.selectorLabels" -}} +app.kubernetes.io/name: {{ include "shlink-web.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "shlink-web.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "shlink-web.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/charts/shlink-web/templates/deployment.yaml b/charts/shlink-web/templates/deployment.yaml new file mode 100644 index 00000000..c4489592 --- /dev/null +++ b/charts/shlink-web/templates/deployment.yaml @@ -0,0 +1,68 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "shlink-web.fullname" . }} + labels: + {{- include "shlink-web.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "shlink-web.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "shlink-web.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "shlink-web.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: SHLINK_SERVER_URL + value: {{ .Values.env.SHLINK_SERVER_URL | quote }} + - name: SHLINK_SERVER_NAME + value: {{ .Values.env.SHLINK_SERVER_NAME | quote }} + {{- if .Values.externalSecret.enabled }} + - name: SHLINK_SERVER_API_KEY + valueFrom: + secretKeyRef: + name: {{ .Values.externalSecret.name | quote }} + key: {{ .Values.externalSecret.key | quote }} + {{- else }} + - name: SHLINK_SERVER_API_KEY + value: {{ .Values.env.SHLINK_SERVER_API_KEY | quote }} + {{- end }} + ports: + - name: http + containerPort: 8080 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + initialDelaySeconds: 30 + periodSeconds: 60 + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/shlink-web/templates/ingress.yaml b/charts/shlink-web/templates/ingress.yaml new file mode 100644 index 00000000..2fa7b176 --- /dev/null +++ b/charts/shlink-web/templates/ingress.yaml @@ -0,0 +1,49 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "shlink-web.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "shlink-web.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + ingressClassName: {{ .Values.ingress.className }} + tls: + - hosts: + - {{ .Values.env.DOMAIN_NAME }} + secretName: {{ .Values.env.DOMAIN_NAME }} + rules: + - host: {{ .Values.env.DOMAIN_NAME }} + http: + paths: + - path: / + {{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }} + pathType: ImplementationSpecific + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} +{{- end }} diff --git a/charts/shlink-web/templates/service.yaml b/charts/shlink-web/templates/service.yaml new file mode 100644 index 00000000..27b77b8c --- /dev/null +++ b/charts/shlink-web/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "shlink-web.fullname" . }} + labels: + {{- include "shlink-web.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "shlink-web.selectorLabels" . | nindent 4 }} diff --git a/charts/shlink-web/templates/serviceaccount.yaml b/charts/shlink-web/templates/serviceaccount.yaml new file mode 100644 index 00000000..4cd4df28 --- /dev/null +++ b/charts/shlink-web/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "shlink-web.serviceAccountName" . }} + labels: + {{- include "shlink-web.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end -}} diff --git a/charts/shlink-web/values.yaml b/charts/shlink-web/values.yaml new file mode 100644 index 00000000..a0a405f0 --- /dev/null +++ b/charts/shlink-web/values.yaml @@ -0,0 +1,77 @@ +# Default values for shlink-web. + +replicaCount: 1 + +image: + # -- Shlink Web image name + repository: ghcr.io/shlinkio/shlink-web-client + # -- Shlink Web image pull policy + pullPolicy: IfNotPresent + +env: + # -- Shlink Web domain + DOMAIN_NAME: shlink.io + # -- Shlink API URL + SHLINK_SERVER_URL: https://shlink.io + # -- Shlink API Key + SHLINK_SERVER_API_KEY: "" + # -- Shlink Server Name + SHLINK_SERVER_NAME: Shlink + +externalSecret: + # -- Specifies whether an external secret should be used + enabled: false + # -- Name of the secret containing the API key + name: shlink-api-key + # -- Key in the secret containing the API key + key: shlink-api-key + +serviceAccount: + # -- Specifies whether a service account should be created + create: false + # -- 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 of the service account + name: + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + # -- Shlink Web service type + type: ClusterIP + # -- Shlink Web service port + port: 80 + +ingress: + # -- Enable ingress for shlink web + enabled: false + # -- Ingress class name + className: nginx + # -- Ingress annotations + annotations: {} + + +resources: {} + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/shlink/Chart.lock b/charts/shlink/Chart.lock new file mode 100644 index 00000000..8942d5b7 --- /dev/null +++ b/charts/shlink/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: postgresql + repository: https://charts.bitnami.com/bitnami + version: 16.3.4 +digest: sha256:e47096b5845be86703bf083d6a44cfb0d7513d9fac02ec1789930aade318e309 +generated: "2024-12-24T10:56:01.222789714+01:00" diff --git a/charts/shlink/Chart.yaml b/charts/shlink/Chart.yaml new file mode 100644 index 00000000..c68ac667 --- /dev/null +++ b/charts/shlink/Chart.yaml @@ -0,0 +1,23 @@ +apiVersion: v2 +name: shlink +description: A Helm chart to deploy shlink +icon: https://shlink.io/favicon.svg +type: application +version: 1.0.0 +appVersion: 4.4.0 +home: https://shlink.io +sources: + - https://github.com/adfinis/helm-charts/tree/main/charts/shlink +maintainers: + - name: adfinis + email: support@adfinis.com + url: https://adfinis.com +dependencies: + - name: postgresql + version: 16.x.x + repository: https://charts.bitnami.com/bitnami + condition: postgresql.enabled +annotations: + artifacthub.io/changes: | + - kind: added + description: "Initial release" diff --git a/charts/shlink/README.md b/charts/shlink/README.md new file mode 100644 index 00000000..0eae4c1a --- /dev/null +++ b/charts/shlink/README.md @@ -0,0 +1,71 @@ +# shlink + +![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 4.4.0](https://img.shields.io/badge/AppVersion-4.4.0-informational?style=flat-square) + +A Helm chart to deploy shlink + +**Homepage:** + +## Maintainers +This chart is maintained by [Adfinis](https://adfinis.com/?pk_campaign=github&pk_kwd=helm-charts). + +## Source Code + +* + +## Requirements + +| Repository | Name | Version | +|------------|------|---------| +| https://charts.bitnami.com/bitnami | postgresql | 16.x.x | + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| affinity | object | `{}` | | +| env.DEFAULT_BASE_URL_REDIRECT | string | `""` | Default base url redirect if no short code is provided | +| env.DEFAULT_DOMAIN | string | `"shlink.io"` | Shlink domain | +| env.DEFAULT_SHORT_CODES_LENGTH | int | `6` | Default short code length | +| env.IS_HTTPS_ENABLED | bool | `true` | Is shlink using https? | +| externalDatabase.database | string | `"shlink"` | Database name of the external database | +| externalDatabase.existingSecretKey | string | `"postgresql-password"` | Key in the secret containing the database password | +| externalDatabase.existingSecretName | string | `""` | Secret name containing the database password | +| externalDatabase.host | string | `"localhost"` | Hostname of the external database | +| externalDatabase.password | string | `"password"` | Password of the external database | +| externalDatabase.port | int | `5432` | Port of the external database | +| externalDatabase.user | string | `"shlink"` | Username of the external database | +| image.pullPolicy | string | `"IfNotPresent"` | Shlink image pull policy | +| image.repository | string | `"ghcr.io/shlinkio/shlink"` | Shlink image name | +| ingress.annotations | object | `{}` | Ingress annotations | +| ingress.className | string | `"nginx"` | Ingress class name | +| ingress.enabled | bool | `false` | Enable ingress for shlink | +| nodeSelector | object | `{}` | | +| podSecurityContext | object | `{}` | | +| postgresql.enabled | bool | `false` | Specifies whether a PostgreSQL chart should be deployed | +| replicaCount | int | `1` | | +| resources | object | `{}` | | +| securityContext | object | `{}` | | +| service.port | int | `80` | Port of the shlink service | +| service.type | string | `"ClusterIP"` | Service type of the shlink service | +| serviceAccount.annotations | object | `{}` | Annotations to add to the service account | +| serviceAccount.create | bool | `false` | Specifies whether a service account should be created | +| serviceAccount.name | string | `nil` | Name of the service account | +| tolerations | list | `[]` | | + +## About this chart + +Adfinis fights for a software world that is more open, where the quality is +better and where software must be accessible to everyone. This chart +is part of the action behind this commitment. Feel free to +[contact](https://adfinis.com/kontakt/?pk_campaign=github&pk_kwd=helm-charts) +us if you have any questions. + +## License + +This Helm chart is free software: you can redistribute it and/or modify it under the terms +of the GNU Affero General Public License as published by the Free Software Foundation, +version 3 of the License. + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs](https://github.com/norwoodj/helm-docs/) diff --git a/charts/shlink/templates/_helpers.tpl b/charts/shlink/templates/_helpers.tpl new file mode 100644 index 00000000..6e3b7d5a --- /dev/null +++ b/charts/shlink/templates/_helpers.tpl @@ -0,0 +1,89 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "shlink.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 "shlink.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 "shlink.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "shlink.labels" -}} +helm.sh/chart: {{ include "shlink.chart" . }} +{{ include "shlink.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "shlink.selectorLabels" -}} +app.kubernetes.io/name: {{ include "shlink.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "shlink.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "shlink.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} + +{{/* +Name of the Secret that contains the PostgreSQL password +*/}} +{{- define "shlink.postgresql.secret" -}} + {{- if .Values.postgresql.enabled }} + {{- include "postgresql.secretName" .Subcharts.postgresql -}} + {{- else if .Values.externalDatabase.existingSecretName }} + {{- .Values.externalDatabase.existingSecretName }} + {{- else }} + {{- .Values.existingSecret | default (include "shlink.fullname" .) }} + {{- end }} +{{- end }} + +{{/* +Name of the key in Secret that contains the PostgreSQL password +*/}} +{{- define "shlink.postgresql.secretKey" -}} + {{- if .Values.postgresql.enabled -}} + {{- include "postgresql.userPasswordKey" .Subcharts.postgresql -}} + {{- else if .Values.externalDatabase.existingSecretName -}} + {{- .Values.externalDatabase.existingSecretKey -}} + {{- else -}} + password + {{- end -}} +{{- end }} diff --git a/charts/shlink/templates/deployment.yaml b/charts/shlink/templates/deployment.yaml new file mode 100644 index 00000000..3caca54f --- /dev/null +++ b/charts/shlink/templates/deployment.yaml @@ -0,0 +1,98 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "shlink.fullname" . }} + labels: + {{- include "shlink.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "shlink.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "shlink.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "shlink.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: DEFAULT_DOMAIN + value: {{required "Default Domain required" .Values.env.DEFAULT_DOMAIN | quote }} + - name: IS_HTTPS_ENABLED + value: {{ .Values.env.IS_HTTPS_ENABLED | quote }} + - name: DEFAULT_SHORT_CODES_LENGTH + value: {{ .Values.env.DEFAULT_SHORT_CODES_LENGTH | quote }} + - name: DEFAULT_BASE_URL_REDIRECT + value: {{ .Values.env.DEFAULT_BASE_URL_REDIRECT | quote }} + - name: DB_DRIVER + value: "postgres" + {{- if .Values.postgresql.enabled }} + - name: DB_HOST + value: {{ include "postgresql.primary.fullname" .Subcharts.postgresql | quote }} + - name: DB_PORT + value: {{ include "postgresql.service.port" .Subcharts.postgresql | quote }} + - name: DB_USER + value: {{ include "postgresql.username" .Subcharts.postgresql | quote }} + - name: DB_NAME + value: {{ include "postgresql.database" .Subcharts.postgresql | quote }} + {{- else }} + - name: DB_HOST + value: {{ .Values.externalDatabase.host | quote }} + - name: DB_PORT + value: {{ .Values.externalDatabase.port | quote }} + - name: DB_USER + value: {{ .Values.externalDatabase.username | quote }} + - name: DB_NAME + value: {{ .Values.externalDatabase.database | quote }} + {{- end }} + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "shlink.postgresql.secret" . | quote }} + key: {{ include "shlink.postgresql.secretKey" . | quote }} + {{- if .Values.env.DEBUG }} + - name: SHELL_VERBOSITY + value: "3" + {{- end }} + ports: + - name: http + containerPort: 8080 + protocol: TCP + livenessProbe: + httpGet: + path: /rest/v2/health + port: http + initialDelaySeconds: 20 + periodSeconds: 5 + readinessProbe: + httpGet: + path: /rest/v2/health + port: http + initialDelaySeconds: 20 + periodSeconds: 5 + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/shlink/templates/ingress.yaml b/charts/shlink/templates/ingress.yaml new file mode 100644 index 00000000..64da2508 --- /dev/null +++ b/charts/shlink/templates/ingress.yaml @@ -0,0 +1,49 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "shlink.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "shlink.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + ingressClassName: {{ .Values.ingress.className }} + tls: + - hosts: + - {{ .Values.env.DEFAULT_DOMAIN }} + secretName: {{ .Values.env.DEFAULT_DOMAIN }} + rules: + - host: {{ .Values.env.DEFAULT_DOMAIN }} + http: + paths: + - path: / + {{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }} + pathType: ImplementationSpecific + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} +{{- end }} diff --git a/charts/shlink/templates/service.yaml b/charts/shlink/templates/service.yaml new file mode 100644 index 00000000..2d9565a8 --- /dev/null +++ b/charts/shlink/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "shlink.fullname" . }} + labels: + {{- include "shlink.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "shlink.selectorLabels" . | nindent 4 }} diff --git a/charts/shlink/templates/serviceaccount.yaml b/charts/shlink/templates/serviceaccount.yaml new file mode 100644 index 00000000..b5132438 --- /dev/null +++ b/charts/shlink/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "shlink.serviceAccountName" . }} + labels: + {{- include "shlink.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end -}} diff --git a/charts/shlink/values.yaml b/charts/shlink/values.yaml new file mode 100644 index 00000000..d23a50ed --- /dev/null +++ b/charts/shlink/values.yaml @@ -0,0 +1,89 @@ +# Default values for shlink. + +replicaCount: 1 + +image: + # -- Shlink image name + repository: ghcr.io/shlinkio/shlink + # -- Shlink image pull policy + pullPolicy: IfNotPresent + +env: + # -- Shlink domain + DEFAULT_DOMAIN: shlink.io + # -- Is shlink using https? + IS_HTTPS_ENABLED: true + # -- Default short code length + DEFAULT_SHORT_CODES_LENGTH: 6 + # -- Default base url redirect if no short code is provided + DEFAULT_BASE_URL_REDIRECT: "" + +postgresql: + # -- Specifies whether a PostgreSQL chart should be deployed + enabled: false + +externalDatabase: + # -- Hostname of the external database + host: localhost + # -- Port of the external database + port: 5432 + # -- Username of the external database + user: shlink + # -- Password of the external database + password: password + # -- Database name of the external database + database: shlink + # -- Secret name containing the database password + existingSecretName: "" + # -- Key in the secret containing the database password + existingSecretKey: postgresql-password + +serviceAccount: + # -- Specifies whether a service account should be created + create: false + # -- 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 of the service account + name: + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + # -- Service type of the shlink service + type: ClusterIP + # -- Port of the shlink service + port: 80 + +ingress: + # -- Enable ingress for shlink + enabled: false + # -- Ingress class name + className: nginx + # -- Ingress annotations + annotations: {} + + +resources: {} + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} From e3d0d35101b05d1fe4ba2912bf67206b630fc465 Mon Sep 17 00:00:00 2001 From: jon4hz Date: Wed, 22 Jan 2025 02:52:22 +0100 Subject: [PATCH 2/7] chore: release as v0.1.0 --- README.md | 4 ++-- charts/shlink-web/Chart.yaml | 2 +- charts/shlink-web/README.md | 2 +- charts/shlink/Chart.yaml | 2 +- charts/shlink/README.md | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3814d398..dee172c2 100644 --- a/README.md +++ b/README.md @@ -53,14 +53,14 @@ Deploy rbac-manager RBACDefinitions via Helm [rbac-definitions](charts/rbac-definitions) #### [shlink](charts/shlink) chart -![Version: 1.0.x](https://img.shields.io/badge/version-1.0.x-brightgreen) ![App version: 4.4.x](https://img.shields.io/badge/app%20version-4.4.x-brightgreen) +![Version: 0.x](https://img.shields.io/badge/version-0.x-brightgreen) ![App version: 4.4.x](https://img.shields.io/badge/app%20version-4.4.x-brightgreen) A Helm chart to deploy shlink [shlink](charts/shlink) #### [shlink-web](charts/shlink-web) chart -![Version: 1.0.x](https://img.shields.io/badge/version-1.0.x-brightgreen) ![App version: 4.3.x](https://img.shields.io/badge/app%20version-4.3.x-brightgreen) +![Version: 0.x](https://img.shields.io/badge/version-0.x-brightgreen) ![App version: 4.3.x](https://img.shields.io/badge/app%20version-4.3.x-brightgreen) A Helm chart to deploy shlink-web diff --git a/charts/shlink-web/Chart.yaml b/charts/shlink-web/Chart.yaml index 23943d13..08939603 100644 --- a/charts/shlink-web/Chart.yaml +++ b/charts/shlink-web/Chart.yaml @@ -3,7 +3,7 @@ name: shlink-web description: A Helm chart to deploy shlink-web icon: https://shlink.io/favicon.svg type: application -version: 1.0.0 +version: 0.1.0 appVersion: 4.3.0 home: https://shlink.io sources: diff --git a/charts/shlink-web/README.md b/charts/shlink-web/README.md index 73b2fd8a..b79963e2 100644 --- a/charts/shlink-web/README.md +++ b/charts/shlink-web/README.md @@ -1,6 +1,6 @@ # shlink-web -![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 4.3.0](https://img.shields.io/badge/AppVersion-4.3.0-informational?style=flat-square) +![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 4.3.0](https://img.shields.io/badge/AppVersion-4.3.0-informational?style=flat-square) A Helm chart to deploy shlink-web diff --git a/charts/shlink/Chart.yaml b/charts/shlink/Chart.yaml index c68ac667..b9178535 100644 --- a/charts/shlink/Chart.yaml +++ b/charts/shlink/Chart.yaml @@ -3,7 +3,7 @@ name: shlink description: A Helm chart to deploy shlink icon: https://shlink.io/favicon.svg type: application -version: 1.0.0 +version: 0.1.0 appVersion: 4.4.0 home: https://shlink.io sources: diff --git a/charts/shlink/README.md b/charts/shlink/README.md index 0eae4c1a..378c038c 100644 --- a/charts/shlink/README.md +++ b/charts/shlink/README.md @@ -1,6 +1,6 @@ # shlink -![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 4.4.0](https://img.shields.io/badge/AppVersion-4.4.0-informational?style=flat-square) +![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 4.4.0](https://img.shields.io/badge/AppVersion-4.4.0-informational?style=flat-square) A Helm chart to deploy shlink From eb6c731c68b1ae8c0be5e0bf72b94afc4b409f40 Mon Sep 17 00:00:00 2001 From: jon4hz Date: Tue, 28 Jan 2025 11:40:01 +0100 Subject: [PATCH 3/7] chore: add shlink repo sources --- charts/shlink-web/Chart.yaml | 1 + charts/shlink-web/README.md | 1 + charts/shlink/Chart.yaml | 1 + charts/shlink/README.md | 1 + 4 files changed, 4 insertions(+) diff --git a/charts/shlink-web/Chart.yaml b/charts/shlink-web/Chart.yaml index 08939603..7582ea36 100644 --- a/charts/shlink-web/Chart.yaml +++ b/charts/shlink-web/Chart.yaml @@ -7,6 +7,7 @@ version: 0.1.0 appVersion: 4.3.0 home: https://shlink.io sources: + - https://github.com/shlinkio/shlink-web-client - https://github.com/adfinis/helm-charts/tree/main/charts/shlink-web maintainers: - name: adfinis diff --git a/charts/shlink-web/README.md b/charts/shlink-web/README.md index b79963e2..fe474d50 100644 --- a/charts/shlink-web/README.md +++ b/charts/shlink-web/README.md @@ -11,6 +11,7 @@ This chart is maintained by [Adfinis](https://adfinis.com/?pk_campaign=github&pk ## Source Code +* * ## Values diff --git a/charts/shlink/Chart.yaml b/charts/shlink/Chart.yaml index b9178535..eef3079c 100644 --- a/charts/shlink/Chart.yaml +++ b/charts/shlink/Chart.yaml @@ -7,6 +7,7 @@ version: 0.1.0 appVersion: 4.4.0 home: https://shlink.io sources: + - https://github.com/shlinkio/shlink - https://github.com/adfinis/helm-charts/tree/main/charts/shlink maintainers: - name: adfinis diff --git a/charts/shlink/README.md b/charts/shlink/README.md index 378c038c..643ece52 100644 --- a/charts/shlink/README.md +++ b/charts/shlink/README.md @@ -11,6 +11,7 @@ This chart is maintained by [Adfinis](https://adfinis.com/?pk_campaign=github&pk ## Source Code +* * ## Requirements From 10df669c708191e287b5b62d8ade728d2ee52dff Mon Sep 17 00:00:00 2001 From: jon4hz Date: Tue, 28 Jan 2025 11:41:42 +0100 Subject: [PATCH 4/7] chore: update CODEOWNERS --- CODEOWNERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CODEOWNERS b/CODEOWNERS index 38fe98f8..9b79009f 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -16,3 +16,5 @@ /charts/timed @adfinis/helm-charts @adfinis/dev-devops /charts/osschallenge @adfinis/helm-charts @adfinis/dev-devops /charts/hedgedoc @adfinis/helm-charts @altesockensuppe @gianklug +/charts/shlink @adfinis/helm-charts @adfinis/wolf +/charts/shlink-web @adfinis/helm-charts @adfinis/wolf From fb94bd9fa64b0be3e2b78f92ab1e58da5306bf90 Mon Sep 17 00:00:00 2001 From: jon4hz Date: Tue, 28 Jan 2025 11:52:32 +0100 Subject: [PATCH 5/7] fix: correct template functions form postgresql chart --- charts/shlink/templates/_helpers.tpl | 4 ++-- charts/shlink/templates/deployment.yaml | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/charts/shlink/templates/_helpers.tpl b/charts/shlink/templates/_helpers.tpl index 6e3b7d5a..d6bee1ce 100644 --- a/charts/shlink/templates/_helpers.tpl +++ b/charts/shlink/templates/_helpers.tpl @@ -67,7 +67,7 @@ Name of the Secret that contains the PostgreSQL password */}} {{- define "shlink.postgresql.secret" -}} {{- if .Values.postgresql.enabled }} - {{- include "postgresql.secretName" .Subcharts.postgresql -}} + {{- include "postgresql.v1.secretName" .Subcharts.postgresql -}} {{- else if .Values.externalDatabase.existingSecretName }} {{- .Values.externalDatabase.existingSecretName }} {{- else }} @@ -80,7 +80,7 @@ Name of the key in Secret that contains the PostgreSQL password */}} {{- define "shlink.postgresql.secretKey" -}} {{- if .Values.postgresql.enabled -}} - {{- include "postgresql.userPasswordKey" .Subcharts.postgresql -}} + {{- include "postgresql.v1.userPasswordKey" .Subcharts.postgresql -}} {{- else if .Values.externalDatabase.existingSecretName -}} {{- .Values.externalDatabase.existingSecretKey -}} {{- else -}} diff --git a/charts/shlink/templates/deployment.yaml b/charts/shlink/templates/deployment.yaml index 3caca54f..e99ba018 100644 --- a/charts/shlink/templates/deployment.yaml +++ b/charts/shlink/templates/deployment.yaml @@ -40,13 +40,13 @@ spec: value: "postgres" {{- if .Values.postgresql.enabled }} - name: DB_HOST - value: {{ include "postgresql.primary.fullname" .Subcharts.postgresql | quote }} + value: {{ include "postgresql.v1.primary.fullname" .Subcharts.postgresql | quote }} - name: DB_PORT - value: {{ include "postgresql.service.port" .Subcharts.postgresql | quote }} + value: {{ include "postgresql.v1.service.port" .Subcharts.postgresql | quote }} - name: DB_USER - value: {{ include "postgresql.username" .Subcharts.postgresql | quote }} + value: {{ include "postgresql.v1.username" .Subcharts.postgresql | quote }} - name: DB_NAME - value: {{ include "postgresql.database" .Subcharts.postgresql | quote }} + value: {{ include "postgresql.v1.database" .Subcharts.postgresql | quote }} {{- else }} - name: DB_HOST value: {{ .Values.externalDatabase.host | quote }} From 4721eb2fb7781c0344de4e1776f383f4b12416e5 Mon Sep 17 00:00:00 2001 From: jon4hz Date: Tue, 28 Jan 2025 11:52:53 +0100 Subject: [PATCH 6/7] ci: fix tests --- charts/shlink/ci/default-values.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 charts/shlink/ci/default-values.yaml diff --git a/charts/shlink/ci/default-values.yaml b/charts/shlink/ci/default-values.yaml new file mode 100644 index 00000000..a9890b76 --- /dev/null +++ b/charts/shlink/ci/default-values.yaml @@ -0,0 +1,9 @@ +env: + DEFAULT_DOMAIN: shlink.io + IS_HTTPS_ENABLED: false +postgresql: + enabled: true + auth: + user: "shlink" + postgresPassword: "password" + password: "password" From 998d30a7c9d654aad2c7ed02f86a99ed9bee0e88 Mon Sep 17 00:00:00 2001 From: jon4hz Date: Tue, 28 Jan 2025 12:13:56 +0100 Subject: [PATCH 7/7] fix: allow reading password from postgresql values --- charts/shlink/ci/default-values.yaml | 1 + charts/shlink/templates/deployment.yaml | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/charts/shlink/ci/default-values.yaml b/charts/shlink/ci/default-values.yaml index a9890b76..bd9f2890 100644 --- a/charts/shlink/ci/default-values.yaml +++ b/charts/shlink/ci/default-values.yaml @@ -7,3 +7,4 @@ postgresql: user: "shlink" postgresPassword: "password" password: "password" + database: shlink diff --git a/charts/shlink/templates/deployment.yaml b/charts/shlink/templates/deployment.yaml index e99ba018..4d15be8e 100644 --- a/charts/shlink/templates/deployment.yaml +++ b/charts/shlink/templates/deployment.yaml @@ -57,11 +57,16 @@ spec: - name: DB_NAME value: {{ .Values.externalDatabase.database | quote }} {{- end }} + {{- if .Values.postgresql.auth.password }} + - name: DB_PASSWORD + value: {{ .Values.postgresql.auth.password | quote }} + {{- else }} - name: DB_PASSWORD valueFrom: secretKeyRef: name: {{ include "shlink.postgresql.secret" . | quote }} key: {{ include "shlink.postgresql.secretKey" . | quote }} + {{- end }} {{- if .Values.env.DEBUG }} - name: SHELL_VERBOSITY value: "3"