polr

by christianhuth

Helm chartv5.1.1App 2.3.0Verified publisher

Polr is a quick, modern, and open-source link shortener

About this chart

polr

Polr is a quick, modern, and open-source link shortener

TL;DR;

helm repo add christianhuth https://charts.christianhuth.de
helm repo update
helm install my-release christianhuth/polr

Or install it from the OCI registry:

helm install my-release oci://ghcr.io/christianhuth/helm-charts/polr

Introduction

This chart bootstraps a quick, modern and open-source link shortener called Polr using the Helm package manager.

Prerequisites

  • Kubernetes 1.26+
  • The mariadb-operator if the bundled MariaDB database is used (mariadb.enabled: true, the default)

Installing the mariadb-operator

The chart bundles the database as a custom resource of the mariadb-operator (via the upstream chart mariadb-cluster). The operator itself is not part of this chart, as it is installed once per Kubernetes cluster:

helm upgrade --install mariadb-operator-crds oci://ghcr.io/mariadb-operator/charts/mariadb-operator-crds --namespace mariadb-operator --create-namespace
helm upgrade --install mariadb-operator oci://ghcr.io/mariadb-operator/charts/mariadb-operator --namespace mariadb-operator --wait

Installing the Chart

To install the chart with the release name my-release:

helm repo add christianhuth https://charts.christianhuth.de
helm repo update
helm install my-release christianhuth/polr

The chart is also published as an OCI artifact which can be installed like this:

helm install my-release oci://ghcr.io/christianhuth/helm-charts/polr

These commands deploy Polr on the Kubernetes cluster in the default configuration. The Values section lists the values that can be configured during installation.

Tip: List all releases using helm list

Uninstalling the Chart

To uninstall the my-release deployment:

helm uninstall my-release

The command removes all the Kubernetes components associated with the chart and deletes the release.

Configuring the Database

Bundled MariaDB with an existing Secret (recommended)

Create a Secret containing the password of the database user and reference it in your values:

kubectl create secret generic polr-database --from-literal=password='<password>'
mariadb:
  mariadb:
    passwordSecretKeyRef:
      name: polr-database
      key: password
      generate: false

If no Secret is referenced, the operator generates a random password and stores it in the Secret <release>-mariadb-password. Polr writes the password into its .env file on startup, so it must not contain spaces, quotes, # or $. By default the database runs as a Galera cluster with 3 instances. All other settings are passed to the upstream chart, see its values and the MariaDB API reference.

The image tag only pins the MariaDB release series (by default the long-term support release 12.3). To upgrade to another release series, change the tag of mariadb.mariadb.image. The operator migrates the system schema on the rollout (updateStrategy.mariadbAutoUpgradeEnabled). Downgrades are not supported by MariaDB, so take a backup before upgrading.

External MariaDB or MySQL

mariadb:
  enabled: false

externalDatabase:
  hostname: mariadb.example.com
  port: 3306
  database: polr
  username: polr
  existingSecret: polr-database
  existingSecretPasswordKey: password

Instead of externalDatabase.existingSecret you can set externalDatabase.password, which lets the chart create the Secret.

Values

