SlideShare a Scribd company logo
Making
Kubernetes
Simple for
Developers
Suraj Deshmukh
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
This talk is going to have a lot of references to Kubernetes or OpenShift and
Docker Compose.
Disclaimer
Story of today’s developer (YMMV)
Deploy application in containers
Learn docker*
* Now called moby
How do I run “stuff” with docker?
$ docker run hello-world
$ docker run -p 5432:5432 postgres
First steps with Docker
Code is local python application:
(venv) $ ls
myapp.py requirements.txt
(venv) $ python myapp.py
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
My code repo ...
$ ls
Dockerfile
myapp.py
README.md
requirements.txt
Run my awesome application
$ docker build -t myapp .
$ docker run -p 8080:8080 myapp
$ curl localhost:8080
Need to add one more service
$ ls
apiserver.py
Dockerfile.apiserver
Dockerfile.myapp
myapp.py
README.md
requirements.txt
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
Enter docker-compose
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
Updated code repo ...
$ ls
apiserver.py
docker-compose.yml
Dockerfile.apiserver
Dockerfile.myapp
myapp.py
README.md
requirements.txt
$ docker-compose up
$ curl localhost:8080
Docker-compose is easier for development
I am happy (Not for long).
Now that everything is running locally, how and
where do I deploy this?
Container orchestrators
● Kubernetes ( OpenShift )
● Docker Swarm
● Mesos
● Docker Compose I can use with Docker Swarm only
● Cannot use the docker-compose as is with swarm
● Kubernetes is robust
● Has Google’s production experience of more than a decade
● Huge contributor base and community
So what is this Kubernetes?
● 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?
services:
postgresql:
image: postgresql
apiserver:
build: Dockerfile.apiserver
env:
POSTGRESQL_HOST: postgresql
myapp:
build: Dockerfile.myapp
Remember this?
More google search
I want to make my life
easier
Enter Kompose!
$ kompose up
Demo!
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? :)
● Works as long as I have fewer services and generic use cases.
● My application is now more than just application and database
containers.
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.
● Most of the things (from previous slide) can be done, but needs changes
in docker-compose.yaml
● May not break application.
● No direct mapping to any docker-compose constructs
● Kompose exploits docker-compose restart.
Kubernetes Jobs
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
Volumes
● Kompose assumes some size for PVC
Ingress and Routes
● No direct mapping in docker-compose world
● Hack around with labels :
labels:
kompose.service.expose: "counter.example.com"
Liveness probe and Readiness probe
● No equivalent concept in docker-compose
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
So what do I do to get around it?
● Generate configs with Kompose
● Edit configs yourself to fill in the gaps
kind: List
apiVersion: v1
metadata: {}
items:
- kind: Service
apiVersion: v1
metadata:
name: etherpad
creationTimestamp:
labels:
service: etherpad
spec:
ports:
- name: '80'
protocol: TCP
port: 80
targetPort: 9001
selector:
service: etherpad
status:
loadBalancer: {}
- kind: Service
apiVersion: v1
metadata:
name: mariadb
creationTimestamp:
labels:
service: mariadb
spec:
ports:
- name: '3306'
protocol: TCP
port: 3306
targetPort: 3306
selector:
service: mariadb
status:
loadBalancer: {}
- kind: Deployment
apiVersion: extensions/v1beta1
metadata:
name: etherpad
creationTimestamp:
spec:
replicas: 1
template:
metadata:
creationTimestamp:
labels:
service: etherpad
spec:
containers:
- name: etherpad
image: centos/etherpad
ports:
- containerPort: 9001
protocol: TCP
env:
- name: DB_DBID
value: etherpad
- name: DB_HOST
value: mariadb
- name: DB_PASS
value: etherpad
- name: DB_PORT
value: '3306'
- name: DB_USER
value: etherpad
resources: {}
restartPolicy: Always
strategy: {}
status: {}
- kind: Deployment
apiVersion: extensions/v1beta1
metadata:
name: mariadb
creationTimestamp:
spec:
replicas: 1
template:
metadata:
creationTimestamp:
labels:
service: mariadb
spec:
volumes:
- name: mariadb-claim0
persistentVolumeClaim:
claimName: mariadb-claim0
containers:
- name: mariadb
image: centos/mariadb
ports:
- containerPort: 3306
protocol: TCP
env:
- name: MYSQL_DATABASE
value: etherpad
- name: MYSQL_PASSWORD
value: etherpad
- name: MYSQL_ROOT_PASSWORD
value: etherpad
- name: MYSQL_USER
value: etherpad
resources: {}
volumeMounts:
- name: mariadb-claim0
mountPath: "/var/lib/mysql"
restartPolicy: Always
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
What’s next?
Enter OpenCompose!
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.
Sample OpenCompose file
version: '0.1-dev'
services:
- name: database
replicas: 2
containers:
- image: mariadb:10
env:
- MYSQL_ROOT_PASSWORD=rootpasswd
- MYSQL_DATABASE=wordpress
- MYSQL_USER=wordpress
- MYSQL_PASSWORD=wordpress
ports:
- port: 3306
- name: web
containers:
- image: wordpress:4
env:
- WORDPRESS_DB_HOST=database:3306
- WORDPRESS_DB_PASSWORD=wordpress
- WORDPRESS_DB_USER=wordpress
- WORDPRESS_DB_NAME=wordpress
ports:
- port: 80
type: external
Running opencompose tool
$ opencompose convert -f wordpress.yaml
created file "database-service.yaml"
created file "database-deployment.yaml"
created file "web-service.yaml"
created file "web-deployment.yaml"
$ kubectl create -f .
Demo!
Kollaborating with Kubernetes community
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
References:
● Kompose http://kompose.io/
● OpenCompose https://github.com/redhat-developer/opencompose/
Meetup
● Upcoming meetup bit.ly/k8s101
● Meetup Page bit.ly/meetupk8s

