SlideShare a Scribd company logo
1 of 19
Download to read offline
Kubernetes for beginners
Dominique Dumont
Debian Project
Nov 2017
Dominique Dumont k8s for beginners
Why Kubernetes ?
docker is nice, but containers tend to multiply
needs to manage / orchestrate them
need to handle network setup between all these images (micro
services beget mega network)
handle ”smooth” updates
Solutions: docker swarm, Kubernetes (other ?)
Dominique Dumont k8s for beginners
New concepts and terminology
New concepts compared to docker:
pod: a group of containers that provide a functionality
node: a worker machine (or VM). old term: minion
deployment: controls lifecycle of a group of pods (rolling
upgrades)
service: deployment frontend. Configure load-balancer and
external access
Dominique Dumont k8s for beginners
Pod in more details
A pod is a group of containers:
share the same IP address.
Must set different listening
ports on each container
declare external ports that
are mapped to container
ports
can mount shared volumes
can be configured with
ConfigMaps and Secrets
through environment
variables or files
Pod
Container
Dominique Dumont k8s for beginners
Deployment
A deployment with its
ReplicaSet is a group of
pods (of the same kind):
ReplicaSet ensures
failover
manage liveness and
readiness probes
manage rolling
upgrades
Deployment
Pod
Container
Replica
controler
Pod
Container
Pod
Container
Dominique Dumont k8s for beginners
Services
A Service is the external front end of a Deployment:
manage load balancing between the pod instances of a
Deployment
map port between external port (e.g. 80) and container ports
(e.g. 8080)
Deployment
Service
Pod
Container
Replica
controler
Balancer
Load
Pod
Container
Pod
Container
Dominique Dumont k8s for beginners
Pod example
Inside a deployment:
spec:
containers:
- name: my-contained-server
image: my-contained-image:latest
imagePullPolicy: Always
livenessProbe:
httpGet: { path: /ping, scheme: HTTPS }
initialDelaySeconds: 15
periodSeconds: 10
timeoutSeconds: 3
readinessProbe: # similar
volumeMounts:
- name: shared-stuff
mountPath: "/var/lib/shared"
- name: side-car
image: side-car:latest
Dominique Dumont k8s for beginners
Deployment example
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: super-duper-server
spec:
replicas: 1
strategy:
type: RollingUpdate
rollingUpdate: { maxUnavailable: 0, maxSurge: 2 }
template:
metadata:
name: super-mega-server
labels: # used by Service
my-server: mega-server
spec:
containers:
[ pod specification ]
Dominique Dumont k8s for beginners
Service example
apiVersion: v1
kind: Service
metadata:
labels:
name: my-super-service
name: super-service
spec:
ports:
- {port: 443, targetPort: 8090}
type: LoadBalancer
# load balancer target
selector:
my-server: mega-server
Dominique Dumont k8s for beginners
Config
namespace: isolated sandboxes within a cluster. Great for
tests
context: associate cluster and namespace
Commands:
$ kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
minikube minikube minikube
* dev-us-west-2 k-uw2.xxx.com us-west-2-user
dod-dev-us-w2 k-uw2.xxx.com us-west-2-user dod-playground
$ kubectl config use-context dod-dev-us-w2
$ kubectl config set-context ...
Dominique Dumont k8s for beginners
Config
namespace: isolated sandboxes within a cluster. Great for
tests
context: associate cluster and namespace
Commands:
$ kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
minikube minikube minikube
* dev-us-west-2 k-uw2.xxx.com us-west-2-user
dod-dev-us-w2 k-uw2.xxx.com us-west-2-user dod-playground
$ kubectl config use-context dod-dev-us-w2
$ kubectl config set-context ...
Dominique Dumont k8s for beginners
Sending config
Create Deployment or services:
$ kubectl apply -f .../file.yaml
Update a deployment:
$ kubectl replace -f .../file.yaml
Dominique Dumont k8s for beginners
Kubernetes console
If enabled by admin, cluster can be controled with a web interface
$ kubectl proxy
Starting to serve on 127.0.0.1:8001
Dominique Dumont k8s for beginners
Connecting to a container
In enabled by sys admin, you can connect to a container in the
cluster:
$ kubectl exec --namespace francois-sandbox 
fco-mode1-n9r-812209105-9wfcs -c omg date
Thu Oct 26 18:01:58 UTC 2017
$ kubectl exec --namespace francois-sandbox
fco-mode1-n9r-812209105-9wfcs -c omg -ti sh / #
Dominique Dumont k8s for beginners
Getting logs
Getting log may be the only way to get debug information. To get
log from a container:
$ kubectl logs --namespace francois-sandbox 
fco-mode1-n9r-812209105-9wfcs omg --since 10s
$ kubectl logs --namespace francois-sandbox 
fco-mode1-n9r-812209105-9wfcs omg -f
Logs from many pods
Problems can occur in any deployed pod. You need to setup a log
aggregator (kibana...)
Dominique Dumont k8s for beginners
Auto-completion
Typings all these options and arguments is tedious and error prone.
Add this in your ~/.bashrc
KFILE=/tmp/kube-completion
if [ -f /usr/local/bin/kubectl ]; then
/usr/local/bin/kubectl completion bash > $KFILE
. $KFILE
rm $KFILE
fi
Dominique Dumont k8s for beginners
Other tools
You can have your prompt display the current environment:
For a command prompt that shows your context, add this in your
~/.bashrc
NORMAL="[033[00m]"
YELLOW="[e[1;33m]"
__kube_prompt() {
# Get current context
CONTEXT=$(perl -nE ’print if s/current-context: //;’ 
~/.kube/config)
if [[ -n "$CONTEXT" ]]
then
echo "$YELLOW(k8s: ${CONTEXT})$NORMALn"
fi
}
PS1=$(__kube_prompt)’${USER}@${HOSTNAME}:${PWD/$HOME/~}$ ’
Dominique Dumont k8s for beginners
Other tools
You can have your prompt display the current environment:
For a command prompt that shows your context, add this in your
~/.bashrc
NORMAL="[033[00m]"
YELLOW="[e[1;33m]"
__kube_prompt() {
# Get current context
CONTEXT=$(perl -nE ’print if s/current-context: //;’ 
~/.kube/config)
if [[ -n "$CONTEXT" ]]
then
echo "$YELLOW(k8s: ${CONTEXT})$NORMALn"
fi
}
PS1=$(__kube_prompt)’${USER}@${HOSTNAME}:${PWD/$HOME/~}$ ’
Dominique Dumont k8s for beginners
MiniKube
MiniKube lets you play with kubernetes your laptop.
Can use kubernetes console to control your minikube
Note: docker commands deal with a docker daemon running
in minikube, not with your ”regular” docker daemon
Dominique Dumont k8s for beginners

