Kubernetes
GreptimeDB Operator
By utilizing the Operator pattern, GreptimeDB Operator can effectively manage GreptimeDB clusters on Kubernetes. This operator abstracts the model of maintaining a highly available GreptimeDB cluster.
1. Create a test Kubernetes cluster
You can use kind to create your own test Kubernetes cluster:
kind create cluster
2. Use Helm to install GreptimeDB Operator
Make sure you have already installed Helm. Use the following commands to install greptimedb-operator
in the default namespace:
helm repo add greptime https://greptimeteam.github.io/helm-charts/
helm repo update
helm install greptimedb-operator greptime/greptimedb-operator -n default
The maintained Helm charts are in helm-charts.
3. Create your own GreptimeDB cluster
Create an etcd cluster for GreptimeDB:
helm install etcd oci://registry-1.docker.io/bitnamicharts/etcd \
--set replicaCount=3 \
--set auth.rbac.create=false \
--set auth.rbac.token.enabled=false \
-n default
Create a GreptimeDB cluster which uses the etcd cluster created at previous step:
helm install mycluster greptime/greptimedb-cluster -n default
Or, if you already have an etcd cluster, you can use etcdEndpoints
to use your etcd cluster:
helm install mycluster greptime/greptimedb-cluster \
--set etcdEndpoints=<your-etcd-cluster-endpoints> \
-n default
After the installation, you can use kubectl port-forward
to forward the MySQL protocol port of the GreptimeDB cluster:
# You can use the MySQL client to connect the cluster, for example: 'mysql -h 127.0.0.1 -P 4002'.
kubectl port-forward svc/mycluster-frontend 4002:4002 > connections.out &
# You can use the PostgreSQL client to connect the cluster, for example: 'psql -h 127.0.0.1 -p 4003 -d public'.
kubectl port-forward svc/mycluster-frontend 4003:4003 > connections.out &
Then you can use MySQL client to connect to the cluster.
4. Destroy GreptimeDB cluster
You can use the following commands to uninstall operator and cluster:
# Uninstall the cluster.
helm uninstall mycluster -n default
# Uninstall etcd.
helm uninstall etcd -n default
# Uninstall the operator.
helm uninstall greptimedb-operator -n default
# Delete crds.
kubectl delete crds greptimedbclusters.greptime.io