cube

by lvauvillier

Helm chartv4.0.0App 1.8.16

A Helm chart for Cube

About this chart

Cube Chart

Table of Contents

  • Get Started
    • Install Chart
    • Uninstall Chart
    • Upgrading Chart
  • Configuration
    • Injecting schema
    • Injecting javascript config
    • Fix duplicate schemas issue
    • Examples
  • Reference
    • Global parameters
    • Image parameters
    • Config parameters
    • JWT parameters
    • Datasources configuration
      • Common parameters
      • Athena parameters
      • Bigquery parameters
      • Databricks parameters
      • DuckDB parameters
      • ClickHouse parameters
      • Firebolt parameters
      • Hive parameters
      • Materialize parameters
      • Presto parameters
      • Snowflake parameters
      • Trino parameters
      • ksqlDB parameters
      • MSSQL parameters
      • MySQL parameters
      • Pinot parameters
      • Redshift parameters
    • Api instance parameters
    • Refresh worker parameters
    • Ingress parameters

Get Started

helm repo add gadsme https://gadsme.github.io/charts
helm repo update

See helm repo for command documentation.

Install Chart

helm install [RELEASE_NAME] gadsme/cube --set [CONFIGURATION]

The command deploys Cube on the Kubernetes cluster using the default configuration.

See configuration below.

See helm install for command documentation.

Uninstall Chart

helm uninstall [RELEASE_NAME]

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

See helm uninstall for command documentation.

Upgrading Chart

helm upgrade [RELEASE_NAME] gadsme/cube --install

Configuration

By default an api instance and one worker will be deployed. You can customize the deployment using helm values.

Refer to the official documentation for more information: https://cube.dev/docs/reference/environment-variables

Injecting schema

To inject your schema files in the deployment you have to use config.volumes and config.volumeMounts values.

Mount path is /cube/conf/schema by default and can be customized with the config.schemaPath value.

A good practice is to use a ConfigMap to store your all the cube definition files:

apiVersion: v1
kind: ConfigMap
metadata:
  name: cube-schema
data:
  Cube1.js: |
    cube(`Cube1`, {
      sql: `SELECT * FROM cube1_data`,

      measures: {
        count: {
          type: `count`,
        },
      },
    });
  Cube2.js: |
    cube(`Cube2`, {
      sql: `SELECT * FROM cube2_data`,

      measures: {
        count: {
          type: `count`,
        },
      },
    });

or using a template:

apiVersion: v1
kind: ConfigMap
metadata:
  name: cube-schema
data:
{{ (.Files.Glob "schema/**.js").AsConfig | indent 2 }}

Injecting javascript config

To inject a javascript config in the deployment you can use config.volumes and config.volumeMounts values.

Mount path is /cube/conf/

Fix duplicate schemas issue

When you mount a secret or configmap as volume, the path at which Kubernetes will mount it will contain the root level items symlinking the same names into a ..data directory, which is symlink to real mountpoint.

As cube will recursively browse the schema folder, it will found duplicate schemas.

To fix this issue you can mount each schema files using a subPath or change the default behavior using your own repositoryFactory:

const path = require("path");
const fs = require("fs");

module.exports = {
  repositoryFactory: () => ({
    dataSchemaFiles: async () => {
      const files = await fs.promises.readdir(
        path.join(process.cwd(), "schema")
      );
      return await Promise.all(
        files
          .filter((file) => file.endsWith(".js") || file.endsWith(".yaml"))
          .map(async (file) => ({
            fileName: file,
            content: await fs.promises.readFile(
              path.join(process.cwd(), "schema", file),
              "utf-8"
            ),
          }))
      );
    },
  }),
};

Examples

Deployment with:

  • BigQuery db with export Bucket on GCS
  • Schema located in a cube-schema ConfigMap
  • Cubestore
$ helm install my-release -f values.yaml gadsme/cube
# values.yaml
config:
  volumes:
    - name: schema
      configMap:
        name: cube-schema
  volumeMounts:
    - name: schema
      readOnly: true
      mountPath: /cube/conf/schema