More Related Content

What's hot

WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...
WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...
WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...Brian Grant
 
Introduction to Kubernetes
Introduction to KubernetesIntroduction to Kubernetes
Introduction to KubernetesRoss Kukulinski
 
Kubernetes 101 for Beginners
Kubernetes 101 for BeginnersKubernetes 101 for Beginners
Kubernetes 101 for BeginnersOktay Esgul
 
DevOps in AWS with Kubernetes
DevOps in AWS with KubernetesDevOps in AWS with Kubernetes
DevOps in AWS with KubernetesOleg Chunikhin
 
Scaling Microservices with Kubernetes
Scaling Microservices with KubernetesScaling Microservices with Kubernetes
Scaling Microservices with KubernetesDeivid Hahn Fração
 
Hands-On Introduction to Kubernetes at LISA17
Hands-On Introduction to Kubernetes at LISA17Hands-On Introduction to Kubernetes at LISA17
Hands-On Introduction to Kubernetes at LISA17Ryan Jarvinen
 
Introduction to Kubernetes Workshop
Introduction to Kubernetes WorkshopIntroduction to Kubernetes Workshop
Introduction to Kubernetes WorkshopBob Killen
 
Kubernetes Introduction
Kubernetes IntroductionKubernetes Introduction
Kubernetes IntroductionEric Gustafson
 
Kubernetes: A Short Introduction (2019)
Kubernetes: A Short Introduction (2019)Kubernetes: A Short Introduction (2019)
Kubernetes: A Short Introduction (2019)Megan O'Keefe
 
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 ServiceBen Hall
 
