Este blog faz parte de uma série de blogs com várias partes que mostra como executar seus aplicativos no Kubernetes. Ele usará o Couchbase, an open source NoSQL distributed document database, as the  Docker
container.

A primeira parte (Couchbase no Kubernetes) explained how to start the Kubernetes cluster using Vagrant. That is a simple and easy way to develop, test, and deploy
Kubernetes cluster on your local machine. But this could be of limited use rather soon as the resources are constrained by the local machine. So what do you do?

Kubernetes cluster can be installed on Amazon as well. This second part will show:

  • How to setup and start the Kubernetes cluster on Amazon Web Services
  • Execute o contêiner do Docker no cluster do Kubernetes
  • Expor o pod no Kubernetes como serviço
  • Desligar o cluster

Aqui está uma visão geral rápida:

Kubernetes Cluster on Amazon with Couchbase

Let’s dig into the details!

Setup Kubernetes Cluster on Amazon Web Services

Getting Started on AWS EC2 provide complete instructions to start Kubernetes cluster on Amazon. Make sure to have the pre-requisites (AWS account, AWS CLI, Full EC2 access)
met before you follow these instructions. Kubernetes cluster can be created on Amazon as:

By default, this provisions a new VPC and a 4 node Kubernetes cluster in us-west-2a (Oregon) with t2.micro instances running on Ubuntu. This means 5 AMIs (one for master and 4 for the worker nodes) are created. Some
properties that are worth updating:

  • Conjunto NUM_MINIONS environment variable to whatever number of nodes are required in the cluster. Set it to 2 if you want only two worker nodes to be created.
  • Each instance size is 1.1.x is t2.micro. Set MASTER_SIZE e MINION_SIZE environment variables to m3.medium otherwise the nodes are going to crawl.

Se você baixou o Kubernetes de github.com/kubernetes/kubernetes/releasestodos os valores podem ser alterados em cluster/aws/config-default.sh. Starting Kubernetes on
Amazon shows the following log:

Amazon Console shows:

Kubernetes Cluster on Amazon

Three instances are created as shown – one for master node and two for worker nodes. Username and password for the Kubernetes master are stored in /Users/arungupta/.kube/config. Look for a section like:

Run Docker container in Kubernetes Cluster on Amazon

Agora que o cluster está em funcionamento, obtenha uma lista de todos os nós:

It shows two worker nodes. Create a new Couchbase pod:

Observe como o nome da imagem pode ser especificado na CLI. Esse comando cria um controlador de replicação com um único pod. O pod usa arungupta/couchbase Imagem do Docker
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

Agora que nosso pod está em execução, como posso acessar o servidor Couchbase? Você precisa expô-lo fora do cluster do Kubernetes. O 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 the Service:

O Loadbalancer attribute Ingress gives you the 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:
Kubernetes on Amazon - Couchbase Login Page

Digite as credenciais como "Administrator" e "password" para ver o console da Web:
Kubernetes on Amazon - Couchbase Web Console

Assim, você acabou de acessar seu pod fora do cluster do Kubernetes.

Shutdown Kubernetes Cluster

Por fim, desligue o cluster usando cluster/kube-down.sh roteiro.

For a complete clean up, you still need to explicitly delete the S3 bucket where Kubernetes binaries are stored.

Aproveite!

Autor

Postado por Arun Gupta, vice-presidente de defesa do desenvolvedor, Couchbase

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

Deixar uma resposta