Open source Kubernetes
Rook is an open source, cloud-native storage orchestrator for Kubernetes, providing the platform, framework, and support that can turn YugabyteDB clusters into self-managing, self-scaling, and self-healing storage services. Rook automates storage-layer tasks, including deployment, bootstrapping, configuration, provisioning, scaling, upgrading, migration, disaster recovery, monitoring, and resource management.
The Rook YugabyteDB operator is a custom controller that uses Custom Resource Definition (CRD) to extend the Kubernetes API and automate deploying, scaling, and managing YugabyteDB clusters. Based on the desired state that you specified in the CRD, the Rook operator observes (watching for changes in state and health), analyzes (comparing current to desired state), and acts (applying changes to the cluster) to maintain the desired state. For details, see YugabyteDB Cluster CRD .
Before you begin
Verify that your Kubernetes cluster is ready for Rook by reviewing the Kubernetes cluster prerequisites for using the Rook operator .
Rook must be installed — see the Rook GitHub Repository . You can install Rook by running the following command:
git clone [email protected]:rook/rook.git
Deploy the Rook YugabyteDB operator
To deploy the YugabyteDB operator:
Change your directory to the Rook directory containing the YugabyteDB example files.
Create the Rook YugabyteDB operator by running the following command:
kubectl create -f operator.yaml
Observe the Rook operator by running the following command:
kubectl -n rook-yugabytedb-system get pods
Create the YugabyteDB Cluster CRD
When using the Rook YugabyteDB operator, your YugabyteDB clusters are controlled using the custom resource object (
ybclusters.yugabytedb.rook.io). The Custom Resource Definition (CRD), used to create this object, is specified in the
A sample Custom Resource Definition (CRD) file, called
cluster.yaml, is located in the following Rook directory:
Make a copy of the sample CRD file (
cluster.yaml) and modify it as needed. For details on the configuration options, see YugabyteDB CRD .
Create a simple YugabyteDB cluster
Create your YugabyteDB cluster by running the following command:
kubectl create -f cluster.yaml
Verify that the custom resource object was created by using the following command:
kubectl -n rook-yugabytedb get ybclusters.yugabytedb.rook.io
Verify that the number of YB-Master and YB- TServer services that are running match the number you specified in the
cluster.yamlfile by running the following command:
kubectl -n rook-yugabytedb get pods
When all of the pods in YugabyteDB cluster are running, you can use the YSQL shell to access the YSQL API, which is PostgreSQL-compliant.
kubectl exec -it yb-tserver-rook-yugabytedb-0 -- /home/yugabyte/bin/ysqlsh -h yb-tserver-rook-yugabytedb-0 --echo-queries
For details on the YSQL API, see:
Run the commands below to clean up all resources created above.
NOTE: This will destroy your database and delete all of its data.
kubectl delete -f cluster.yaml kubectl delete -f operator.yaml
Manually delete any Persistent Volumes that were created for this YugabyteDB cluster.
Review the operator logs
If the cluster does not start, run following command to take a look at operator logs.
kubectl -n rook-yugabytedb-system logs -l app=rook-yugabytedb-operator
Review the YugabyteDB logs
If everything is OK in the operator logs, check the YugabyteDB logs for YB-Master and YB-TServer.
kubectl -n rook-yugabytedb logs -l app=yb-master-rook-yugabytedb kubectl -n rook-yugabytedb logs -l app=yb-tserver-rook-yugabytedb