More Related Content

What's hot

Kubernetes Introduction
Kubernetes IntroductionKubernetes Introduction
Kubernetes Introduction
Eric Gustafson
 
IPC16: A Practical Introduction to Kubernetes
IPC16: A Practical Introduction to Kubernetes IPC16: A Practical Introduction to Kubernetes
IPC16: A Practical Introduction to Kubernetes
Robert Lemke
 
Container Orchestration using Kubernetes
Container Orchestration using KubernetesContainer Orchestration using Kubernetes
Container Orchestration using Kubernetes
Hesham Amin
 
Kubernetes Basic Operation
Kubernetes Basic OperationKubernetes Basic Operation
Kubernetes Basic Operation
Simon Su
 
DevOps in AWS with Kubernetes
DevOps in AWS with KubernetesDevOps in AWS with Kubernetes
DevOps in AWS with Kubernetes
Oleg Chunikhin
 
Kubernetes basics and hands on exercise
Kubernetes basics and hands on exerciseKubernetes basics and hands on exercise
Kubernetes basics and hands on exercise
Cloud Technology Experts
 
Introduction kubernetes 2017_12_24
Introduction kubernetes 2017_12_24Introduction kubernetes 2017_12_24
Introduction kubernetes 2017_12_24
Sam Zheng
 
Kubernetes - introduction
Kubernetes - introductionKubernetes - introduction
Kubernetes - introduction
Sparkbit
 
Kubernetes and Hybrid Deployments
Kubernetes and Hybrid DeploymentsKubernetes and Hybrid Deployments
Kubernetes and Hybrid Deployments
Sandeep Parikh
 
Containers without docker
Containers without dockerContainers without docker
Containers without docker
Ben Hall
 
Docker Athens: Docker Engine Evolution & Containerd Use Cases
Docker Athens: Docker Engine Evolution & Containerd Use CasesDocker Athens: Docker Engine Evolution & Containerd Use Cases
Docker Athens: Docker Engine Evolution & Containerd Use Cases
Phil Estes
 
Kubernetes architecture
Kubernetes architectureKubernetes architecture
Kubernetes architecture
Janakiram MSV
 
Kubernetes with docker
Kubernetes with dockerKubernetes with docker
Kubernetes with docker
Docker, Inc.
 
kubernetes for beginners
kubernetes for beginnerskubernetes for beginners
kubernetes for beginners
Dominique Dumont
 
Kubernetes kubecon-roundup
Kubernetes kubecon-roundupKubernetes kubecon-roundup
Kubernetes kubecon-roundup
Sebastien Goasguen
 
Docker Compose by Aanand Prasad
Docker Compose by Aanand Prasad Docker Compose by Aanand Prasad
Docker Compose by Aanand Prasad
Docker, Inc.
 
Rapid Development With Docker Compose
Rapid Development With Docker ComposeRapid Development With Docker Compose
Rapid Development With Docker Compose
Justin Crown
 