KeyTypeDefaultDescription
admin.emailstring""
admin.existingSecretstring""
admin.passwordstring"admin"
admin.usernamestring"admin"
affinityobject{}Affinity settings for pod assignment
autoscaling.enabledboolfalse
autoscaling.maxReplicasint100
autoscaling.minReplicasint1
autoscaling.targetCPUUtilizationPercentageint80
deploymentStrategyobject{}Update strategy for the deployment
env[0].namestring"APP_ADDRESS"
env[0].valuestring"polr.local"
env[1].namestring"APP_NAME"
env[1].valuestring"Polr"
externalDatabase.databasestring"polr"Name of the database to use
externalDatabase.existingSecretstring""Name of an existing Secret containing the password of the user
externalDatabase.existingSecretPasswordKeystring"password"Key in the existing Secret containing the password
externalDatabase.hostnamestring""Hostname of the external MariaDB or MySQL database. Used if mariadb.enabled is false.
externalDatabase.passwordstring""Password of the user. Ignored if externalDatabase.existingSecret is set.
externalDatabase.portint3306Port of the external database
externalDatabase.usernamestring"polr"Name of the user to use
fullnameOverridestring""String to fully override "polr.fullname"
image.pullPolicystring"Always"image pull policy
image.registrystring"docker.io"image registory
image.repositorystring"ajanvier/polr"image repository
image.tagstring"2.3.0"Overrides the image tag
imagePullSecretslist[]If defined, uses a Secret to pull an image from a private Docker registry or repository.
ingress.annotationsobject{}
ingress.classNamestring""
ingress.enabledboolfalse
ingress.hosts[0].hoststring"chart-example.local"
ingress.hosts[0].paths[0].pathstring"/"
ingress.hosts[0].paths[0].pathTypestring"ImplementationSpecific"
ingress.tlslist[]
mail.enabledboolfalse
mail.existingSecretstring""
mail.fromAddressstring""
mail.fromNamestring""
mail.hoststring""
mail.passwordstring""
mail.portstring""
mail.usernamestring""
mariadb.enabledbooltrueEnable a MariaDB instance managed by the mariadb-operator. Requires the operator to be installed in the cluster (see README).
mariadb.mariadb.databasestring"polr"Name of the database to create
mariadb.mariadb.galera.enabledbooltrueEnable Galera to run multiple instances
mariadb.mariadb.imagestring"mariadb:12.3"MariaDB image. The tag only pins the release series (12.3 is the current long-term support release), so restarted instances get its latest patch version.
mariadb.mariadb.imagePullPolicystring"Always"Pull the image on every start to get the latest patch version of the release series
mariadb.mariadb.passwordSecretKeyRef.generatebooltrueLet the operator generate the Secret with a random password if it does not exist
mariadb.mariadb.passwordSecretKeyRef.keystring"password"Key of the password inside the Secret
mariadb.mariadb.passwordSecretKeyRef.namestring""Name of an existing Secret containing the password of the user. If empty, the Secret <release>-mariadb-password is used.
mariadb.mariadb.replicasint3Number of MariaDB instances. More than one instance requires Galera or replication.
mariadb.mariadb.storage.sizestring"8Gi"Size of the PVC of each instance
mariadb.mariadb.updateStrategy.mariadbAutoUpgradeEnabledbooltrueRun mariadb-upgrade on start, so that changing the release series in image migrates the system schema. It is a no-op if there is nothing to migrate.
mariadb.mariadb.usernamestring"polr"Name of the user to create
nameOverridestring""Provide a name in place of polr
nodeSelectorobject{}Node labels for pod assignment
podAnnotationsobject{}Annotations to be added to pods
podSecurityContextobject{}pod-level security context
replicaCountint1Number of replicas
resourcesobject{}Resource limits and requests for the headwind pods.
revisionHistoryLimitint10The number of old ReplicaSets to retain
route.main.additionalRuleslist[]Additional custom rules that can be added to the route
route.main.annotationsobject{}Add annotations to the route
route.main.apiVersionstring"gateway.networking.k8s.io/v1"Set the route apiVersion, e.g. gateway.networking.k8s.io/v1 or gateway.networking.k8s.io/v1alpha2
route.main.enabledboolfalseEnables or disables the route
route.main.filterslist[]Filters define the filters that are applied to requests that match this rule.
route.main.hostnameslist[]Hostnames to be matched
route.main.httpsRedirectboolfalseadds a filter for redirecting to https (HTTP 301 Moved Permanently). To redirect HTTP traffic to HTTPS, you need to have a Gateway with both HTTP and HTTPS listeners. Matches and filters do not take effect if enabled. Ref. https://gateway-api.sigs.k8s.io/guides/http-redirect-rewrite/
route.main.kindstring"HTTPRoute"Set the route kind Valid options are GRPCRoute, HTTPRoute, TCPRoute, TLSRoute, UDPRoute
route.main.labelsobject{}Add labels to the route
route.main.matcheslistsee values.yamldefine conditions used for matching the rule against incoming HTTP requests.
route.main.parentRefslist[]Parent references (Gateway)
route.main.timeoutsobject{}defines the timeouts that can be configured for an HTTP request
securityContextobject{}container-level security context
service.portint80Kubernetes port where service is exposed
service.typestring"ClusterIP"Kubernetes service type
serviceAccount.annotationsobject{}Annotations to add to the service account
serviceAccount.createbooltrueSpecifies whether a service account should be created
serviceAccount.namestring""The name of the service account to use. If not set and create is true, a name is generated using the fullname template
tolerationslist[]Toleration labels for pod assignment

Specify each parameter using the --set key=value[,key=value] argument to helm install.

Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,

helm install my-release -f values.yaml christianhuth/polr

Upgrading the Chart

To 5.0.0

This major replaces the Bitnami MySQL subchart with a MariaDB instance managed by the mariadb-operator (upstream chart mariadb-cluster). MariaDB is compatible with the MySQL driver used by Polr. Install the operator first (see Prerequisites). The values changed as follows:

  • mysql.* is replaced by mariadb.* with the values of the upstream chart, e.g. mariadb.mariadb.database and mariadb.mariadb.username
  • an inline password for the bundled database is no longer supported. Use an existing Secret or let the operator generate one (see Configuring the Database)
  • externalDatabase.host is renamed to externalDatabase.hostname, and the key of the password in externalDatabase.existingSecret is configurable with externalDatabase.existingSecretPasswordKey (previously the fixed key mysql-password)

The upgrade creates a new, empty database. The Bitnami StatefulSet is removed, but its PersistentVolumeClaim data-<release>-mysql-0 is kept. A dump of the MySQL database can be restored into MariaDB without changes. To take your data along:

  1. Dump the database before upgrading:

    kubectl exec <release>-mysql-0 -- sh -c 'mysqldump -u"$MYSQL_USER" -p"$(cat "$MYSQL_PASSWORD_FILE")" --no-tablespaces "$MYSQL_DATABASE"' > polr.sql
    
  2. Upgrade the chart with Polr scaled down, so it does not initialize the new database. Then wait until the operator has created the database and its user:

    helm upgrade <release> christianhuth/polr --version 5.0.0 -f values.yaml --set replicaCount=0 --wait
    kubectl wait --for=create user/<release>-mariadb-user --timeout=10m
    kubectl wait --for=create grant/<release>-mariadb-user-all --timeout=10m
    kubectl wait --for=condition=Ready user/<release>-mariadb-user grant/<release>-mariadb-user-all --timeout=10m
    
  3. Restore the dump. Use the Secret from mariadb.mariadb.passwordSecretKeyRef or the generated <release>-mariadb-password:

    PASSWORD=$(kubectl get secret <release>-mariadb-password -o jsonpath='{.data.password}' | base64 -d)
    kubectl exec -i <release>-mariadb-0 -c mariadb -- mariadb -u polr --password="$PASSWORD" polr < polr.sql
    
  4. Scale Polr up again:

    helm upgrade <release> christianhuth/polr --version 5.0.0 -f values.yaml --wait
    
  5. Once everything works, delete the old PersistentVolumeClaim data-<release>-mysql-0.

To 4.0.0

This major updates the MySQL subchart to its newest major, 14.0.0: Here you can find more information about the changes introduced in that version.

To 3.0.0

This major updates the MySQL subchart to its newest major, 13.0.0:

Deploy polr with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has polr on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartpolr is pinned at v5.1.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply