This is a journey of a developer who goes from docker-compose to kompose to opencompose. Which tool can help her best to move to Kubernetes? Find out in the slides. Also there is a demo in the slides which shows how these tools can help.
This talk was presented at DevConf India on May 12th 2017. DevConf India was a parallel track with rootconf 2017. Visit devconf.in to know more.
2. About me: ● Works for Red Hat in Developer Tools team
● Contributes to Kompose, OpenCompose, Kubernetes,
OpenShift, etc.
● IRC, slack - surajd
● Twitter - surajd_
● Github - surajssd
● Email - surajd.service@gmail.com
3. This talk is going to have a lot of references to Kubernetes or OpenShift and
Docker Compose.
Disclaimer
7. How do I run “stuff” with docker?
$ docker run hello-world
$ docker run -p 5432:5432 postgres
First steps with Docker
8. Code is local python application:
(venv) $ ls
myapp.py requirements.txt
(venv) $ python myapp.py
9. What do you need to package your
application?
● A Dockerfile, here I am copying code from my machine to the container doing builds
locally.
FROM centos
RUN yum install -y python-pip3
COPY . /code
WORKDIR /code
RUN cd /code && pip install -r requirements.txt
CMD [ “myapp” ]
● And few commands
Note: Don’t try this in production :p
10. My code repo ...
$ ls
Dockerfile
myapp.py
README.md
requirements.txt
11. Run my awesome application
$ docker build -t myapp .
$ docker run -p 8080:8080 myapp
$ curl localhost:8080
12. Need to add one more service
$ ls
apiserver.py
Dockerfile.apiserver
Dockerfile.myapp
myapp.py
README.md
requirements.txt
13. And to bring this all up
$ docker build -t myapp -f Dockerfile.myapp .
$ docker build -t apiserver -f Dockerfile.apiserver .
$ docker run postgres
$ docker run apiserver
$ docker run -p 8080:8080 myapp
$ curl localhost:8080
15. I write everything in a docker-compose file, which looks like this:
services:
postgresql:
image: postgresql
apiserver:
build: Dockerfile.apiserver
env:
POSTGRESQL_HOST: postgresql
myapp:
build: Dockerfile.myapp
25. ● Lot of new concepts for someone new in this world
● Pods, Service, Deployment, ReplicaSets etc.
● And what happened to all the investment I made with Docker Compose?
31. Kompose helps me with
● Generating Kubernetes configurations.
● Defaults generated by Kompose are good enough.
● Kompose helps as long as the Docker Compose syntax helps
● But we don’t stop at good enough, do we? :)
32. ● Works as long as I have fewer services and generic use cases.
● My application is now more than just application and database
containers.
33. Use cases where kompose cannot do
anything:
● Define service type.
● Kubernetes Jobs
● Secrets and Configmaps cannot be defined.
● Difficult to define volumes info.
● No way to define liveness probes and readiness probes
● How to club multiple containers in single pod
● Generating openshift templates directly.
34. ● Most of the things (from previous slide) can be done, but needs changes
in docker-compose.yaml
● May not break application.
35. ● No direct mapping to any docker-compose constructs
● Kompose exploits docker-compose restart.
Kubernetes Jobs
36. Secrets and Configmaps
● No direct mapping to any docker-compose constructs
● But other ways of doing it.
service:
foo:
Env:
SECRET: devenv
service:
foo:
Env:
SECRET: prodenv
38. Ingress and Routes
● No direct mapping in docker-compose world
● Hack around with labels :
labels:
kompose.service.expose: "counter.example.com"
39. Liveness probe and Readiness probe
● No equivalent concept in docker-compose
40. Kubernetes Service type
● Here also there is no direct mapping in docker-compose world to do so.
● More hacking with labels :
labels:
kompose.service.type: nodeport
41. So what do I do to get around it?
● Generate configs with Kompose
● Edit configs yourself to fill in the gaps
43. As a kompose developer ...
● It’s tempting to extend docker-compose, which is done right now with
labels.
● Need to build a solution that overcomes docker-compose limitations with
respect to Kubernetes
46. What is OpenCompose?
● OpenCompose is a declarative higher level abstraction for specific
Kubernetes resources.
● Simple for developers to comprehend use it in their day to day
development workflow.
● Kubernetes resources define how to deploy an application,
OpenCompose tries to stick to define application only.
51. Comparison of all three tools
Feature docker-compose Kompose OpenCompose
Define k8s service type - Using docker-compose
labels.
Define type under port
Kubernetes Jobs - Using docker-compose
restart
-
Secrets - - Define a secret
Volumes Cannot define size Creates a pvc of
100MB
Well defined data
structure for volumes
Liveness and
Readiness
- - Define health
Multiple containers in
one Pod
- - Define container list
under each service