DEV Community

Franck Pachot for YugabyteDB

Posted on • Updated on

"I want to try it" 🚀 YugabyteDB at KubeCon

As a Developer Advocate, staying at the Yugabyte booth at KubeCon Europe 2022 was fun with great discussions around distributed SQL databases with awesome people. And so many "I want to try it" reactions! The simplest is a docker container on your laptop:

docker network create -d bridge yb

docker run -d --name yb0 --hostname yb0 --net=yb -p5433:5433 -p7000:7000 yugabytedb/yugabyte:latest yugabyted start --daemon=false --listen yb0.yb --tserver_flags="ysql_enable_auth=false"

Enter fullscreen mode Exit fullscreen mode

That's all. It may take a few minutes to download the image if not already done. yugabyted creates and starts the cluster. You can connect to it with whatever you use for PostgreSQL - tools, applications, frameworks... you use the same drivers, and you get the same behavior. Why not a simple:

docker exec -it yb0 bash -c "PGPASSWORD=yugabyte ysqlsh -P pager=off -h yb0 -p 5433 -U yugabyte yugabyte"

Enter fullscreen mode Exit fullscreen mode

This starts ysqlsh in the container. It is the same as psql: you quit it with \q. You can also connect any PostgreSQL application to your localhost port 5433.

From this command line, you create your users, your database, your schema... just as you do in PostgreSQL. This is sufficient to test postgres compatibility. If you find something not compatible, please check GitHub issues or open one. YSQL is the name of the PostgreSQL API which re-uses the postgres code for the best compatibility.

With this container, you have the features of PostgreSQL, but with a different storage layer: no vacuum issues, no bloat, no XID wraparound... But you want more, right?

You want to scale-out:

docker run -d --name yb1 --hostname yb1 --net=yb -p5434:5433 yugabytedb/yugabyte:latest yugabyted start --daemon=false --listen yb1.yb --tserver_flags="ysql_enable_auth=false" --join yb0 

docker run -d --name yb2 --hostname yb2 --net=yb -p5435:5433 yugabytedb/yugabyte:latest yugabyted start --daemon=false --listen yb2.yb --tserver_flags="ysql_enable_auth=false" --join yb0

Enter fullscreen mode Exit fullscreen mode

With those two additional containers joining the cluster, you can play with high availability. The data you have created is balanced and replicated over the three nodes. And you can connect to any node. To scale connections, data processing and storage, just add more nodes.

You have exposed port 7000 on the first container so you can check the control plane in http://localhost:7000 - see your cluster status, the tablet server nodes, the tables split into tablets... and claim your free T-Shirt 👕 to match with the sunglasses you got in KubeCon Valencia !

Now that you know how to scale out, just with the --join option of yugabyted, you can build your docker-compose file. For example, to replace PostgreSQL in a Docker Compose used for tests, I use the same variables as the PostgreSQL image - example here. And yugabyted is convenient for quick start, but you can have more control by starting all components like I do when I demo high availability and elasticity:

To claim your free T-Shirt, you joined our Slack. Please say hello in #introduction channel and if we've met at KubeCon or elsewhere please mention it. We had great discussions at the booth. Our dream team was so happy to be there and meet you

When you are done, you can remove the docker containers with:

docker container rm -f yb0
docker container rm -f yb1
docker container rm -f yb2
docker network rm yb
Enter fullscreen mode Exit fullscreen mode

Top comments (0)