SlideShare uma empresa Scribd logo
1 de 53
Baixar para ler offline
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

Mais conteúdo relacionado

Mais procurados

Docker Compose by Aanand Prasad
Docker Compose by Aanand Prasad Docker Compose by Aanand Prasad
Docker Compose by Aanand Prasad
Docker, Inc.
 

Mais procurados (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
 

Semelhante a Making kubernetes simple for developers

Developing and Deploying PHP with Docker
Developing and Deploying PHP with DockerDeveloping and Deploying PHP with Docker
Developing and Deploying PHP with Docker
Patrick Mizer
 

Semelhante a 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
 

Mais de Suraj Deshmukh

Mais de 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
 

Último

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 

Último (20)

%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 

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