Running YDB in Minikube
- Before you start
- Install the YDB controller in the cluster
- Create a YDB cluster
- Create a database
- Test the controller
- Release the resources you don’t use
To create a YDB cluster using Minikube, follow these steps.
Before you start
- Install the Kubernetes CLI kubectl.
- Install and run Minikube.
- Install the Kubernetes Helm 3 package manager.
- Clone the repository with ydb-kubernetes-operator.
1. git clone https://github.com/ydb-platform/ydb-kubernetes-operator && cd ydb-kubernetes-operator

Installing a cluster
Install the YDB controller in the cluster
Install YDB in the standard configuration:
CLI
Run the command:
1. helm upgrade --install ydb-operator deploy/ydb-operator --set metrics.enabled=false

ydb-operator: The release name.ydb/operator: The name of the chart in the repository you added earlier.
Output:
1. Release "ydb-operator" does not exist. Installing it now.
2. NAME: ydb-operator
3. LAST DEPLOYED: Tue Mar 22 08:54:08 2022
4. NAMESPACE: default
5. STATUS: deployed
6. REVISION: 1
7. TEST SUITE: None

Create a YDB cluster
Apply the manifest for creating a YDB cluster:
CLI
Run the command:
1. kubectl apply -f samples/minikube/storage.yaml

This command creates a StatefulSet object that describes a set of containers with stable network IDs and disks assigned to them, as well as Service and ConfigMap objects that are required for the cluster to work.
You can check the progress of YDB cluster creation using the following commands:
1. kubectl get storages.ydb.tech
2. kubectl describe storages.ydb.tech

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:
1. 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:
1. kubectl describe database.ydb.tech
3. Name: database-sample
4. Namespace: default
5. Labels: <none>
6. Annotations: <none>
7. API Version: ydb.tech/v1alpha1
8. Kind: Database
9. ...
10. Status:
11. ...
12. State: Ready
13. Events:
14. Type Reason Age From Message
15. ---- ------ ---- ---- -------
16. Normal Provisioning 6m32s ydb-operator Resource: *v1.ConfigMap, Namespace: default, Name: database-minikube-sample, changed, result: created
17. Normal Provisioning 6m32s ydb-operator Resource: *v1.Service, Namespace: default, Name: database-minikube-sample-grpc, changed, result: created
18. Normal Provisioning 6m32s ydb-operator Resource: *v1.Service, Namespace: default, Name: database-minikube-sample-interconnect, changed, result: created
19. Normal Provisioning 6m32s ydb-operator Resource: *v1.Service, Namespace: default, Name: database-minikube-sample-status, changed, result: created
20. Normal Provisioning 6m32s ydb-operator Resource: *v1.StatefulSet, Namespace: default, Name: database-minikube-sample, changed, result: created
21. Normal Initialized 6m31s ydb-operator Tenant /Root/database-minikube-sample created
22. Normal ResourcesReady 6m30s ydb-operator Resource are ready and DB is initialized

The database is ready to run.
Test the controller
Test how YDB works:
CLI
- Check that all nodes are in the
Readystatus:
1. kubectl get pods
2. NAME READY STATUS RESTARTS AGE
3. database-minikube-sample-0 1/1 Running 0 9m33s
4. storage-minikube-sample-0 1/1 Running 0 11m
5. ydb-operator-6fc76b5b68-q269l 1/1 Running 0 12m
2. Forward port 2135:
1. kubectl port-forward database-minikube-sample-0 2135
3. Install the YDB CLI as described in Installing the YDB CLI.
4. Query the YDB database:
1. ydb \
2. --endpoint grpc://localhost:2135 \
3. --database /Root/database-minikube-sample \
4. table query execute --query 'select 1;'

--endpoint: Database endpoint.--database: The name of the created database.--query: Query text.
Output:
1. ┌─────────┐
2. | column0 |
3. ├─────────┤
4. | 1 |
5. └─────────┘

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
Databaseresource mapped to it:
1. kubectl delete database.ydb.tech database-minikube-sample
2. To delete a YDB cluster, run the following commands:
1. kubectl delete storage.ydb.tech storage-minikube-sample
3. To remove the YDB controller from the Kubernetes cluster, delete the release created by Helm:
1. helm delete ydb-operator

ydb-operator: The name of the release that the controller was installed under.