Microservices at scale with docker and kubernetes - AMS JUG 2017
Microservices at scale with docker and kubernetes - AMS JUG 2017Microservices at scale with docker and kubernetes - AMS JUG 2017
Microservices at scale with docker and kubernetes - AMS JUG 2017
Arjen Wassink
 
Kubernetes上で動作する機械学習モジュールの配信&管理基盤Rekcurd について
Kubernetes上で動作する機械学習モジュールの配信&管理基盤Rekcurd についてKubernetes上で動作する機械学習モジュールの配信&管理基盤Rekcurd について
Kubernetes上で動作する機械学習モジュールの配信&管理基盤Rekcurd について
LINE Corporation
 
Docker & Kubernetes intro
Docker & Kubernetes introDocker & Kubernetes intro
Docker & Kubernetes intro
Arnon Rotem-Gal-Oz
 

What's hot (20)

Kubernetes Introduction
Kubernetes IntroductionKubernetes Introduction
Kubernetes Introduction
 
IPC16: A Practical Introduction to Kubernetes
IPC16: A Practical Introduction to Kubernetes IPC16: A Practical Introduction to Kubernetes
IPC16: A Practical Introduction to Kubernetes
 
Container Orchestration using Kubernetes
Container Orchestration using KubernetesContainer Orchestration using Kubernetes
Container Orchestration using Kubernetes
 
Kubernetes Basic Operation
Kubernetes Basic OperationKubernetes Basic Operation
Kubernetes Basic Operation
 
DevOps in AWS with Kubernetes
DevOps in AWS with KubernetesDevOps in AWS with Kubernetes
DevOps in AWS with Kubernetes
 
Kubernetes basics and hands on exercise
Kubernetes basics and hands on exerciseKubernetes basics and hands on exercise
Kubernetes basics and hands on exercise
 
Introduction kubernetes 2017_12_24
Introduction kubernetes 2017_12_24Introduction kubernetes 2017_12_24
Introduction kubernetes 2017_12_24
 
Kubernetes - introduction
Kubernetes - introductionKubernetes - introduction
Kubernetes - introduction
 
Kubernetes and Hybrid Deployments
Kubernetes and Hybrid DeploymentsKubernetes and Hybrid Deployments
Kubernetes and Hybrid Deployments
 
Containers without docker
Containers without dockerContainers without docker
Containers without docker
 
Docker Athens: Docker Engine Evolution & Containerd Use Cases
Docker Athens: Docker Engine Evolution & Containerd Use CasesDocker Athens: Docker Engine Evolution & Containerd Use Cases
Docker Athens: Docker Engine Evolution & Containerd Use Cases
 
Kubernetes architecture
Kubernetes architectureKubernetes architecture
Kubernetes architecture
 
Kubernetes with docker
Kubernetes with dockerKubernetes with docker
Kubernetes with docker
 
kubernetes for beginners
kubernetes for beginnerskubernetes for beginners
kubernetes for beginners
 
Kubernetes kubecon-roundup
Kubernetes kubecon-roundupKubernetes kubecon-roundup
Kubernetes kubecon-roundup
 
Docker Compose by Aanand Prasad
Docker Compose by Aanand Prasad Docker Compose by Aanand Prasad
Docker Compose by Aanand Prasad
 
Rapid Development With Docker Compose
Rapid Development With Docker ComposeRapid Development With Docker Compose
Rapid Development With Docker Compose
 
Microservices at scale with docker and kubernetes - AMS JUG 2017
Microservices at scale with docker and kubernetes - AMS JUG 2017Microservices at scale with docker and kubernetes - AMS JUG 2017
Microservices at scale with docker and kubernetes - AMS JUG 2017
 
Kubernetes上で動作する機械学習モジュールの配信&管理基盤Rekcurd について
Kubernetes上で動作する機械学習モジュールの配信&管理基盤Rekcurd についてKubernetes上で動作する機械学習モジュールの配信&管理基盤Rekcurd について
Kubernetes上で動作する機械学習モジュールの配信&管理基盤Rekcurd について
 
Docker & Kubernetes intro
Docker & Kubernetes introDocker & Kubernetes intro
Docker & Kubernetes intro
 

Similar to Making kubernetes simple for developers

Taking containers from development to production
Taking containers from development to productionTaking containers from development to production
Taking containers from development to production
Suraj Deshmukh
 