Kubernetes Basic Operation
Kubernetes Basic OperationKubernetes Basic Operation
Kubernetes Basic OperationSimon Su
 
Monitoring, Logging and Tracing on Kubernetes
Monitoring, Logging and Tracing on KubernetesMonitoring, Logging and Tracing on Kubernetes
Monitoring, Logging and Tracing on KubernetesMartin Etmajer
 
Platform Orchestration with Kubernetes and Docker
Platform Orchestration with Kubernetes and DockerPlatform Orchestration with Kubernetes and Docker
Platform Orchestration with Kubernetes and DockerJulian Strobl
 
Docker and Kubernetes 101 workshop
Docker and Kubernetes 101 workshopDocker and Kubernetes 101 workshop
Docker and Kubernetes 101 workshopSathish VJ
 
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka Mario Ishara Fernando
 

What's hot (20)

WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...
WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...
WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...
 
Introduction to Kubernetes
Introduction to KubernetesIntroduction to Kubernetes
Introduction to Kubernetes
 
Kubernetes 101
Kubernetes 101Kubernetes 101
Kubernetes 101
 
Kubernetes 101 for Beginners
Kubernetes 101 for BeginnersKubernetes 101 for Beginners
Kubernetes 101 for Beginners
 
DevOps in AWS with Kubernetes
DevOps in AWS with KubernetesDevOps in AWS with Kubernetes
DevOps in AWS with Kubernetes
 
Kubernetes 101
Kubernetes 101Kubernetes 101
Kubernetes 101
 
Scaling Microservices with Kubernetes
Scaling Microservices with KubernetesScaling Microservices with Kubernetes
Scaling Microservices with Kubernetes
 
Intro to Kubernetes
Intro to KubernetesIntro to Kubernetes
Intro to Kubernetes
 
Hands-On Introduction to Kubernetes at LISA17
Hands-On Introduction to Kubernetes at LISA17Hands-On Introduction to Kubernetes at LISA17
Hands-On Introduction to Kubernetes at LISA17
 
Introduction to Kubernetes Workshop
Introduction to Kubernetes WorkshopIntroduction to Kubernetes Workshop
Introduction to Kubernetes Workshop
 
Kubernetes Introduction
Kubernetes IntroductionKubernetes Introduction
Kubernetes Introduction
 
Kubernetes: A Short Introduction (2019)
Kubernetes: A Short Introduction (2019)Kubernetes: A Short Introduction (2019)
Kubernetes: A Short Introduction (2019)
 
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
 
Kubernetes Basic Operation
Kubernetes Basic OperationKubernetes Basic Operation
Kubernetes Basic Operation
 
Kubernetes Introduction
Kubernetes IntroductionKubernetes Introduction
Kubernetes Introduction
 
Rex gke-clustree
Rex gke-clustreeRex gke-clustree
Rex gke-clustree
 
Monitoring, Logging and Tracing on Kubernetes
Monitoring, Logging and Tracing on KubernetesMonitoring, Logging and Tracing on Kubernetes
Monitoring, Logging and Tracing on Kubernetes
 
Platform Orchestration with Kubernetes and Docker
Platform Orchestration with Kubernetes and DockerPlatform Orchestration with Kubernetes and Docker
Platform Orchestration with Kubernetes and Docker
 
Docker and Kubernetes 101 workshop
Docker and Kubernetes 101 workshopDocker and Kubernetes 101 workshop
Docker and Kubernetes 101 workshop
 
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka
 

Viewers also liked

Introduction to Kubernetes
Introduction to KubernetesIntroduction to Kubernetes
Introduction to Kubernetesrajdeep
 
An Introduction to Kubernetes
An Introduction to KubernetesAn Introduction to Kubernetes
An Introduction to KubernetesImesh Gunaratne
 
Kubernetes project update and how to contribute
Kubernetes project update and how to contributeKubernetes project update and how to contribute
Kubernetes project update and how to contributeinwin stack
 
Scaling Docker with Kubernetes
Scaling Docker with KubernetesScaling Docker with Kubernetes
Scaling Docker with KubernetesCarlos Sanchez
 
Kubernetes Architecture and Introduction – Paris Kubernetes Meetup
Kubernetes Architecture and Introduction – Paris Kubernetes MeetupKubernetes Architecture and Introduction – Paris Kubernetes Meetup
Kubernetes Architecture and Introduction – Paris Kubernetes MeetupStefan Schimanski
 
