Deploy Docker container using Kubernetes

1/18/2016

I'm learning about Kubernetes because it's a very useful tool to manage and deploy container.

So My question is:

For example i have 2 instances Amazon EC2 called Kube1 and Kube2. So on Kube1 i create some container using Docker and deploy wordpress successfully. Now i want to make a cluster between Kube1 and Kube2 and after that using Kubernetes to deploy all of the containers on Kube1 to Kube2. Is there any step-by-step tutorial to get me through it? I'm kind of stuck with a lot of new concept of Kubernetes.

-- The One
amazon-web-services
deployment
docker
kubernetes

1 Answer

1/18/2016

Kubernetes is an orchestration tool. I lets you deploy containers on a cluster to insure availability.

What that means is that you define containers specs (or sets of containers) called Pods, and you send them to the cluster manager to be deployed.

You do not choose where the Pods get deployed: Kubernetes decides where you Pod is deployed depending on the resources it needs and the resources that are available in the cluster.

There is a concept of Service, (which I find is confusing as 'service' often means your 'application' in today's jargon), but a Kubernetes Service is a load balanced proxy to the Pod you target. The Service insures that you can talk to a Pod using a 'selector' which defines what Pods are targeted.

If you have a Wordpress site, it serves content. If you have 2 containers running this site, that are the same, then the Service would load balance the requests to either one of the 2 Pods.

Now, for this to work, you need the 2 Pods to be the same, that means if the data is updated (as it would be on a blog) the data needs to get to the Wordpress server somehow from a single source. You could have a shared Database Pod that both servers connect to. Ideally you use a distributed version of the database that takes care of replication. Or you'd need to mirror the DB.

The use-case you mention though is a bit different: you're talking about porting an infrastructure to another server. If you have your containers running on one node, replicating somewhere else should be as easy as pushing your containers to a registry and pulling then on to the other node. For the data, you may need to backup the volume and move it manually, or create a Docker volume to push to your registry.

-- MrE
Source: StackOverflow