From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...
Jérôme Petazzoni
 
Настройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'aНастройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'a
corehard_by
 
Adventures in docker compose
Adventures in docker composeAdventures in docker compose
Adventures in docker compose
LinkMe Srl
 
Docker in everyday development
Docker in everyday developmentDocker in everyday development
Docker in everyday development
Justyna Ilczuk
 
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container ServiceScaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container Service
Ben Hall
 
Docker as development environment
Docker as development environmentDocker as development environment
Docker as development environment
Bruno de Lima e Silva
 
Docker module 1
Docker module 1Docker module 1
Docker module 1
Liang Bo
 
Start tracking your ruby infrastructure
Start tracking your ruby infrastructureStart tracking your ruby infrastructure
Start tracking your ruby infrastructure
Sergiy Kukunin
 
K8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals TrainingK8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals Training
Piotr Perzyna
 
Ruby microservices with Docker - Sergii Koba
Ruby microservices with Docker -  Sergii KobaRuby microservices with Docker -  Sergii Koba
Ruby microservices with Docker - Sergii Koba
Ruby Meditation
 
JDD2014: Docker.io - versioned linux containers for JVM devops - Dominik Dorn
JDD2014: Docker.io - versioned linux containers for JVM devops - Dominik DornJDD2014: Docker.io - versioned linux containers for JVM devops - Dominik Dorn
JDD2014: Docker.io - versioned linux containers for JVM devops - Dominik Dorn
PROIDEA
 
DevAssistant, Docker and You
DevAssistant, Docker and YouDevAssistant, Docker and You
DevAssistant, Docker and You
BalaBit
 
20170321 docker with Visual Studio 2017
20170321 docker with Visual Studio 201720170321 docker with Visual Studio 2017
20170321 docker with Visual Studio 2017
Takayoshi Tanaka
 
Clustering with Docker Swarm - Dockerops 2016 @ Cento (FE) Italy
Clustering with Docker Swarm - Dockerops 2016 @ Cento (FE) ItalyClustering with Docker Swarm - Dockerops 2016 @ Cento (FE) Italy
Clustering with Docker Swarm - Dockerops 2016 @ Cento (FE) Italy
Giovanni Toraldo
 
