cadence

by Helm

Helm chartv0.24.2App 0.24.0

Cadence is a distributed, scalable, durable, and highly available orchestration engine to execute asynchronous long-running business logic in a scalable and resilient way.

About this chart

Cadence

Cadence is a distributed, scalable, durable, and highly available orchestration engine to execute asynchronous long-running business logic in a scalable and resilient way.

TL;DR;

$ helm repo add banzaicloud-stable https://kubernetes-charts.banzaicloud.com
$ helm repo update

Introduction

This chart bootstraps a Cadence and a Cadence-UI deployment on a Kubernetes cluster using the Helm package manager.

Prerequisites

  • Kubernetes 1.7+ with Beta APIs enabled
  • Cadence 0.24.0+

Installing the Chart

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

$ helm install --name my-release --namespace cadence banzaicloud-stable/cadence

Tip: List all releases using helm list

Upgrading Chart

# Helm
$ helm upgrade [RELEASE_NAME] banzaicloud-stable/cadence

From 0.20.x (or below) to 0.21.y (or above)

Version 0.21.0 extends the configuration interface by introducing clusterMetadata settings to the values.yaml in a backward incompatible manner with existing Cadence clusters.

To upgrade the Cadence deployment under existing Cadence clusters from version 0.20.x (or below) to 0.21.y (or above) you MUST set the existing cluster's configuration in the values.yaml file's .server.config.clusterMetadata section to be used for the upgrade.

Example configuration for upgrading from version 0.16.x (or below)

server:
  # ...
  config:
    clusterMetadata:
      enableGlobalDomain: true
      maximumClusterCount: 10
      masterClusterName: "active"
      currentClusterName: "active"
      clusterInformation:
        - name: active
          enabled: true

Example configuration for upgrading from version 0.17.x

server:
  # ...
  config:
    clusterMetadata:
      enableGlobalDomain: true
      maximumClusterCount: 10
      masterClusterName: "master"
      currentClusterName: "master"
      clusterInformation:
        - name: master
          enabled: true

Example configuration for upgrading from 0.18.x (or above), single Cadence cluster

server:
  # ...
  config:
    clusterMetadata:
      enableGlobalDomain: true
      maximumClusterCount: 10
      masterClusterName: "primary"
      currentClusterName: "primary"
      clusterInformation:
        - name: primary
          enabled: true

Example configuration for upgrading from 0.18.x (or above), multiple Cadence clusters

server:
  # ...
  config:
    clusterMetadata:
      enableGlobalDomain: true
      maximumClusterCount: 10
      masterClusterName: "primary"
      currentClusterName: "primary" # "secondary" # Note: use the name of the Cadence cluster you are using on the cluster/namespace/release you are upgrading.
      clusterInformation:
        - name: primary
          enabled: true
        - name: secondary
          enabled: true

Uninstalling the Chart

To uninstall/delete the my-release deployment:

$ helm delete my-release

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

Install the Chart with Cassandra

The chart comes with a single node Cassandra by default (from incubator/cassandra).

$ helm install banzaicloud-stable/cadence

You can increase the number of Cassandra nodes if you want:

$ helm install --set cassandra.config.cluster_size=3 banzaicloud-stable/cadence

Note: It takes a few minutes to start Cassandra. You can speed it up by using configuration from values.dev.yaml.

Configure the Chart to use existing Cassandra cluster

You can configure the chart to use an existing Cassandra cluster instead of installing one.

Prerequisites:

  • Running Cassandra cluster
  • Existing keyspaces for default and visibility stores
  • Existing user(s) with access to those keyspaces (if authentication is required)

You can easily start your own Cassandra cluster using the same incubator/cassandra chart:

$ helm install -f values/cassandra.yaml --name cassandra incubator/cassandra

Wait for Cassandra to become ready:

$ kubectl wait --for=condition=Ready pod/cassandra-0 --timeout=90s

Create two Cassandra keyspaces:

$ kubectl exec -it cassandra-0 -- cqlsh -e "CREATE KEYSPACE cadence WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };"
$ kubectl exec -it cassandra-0 -- cqlsh -e "CREATE KEYSPACE cadence_visibility WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };"
$ helm install -f values/values.cassandra.yaml banzaicloud-stable/cadence

Alternatively, install the chart with manual migrations. Follow the steps in migrations.md.

$ helm install -f values/values.cassandra.yaml --set schema.setup.enabled=false --set schema.update.enabled=false banzaicloud-stable/cadence

Install the Chart with MySQL

Note: MySQL support is currently beta in Cadence.

The chart can be installed with a single node MySQL (from stable/mysql).

$ helm install --set cassandra.enabled=false --set mysql.enabled=true --set mysql.mysqlPassword=cadence banzaicloud-stable/cadence

Note: When installing MySQL from within the chart with automatic migrations, you must configure a password. See the Limitations section for details.

Configure the Chart to use existing MySQL instance

You can configure the chart to use an existing MySQL instance instead of installing one.

Prerequisites:

  • Running MySQL instance
  • Existing databases for default and visibility stores
  • Existing user(s) with access to those databases

