Couchbase Server

Kubernetes Cluster on Azure and Expose Couchbase Service

Kubernetes Logo

This blog is part of a multi-part blog series that shows how to run your applications on Kubernetes. It will use the Couchbase, an open source NoSQL distributed document database, as the  Docker
container.

This fourth part will show:

  • How to setup and start the Kubernetes cluster on Azure
  • Run Docker container in the Kubernetes cluster
  • Expose Pod on Kubernetes as Service
  • Shutdown the cluster

azure-kubernetes-couchbase-cluster

Many thanks to @colemickens  for helping me through this recipe.

Install and Configure Azure CLI

Azure CLI is a command-line interface to develop, deploy and manage Azure applications. This is needed in order to install Kubernetes cluster on Azure.

  1. Install Node:

  2. Install Azure CLI:

  3. Sign up for free trial at https://azure.microsoft.com/en-us/free/.
  4. Login to Azure using the command azure login:

  5. Get account information using azure account show command:

    Note the value shown instead of XXX and YYY. These will be used to configure the Kubernetes cluster.

Start Kubernetes Cluster

  1. Download Kubernetes 1.2.4 and extract it.
  2. Kubernetes cluster on Azure can be started as:

    Make sure to specify the appropriate values for XXX e YYY from the previous command. AZURE_SUBSCRIPTION_ID e AZURE_TENANT_ID are specific to Azure. These values
    can also be edited in cluster/azure/config-default.sh.

  3. Start Kubernetes cluster:

    It starts four nodes of Standard_A1 size. Each
    node gives you 1 core, 1.75 GB RAM, and 40GB HDD.

Run Docker Container in Kubernetes Cluster on Azure

Now that the cluster is up and running, get a list of all the nodes:

Four instances are created as shown – one for master node and three for worker nodes. Azure Portal shows all the created artifacts in the Resource Group:
 azure-portal-kubernetes-resource-group-1024x578

More details about the created nodes is available:

 azure-portal-kubernetes-resource-group-1024x578

Create a Couchbase pod:

Notice, how the image name can be specified on the CLI. Kubernetes pre-1.2 versions created a Replication Controller with this command. This is explained in  Kubernetes on Amazon Web Services ou Kubernetes on Google Cloud. Kubernetes 1.2 introduced Deployments e
so this creates a Deployment instead. This enables simplified application deployment and management including versioning, multiple simultaneous rollouts, aggregating status across all pods, maintaining application availability and rollback.

The pod uses arungupta/couchbase Docker image that provides a pre-configured Couchbase server. Any Docker image can be specified here. Status of the pod can be watched:

Get more details about the pod:

Expose Pod on Kubernetes as Service

Now that our pod is running, how do I access the Couchbase server? You need to expose the Deployment as a Service outside the Kubernetes cluster. Typically, this will be exposed using the command:

0

But Azure does not support --type=LoadBalancer at this time. This feature is being worked upon and will hopefully be available in the near future. So in the meanwhile, we’ll expose the Service as:

1

Now proxy to this Service using kubectl proxy command:

2

And now this exposed Service is accessible at https://127.0.0.1:9999/api/v1/proxy/namespaces/default/services/couchbase/index.html. This shows the login
screen of Console da Web do Couchbase:
azure-kubernetes-couchbase-web-console

Shutdown Kubernetes Cluster

Finally, shutdown the cluster using cluster/kube-down.sh script.

3

This script shuts down the cluster but the Azure resource group need to be explicitly removed. This can be done by selecting the Resource Group from portal.azure.com:
 azure-portal-kubernetes-delete-resource-group

This is filed as #26601.

Further references …

Enjoy!

Compartilhe este artigo

Autor

Arun Gupta é o vice-presidente de defesa de desenvolvedores (developer advocacy) na Couchbase. Ele construiu e liderou comunidades de desenvolvedores por mais de 10 anos na Sun, Oracle e Red Hat. Ele possui vasta experiência na liderança de equipes multifuncionais para desenvolver e executar estratégias, planejamento e execução de conteúdos, campanhas de marketing e programas. Antes disso, ele liderou equipes de engenharia na Sun e é um membro fundador da equipe do Java EE. Gupta é autor de mais de 2.000 posts em blogs sobre tecnologia. Ele tem ampla experiência em palestras em mais de 40 países sobre uma miríade de tópicos e é um JavaOne Rock Star por três anos consecutivos. Gupta também fundou o capítulo do Devoxx4Kids nos EUA e continua a promover a educação tecnológica entre crianças. Autor de vários livros sobre tecnologia, um corredor ávido, um viajante do mundo, um Java Champion, líder de JUG, membro do NetBeans Dream Team e um Docker Captain, ele é facilmente acessível em @arungupta.

Uma resposta

  1. Avatar de wilsondy
    wilsondy

    I made good progress on trying this but hit a problem at the very end. I can manually hit the pools endpoint on the proxied connection and authenticate, but the web ui isn’t trying to use the proxied URL and is instead just trying 127.0.0.1:9999/pools (instead of the full proxied url). Did I miss a step? As an aside, I was able to use the –type=LoadBalancer which is now apparently available.

Deixe um comentário

Pronto para começar com o Couchbase Capella?

Começar a construir

Confira nosso portal para desenvolvedores para explorar o NoSQL, navegar por recursos e começar com tutoriais.

Use o Capella free

Coloque a mão na massa com o Couchbase em apenas alguns cliques. O Capella DBaaS é a maneira mais fácil e rápida de começar.

Entre em contato

Quer saber mais sobre as ofertas do Couchbase? Deixe-nos ajudar.