Kubernetes Architecture and Introduction
Kubernetes Architecture and IntroductionKubernetes Architecture and Introduction
Kubernetes Architecture and IntroductionStefan Schimanski
 

Viewers also liked (7)

Introduction to Kubernetes
Introduction to KubernetesIntroduction to Kubernetes
Introduction to Kubernetes
 
An Introduction to Kubernetes
An Introduction to KubernetesAn Introduction to Kubernetes
An Introduction to Kubernetes
 
Kubernetes project update and how to contribute
Kubernetes project update and how to contributeKubernetes project update and how to contribute
Kubernetes project update and how to contribute
 
DevOpsDays Brasilia 2017
DevOpsDays Brasilia 2017DevOpsDays Brasilia 2017
DevOpsDays Brasilia 2017
 
Scaling Docker with Kubernetes
Scaling Docker with KubernetesScaling Docker with Kubernetes
Scaling Docker with Kubernetes
 
Kubernetes Architecture and Introduction – Paris Kubernetes Meetup
Kubernetes Architecture and Introduction – Paris Kubernetes MeetupKubernetes Architecture and Introduction – Paris Kubernetes Meetup
Kubernetes Architecture and Introduction – Paris Kubernetes Meetup
 
Kubernetes Architecture and Introduction
Kubernetes Architecture and IntroductionKubernetes Architecture and Introduction
Kubernetes Architecture and Introduction
 

Similar to kubernetes for beginners

Scaling docker with kubernetes
Scaling docker with kubernetesScaling docker with kubernetes
Scaling docker with kubernetesLiran Cohen
 
Docker: A New Way to Turbocharging Your Apps Development
Docker: A New Way to Turbocharging Your Apps DevelopmentDocker: A New Way to Turbocharging Your Apps Development
Docker: A New Way to Turbocharging Your Apps Developmentmsyukor
 
Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020CloudHero
 
Get you Java application ready for Kubernetes !
Get you Java application ready for Kubernetes !Get you Java application ready for Kubernetes !
Get you Java application ready for Kubernetes !Anthony Dahanne
 
Kubernetes laravel and kubernetes
Kubernetes   laravel and kubernetesKubernetes   laravel and kubernetes
Kubernetes laravel and kubernetesWilliam Stewart
 
IBM MQ in containers MQTC 2017
IBM MQ in containers MQTC 2017IBM MQ in containers MQTC 2017
IBM MQ in containers MQTC 2017Robert Parker
 
Be a happier developer with Docker: Tricks of the trade
Be a happier developer with Docker: Tricks of the tradeBe a happier developer with Docker: Tricks of the trade
Be a happier developer with Docker: Tricks of the tradeNicola Paolucci
 
Docker HK Meetup - 201707
Docker HK Meetup - 201707Docker HK Meetup - 201707
Docker HK Meetup - 201707Clarence Ho
 
When Docker Engine 1.12 features unleashes software architecture
When Docker Engine 1.12 features unleashes software architectureWhen Docker Engine 1.12 features unleashes software architecture
When Docker Engine 1.12 features unleashes software architecture Adrien Blind
 
Using Docker For Development
Using Docker For DevelopmentUsing Docker For Development
Using Docker For DevelopmentLaura Frank Tacho
 
Real World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and ProductionReal World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and ProductionBen Hall
 
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz LachJDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz LachPROIDEA
 
Rooting Out Root: User namespaces in Docker
Rooting Out Root: User namespaces in DockerRooting Out Root: User namespaces in Docker
Rooting Out Root: User namespaces in DockerPhil Estes
 
DockerCon 18 docker storage
DockerCon 18 docker storageDockerCon 18 docker storage
DockerCon 18 docker storageDaniel Finneran
 
Docker Basic to Advance
Docker Basic to AdvanceDocker Basic to Advance
Docker Basic to AdvanceParas Jain
 
BBL Premiers pas avec Docker
BBL Premiers pas avec DockerBBL Premiers pas avec Docker
BBL Premiers pas avec Dockerkanedafromparis
 
