Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Kubernetes be used like Docker Compose?

I have been digging through the Kubernetes documentation for hours. I understand the core design, and the notion of services, controllers, pods, etc.

What I don't understand, however, is the process in which I can declaratively configure the cluster. That is, a way for me to write a config file (or a set thereof) to define the makeup, and scaling options of the cloud deployment. I want to be able to declare which containers I want in which pods, how they will communicate, how they will scale, etc. without running a ton of cli commands.

Is there docker-compose functionality for Kubernetes?

I want my application to be defined in git—to be version controlled–without relying on manual cli interactions.

Is this possible to do in a concise way? Is there a reference that is more clear than the official documentation?

like image 615
Don Scott Avatar asked Jun 15 '16 21:06

Don Scott


People also ask

Is Kubernetes similar to Docker compose?

Kubernetes and Docker Compose are both container orchestration frameworks. Kubernetes runs containers over a number of computers, virtual or real. Docker Compose runs containers on a single host machine.

Can I use Kubernetes instead of Docker?

Kubernetes is a tool which manages (“orchestrates”) container-based applications running on a cluster of servers. You can use Docker without Kubernetes… and you can use Kubernetes without Docker.

Can I deploy a Docker compose to Kubernetes?

Kompose is a tool that lets you take Docker Compose files and deploy them to Kubernetes clusters. It's developed as part of the Kubernetes project. Current Kompose versions are limited to YAML file conversions. You must apply the converted Kubernetes resource manifests to your cluster using a tool like Kubectl.


2 Answers

If you have existing Docker Composer files, you may take a look at the Kompose project.

kompose is a tool to help users who are familiar with docker-compose move to Kubernetes. kompose takes a Docker Compose file and translates it into Kubernetes resources.

kompose is a convenience tool to go from local Docker development to managing your application with Kubernetes. Transformation of the Docker Compose format to Kubernetes resources manifest may not be exact, but it helps tremendously when first deploying an application on Kubernetes.

To run docker-compose.yaml file or your own, run:

kompose up 

To convert docker-compose.yaml into Kubernetes deployments and services with one simple command:

$ kompose convert -f docker-compose.yaml INFO Kubernetes file "frontend-service.yaml" created          INFO Kubernetes file "redis-master-service.yaml" created      INFO Kubernetes file "redis-slave-service.yaml" created       INFO Kubernetes file "frontend-deployment.yaml" created       INFO Kubernetes file "redis-master-deployment.yaml" created   INFO Kubernetes file "redis-slave-deployment.yaml" created 

For more info, check: http://kompose.io/

like image 38
JoaoCC Avatar answered Oct 03 '22 17:10

JoaoCC


If you're still looking, maybe this tool can help: https://github.com/kelseyhightower/compose2kube

You can create a compose file:

# sample compose file with 3 services web:   image: nginx   ports:     - "80"     - "443" database:   image: postgres   ports:     - "5432" cache:   image: memcached   ports:     - "11211" 

Then use the tool to convert it to kubernetes objects:

compose2kube -compose-file docker-compose.yml -output-dir output 

Which will create these files:

output/cache-rc.yaml output/database-rc.yaml output/web-rc.yaml 

Then you can use kubectl to apply them to kubernetes.

like image 143
Ahmad Aabed Avatar answered Oct 03 '22 17:10

Ahmad Aabed