Getting Started With Distributed SQL on Azure Kubernetes Service
Get the Northwind sample database running on top of distributed SQL and Azure Kubernetes Service, step-by-step
Join the DZone community and get the full member experience.Join For Free
Microsoft’s Azure Kubernetes Service (AKS) offers a highly available, secure, and fully managed Kubernetes service for developers looking to host their applications on containers in the cloud. AKS features elastic provisioning, an integrated developer experience for rapid application development, enterprise security features, and the most available regions of any cloud provider.
YugabyteDB is a natural fit for AKS because it was designed to support cloud native environments since its initial design.
YugabyteDB is an open source, high-performance distributed SQL database built on a scalable and fault-tolerant design inspired by Google Spanner. Yugabyte’s SQL API (YSQL) is PostgreSQL wire compatible.
If your organization is looking to build an application that requires Kubernetes support, geo distributed data, high performance and availability, plus the familiarity of SQL, then YugabyteDB should be in the top on your shortlist of databases to use as a backend.
In this blog post, we’ll show you how easy it is to get started with YugabyteDB on AKS in just a few minutes. As a bonus, we’ll also show you how to deploy the familiar Northwind sample database.
Below is a list of the various components we’ll be installing and configuring for the purposes of this post:
- YugabyteDB version 2.1.4
- Kubectl version 1.18.0
- Helm version 3.1.0
- A Microsoft Azure account with “Pay As You Go” enabled
To get YugabyteDB up and running on an Azure Kubernetes cluster we’ll need to perform the following steps:
- Step 1: Install the Azure CLI
- Step 2: Create a resource group
- Step 3: Create a Kubernetes cluster
- Step 4: Install YugabyteDB
- Bonus: Install the Northwind sample database
Step 1: Install the Azure CLI
Before we create our Kubernetes cluster, let’s first install the Azure CLI on our local machine. To install the Azure CLI on your operating system follow the instructions in the link here.
On Mac, you can install the CLI via Homebrew with:
Once installed, login at the command line with:
…or open up a browser page at https://aka.ms/devicelogin and enter the authorization code displayed in your terminal. You should now be able to access the Azure Portal UI by going to https://portal.azure.com/..
Step 2: Create a Resource Group
To create a resource group, we’ll need to first choose the location where it will be hosted. Run the following command to retrieve a list of the available locations:
For the purposes of this demo we are going to choose the “West US” location.
Next, create the resource group by running the following command using whatever location you decided on:
You should now be able to view the “yugabytedbRG” resource group in the Azure Portal by clicking on Resource Groups.
Step 3: Create the Kubernetes Cluster
We can now create our Kubernetes cluster by running the following command. Note that we have not specified any zones in the command below which means the AKS control plane components for the cluster will essentially be deployed in a single zone.
--generate-ssh-keys argument auto-generates SSH public and private key files that will be stored in the
You should see the following output:
We should now see ”yugabytedbAKSCluster” in the UI.
To create the cluster and use your own ssh keys, run the following command:
Follow the prompts to create the
id_rsa.pub files and note the location where they are stored. Now, execute:
Once the cluster is installed, point
kubectl to the cluster by running the following command:
You should see output similar to:
If you generated your own ssh-keys, point
kubectl to the cluster by running the following command instead:
Verify that the cluster nodes are running using the following command:
You should see output similar to:
You can also view the details of the cluster in the Kubernetes Dashboard by running the following commands:
Running the command above will open a browser window where you can view the Kubernetes dashboard:
Step 4: Install YugabyteDB Using Helm Chart
Now that we have our Kubernetes cluster up and running, we’ll need to perform the following steps to get YugabyteDB deployed:
- Add the YugabyteDB Helm repo
- Create a namespace
- Install YugabyteDB using Helm
Let’s first add the YugabyteDB repo by running the following commands:
Create the yb-demo namespace.
Next, we’ll install YugabyteDB in the yb-demo namespace by executing the following commands to specify settings for resource constrained environments.
Depending on your resources, it may take some time to get everything installed, deployed, and configured. Once the command prompt returns with success, let’s verify that the YugabyteDB pods are running using the following command:
To access the Yugabyte Admin UI run the following command to locate the External IP entry associated with yb-master-ui and port 7000.
Now, go to
http://EXTERNAL_IP:7000. Replace EXTERNAL_IP with your own. You should see the following:
Bonus: Installing the Northwind Sample Database
If you’d like to install a sample database and you are coming from the Microsoft or SQL Server world, the Northwind database is a familiar one to install and get started with.
The following files that will be used to create and populate the example tables are already present on the YugabyteDB pods:
- Northwind_ddl: Contains DDL statements to create tables and other database objects.
- Northwind_data: Contains DML statements to load the sample data.
Connect to the YSQL shell by running the following commands:
Create the Northwind database and the tables by running the following commands from within the YSQL shell:
We can do a simple verification that the data has been inserted into the tables by running the following command:
That’s it, you now have YugabyteDB and the Northwind sample database running on an Azure Kubernetes cluster! At this point, you are ready to start exploring YSQL’s capabilities. We recommend starting with the YSQL docs and then reading up on the YugabyteDB’s architecture and design goals.
Published at DZone with permission of Jimmy Guerrero. See the original article here.
Opinions expressed by DZone contributors are their own.