Dayta AI Seminar - Kubernetes, Docker and AI on Cloud
Dayta AI Seminar - Kubernetes, Docker and AI on CloudDayta AI Seminar - Kubernetes, Docker and AI on Cloud
Dayta AI Seminar - Kubernetes, Docker and AI on CloudJung-Hong Kim
 

Similar to kubernetes for beginners (20)

Scaling docker with kubernetes
Scaling docker with kubernetesScaling docker with kubernetes
Scaling docker with kubernetes
 
Docker: A New Way to Turbocharging Your Apps Development
Docker: A New Way to Turbocharging Your Apps DevelopmentDocker: A New Way to Turbocharging Your Apps Development
Docker: A New Way to Turbocharging Your Apps Development
 
Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020
 
Get you Java application ready for Kubernetes !
Get you Java application ready for Kubernetes !Get you Java application ready for Kubernetes !
Get you Java application ready for Kubernetes !
 
Cloud RPI4 tomcat ARM64
Cloud RPI4 tomcat ARM64Cloud RPI4 tomcat ARM64
Cloud RPI4 tomcat ARM64
 
Kubernetes laravel and kubernetes
Kubernetes   laravel and kubernetesKubernetes   laravel and kubernetes
Kubernetes laravel and kubernetes
 
IBM MQ in containers MQTC 2017
IBM MQ in containers MQTC 2017IBM MQ in containers MQTC 2017
IBM MQ in containers MQTC 2017
 
Be a happier developer with Docker: Tricks of the trade
Be a happier developer with Docker: Tricks of the tradeBe a happier developer with Docker: Tricks of the trade
Be a happier developer with Docker: Tricks of the trade
 
Docker HK Meetup - 201707
Docker HK Meetup - 201707Docker HK Meetup - 201707
Docker HK Meetup - 201707
 
When Docker Engine 1.12 features unleashes software architecture
When Docker Engine 1.12 features unleashes software architectureWhen Docker Engine 1.12 features unleashes software architecture
When Docker Engine 1.12 features unleashes software architecture
 
Using Docker For Development
Using Docker For DevelopmentUsing Docker For Development
Using Docker For Development
 
Real World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and ProductionReal World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and Production
 
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz LachJDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
 
Rooting Out Root: User namespaces in Docker
Rooting Out Root: User namespaces in DockerRooting Out Root: User namespaces in Docker
Rooting Out Root: User namespaces in Docker
 
DockerCon 18 docker storage
DockerCon 18 docker storageDockerCon 18 docker storage
DockerCon 18 docker storage
 
Docker Basic to Advance
Docker Basic to AdvanceDocker Basic to Advance
Docker Basic to Advance
 
Docker advance1
Docker advance1Docker advance1
Docker advance1
 
From a cluster to the Cloud
From a cluster to the CloudFrom a cluster to the Cloud
From a cluster to the Cloud
 
BBL Premiers pas avec Docker
BBL Premiers pas avec DockerBBL Premiers pas avec Docker
BBL Premiers pas avec Docker
 
Dayta AI Seminar - Kubernetes, Docker and AI on Cloud
Dayta AI Seminar - Kubernetes, Docker and AI on CloudDayta AI Seminar - Kubernetes, Docker and AI on Cloud
Dayta AI Seminar - Kubernetes, Docker and AI on Cloud
 

More from Dominique Dumont

Quelques astuces pour débogguer Terraform.pdf
Quelques astuces pour débogguer Terraform.pdfQuelques astuces pour débogguer Terraform.pdf
Quelques astuces pour débogguer Terraform.pdfDominique Dumont
 
Terraform - IAC - de quoi s'agit t'il ?.pdf
Terraform - IAC - de quoi s'agit t'il ?.pdfTerraform - IAC - de quoi s'agit t'il ?.pdf
Terraform - IAC - de quoi s'agit t'il ?.pdfDominique Dumont
 
Comment contribuer à un projet open source ?
Comment contribuer à un projet open source ?Comment contribuer à un projet open source ?
Comment contribuer à un projet open source ?Dominique Dumont
 
Cme: a tool to edit and validate configuration files
Cme: a tool to edit and validate configuration filesCme: a tool to edit and validate configuration files
Cme: a tool to edit and validate configuration filesDominique Dumont
 
