Rahul Vedpathak
Rahul Vedpathak

Reputation: 1436

Onboarding existing containers in Docker on Kubernetes platform

I am new to kubernetes world. I have a cluster setup where multiple nodes are running different containers. I want to migrate the setup to kubernetes. I am planning to install kubernetes master on one of the node and prepare other nodes as kubernetes worker.

If I prepare a kubernetes cluster will kubernetes detect existing running containers on these hosts ? If not is there any plugin/facility which will create corresponding kubernetes objects for the running containers ?

Upvotes: 0

Views: 91

Answers (1)

David Maze
David Maze

Reputation: 158937

I would essentially start from scratch here. Kubernetes can use your existing Docker images, but it should have its own dedicated hardware, and you'll need to write new YAML files to deploy it.

Kubernetes only knows about containers it manages itself. In most cases Kubernetes wants to manage multiple entire nodes exclusively; it doesn't make sense to run a node "partly Kubernetes" with some manually-managed containers. If you can use components like the cluster autoscaler then nodes can be dynamically added and removed based on actual cluster load, outside of your direct control; anything that was on a node that gets removed will just be lost if Kubernetes doesn't know to relocate it somewhere else.

There are tools like Kompose to try to migrate a Docker Compose setup to Kubernetes YAML, but they're limited, and you need to actually learn the Kubernetes setup to work around these limitations. The most prominent example is bind-mounted host directories: you can't directly use host files in Kubernetes (...from which host?) and Kompose just drops the volume mount. To fix this you need to learn about Secrets and ConfigMaps, and Kubernetes's abstract notion of a "volume", and where it fits in a Pod spec and then a Deployment spec; if you have a good handle on this then you can just directly write the Kubernetes YAML.

Upvotes: 1

Related Questions