Couchbase Server

Cluster Kubernetes no Google Cloud e Exposição do Serviço Couchbase

12 MIN DE LEITURA

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.

The first part (Couchbase on Kubernetes) explained how to start the Kubernetes cluster using Vagrant. The second part (Kubernetes on Amazon) explained how run that setup on Amazon Web Services.

This third part will show:

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

Here is a quick overview:

Kubernetes Cluster on Google Cloud

Let’s get into details!

Getting Started with Google Compute Engine provide detailed instructions on how to setup Kubernetes on Google Cloud.

Download and Configure Google Cloud SDK

There is a bit of setup required if you’ve never accessed Google Cloud on your machine. This was a bit overwhelming and wish can be simplified.

  • Create a billable account on Google Cloud
  • Instalar Google Cloud SDK
  • Configure credentials: gcloud auth login
  • Create a new Google Cloud project and name it couchbase-on-kubernetes
  • Set the project: gcloud config set project couchbase-on-kubernetes
  • Set default zone: gcloud config set compute/zone us-central1-a
  • Create an instance: gcloud compute instances create example-instance --machine-type n1-standard-1 --image debian-8
  • SSH into the instance: gcloud compute ssh example-instance
  • Delete the instance: gcloud compute instances delete example-instance

Setup Kubernetes Cluster on Google Cloud

Kubernetes cluster can be created on Google Cloud as:

Make sure KUBERNETES_PROVIDER is either set to gce or not set at all. By default, this provisions a 4 node Kubernetes cluster with one master. This means 5 Virtual Machines are created.

If you downloaded Kubernetes from github.com/kubernetes/kubernetes/releases, then all the values can be changed in cluster/aws/config-default.sh.

Starting Kubernetes on Google Cloud shows the following log. Google Cloud SDK was behaving little weird but taking the defaults seem to work:

There are a couple of unbound variables and a WARNING message, but that didn’t seem to break the script. Google Cloud Console shows: Google Cloud Compute Instances On Kubernetes Cluster

Five instances are created as shown – one for master node and four for worker nodes.

Run Docker Container in Kubernetes Cluster on Google Cloud

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

It shows four worker nodes. Create a Couchbase pod:

Notice, how the image name can be specified on the CLI. This command creates a Replication Controller with a single pod. The pod uses arungupta/couchbase Docker image that provides a pre-configured Couchbase server. Any Docker image can be specified here.

Get all the RC resources:

This shows the Replication Controller that is created for you.

Get all the Pods:

The output shows the Pod that is created as part of the Replication Controller.

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 it outside the Kubernetes cluster. The kubectl expose command takes a pod, service or replication controller and expose it as a Kubernetes Service.

Let’s expose the replication controller previously created and expose it:

Get more details about Service:

A Loadbalancer Ingress attribute gives you the IP address of the load balancer that is now publicly accessible. Wait for 3 minutes to let the load balancer settle down. Access it using port 8091 and the login page for Couchbase Web Console shows up: Google Cloud Kubernetes Couchbase Login Page

Enter the credentials as “Administrator” and “password” to see the Web Console: Google Cloud Kubernetes Couchbase Web Console

And so you just accessed your pod outside the Kubernetes cluster.

Shutdown Kubernetes Cluster

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

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.

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.