Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ CHARTS_INTEGRATION := wire-server databases-ephemeral redis-cluster fake-aws
# (e.g. move charts/brig to charts/wire-server/brig)
# this list could be generated from the folder names under ./charts/ like so:
# CHARTS_RELEASE := $(shell find charts/ -maxdepth 1 -type d | xargs -n 1 basename | grep -v charts)
CHARTS_RELEASE := wire-server redis-ephemeral redis-cluster databases-ephemeral fake-aws fake-aws-s3 fake-aws-sqs aws-ingress fluent-bit kibana backoffice calling-test demo-smtp elasticsearch-curator elasticsearch-external elasticsearch-ephemeral minio-external cassandra-external nginx-ingress-controller nginx-ingress-services reaper sftd restund coturn inbucket
CHARTS_RELEASE := wire-server redis-ephemeral redis-cluster databases-ephemeral \
fake-aws fake-aws-s3 fake-aws-sqs aws-ingress fluent-bit kibana backoffice \
calling-test demo-smtp elasticsearch-curator elasticsearch-external \
elasticsearch-ephemeral minio-external cassandra-external \
nginx-ingress-controller nginx-ingress-services reaper sftd restund coturn \
inbucket k8ssandra-test-cluster
KIND_CLUSTER_NAME := wire-server

package ?= all
Expand Down
1 change: 1 addition & 0 deletions changelog.d/5-internal/k8ssandra-cluster-helm-chart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add Helm chart to configure clusters managed by k8ssandra-operator for test environments.
23 changes: 23 additions & 0 deletions charts/k8ssandra-test-cluster/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
9 changes: 9 additions & 0 deletions charts/k8ssandra-test-cluster/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v2
name: k8ssandra-test-cluster
description: K8ssandra (Cassandra cluster) K8ssandraCluster object for wire test servers. (This does not install K8ssandra itself!)

type: application

version: 0.1.0

appVersion: "0.39.2"
89 changes: 89 additions & 0 deletions charts/k8ssandra-test-cluster/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# k8ssandra-test-cluster Helm chart

`k8ssandra-test-cluster` provides a `K8ssandraCluster` object to create a
*Cassandra* database with
[`k8ssandra-operator`](https://artifacthub.io/packages/helm/k8ssandra/k8ssandra-operator).
**It does not install `k8ssandra-operator` itself!** This configuration is meant
to be used in test environments: **It lacks crucial parts like backups
(`medusa`)!**

## Usage in Helmfile

### Prerequisites

You need a *storage class* that can automatically request storage volumes. For
Hetzner's cloud see: [Container Storage Interface driver for Hetzner
Cloud](https://github.com/hetznercloud/csi-driver)

### Usage

These entries are used in the `helfile` file:

``` yaml
...

repositories:
- name: wire
url: 'https://s3-eu-west-1.amazonaws.com/public.wire.com/charts'
- name: k8ssandra-stable
url: https://helm.k8ssandra.io/stable

...

releases:
- name: k8ssandra-operator
chart: 'k8ssandra-stable/k8ssandra-operator'
namespace: databases
version: 0.39.2
values:
# Use a cass-operator image that is compatible to the K8s cluster version
- cass-operator:
image:
tag: v1.10.5

# Installs CDRs automatically
- name: k8ssandra-test-cluster
chart: "wire/k8ssandra-test-cluster"
namespace: "databases"
version: {{ .Values.wireChartVersion | quote }}
needs:
- 'databases/k8ssandra-operator'
wait: true
waitForJobs: true

- name: 'wire-server'
namespace: 'wire'
chart: 'wire/wire-server'
version: {{ .Values.wireChartVersion | quote }}
values:
- './helm_vars/wire-server/values.yaml.gotmpl'
secrets:
- './helm_vars/wire-server/secrets.yaml'
needs:
- 'databases/k8ssandra-test-cluster'

...
```

Please note the `needs` relations of the releases: `wire-server` *needs*
`k8ssandra-test-cluster` which *needs* `k8ssandra-operator`.

`wait` and `waitForJobs` are mandatory for `k8ssandra-test-cluster` in this
setup: These settings ensure that the database really exists before resuming
with the deployment.

## Implementation details

### k8ssandra-cluster.yaml

Contains the `K8ssandraCluster` object. Its schema is described in the [CRD
reference](https://docs-v2.k8ssandra.io/reference/crd/k8ssandra-operator-crds-latest/#k8ssandracluster)

The specified *Cassandra* cluster runs on a single Node with reasonable
resources for test environments.

### check-cluster-job.yaml

Defines a job that tries to connect to the final *Cassandra* database. Other
deployments can wait on this. This is useful because `wire-server` needs a
working database right from the beginning of it's deployment.
19 changes: 19 additions & 0 deletions charts/k8ssandra-test-cluster/templates/check-cluster-job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This job fails until the Cassandra created database is reachable. The Helmfile
# deployment can wait for it. This is used to start wire-server deployments only
# with a reachable database.
apiVersion: batch/v1
kind: Job
metadata:
name: check-cluster-job
namespace: databases
spec:
template:
spec:
containers:
- name: cassandra
image: cassandra:3.11
command: ["cqlsh", "k8ssandra-cluster-datacenter-1-service"]
restartPolicy: OnFailure
# Default is 6 retries. 8 is a bit arbitrary, but should be sufficient for
# low resource environments (e.g. Wire-in-a-box.)
backoffLimit: 8
43 changes: 43 additions & 0 deletions charts/k8ssandra-test-cluster/templates/k8ssandra-cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: k8ssandra.io/v1alpha1
kind: K8ssandraCluster
metadata:
name: k8ssandra-cluster
namespace: databases
spec:
auth: false
cassandra:
serverVersion: "3.11.11"
telemetry:
prometheus:
enabled: true
resources:
requests:
cpu: 1
memory: "4.0Gi"
limits:
memory: "4.0Gi"
config:
jvmOptions:
# Intentionally, half of the available memory
heap_max_size: "2G"
heap_initial_size: "2G"
gc_g1_rset_updating_pause_time_percent: 5
gc: "G1GC"
gc_g1_max_gc_pause_ms: 300
gc_g1_initiating_heap_occupancy_percent: 55
gc_g1_parallel_threads: 16
datacenters:
- metadata:
name: datacenter-1
size: 1
storageConfig:
cassandraDataVolumeClaimSpec:
storageClassName: {{ .Values.storageClassName }}
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.storageSize }}
reaper:
autoScheduling:
enabled: true
13 changes: 13 additions & 0 deletions charts/k8ssandra-test-cluster/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# The values in k8ssandra-cluster.yaml are well choosen. Please only export and
# override them if you are confident the change is needed.

# storageClassName: the name storageClass to use. This defines where the data is
# stored. Storage is automatically requested if the storage class is correctly
# setup.
storageClassName: hcloud-volumes-encrypted

# storageSize: Size of the storage (persistent volume claim) to request. At
# Hetzner's cloud the smallest volume is 10GB. So, even if you need much less
# storage, it's fine to request 10GB. The memory units are described here:
# https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-memory
storageSize: 10G