2023-06-02 21:16:36 +02:00
# Running a Calckey server with Kubernetes and Helm
2023-05-11 01:07:45 +02:00
2023-06-07 22:35:58 +02:00
There is a [Helm ](https://helm.sh/ ) chart directory found [here ](../charts/calckey/README.md )
that you can use to deploy Calckey to a Kubernetes cluster
2023-05-11 01:07:45 +02:00
2023-06-07 22:35:58 +02:00
## Basic Usage
2023-05-11 01:07:45 +02:00
2023-06-07 22:35:58 +02:00
1. Copy the example helm values file:
2023-05-11 01:07:45 +02:00
```shell
cp .config/helm_values_example.yml .config/helm_values.yml
```
2023-06-07 22:35:58 +02:00
2. Edit your `.config/helm_values.yml` to match your needs. See [chart default values ](../charts/calckey/values.yaml ) for all possible options. At a minimum, update the following fields:
```yaml
calckey:
domain: example.tld
ingress:
hosts:
- host: example.tld
paths:
- path: /
pathType: ImplementationSpecific
tls:
- secretName: example-tld-certificate
hosts:
- example.tld
postgresql:
auth:
password: CHANGEME
postgresPassword: CHANGEME
primary:
persistence:
enabled: true
storageClass: example-storage-class
redis:
auth:
password: CHANGEME
master:
persistence:
storageClass: example-storage-class
```
3. Update helm dependencies:
2023-05-11 01:07:45 +02:00
```shell
2023-06-07 22:35:58 +02:00
cd charts/calckey
2023-05-11 01:07:45 +02:00
helm dependency list $dir 2> /dev/null | tail +2 | head -n -1 | awk '{ print "helm repo add " $1 " " $3 }' | while read cmd; do $cmd; done;
2023-06-07 22:35:58 +02:00
cd ../../
2023-05-11 01:07:45 +02:00
```
2023-06-07 22:35:58 +02:00
4. Create the calckey helm release (also used to update an existing deployment):
2023-05-11 01:07:45 +02:00
```shell
helm upgrade \
--install \
--namespace calckey \
--create-namespace \
2023-06-07 22:35:58 +02:00
calckey charts/calckey/ \
2023-05-11 01:07:45 +02:00
-f .config/helm_values.yml
```
2023-06-07 22:35:58 +02:00
5. Watch your calckey server spin up:
2023-05-11 01:07:45 +02:00
```shell
kubectl -n calckey get po -w
```
2023-06-07 22:35:58 +02:00
6. Any time you make changes to `.config/helm_values.yml` , re-run the helm upgrade command in step 4 to apply the changes.
7. Enjoy!
## Advanced Usage
### Connect to external PostgreSQL, Redis, or Elasticsearch
Edit `.config/helm_values.yml` to disable the built-in update the settings to meet your needs:
```yaml
postgresql:
enabled: false
hostname: database.example.tld
port: 5432
auth:
database: calckey_production
username: calckey
password: CHANGEME
redis:
enabled: false
hostname: redis.example.tld
port: 6379
db: 0
auth:
password: CHANGEME
elasticsearch:
enabled: false
hostname: elasticsearch.example.tld
port: 9200
ssl: false
auth:
username: myuser
password: CHANGEME
```
### Managed Configuration
**[WARNING] This is an advanced option. Use at your own risk!**
Edit `.config/helm_values.yml` and set `calckey.isManagedHosting` to `true` and the settings you want to manage:
```yaml
calckey:
isManagedHosting: true
libreTranslate:
managed: true
apiUrl: "https://translate.example.tld/translate"
apiKey: "totallyFakeKey"
smtp:
managed: true
from_address: noreply@example.tld
port: 587
server: smtp.gmail.com
useImplicitSslTls: false
login: me@example.tld
password: CHANGEME
objectStorage:
managed: true
baseUrl: https://example-bucket.nyc3.cdn.digitaloceanspaces.com
access_key: CHANGEME
access_secret: CHANGEME
bucket: example-bucket
endpoint: nyc3.digitaloceanspaces.com:443
region: nyc3
```
Initial the admin user and managed config:
2023-05-11 01:07:45 +02:00
```shell
2023-06-07 22:35:58 +02:00
# Change these values to your desired user, password, and the correct host
2023-05-11 01:07:45 +02:00
export CALCKEY_USERNAME="my_desired_admin_handle" & & \
export CALCKEY_PASSWORD="myDesiredInitialPassword" & & \
2023-06-07 22:35:58 +02:00
export CALCKEY_HOST="example.tld"
# Use the API to create the initial admin user and capture the user token
2023-05-11 01:07:45 +02:00
export CALCKEY_TOKEN=$(curl -X POST https://$CALCKEY_HOST/api/admin/accounts/create -H "Content-Type: application/json" -d "{ \"username\":\"$CALCKEY_USERNAME\", \"password\":\"$CALCKEY_PASSWORD\" }" | jq -r '.token') && \
2023-06-07 22:35:58 +02:00
echo "Save this token: ${CALCKEY_TOKEN}"
# Use the API to pull in the managed config settings
2023-05-11 01:07:45 +02:00
curl -X POST -H "Authorization: Bearer $CALCKEY_TOKEN" https://$CALCKEY_HOST/api/admin/accounts/hosted
```
2023-06-07 22:35:58 +02:00
You should now be good to go!
Any time you make changes to your managed settings you will need to re-run the
last curl command to tell the API to pull in the latest config changes.