Deploy GreptimeDB Cluster

Before the deployment, make sure you have already installed GreptimeDB Operator on your Kubernetes cluster.

Using Helm for deployment

Create an etcd cluster

First, establish an etcd cluster to support GreptimeDB by executing the following command:

  1. helm install etcd oci://registry-1.docker.io/bitnamicharts/etcd \
  2. --set replicaCount=3 \
  3. --set auth.rbac.create=false \
  4. --set auth.rbac.token.enabled=false \
  5. --create-namespace \
  6. -n etcd

After the installation, you can get the etcd cluster endpoints etcd.etcd.svc.cluster.local:2379 from the installation logs. The endpoints are required for deploying the GreptimeDB cluster in the subsequent step.

Create a GretpimeDB cluster

Deploy the GreptimeDB cluster, ensuring it connects to the previously established etcd cluster:

  1. helm install greptimedb greptime/greptimedb-cluster \
  2. --set meta.etcdEndpoints=etcd.etcd.svc.cluster.local:2379 \
  3. --create-namespace \
  4. -n greptimedb-cluster

Setting Resource requests and limits

The GreptimeDB Helm charts enable you to specify resource requests and limits for each component within your deployment.

Here’s how you can configure these settings:

  1. helm install greptimedb greptime/greptimedb-cluster \
  2. --set meta.etcdEndpoints=etcd.etcd.svc.cluster.local:2379 \
  3. --set meta.podTemplate.main.resources.requests.cpu=<cpu-resource> \
  4. --set meta.podTemplate.main.resources.requests.memory=<mem-resource> \
  5. --set datanode.podTemplate.main.resources.requests.cpu=<cpu-resource> \
  6. --set datanode.podTemplate.main.resources.requests.memory=<mem-resource> \
  7. --set frontend.podTemplate.main.resources.requests.cpu=<cpu-resource> \
  8. --set frontend.podTemplate.main.resources.requests.memory=<mem-resource> \
  9. --create-namespace \
  10. -n greptimedb-cluster

For a comprehensive list of configurable values via Helm, please refer to the value configuration.

Using kubectl for deployment

Alternatively, you can manually create a GreptimeDB cluster using kubectl. Start by creating a configuration file named greptimedb-cluster.yaml with the following content:

  1. apiVersion: greptime.io/v1alpha1
  2. kind: GreptimeDBCluster
  3. metadata:
  4. name: greptimedb
  5. namespace: greptimedb-cluster
  6. spec:
  7. base:
  8. main:
  9. image: greptime/greptimedb
  10. frontend:
  11. replicas: 1
  12. meta:
  13. replicas: 1
  14. etcdEndpoints:
  15. - "etcd.etcd.svc.cluster.local:2379"
  16. datanode:
  17. replicas: 3

Apply this configuration to instantiate the GreptimeDB cluster:

  1. kubectl apply -f greptimedb-cluster.yaml

Connect to the cluster

After the installation, you can use kubectl port-forward to forward the MySQL protocol port of the GreptimeDB cluster:

  1. # You can use the MySQL client to connect the cluster, for example: 'mysql -h 127.0.0.1 -P 4002'.
  2. kubectl port-forward svc/greptimedb-frontend 4002:4002 -n greptimedb-cluster > connections.out &
  3. # You can use the PostgreSQL client to connect the cluster, for example: 'psql -h 127.0.0.1 -p 4003 -d public'.
  4. kubectl port-forward svc/greptimedb-frontend 4003:4003 -n greptimedb-cluster > connections.out &

Then you can use the MySQL client to connect to the cluster.