Creating a Kubernetes Cluster

Below you will find examples of creating a small 3 node Kubernetes cluster to try NATS on multiple clouds.

Google Kubernetes Engine

Use gcloud to create a 3 node regional Kubernetes cluster on us-west2.

  1. # Create a 3 node Kubernetes cluster. One node in each of the region's three zones.
  2. gcloud container clusters create nats-k8s-cluster \
  3. --project $YOUR_GOOGLE_CLOUD_PROJECT \
  4. --region us-west2 \
  5. --num-nodes 1 \
  6. --machine-type n1-standard-2

Note that since this is a regional cluster we are specifying --num-nodes 1 which will create a kubelet on 3 different zones. If you are creating a single-zone cluster but want 3 nodes then you have to specify --num-nodes 3.

Amazon Kubernetes Service

The eksctl is a very helpful tool to manage EKS clusters, you can find more docs on how to set it up here.

  1. # Create 3 node Kubernetes cluster
  2. eksctl create cluster --name nats-k8s-cluster \
  3. --nodes 3 \
  4. --node-type=t3.large \
  5. --region=eu-west-1
  6. # Get the credentials for your cluster
  7. eksctl utils write-kubeconfig --name $YOUR_EKS_NAME --region eu-west-1

Digital Ocean

You can use doctl to create a cluster as follows:

  1. doctl kubernetes cluster create nats-k8s-nyc2 --count 3 --region nyc1

Azure Kubernetes Service

Using az you can create a cluster like this:

  1. # In case not done already, register to use some services:
  2. az login
  3. az provider register -n Microsoft.Network
  4. az provider register -n Microsoft.Storage
  5. az provider register -n Microsoft.Compute
  6. az provider register -n Microsoft.ContainerService
  7. # Create resource group and 3 node cluster
  8. az group create --name nats --location westus
  9. az aks create \
  10. --resource-group nats \
  11. --name nats \
  12. --node-count 3 \
  13. --node-vm-size Standard_DS2_v2 \
  14. --load-balancer-sku basic \
  15. --enable-node-public-ip
  16. az aks get-credentials --resource-group nats --name nats

Eventually your cluster will be provided ExternalIPs that the NATS cluster can advertise to clients:

  1. kubectl get nodes -o wide
  2. NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
  3. aks-nodepool1-18657977-0 Ready agent 5d16h v1.13.12 10.240.0.6 52.191.186.114 Ubuntu 16.04.6 LTS 4.15.0-1060-azure docker://3.0.7
  4. aks-nodepool1-18657977-1 Ready agent 5d17h v1.13.12 10.240.0.4 52.229.11.82 Ubuntu 16.04.6 LTS 4.15.0-1060-azure docker://3.0.7
  5. aks-nodepool1-18657977-2 Ready agent 5d17h v1.13.12 10.240.0.5 13.77.149.235 Ubuntu 16.04.6 LTS 4.15.0-1060-azure docker://3.0.7