datasources:
  default:
    type: bigquery
    export:
      type: gcp
      name: <bucket-name>
      gcsCredentialsFromSecret:
    name: <service-account-secret-name>
    key: <service-account-secret-key>
    bigquery:
      projectId: <project-id>
      credentialsFromSecret:
        name: <service-account-secret-name>
        key: <service-account-secret-key>

cubestore:
  host: <cubestore-host>

Multiple datasources sample:

# values.yaml
config:
  volumes:
    - name: schema
      configMap:
        name: cube-schema
  volumeMounts:
    - name: schema
      readOnly: true
      mountPath: /cube/conf/schema

datasources:
  default:
    type: bigquery
    export:
      type: gcp
      name: <bucket-name>
      gcsCredentialsFromSecret:
    name: <service-account-secret-name>
    key: <service-account-secret-key>
    bigquery:
      projectId: <project-id>
      credentialsFromSecret:
        name: <service-account-secret-name>
        key: <service-account-secret-key>
  postgres:
    type: postgres
    host: <postgres-host>
    name: <postgres-database>
    user: <postgres-user>
    passFromSecret:
      name: <postgres-password-secret-name>
      key: <postgres-password-secret-key>

cubestore:
  host: <cubestore-host>

Reference

Global parameters

NameDescriptionValue
nameOverrideOverride the name""
fullnameOverrideProvide a name to substitute for the full names of resources""
commonLabelsLabels to add to all deployed objects{}
commonAnnotationsAnnotations to add to all deployed objects{}
extraEnvVarsExtra environment variables to pass on to all pods. The value is evaluated as a template[]
extraEnvVarsFromConfigMapName of a Config Map containing extra environment variables to pass on to all pods
extraEnvVarsFromSecretName of a Secret containing extra environment variables to pass on to all pods

Image parameters

NameDescriptionValue
image.repositoryCube image repositorycubejs/cube
image.tagCube image tag (immutable tags are recommended)1.2.0
image.pullPolicyCube image pull policyIfNotPresent
image.pullSecretsIf defined, uses a Secret to pull an image from a private Docker registry or repository[]

Config parameters

NameDescriptionValue
config.apiPortThe port for a Cube deployment to listen to API connections on4000
config.pgSqlPortThe port to listen to Postgres-compatible connections on
config.sqlSuperUserThe superuser name to access the SQL api
config.sqlUserThe username to access the SQL api
config.sqlPasswordThe password to access the SQL api
config.sqlPasswordFromSecret.nameThe password to access the SQL api (using secret)
config.sqlPasswordFromSecret.keyThe password to access the SQL api (using secret)
config.devModeIf true, enables development modefalse
config.debugIf true, enables debug loggingfalse
config.logLevelThe logging level for Cubewarn
config.telemetryIf true, then send telemetry to Cubefalse
config.apiSecretThe secret key used to sign and verify JWTs. Generated on project scaffold
config.apiSecretFromSecret.nameThe secret key used to sign and verify JWTs. Generated on project scaffold (using secret)
config.apiSecretFromSecret.keyThe secret key used to sign and verify JWTs. Generated on project scaffold (using secret)
config.defaultApiScopesAPI scopes used to allow or disallow access to REST API endpoints.
config.Values.config.playgroundAuthSecretThe secret key used to enable system APIs
config.Values.config.playgroundAuthSecretFromSecret.nameThe secret key used to enable system APIs (using secret)
config.Values.config.playgroundAuthSecretFromSecret.keyThe secret key used to enable system APIs (using secret)
config.schemaPathThe path where Cube loads schemas from. Defaults to schema
config.appAn application ID used to uniquely identify the Cube deployment. Can be different for multitenant setups. Defaults to cubejs
config.rollupOnlyIf true, this instance of Cube will only query rollup pre-aggregations. Defaults to false
config.scheduledRefreshTimezonesA comma-separated list of timezones to schedule refreshes for
config.scheduledRefreshQueriesPerAppId

Deploy cube with OpenTenant

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