[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안
양재동 코드랩
 
Developing and Deploying PHP with Docker
Developing and Deploying PHP with DockerDeveloping and Deploying PHP with Docker
Developing and Deploying PHP with DockerPatrick Mizer
 
Docker
DockerDocker
DevEx | there’s no place like k3s
DevEx | there’s no place like k3sDevEx | there’s no place like k3s
DevEx | there’s no place like k3s
Haggai Philip Zagury
 
Deploy Nodejs on Docker
Deploy Nodejs on DockerDeploy Nodejs on Docker
Deploy Nodejs on Docker
Will Button
 

Similar to Making kubernetes simple for developers (20)

Taking containers from development to production
Taking containers from development to productionTaking containers from development to production
Taking containers from development to production
 
From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...
 
Настройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'aНастройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'a
 
Adventures in docker compose
Adventures in docker composeAdventures in docker compose
Adventures in docker compose
 
Docker in everyday development
Docker in everyday developmentDocker in everyday development
Docker in everyday development
 
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container ServiceScaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container Service
 
Docker as development environment
Docker as development environmentDocker as development environment
Docker as development environment
 
Docker module 1
Docker module 1Docker module 1
Docker module 1
 
Start tracking your ruby infrastructure
Start tracking your ruby infrastructureStart tracking your ruby infrastructure
Start tracking your ruby infrastructure
 
K8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals TrainingK8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals Training
 
Ruby microservices with Docker - Sergii Koba
Ruby microservices with Docker -  Sergii KobaRuby microservices with Docker -  Sergii Koba
Ruby microservices with Docker - Sergii Koba
 
JDD2014: Docker.io - versioned linux containers for JVM devops - Dominik Dorn
JDD2014: Docker.io - versioned linux containers for JVM devops - Dominik DornJDD2014: Docker.io - versioned linux containers for JVM devops - Dominik Dorn
JDD2014: Docker.io - versioned linux containers for JVM devops - Dominik Dorn
 
DevAssistant, Docker and You
DevAssistant, Docker and YouDevAssistant, Docker and You
DevAssistant, Docker and You
 
20170321 docker with Visual Studio 2017
20170321 docker with Visual Studio 201720170321 docker with Visual Studio 2017
20170321 docker with Visual Studio 2017
 
Clustering with Docker Swarm - Dockerops 2016 @ Cento (FE) Italy
Clustering with Docker Swarm - Dockerops 2016 @ Cento (FE) ItalyClustering with Docker Swarm - Dockerops 2016 @ Cento (FE) Italy
Clustering with Docker Swarm - Dockerops 2016 @ Cento (FE) Italy
 
[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안
 
Developing and Deploying PHP with Docker
Developing and Deploying PHP with DockerDeveloping and Deploying PHP with Docker
Developing and Deploying PHP with Docker
 
Docker
DockerDocker
Docker
 
DevEx | there’s no place like k3s
DevEx | there’s no place like k3sDevEx | there’s no place like k3s
DevEx | there’s no place like k3s
 
Deploy Nodejs on Docker
Deploy Nodejs on DockerDeploy Nodejs on Docker
Deploy Nodejs on Docker
 

More from Suraj Deshmukh

Building Container Defence Executable at a Time.pdf
Building Container Defence Executable at a Time.pdfBuilding Container Defence Executable at a Time.pdf
Building Container Defence Executable at a Time.pdf
Suraj Deshmukh
 
Kubernetes psp and beyond
Kubernetes psp and beyondKubernetes psp and beyond
Kubernetes psp and beyond
Suraj Deshmukh
 
Hardening Kubernetes by Securing Pods
Hardening Kubernetes by Securing PodsHardening Kubernetes by Securing Pods
Hardening Kubernetes by Securing Pods
Suraj Deshmukh
 
Kubernetes Security Updates from Kubecon 2018 Seattle
Kubernetes Security Updates from Kubecon 2018 SeattleKubernetes Security Updates from Kubecon 2018 Seattle
Kubernetes Security Updates from Kubecon 2018 Seattle
Suraj Deshmukh
 
Kubernetes on CRI-O
Kubernetes on CRI-OKubernetes on CRI-O
Kubernetes on CRI-O
Suraj Deshmukh
 
JSONSchema with golang
JSONSchema with golangJSONSchema with golang
JSONSchema with golang
Suraj Deshmukh
 
What's new in kubernetes 1.3?
What's new in kubernetes 1.3?What's new in kubernetes 1.3?
What's new in kubernetes 1.3?
Suraj Deshmukh
 
Python testing using mock and pytest
Python testing using mock and pytestPython testing using mock and pytest
Python testing using mock and pytest
Suraj Deshmukh
 
OpenShift meetup Bangalore
OpenShift meetup BangaloreOpenShift meetup Bangalore
OpenShift meetup Bangalore
Suraj Deshmukh
 
macvlan and ipvlan
macvlan and ipvlanmacvlan and ipvlan
macvlan and ipvlan
Suraj Deshmukh
 
Henge
HengeHenge

More from Suraj Deshmukh (11)

Building Container Defence Executable at a Time.pdf
Building Container Defence Executable at a Time.pdfBuilding Container Defence Executable at a Time.pdf
Building Container Defence Executable at a Time.pdf
 
Kubernetes psp and beyond
Kubernetes psp and beyondKubernetes psp and beyond
Kubernetes psp and beyond
 
Hardening Kubernetes by Securing Pods
Hardening Kubernetes by Securing PodsHardening Kubernetes by Securing Pods
Hardening Kubernetes by Securing Pods
 
Kubernetes Security Updates from Kubecon 2018 Seattle
Kubernetes Security Updates from Kubecon 2018 SeattleKubernetes Security Updates from Kubecon 2018 Seattle
Kubernetes Security Updates from Kubecon 2018 Seattle
 
Kubernetes on CRI-O
Kubernetes on CRI-OKubernetes on CRI-O
Kubernetes on CRI-O
 
JSONSchema with golang
JSONSchema with golangJSONSchema with golang
JSONSchema with golang
 
What's new in kubernetes 1.3?
What's new in kubernetes 1.3?What's new in kubernetes 1.3?
What's new in kubernetes 1.3?
 
Python testing using mock and pytest
Python testing using mock and pytestPython testing using mock and pytest
Python testing using mock and pytest
 
OpenShift meetup Bangalore
OpenShift meetup BangaloreOpenShift meetup Bangalore
OpenShift meetup Bangalore
 
macvlan and ipvlan
macvlan and ipvlanmacvlan and ipvlan
macvlan and ipvlan
 
Henge
HengeHenge
Henge
 

Recently uploaded

De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
Jelle | Nordend
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
KrzysztofKkol1
 
Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024
Sharepoint Designs
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
varshanayak241
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
Peter Caitens
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 

Recently uploaded (20)

De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 

Making kubernetes simple for developers

  • 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
  • 4. Story of today’s developer (YMMV)
  • 6. Learn docker* * Now called moby
  • 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
  • 16. Updated code repo ... $ ls apiserver.py docker-compose.yml Dockerfile.apiserver Dockerfile.myapp myapp.py README.md requirements.txt
  • 17. $ docker-compose up $ curl localhost:8080
  • 18. Docker-compose is easier for development I am happy (Not for long).
  • 19. Now that everything is running locally, how and where do I deploy this?
  • 20. Container orchestrators ● Kubernetes ( OpenShift ) ● Docker Swarm ● Mesos
  • 21. ● Docker Compose I can use with Docker Swarm only ● Cannot use the docker-compose as is with swarm
  • 22. ● Kubernetes is robust ● Has Google’s production experience of more than a decade ● Huge contributor base and community
  • 23. So what is this Kubernetes?
  • 24.
  • 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?
  • 27. More google search I want to make my life easier
  • 30. Demo!
  • 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
  • 37. Volumes ● Kompose assumes some size for PVC
  • 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
  • 42. kind: List apiVersion: v1 metadata: {} items: - kind: Service apiVersion: v1 metadata: name: etherpad creationTimestamp: labels: service: etherpad spec: ports: - name: '80' protocol: TCP port: 80 targetPort: 9001 selector: service: etherpad status: loadBalancer: {} - kind: Service apiVersion: v1 metadata: name: mariadb creationTimestamp: labels: service: mariadb spec: ports: - name: '3306' protocol: TCP port: 3306 targetPort: 3306 selector: service: mariadb status: loadBalancer: {} - kind: Deployment apiVersion: extensions/v1beta1 metadata: name: etherpad creationTimestamp: spec: replicas: 1 template: metadata: creationTimestamp: labels: service: etherpad spec: containers: - name: etherpad image: centos/etherpad ports: - containerPort: 9001 protocol: TCP env: - name: DB_DBID value: etherpad - name: DB_HOST value: mariadb - name: DB_PASS value: etherpad - name: DB_PORT value: '3306' - name: DB_USER value: etherpad resources: {} restartPolicy: Always strategy: {} status: {} - kind: Deployment apiVersion: extensions/v1beta1 metadata: name: mariadb creationTimestamp: spec: replicas: 1 template: metadata: creationTimestamp: labels: service: mariadb spec: volumes: - name: mariadb-claim0 persistentVolumeClaim: claimName: mariadb-claim0 containers: - name: mariadb image: centos/mariadb ports: - containerPort: 3306 protocol: TCP env: - name: MYSQL_DATABASE value: etherpad - name: MYSQL_PASSWORD value: etherpad - name: MYSQL_ROOT_PASSWORD value: etherpad - name: MYSQL_USER value: etherpad resources: {} volumeMounts: - name: mariadb-claim0 mountPath: "/var/lib/mysql" restartPolicy: Always
  • 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.
  • 47. Sample OpenCompose file version: '0.1-dev' services: - name: database replicas: 2 containers: - image: mariadb:10 env: - MYSQL_ROOT_PASSWORD=rootpasswd - MYSQL_DATABASE=wordpress - MYSQL_USER=wordpress - MYSQL_PASSWORD=wordpress ports: - port: 3306 - name: web containers: - image: wordpress:4 env: - WORDPRESS_DB_HOST=database:3306 - WORDPRESS_DB_PASSWORD=wordpress - WORDPRESS_DB_USER=wordpress - WORDPRESS_DB_NAME=wordpress ports: - port: 80 type: external
  • 48. Running opencompose tool $ opencompose convert -f wordpress.yaml created file "database-service.yaml" created file "database-deployment.yaml" created file "web-service.yaml" created file "web-deployment.yaml" $ kubectl create -f .
  • 49. Demo!
  • 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
  • 52. References: ● Kompose http://kompose.io/ ● OpenCompose https://github.com/redhat-developer/opencompose/
  • 53. Meetup ● Upcoming meetup bit.ly/k8s101 ● Meetup Page bit.ly/meetupk8s