The reports of Perl's death have been greatly exaggerated
The reports of Perl's death have been greatly exaggeratedThe reports of Perl's death have been greatly exaggerated
The reports of Perl's death have been greatly exaggeratedDominique Dumont
 

More from Dominique Dumont (8)

Quelques astuces pour débogguer Terraform.pdf
Quelques astuces pour débogguer Terraform.pdfQuelques astuces pour débogguer Terraform.pdf
Quelques astuces pour débogguer Terraform.pdf
 
Terraform - IAC - de quoi s'agit t'il ?.pdf
Terraform - IAC - de quoi s'agit t'il ?.pdfTerraform - IAC - de quoi s'agit t'il ?.pdf
Terraform - IAC - de quoi s'agit t'il ?.pdf
 
Démarrer avec Helm
Démarrer avec HelmDémarrer avec Helm
Démarrer avec Helm
 
Comment contribuer à un projet open source ?
Comment contribuer à un projet open source ?Comment contribuer à un projet open source ?
Comment contribuer à un projet open source ?
 
Cme: a tool to edit and validate configuration files
Cme: a tool to edit and validate configuration filesCme: a tool to edit and validate configuration files
Cme: a tool to edit and validate configuration files
 
How to keep promises
How to keep promisesHow to keep promises
How to keep promises
 
The reports of Perl's death have been greatly exaggerated
The reports of Perl's death have been greatly exaggeratedThe reports of Perl's death have been greatly exaggerated
The reports of Perl's death have been greatly exaggerated
 
Magit
MagitMagit
Magit
 

Recently uploaded

FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptMsecMca
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...tanu pandey
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...SUHANI PANDEY
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfRagavanV2
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfRagavanV2
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projectssmsksolar
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 

Recently uploaded (20)

FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 

