Running YDB in Minikube

  1. Install the Kubernetes CLI kubectl.

  2. Install and run .

  3. Install the Kubernetes Helm 3 package manager.

  4. Clone the repository with .

Installing a cluster

Install the YDB controller in the cluster

Install YDB in the standard configuration:

CLI

Run the command:

Minikube - 图2

  • 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. TEST SUITE: None

Apply the manifest for creating a YDB cluster:

CLI

Run the command:

  1. kubectl apply -f samples/minikube/storage.yaml

Minikube - 图4

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:

  1. kubectl apply -f samples/minikube/database.yaml

Minikube - 图6

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

The database is ready to run.

Test how YDB works:

CLI

  1. Forward port 2135:

    Minikube - 图9

  2. Install the YDB CLI as described in .

  3. 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. └─────────┘

    Minikube - 图11

    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

  1. To delete a YDB database, just delete the Database resource mapped to it:

    1. kubectl delete database.ydb.tech database-minikube-sample

  2. To delete a YDB cluster, run the following commands:

    Minikube - 图13