Running YDB in Minikube
Install the Kubernetes CLI kubectl.
Install and run .
Install the Kubernetes Helm 3 package manager.
Clone the repository with .
Installing a cluster
Install the YDB controller in the cluster
Install YDB in the standard configuration:
CLI
Run the command:
ydb-operator
: The release name.ydb/operator
: The name of the chart in the repository you added earlier.
Output:
Release "ydb-operator" does not exist. Installing it now.
NAME: ydb-operator
LAST DEPLOYED: Tue Mar 22 08:54:08 2022
NAMESPACE: default
STATUS: deployed
TEST SUITE: None
Apply the manifest for creating a YDB cluster:
CLI
Run the command:
kubectl apply -f samples/minikube/storage.yaml
You can check the progress of YDB cluster creation using the following commands:
Wait until the status of the Storage resource changes to Ready
.
Warning
The cluster configuration is static. The controller won’t process any changes when the manifest is reapplied. You can only update cluster parameters such as version or disk size by creating a new cluster.
Create a database
Apply the manifest for creating a database:
CLI
Run the command:
kubectl apply -f samples/minikube/database.yaml
After processing the manifest, a StatefulSet object that describes a set of dynamic nodes is created. The created database will be accessible from inside the Kubernetes cluster by the database-minikube-sample
DNS name. The database is connected to through port 2135
.
View the status of the created resource:
kubectl describe database.ydb.tech
Name: database-sample
Namespace: default
Annotations: <none>
API Version: ydb.tech/v1alpha1
Kind: Database
...
Status:
...
State: Ready
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Provisioning 6m32s ydb-operator Resource: *v1.ConfigMap, Namespace: default, Name: database-minikube-sample, changed, result: created
Normal Provisioning 6m32s ydb-operator Resource: *v1.Service, Namespace: default, Name: database-minikube-sample-grpc, changed, result: created
Normal Provisioning 6m32s ydb-operator Resource: *v1.Service, Namespace: default, Name: database-minikube-sample-interconnect, changed, result: created
Normal Provisioning 6m32s ydb-operator Resource: *v1.Service, Namespace: default, Name: database-minikube-sample-status, changed, result: created
Normal Provisioning 6m32s ydb-operator Resource: *v1.StatefulSet, Namespace: default, Name: database-minikube-sample, changed, result: created
Normal Initialized 6m31s ydb-operator Tenant /Root/database-minikube-sample created
Normal ResourcesReady 6m30s ydb-operator Resource are ready and DB is initialized
The database is ready to run.
Test how YDB works:
CLI
Forward port 2135:
Install the YDB CLI as described in .
Query the YDB database:
ydb \
--endpoint grpc://localhost:2135 \
--database /Root/database-minikube-sample \
table query execute --query 'select 1;'
--endpoint
: Database endpoint.--database
: The name of the created database.--query
: Query text.
Output:
┌─────────┐
| column0 |
├─────────┤
| 1 |
└─────────┘
For more on YDB CLI commands, see the documentation.
Release the resources you don’t use
If you no longer need the created resources, delete them:
CLI
To delete a YDB database, just delete the
Database
resource mapped to it:kubectl delete database.ydb.tech database-minikube-sample
To delete a YDB cluster, run the following commands:
-