Skip to content

Commit

Permalink
rework rabbitmq, add qr code variables, update readme and schema
Browse files Browse the repository at this point in the history
  • Loading branch information
christianhuth committed Jan 31, 2025
1 parent 29e76e7 commit 6ece306
Show file tree
Hide file tree
Showing 21 changed files with 567 additions and 57 deletions.
30 changes: 26 additions & 4 deletions charts/shlink-backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ The command removes all the Kubernetes components associated with the chart and
| autoscaling.maxReplicas | int | `100` | |
| autoscaling.minReplicas | int | `1` | |
| autoscaling.targetCPUUtilizationPercentage | int | `80` | |
| config.database.auth.database | string | `"shlink"` | The database name to be used when using an external database driver. Will be ignored when you activate one of the integrated databases with mariadb.enabled, mysql.enabled or postgresql.enabled |
| config.database.auth.database | string | `""` | The database name to be used when using an external database driver. Will be ignored when you activate one of the integrated databases with mariadb.enabled, mysql.enabled or postgresql.enabled |
| config.database.auth.existingSecret | string | `""` | Use existing secret for password details (`config.database.auth.password` will be ignored and picked up from this secret). The secret has to contain the key `database-password`. |
| config.database.auth.password | string | `"shlink"` | The password credential to be used when using an external database driver. |
| config.database.auth.username | string | `"shlink"` | The username credential to be used when using an external database driver. |
| config.database.auth.password | string | `""` | The password credential to be used when using an external database driver. |
| config.database.auth.username | string | `""` | The username credential to be used when using an external database driver. |
| config.database.driver | string | `"sqlite"` | mysql, maria, postgres or sqlite. Will be set automatically when you activate one of the integrated databases with mariadb.enabled, mysql.enabled or postgresql.enabled |
| config.database.host | string | `""` | The host name of the database server when using an external database driver. Will be ignored when you activate one of the integrated databases with mariadb.enabled, mysql.enabled or postgresql.enabled |
| config.database.port | int | `0` | The port in which the database service is running when using an external database driver. Default value is based on the value provided for DB_DRIVER. Will be ignored when you activate one of the integrated databases with mariadb.enabled, mysql.enabled or postgresql.enabled |
Expand All @@ -71,20 +71,39 @@ The command removes all the Kubernetes components associated with the chart and
| config.matomo.auth.apiToken | string | `""` | The API token so that Shlink can call Matomo’s API |
| config.matomo.auth.existingSecret | string | `""` | Use existing secret for the API token details (`config.matomo.auth.apiToken` will be ignored and picked up from this secret). The secret has to contain the key `api-token`. |
| config.matomo.baseUrl | string | `""` | The external Matomo server URL. |
| config.matomo.enabled | bool | `false` | Tells if visits should be sent to a Matomo instance. |
| config.matomo.enabled | bool | `false` | Enable the Matomo integration to sent visits |
| config.matomo.siteId | string | `""` | The site ID to be used for Shlink visits. |
| config.mercure.auth.existingSecret | string | `""` | Use existing secret for the JWT secret details (`config.mercure.auth.jwtSecret` will be ignored and picked up from this secret). The secret has to contain the key `jwt-secret`. |
| config.mercure.auth.jwtSecret | string | `""` | The secret key that was provided to the mercure hub server, in order to be able to generate valid JWTs for publishing/subscribing to that server. |
| config.mercure.enabled | bool | `false` | Enable the Mercure Hub integration. |
| config.mercure.internalHubUrl | string | `""` | An internal URL for a mercure hub. Will be used only when publishing updates to mercure, and does not need to be public. |
| config.mercure.publicHubUrl | string | `""` | The public URL of a mercure hub server to which Shlink will sent updates. This URL will also be served to consumers that want to subscribe to those updates. |
| config.qrCodes.codeForDisabledShortUrls | bool | `true` | Whether generating QR codes should work for disabled short URLs. Disabled short URLs are those which reached the maximum amount of visits, have a validSince date in the future, or a validUntil date in the past. |
| config.qrCodes.defaultColors.background | string | `"#FFFFFF"` | The QR code background color. |
| config.qrCodes.defaultColors.foreground | string | `"#000000"` | The QR code foreground color. |
| config.qrCodes.defaultErrorCorrection | string | `"l"` | One of L (Low), M (Medium), Q (Quartile) or H (High), to determine the default error correction of generated QR codes when the errorCorrection query param is not provided. |
| config.qrCodes.defaultFormat | string | `"png"` | One of png or svg, to determine the default format of generated QR codes when the format query param is not provided. |
| config.qrCodes.defaultLogoUrl | string | `""` | A URL pointing to a logo that will be placed in the middle of the QR code. This one is experimental, as some images might break the QR code. |
| config.qrCodes.defaultMargin | int | `0` | A value greater than 0 to determine the default margin of generated QR codes when the margin query param is not provided. |
| config.qrCodes.defaultRoundBlockSize | bool | `true` | Tells if the block size should be round on QR codes, making it more readable, but potentially adding some extra margin as a side effect. |
| config.qrCodes.defaultSize | int | `300` | A value between 50 and 1000 to determine the default size of generated QR codes when the size query param is not provided. |
| config.rabbitmq.auth.existingSecret | string | `""` | Use existing secret for password details (`config.rabbitmq.auth.password` will be ignored and picked up from this secret). The secret has to contain the key `rabbitmq-password`. |
| config.rabbitmq.auth.password | string | `""` | The password credential to be used when using an external database driver. |
| config.rabbitmq.auth.username | string | `""` | The username credential to be used when using an external database driver. |
| config.rabbitmq.enabled | bool | `false` | enable RabbitMQ™ Integration |
| config.rabbitmq.host | string | `""` | The RabbitMQ server host name |
| config.rabbitmq.useSsl | bool | `false` | Whether connection is encrypted with SSL/TLS or not. |
| config.rabbitmq.vhost | string | `"/"` | The RabbitMQ server VHost |
| config.redirects.cacheLifetime | int | `30` | Allows to set the amount of seconds that redirects should be cached when redirect status is 301 or 308. |
| config.redirects.defaultBaseUrlRedirect | string | `""` | If a URL is provided here, when a user tries to access Shlink’s base URL, and the visited domain does not have a redirect URL of its own, he/she will be redirected to this value. If this env var is not provided, the user will see a generic 404 - not found page. |
| config.redirects.defaultInvalidShortUrlRedirect | string | `""` | If a URL is provided here, when a user tries to access an invalid short URL, and the visited domain does not have a redirect URL of its own, he/she will be redirected to this value. If this env var is not provided, the user will see a generic 404 - not found page. |
| config.redirects.defaultRegular404Redirect | string | `""` | If a URL is provided here, when a user tries to access a URL not matching any supported by the router, and the visited domain does not have a redirect URL of its own, he/she will be redirected to this value. If this env var is not provided, the user will see a generic 404 - not found page. |
| config.redirects.extraPathMode | string | `"default"` | Determines how Shlink should match short URLs when they start with a known short code. Valid values are default, append and ignore. (See [Extra path forwarding](https://shlink.io/documentation/some-features/#extra-path-forwarding) for more info). |
| config.redirects.statusCode | int | `302` | 301, 302, 308 or 307 (last two since v3.5.0). Determines the status code that should be used on redirects from short to long URLs. Setting 308 or 307 implicitly makes requests to short URLs work regardless the HTTP method. |
| config.redis.enabled | bool | `false` | enable Redis™ Integration |
| config.redis.pubSubEnabled | bool | `false` | Tells if the configured redis instance/cluster should also be used to publish real-time updates via redis pub/sub. |
| config.redis.sentinal.enabled | bool | `false` | |
| config.redis.sentinal.service | string | `""` | The name of the sentinel service if you want to use redis sentinel. If this value is provided, the servers provided in config.redis.servers will be considered sentinel instances. |
| config.redis.servers | string | `""` | The comma-separated list of Redis servers when using external Redis servers. Will be ignored when you activate one of the integrated Redis subchart with redis.enabled |
| config.robots.allowAllShortUrls | bool | `false` | Whether all short URLs should be allowed via robots.txt or not. If set to true, the crawlable option set in individual short URLs will be ignored. |
| config.robots.userAgents | string | `"*"` | A comma-separated list of allowed user agents via robots.txt. |
Expand Down Expand Up @@ -134,8 +153,11 @@ The command removes all the Kubernetes components associated with the chart and
| postgresql.auth.username | string | `"shlink"` | The username credential to be used when using the integrated PostgreSQL database. |
| postgresql.enabled | bool | `false` | enable integrated PostgreSQL™ subchart from Bitnami |
| rabbitmq.enabled | bool | `false` | enable integrated RabbitMQ™ subchart from Bitnami |
| redis.architecture | string | `"standalone"` | Redis™ architecture. Allowed values: `standalone` or `replication` |
| redis.auth.enabled | bool | `false` | Enable password authentication |
| redis.auth.sentinel | bool | `false` | Enable password authentication on Redis™ Sentinels |
| redis.enabled | bool | `false` | enable integrated Redis™ subchart from Bitnami |
| redis.sentinel.enabled | bool | `false` | Use Redis™ Sentinel on Redis™ pods |
| replicaCount | int | `1` | Number of replicas |
| resources | object | `{}` | Resource limits and requests for the headwind pods. |
| revisionHistoryLimit | int | `10` | The number of old ReplicaSets to retain |
Expand Down
1 change: 1 addition & 0 deletions charts/shlink-backend/ci/00-sqlite-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
14 changes: 14 additions & 0 deletions charts/shlink-backend/ci/04-integrations-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
config:
matomo:
enabled: true
auth:
apiToken: "a-test-api-tokeen"
baseUrl: "my-matomo.com"
siteId: "SMj6N3zV5eK0Y8dO7TXG41I9LvfDoRl2"
mercure:
enabled: true
auth:
jwtSecret: "a-test-jwt-secret"
publicHubUrl: "my-public-mercure-hub.com"
internalHubUrl: "my-internal-mercure-hub.com"
3 changes: 0 additions & 3 deletions charts/shlink-backend/ci/04-rabbitmq-values.yaml

This file was deleted.

5 changes: 5 additions & 0 deletions charts/shlink-backend/ci/05-rabbitmq-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
rabbitmq:
enabled: true
auth:
password: my-test-password
4 changes: 3 additions & 1 deletion charts/shlink-backend/templates/database/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{{- if and (not .Values.config.database.auth.existingSecret) (not .Values.mariadb.enabled) (not .Values.mysql.enabled) (not .Values.postgresql.enabled) -}}
{{- if and (not .Values.mariadb.enabled) (not .Values.mysql.enabled) (not .Values.postgresql.enabled) (not .Values.config.database.auth.existingSecret) -}}
---
apiVersion: v1
kind: Secret
metadata:
labels:
{{- include "shlink-backend.labels" . | nindent 4 }}
name: {{ include "shlink-backend.database.auth.secretName" . }}
data:
{{- include "shlink-backend.database.auth.secretKey" . | nindent 2 }}: {{ .Values.config.database.auth.password | b64enc }}
Expand Down
11 changes: 11 additions & 0 deletions charts/shlink-backend/templates/matomo/_matomo.tpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
{{/*
Define if the Matomo integration is enabled
*/}}
{{- define "shlink-backend.matomo.enabled" -}}
{{- $enabled := "" -}}
{{- if .Values.config.matomo.enabled -}}
{{- $enabled = "true" -}}
{{- end }}
{{- $enabled -}}
{{- end }}

{{/*
Get the name of the secret containing the API token
*/}}
Expand Down
4 changes: 3 additions & 1 deletion charts/shlink-backend/templates/matomo/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{{- if and (.Values.config.matomo.enabled) (not .Values.config.matomo.auth.existingSecret) -}}
{{- if and (include "shlink-backend.matomo.enabled" .) (not .Values.config.matomo.auth.existingSecret) -}}
---
apiVersion: v1
kind: Secret
metadata:
labels:
{{- include "shlink-backend.labels" . | nindent 4 }}
name: {{ include "shlink-backend.matomo.auth.secretName" . }}
data:
api-token: {{ .Values.config.matomo.auth.apiToken | b64enc }}
Expand Down
11 changes: 11 additions & 0 deletions charts/shlink-backend/templates/mercure/_mercure.tpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
{{/*
Define if the Mercure integration is enabled
*/}}
{{- define "shlink-backend.mercure.enabled" -}}
{{- $enabled := "" -}}
{{- if .Values.config.mercure.enabled -}}
{{- $enabled = "true" -}}
{{- end }}
{{- $enabled -}}
{{- end }}

{{/*
Get the name of the secret containing the API token
*/}}
Expand Down
4 changes: 3 additions & 1 deletion charts/shlink-backend/templates/mercure/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{{- if and (.Values.config.mercure.enabled) (not .Values.config.mercure.auth.existingSecret) -}}
{{- if and (include "shlink-backend.mercure.enabled" .) (not .Values.config.mercure.auth.existingSecret) -}}
---
apiVersion: v1
kind: Secret
metadata:
labels:
{{- include "shlink-backend.labels" . | nindent 4 }}
name: {{ include "shlink-backend.mercure.auth.secretName" . }}
data:
jwt-secret: {{ .Values.config.mercure.auth.jwtSecret | b64enc }}
Expand Down
77 changes: 77 additions & 0 deletions charts/shlink-backend/templates/rabbitmq/_rabbitmq.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{{/*
Define if the RabbitMQ integration is enabled
*/}}
{{- define "shlink-backend.rabbitmq.enabled" -}}
{{- $enabled := "" -}}
{{- if or (.Values.rabbitmq.enabled) (.Values.config.rabbitmq.enabled) -}}
{{- $enabled = "true" -}}
{{- end }}
{{- $enabled -}}
{{- end }}

{{/*
Get the name of the secret containing the RabbitMQ password
*/}}
{{- define "shlink-backend.rabbitmq.auth.secretName" -}}
{{- $secretName := "" -}}
{{- if .Values.rabbitmq.enabled -}}
{{- $secretName = (include "rabbitmq.secretPasswordName" .Subcharts.rabbitmq) -}}
{{- else if .Values.config.rabbitmq.auth.existingSecret -}}
{{- $secretName = .Values.config.rabbitmq.auth.existingSecret -}}
{{- else -}}
{{- $secretName = printf "%s-rabbitmq" (include "shlink-backend.fullname" .) -}}
{{- end -}}
{{- $secretName -}}
{{- end -}}

{{/*
Define the RabbitMQ username
*/}}
{{- define "shlink-backend.rabbitmq.auth.username" -}}
{{- $username := "" -}}
{{- if .Values.rabbitmq.enabled -}}
{{- $username = .Values.rabbitmq.auth.username -}}
{{- else -}}
{{- $username = .Values.config.rabbitmq.auth.username -}}
{{- end -}}
{{- if not $username -}}
{{- fail "Unable to determine the RabbitMQ username. Use config.rabbitmq.auth.username or activate the integrated RabbitMQ subchart." -}}
{{- end -}}
{{- $username -}}
{{- end }}

{{/*
Define the RabbitMQ host
*/}}
{{- define "shlink-backend.rabbitmq.host" -}}
{{- $host := "" -}}
{{- if .Values.rabbitmq.enabled -}}
{{- $host = (include "common.names.fullname" .Subcharts.rabbitmq) -}}
{{- else -}}
{{- $host = .Values.config.rabbitmq.host -}}
{{- end -}}
{{- if not $host -}}
{{- fail "Unable to determine the RabbitMQ host. Use config.rabbitmq.host or activate the integrated RabbitMQ subchart." -}}
{{- end -}}
{{- $host -}}
{{- end }}

{{/*
Define the RabbitMQ port
*/}}
{{- define "shlink-backend.rabbitmq.port" -}}
{{- $port := "" -}}
{{- if .Values.rabbitmq.enabled -}}
{{- if or (.Values.rabbitmq.service.portEnabled) (not .Values.rabbitmq.auth.tls.enabled) }}
{{ $port = .Values.rabbitmq.service.ports.amqp }}
{{- else if .Values.rabbitmq.auth.tls.enabled }}
{{ $port = .Values.rabbitmq.service.ports.amqpTls }}
{{- end }}
{{- else -}}
{{- $port = .Values.config.rabbitmq.port -}}
{{- end -}}
{{- if not $port -}}
{{- fail "Unable to determine the RabbitMQ port. Use config.rabbitmq.port or activate the integrated RabbitMQ subchart." -}}
{{- end -}}
{{- $port -}}
{{- end }}
11 changes: 11 additions & 0 deletions charts/shlink-backend/templates/rabbitmq/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- if and (not .Values.rabbitmq.enabled) (.Values.config.rabbitmq.auth.existingSecret) -}}
---
apiVersion: v1
kind: Secret
metadata:
labels:
{{- include "shlink-backend.labels" . | nindent 4 }}
name: {{ include "shlink-backend.rabbitmq.auth.secretName" . }}
data:
rabbitmq-password: {{ .Values.config.rabbitmq.auth.password | b64enc }}
{{- end }}
39 changes: 36 additions & 3 deletions charts/shlink-backend/templates/redis/_redis.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Define if the Redis integration is enabled
*/}}
{{- define "shlink-backend.redis.enabled" -}}
{{- $enabled := "" -}}
{{- if or (.Values.redis.enabled) (.Values.config.redis.servers) -}}
{{- if or (.Values.redis.enabled) (.Values.config.redis.enabled) -}}
{{- $enabled = "true" -}}
{{- end }}
{{- $enabled -}}
Expand All @@ -17,12 +17,45 @@ Define the redis servers
{{- if .Values.redis.enabled -}}
{{- $host := (include "common.names.fullname" .Subcharts.redis) -}}
{{- $port := (.Values.redis.master.service.ports.redis | toString) -}}
{{- $servers = (printf "%s-master:%s" $host $port) -}}
{{- if (include "shlink-backend.redis.sentinal.enabled" .) -}}
{{- $servers = (printf "%s:%s" $host $port) -}}
{{- else -}}
{{- $servers = (printf "%s-master:%s" $host $port) -}}
{{- end -}}
{{- else -}}
{{- $servers = .Values.config.redis.servers -}}
{{- end -}}
{{- if not $servers -}}
{{- fail "Unable to determine the list of redis server. Use config.redis.servers or activate one of the integrated Redis subchart." -}}
{{- fail "Unable to determine the list of redis server. Use config.redis.servers or activate the integrated Redis subchart." -}}
{{- end -}}
{{- $servers -}}
{{- end }}

{{/*
Define the redis sentinal service is enabled
*/}}
{{- define "shlink-backend.redis.sentinal.enabled" -}}
{{- $enabled := "" -}}
{{- if or (.Values.redis.sentinel.enabled) (.Values.config.redis.sentinal.enabled) -}}
{{- $enabled = "true" -}}
{{- end }}
{{- $enabled -}}
{{- end }}

{{/*
Define the redis sentinal service
*/}}
{{- define "shlink-backend.redis.sentinal.service" -}}
{{- $sentinalService := "" -}}
{{- if .Values.redis.enabled -}}
{{- $host := (include "common.names.fullname" .Subcharts.redis) -}}
{{- $port := (.Values.redis.sentinel.containerPorts.sentinel | toString) -}}
{{- $sentinalService = (printf "%s:%s" $host $port) -}}
{{- else -}}
{{- $sentinalService = .Values.config.redis.sentinalService -}}
{{- end -}}
{{- if not $sentinalService -}}
{{- fail "Unable to determine the name of the redis sentinal service. Use config.redis.sentinal.service or activate the integrated Redis subchart." -}}
{{- end -}}
{{- $sentinalService -}}
{{- end }}
Loading

0 comments on commit 6ece306

Please sign in to comment.