Microsoft Azure

AttentionThis page documents an earlier version. Go to the latest (v2.1)version.

Prerequisites

  • Connect to the Azure Cloud Shell. You can connect and get a shell from the browser by navigating to Azure bash cloud shell.

  • Register the necessary Azure service providers by running the following:

  1. az provider register -n Microsoft.Network
  2. az provider register -n Microsoft.Storage
  3. az provider register -n Microsoft.Compute
  4. az provider register -n Microsoft.ContainerService
  • Configure a default location. Remember to replace eastus with an appropriate Azure location (region) of your choice that supports AKS clusters.
  1. $ az configure --defaults location=eastus

1. Create an Azure cluster

  • Create an Azure resource

An Azure resource group is a logical group in which Azure resources are deployed and managed. You need to specify a default location or pass the location parameter to create the resource. The resources we create for the AKS cluster will live in this Azure resouce.

  1. $ az group create --name yb-eastus-resource
  • Create the AKS cluster.

You can create a three node AKS cluster by running the following command.

  1. $ az aks create --resource-group yb-eastus-resource --name yb-aks-cluster --node-count 3 --generate-ssh-keys

Configure kubectl to work with this cluster.

  1. $ az aks get-credentials --resource-group yb-eastus-resource --name yb-aks-cluster

Verify the cluster by running the following command.

  1. $ kubectl get nodes
  1. NAME STATUS ROLES AGE VERSION
  2. aks-nodepool1-25019584-0 Ready agent 4h v1.7.9
  3. aks-nodepool1-25019584-1 Ready agent 4h v1.7.9
  4. aks-nodepool1-25019584-2 Ready agent 4h v1.7.9

2. Create a YugabyteDB cluster

Create a YugabyteDB cluster by running the following.

  1. $ kubectl create -f https://raw.githubusercontent.com/yugabyte/yugabyte-db/master/cloud/kubernetes/yugabyte-statefulset.yaml
  1. service "yb-masters" created
  2. statefulset "yb-master" created
  3. service "yb-tservers" created
  4. statefulset "yb-tserver" created

3. Check the cluster

You should see the following pods running.

  1. $ kubectl get pods
  1. NAME READY STATUS RESTARTS AGE
  2. yb-master-0 1/1 Running 0 3m
  3. yb-master-1 1/1 Running 0 3m
  4. yb-master-2 1/1 Running 0 3m
  5. yb-tserver-0 1/1 Running 0 3m
  6. yb-tserver-1 1/1 Running 0 3m
  7. yb-tserver-2 1/1 Running 0 3m

You can view the persistent volumes.

  1. kubectl get persistentvolumes
  1. NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
  2. pvc-849395f7-36f2-11e8-9445-0a58ac1f27f1 1Gi RWO Delete Bound default/datadir-yb-master-0 default 12m
  3. pvc-8495d8cd-36f2-11e8-9445-0a58ac1f27f1 1Gi RWO Delete Bound default/datadir-yb-master-1 default 12m
  4. pvc-8498b836-36f2-11e8-9445-0a58ac1f27f1 1Gi RWO Delete Bound default/datadir-yb-master-2 default 12m
  5. pvc-84abba1a-36f2-11e8-9445-0a58ac1f27f1 1Gi RWO Delete Bound default/datadir-yb-tserver-0 default 12m
  6. pvc-84af3484-36f2-11e8-9445-0a58ac1f27f1 1Gi RWO Delete Bound default/datadir-yb-tserver-1 default 12m
  7. pvc-84b35d19-36f2-11e8-9445-0a58ac1f27f1 1Gi RWO Delete Bound default/datadir-yb-tserver-2 default 12m

You can view all the services by running the following command.

  1. $ kubectl get services
  1. NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
  2. kubernetes ClusterIP XX.XX.XX.X <none> 443/TCP 23m
  3. yb-masters ClusterIP None <none> 7000/TCP,7100/TCP 17m
  4. yb-tservers ClusterIP None <none> 9000/TCP,9100/TCP,9042/TCP,6379/TCP 14m

4. Connect to the cluster

You can connect to the YCQL API by running the following.

  1. $ kubectl exec -it yb-tserver-0 bin/cqlsh
  1. Connected to local cluster at 127.0.0.1:9042.
  2. [cqlsh 5.0.1 | Cassandra 3.9-SNAPSHOT | CQL spec 3.4.2 | Native protocol v4]
  3. Use HELP for help.
  4. cqlsh> DESCRIBE KEYSPACES;
  5. system_schema system_auth system

5. Destroy the YugabyteDB cluster (optional)

Destroy the YugabyteDB cluster we created above by running the following.

  1. $ kubectl delete -f https://raw.githubusercontent.com/yugabyte/yugabyte-db/master/cloud/kubernetes/yugabyte-statefulset.yaml
  1. service "yb-masters" deleted
  2. statefulset "yb-master" deleted
  3. service "yb-tservers" deleted
  4. statefulset "yb-tserver" deleted

To destroy the persistent volume claims (you will lose all the data if you do this), run:

  1. $ kubectl delete pvc -l app=yb-master
  2. $ kubectl delete pvc -l app=yb-tserver

6. Destroy the AKS cluster (optional)

To destroy the resource we created for the AKS cluster, run the following.

  1. $ az group delete --name yb-eastus-resource

Advanced Kubernetes Deployment

More advanced scenarios for deploying in Kubernetes are covered in the Kubernetes Deployments section.