kubernetes for beginners

  • 1. Kubernetes for beginners Dominique Dumont Debian Project Nov 2017 Dominique Dumont k8s for beginners
  • 2. Why Kubernetes ? docker is nice, but containers tend to multiply needs to manage / orchestrate them need to handle network setup between all these images (micro services beget mega network) handle ”smooth” updates Solutions: docker swarm, Kubernetes (other ?) Dominique Dumont k8s for beginners
  • 3. New concepts and terminology New concepts compared to docker: pod: a group of containers that provide a functionality node: a worker machine (or VM). old term: minion deployment: controls lifecycle of a group of pods (rolling upgrades) service: deployment frontend. Configure load-balancer and external access Dominique Dumont k8s for beginners
  • 4. Pod in more details A pod is a group of containers: share the same IP address. Must set different listening ports on each container declare external ports that are mapped to container ports can mount shared volumes can be configured with ConfigMaps and Secrets through environment variables or files Pod Container Dominique Dumont k8s for beginners
  • 5. Deployment A deployment with its ReplicaSet is a group of pods (of the same kind): ReplicaSet ensures failover manage liveness and readiness probes manage rolling upgrades Deployment Pod Container Replica controler Pod Container Pod Container Dominique Dumont k8s for beginners
  • 6. Services A Service is the external front end of a Deployment: manage load balancing between the pod instances of a Deployment map port between external port (e.g. 80) and container ports (e.g. 8080) Deployment Service Pod Container Replica controler Balancer Load Pod Container Pod Container Dominique Dumont k8s for beginners
  • 7. Pod example Inside a deployment: spec: containers: - name: my-contained-server image: my-contained-image:latest imagePullPolicy: Always livenessProbe: httpGet: { path: /ping, scheme: HTTPS } initialDelaySeconds: 15 periodSeconds: 10 timeoutSeconds: 3 readinessProbe: # similar volumeMounts: - name: shared-stuff mountPath: "/var/lib/shared" - name: side-car image: side-car:latest Dominique Dumont k8s for beginners
  • 8. Deployment example apiVersion: extensions/v1beta1 kind: Deployment metadata: name: super-duper-server spec: replicas: 1 strategy: type: RollingUpdate rollingUpdate: { maxUnavailable: 0, maxSurge: 2 } template: metadata: name: super-mega-server labels: # used by Service my-server: mega-server spec: containers: [ pod specification ] Dominique Dumont k8s for beginners
  • 9. Service example apiVersion: v1 kind: Service metadata: labels: name: my-super-service name: super-service spec: ports: - {port: 443, targetPort: 8090} type: LoadBalancer # load balancer target selector: my-server: mega-server Dominique Dumont k8s for beginners
  • 10. Config namespace: isolated sandboxes within a cluster. Great for tests context: associate cluster and namespace Commands: $ kubectl config get-contexts CURRENT NAME CLUSTER AUTHINFO NAMESPACE minikube minikube minikube * dev-us-west-2 k-uw2.xxx.com us-west-2-user dod-dev-us-w2 k-uw2.xxx.com us-west-2-user dod-playground $ kubectl config use-context dod-dev-us-w2 $ kubectl config set-context ... Dominique Dumont k8s for beginners
  • 11. Config namespace: isolated sandboxes within a cluster. Great for tests context: associate cluster and namespace Commands: $ kubectl config get-contexts CURRENT NAME CLUSTER AUTHINFO NAMESPACE minikube minikube minikube * dev-us-west-2 k-uw2.xxx.com us-west-2-user dod-dev-us-w2 k-uw2.xxx.com us-west-2-user dod-playground $ kubectl config use-context dod-dev-us-w2 $ kubectl config set-context ... Dominique Dumont k8s for beginners
  • 12. Sending config Create Deployment or services: $ kubectl apply -f .../file.yaml Update a deployment: $ kubectl replace -f .../file.yaml Dominique Dumont k8s for beginners
  • 13. Kubernetes console If enabled by admin, cluster can be controled with a web interface $ kubectl proxy Starting to serve on 127.0.0.1:8001 Dominique Dumont k8s for beginners
  • 14. Connecting to a container In enabled by sys admin, you can connect to a container in the cluster: $ kubectl exec --namespace francois-sandbox fco-mode1-n9r-812209105-9wfcs -c omg date Thu Oct 26 18:01:58 UTC 2017 $ kubectl exec --namespace francois-sandbox fco-mode1-n9r-812209105-9wfcs -c omg -ti sh / # Dominique Dumont k8s for beginners
  • 15. Getting logs Getting log may be the only way to get debug information. To get log from a container: $ kubectl logs --namespace francois-sandbox fco-mode1-n9r-812209105-9wfcs omg --since 10s $ kubectl logs --namespace francois-sandbox fco-mode1-n9r-812209105-9wfcs omg -f Logs from many pods Problems can occur in any deployed pod. You need to setup a log aggregator (kibana...) Dominique Dumont k8s for beginners
  • 16. Auto-completion Typings all these options and arguments is tedious and error prone. Add this in your ~/.bashrc KFILE=/tmp/kube-completion if [ -f /usr/local/bin/kubectl ]; then /usr/local/bin/kubectl completion bash > $KFILE . $KFILE rm $KFILE fi Dominique Dumont k8s for beginners
  • 17. Other tools You can have your prompt display the current environment: For a command prompt that shows your context, add this in your ~/.bashrc NORMAL="[033[00m]" YELLOW="[e[1;33m]" __kube_prompt() { # Get current context CONTEXT=$(perl -nE ’print if s/current-context: //;’ ~/.kube/config) if [[ -n "$CONTEXT" ]] then echo "$YELLOW(k8s: ${CONTEXT})$NORMALn" fi } PS1=$(__kube_prompt)’${USER}@${HOSTNAME}:${PWD/$HOME/~}$ ’ Dominique Dumont k8s for beginners
  • 18. Other tools You can have your prompt display the current environment: For a command prompt that shows your context, add this in your ~/.bashrc NORMAL="[033[00m]" YELLOW="[e[1;33m]" __kube_prompt() { # Get current context CONTEXT=$(perl -nE ’print if s/current-context: //;’ ~/.kube/config) if [[ -n "$CONTEXT" ]] then echo "$YELLOW(k8s: ${CONTEXT})$NORMALn" fi } PS1=$(__kube_prompt)’${USER}@${HOSTNAME}:${PWD/$HOME/~}$ ’ Dominique Dumont k8s for beginners
  • 19. MiniKube MiniKube lets you play with kubernetes your laptop. Can use kubernetes console to control your minikube Note: docker commands deal with a docker daemon running in minikube, not with your ”regular” docker daemon Dominique Dumont k8s for beginners