You can easily start your own MySQL instance using the same stable/mysql chart:

$ helm install -f values/mysql.yaml --name mysql stable/mysql

Wait for MySQL to become ready:

$ kubectl wait --for=condition=Ready pod/$(kubectl get pods -l 'app=mysql' -o jsonpath='{..metadata.name}') --timeout=90s
$ helm install -f values/values.mysql.yaml banzaicloud-stable/cadence

Alternatively, install the chart with manual migrations. Follow the steps in migrations.md.

$ helm install -f values/values.mysql.yaml --set schema.setup.enabled=false --set schema.update.enabled=false banzaicloud-stable/cadence

Prometheus monitoring

As of 0.5.8 Cadence exports Prometheus metrics. The chart supports annotating Cadence components with Prometheus annotations, so that Prometheus can scrape them:

$ helm install --set server.metrics.annotations.enabled=true banzaicloud-stable/cadence

Alternatively, you can enable ServiceMonitor when using Prometheus Operator:

$ helm install --set server.metrics.serviceMonitor.enabled=true banzaicloud-stable/cadence

Note that you can enable monitoring for each service separately. See the configuration reference bellow.

Scaling Cadence

Cadence server components (frontend, history, matching, worker) are executed in separate Deployments, so scaling them separately is possible. However you can decide to apply the same replica count to each service (just like in case of resource limits and taint/affinity settings).

See the configuration reference bellow for details.

Recommended setup

The chart is self-contained, meaning it installs everything required for running the application by default. It can install Cassandra (default) or MySQL, but it is recommended that you configure every component and run migrations manually.

See values.prod.yaml for details of a production setup.

See migrations.md for running migrations manually.

Limitations

In order to use the automatic migration feature, you have to manually set credentials for the chosen storage type (if there is any). The default Cassandra store is installed without password, but for MySQL to work you have to set mysql.mysqlPassword manually (if you install a storage engine from within the chart).

The reason behind this limitation is that migrations are executed as helm hooks, which needs the credentials before MySQL is even started.

Port forwarding to Cadence frontend

As of version 0.5.1 of this chart service (frontend, history, matching, worker) pods use the pod IP as bind address.

This is a limitation of how Cadence cluster membership works and is required for scaling Cadence components.

Unfortunately, this change caused kubectl port-forward directly to Cadence pods to stop working.

If you need to port forward to any of the components (eg. to create a domain), you can use a socat sidecar container (for example by installing and configuring the stable/socat-tunneller chart):

helm install stable/socat-tunneller --name cadence-frontend-tunnel --set tunnel.host=cadence-frontend --set tunnel.port=7933 --set nameOverride=cadence-frontend-tunnel

Then you can port-forward to this tunnel:

kubectl port-forward svc/cadence-frontend-tunnel 7933:7933

and create a domain:

docker run --rm ubercadence/cli:master --address host.docker.internal:7933 --domain samples-domain domain register --global_domain false

Metrics

Note: from chart version 0.19.0, the metrics collection services (Prometheus, StatsD) are mutually exclusive - only one of those can be enabled at the same time based on the values configuration. The default configuration enables Prometheus.

If you want to enable StatsD (and disable Prometheus), you may edit the global metrics configuration values accordingly. If you want to use them in a mixed fashion, make sure to disable both in the global metrics configuration values and enable the desired one in the service-specific configuration values (this is required, because global configurations take precedence over service-specific configurations).

Configuration

The following table lists the configurable parameters of the chart and their default values. Global options overridable per service are marked with an asterisk.

ParameterDescriptionDefault
nameOverrideOverride name of the application``
fullnameOverrideOverride full name of the application``
server.image.repositoryServer image repositoryubercadence/server
server.image.tagServer image tag0.24.0
server.image.pullPolicyServer image pull policyIfNotPresent
server.replicaCount*Server replica count1
server.metrics.annotations.enabled*Annotate pods with Prometheus annotationsfalse
server.metrics.serviceMonitor.enabled*Enable Prometheus ServiceMonitorfalse
server.metrics.prometheus.timerType*Prometheus timer typehistogram
server.metrics.statsd.hostPort*Statsd daemon host and port``
server.podAnnotations*Server pod annotations{}
server.podSecurityContext*Server pod security context{}
server.securityContext*Server security context{}
server.resources*Server CPU/Memory resource requests/limits{}
server.nodeSelector*Node labels for pod assignment{}
server.tolerations*Toleration labels for pod assignment[]
server.affinity*Affinity settings for pod assignment{}
server.config.logLevelServer log leveldebug,info
server.config.numHistoryShardsNumber of history shards1000
server.config.persistence.[store].driverConnection drivercassandra
server.config.persistence.[store].cassandraCassandra connection details (see values.yaml){}
server.config.persistence.[store].sqlSQL connection details (see values.yaml){}
server.[service].service.type[service] service typeClusterIP
`server.[service].serv

Deploy cadence with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has cadence 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 chartcadence is pinned at v0.24.2 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