SlideShare a Scribd company logo
Kubernetes 101
Tame your containers
Docker concepts
Container
● An extremely lightweight VM
holding code, libraries needed to
run apps
● Uses certain linux utilities to
provide isolation (namespaces,
cgroups)
● Fast start, hyper dense, and
portable
Image
A read-only template format
used to create docker containers
from a spec (Dockerfile)
Registry
Docker registry holds images,
just like S3.
Example: Dockerhub, AWS
ECR, GCP GCR, etc...
Dockerfile to Docker Image
> docker build -t demo .
Sending build context to Docker
daemon 365.6kB
Step 1/14 : FROM ruby:2.4-slim-jessie
---> aef69a49c1cd
...
> docker run alpine echo Hello World
Unable to find image 'alpine:latest' locally
latest: Pulling from library/alpine
Digest: sha256:769fddc7cc2f0a1c35abb2f91432e8beecf83916c421420e6a6da9f8975464b6
Status: Downloaded newer image for alpine:latest
Hello World
Docker CLI
docker --help
Usage: docker [OPTIONS] COMMAND
A self-sufficient runtime for containers
Commands:
build Build an image from a Dockerfile
cp Copy files/folders between a container and the local filesystem
exec Run a command in a running container
images List images
inspect Return low-level information on Docker objects
kill Kill one or more running containers
logs Fetch the logs of a container
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
restart Restart one or more containers
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
wait Block until one or more containers stop, then print their exit codes
Run 'docker COMMAND --help' for more information on a command.
Challenges with multiple containers
● How to scale?
● How to avoid port conflicts?
● How to manage them in multiple
hosts?
● What happens if a host has a trouble?
● How to keep them running?
● How to update them?
● Where are my containers?
- Configuration
- Scaling & Health
- Monitoring
- Scheduling
- Discovery
- Security
Meet kubernetes
Kubernetes is a an open source system for automating
containerized applications.
Manage applications, not machines
● Very Powerful and huge community
● Manages containers at scale
● Run everywhere (supports multiple cloud and bare-metal environments)
● Self healing
● Get more out of hardware
● Platform for Platform (distributed systems)
What can it do ?
● Start 5 containers using image
demo/api:v1
● Place an internal load balancer in front
of those containers
● Start 10 containers using image
demo/web:v1
● Place a public load balancer in front of
those containers
● If traffic spikes, grow those out cluster
and add containers
● New release! replace my container with
new version demo/web:v2
● Basic Auto-Scaling/Monitoring
● Long running processes ( Job,
Cronjobs)
● Stateful services (databases, caches)
● Resources & Capacity planning
● Storing configurations/secrets
● etc ...
Architecture -Cluster
The cluster is made of two types of
Nodes - Master and Worker
K8S Control plane (api, etcd,
scheduler) runs on master nodes,
which manages entire thing
Your apps run on worker nodes
Interacting with Cluster
Kubectl - a rich CLI to talk to
Kubernetes API
> alias kc = kubectl
kc get nodes
kc get nodes -o yaml
kc edit node ip-xx-xx
> kubectl get nodes
NAME STATUS ROLES AGE VERSION
ip-172-20-107-197.ec2.internal Ready node 170d v1.10.11
ip-172-20-107-51.ec2.internal Ready master 170d v1.10.11
ip-172-20-114-41.ec2.internal Ready node 170d v1.10.11
ip-172-20-52-179.ec2.internal Ready node 64d v1.10.11
ip-172-20-60-229.ec2.internal Ready master 170d v1.10.11
ip-172-20-69-22.ec2.internal Ready node 170d v1.10.11
ip-172-20-86-122.ec2.internal Ready master 170d v1.10.11
Pod
Small group of tightly coupled containers
The smallest deployed object
Shared namespace (IP, disk)
Not durable and ephemeral in nature
example: data-puller and web-service
Deployment
Represent an application deployment
and controls number of pods. It
handles:
● Scaling
● Updating software versions
● Rolling updates
● Pod health checking and healing
● Rollback
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
Services
● Acts as a load-balancer for pods
● Persistent endpoint
● exposes the pods (internal and external)
● Service is associate with pod through label
selector
- ClusterIP – exposed on cluster-internal IP
- NodePort – exposed on nodes IP .via static port
- LoadBalancer – exposed externally on providers NLB
- ExternalName – map service to DNS name
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
selector:
app: my-app
ports:
- name: http
protocol: TCP
port: 80
targetPort: 9376
- name: https
protocol: TCP
port: 443
targetPort: 9377
YAML Manifests
YAML file to declare desired state of
Kubernetes object types
● Define Kubernetes type
● Define type specification
● Labels / Annotations
● Metadata
Use kubectl to apply them against
cluster
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
annotations:
app/instance: “nginx”
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
Advance Objects
ConfigMap, Secrets
Volume, PersistentVolume, PVC
DaemonSets, StatefulSets
Jobs, CronJobs
Third Party extensions (CRD)
Demo (101)
Shipping images to registry
Running application on Kubernetes
Scaling out demo app
Rolling upgrades
Demo (advance)
Here is the source code - Github
DockerCoins is made of 5 services:
- rng = web service generating random bytes
- hasher = web service computing hash of POSTed data
- worker = background process calling rng and hasher
- webui = web interface to watch progress
- redis = data store (holds a counter updated by worker)
Deploy
● Deploy Redis
kubectl create deployment redis --image=redis
● Deploy everything else
for SERVICE in hasher rng webui worker; do
kubectl create deployment $SERVICE --image=$REGISTRY/$SERVICE:$TAG
Done
● Expose deployments
kubectl expose deployment redis --port 6379
kubectl expose deployment rng --port 80
kubectl expose deployment hasher --port 80
kubectl expose deploy/webui --type=NodePort --port=80
We are always available to talk about your
challenges moving forward towards
microservices and containers.
Dinesh Yadav (dinesh@razorops.com)
https://razorops.com

More Related Content

Recently uploaded

IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoTAnalytics
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutesconfluent
 
НАДІЯ ФЕДЮШКО БАЦ «Професійне зростання QA спеціаліста»
НАДІЯ ФЕДЮШКО БАЦ  «Професійне зростання QA спеціаліста»НАДІЯ ФЕДЮШКО БАЦ  «Професійне зростання QA спеціаліста»
НАДІЯ ФЕДЮШКО БАЦ «Професійне зростання QA спеціаліста»QADay
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupCatarinaPereira64715
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlPeter Udo Diehl
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...Sri Ambati
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor TurskyiFwdays
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxAbida Shariff
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀DianaGray10
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsExpeed Software
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxDavid Michel
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsPaul Groth
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Product School
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Alison B. Lowndes
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Product School
 

Recently uploaded (20)

IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
НАДІЯ ФЕДЮШКО БАЦ «Професійне зростання QA спеціаліста»
НАДІЯ ФЕДЮШКО БАЦ  «Професійне зростання QA спеціаліста»НАДІЯ ФЕДЮШКО БАЦ  «Професійне зростання QA спеціаліста»
НАДІЯ ФЕДЮШКО БАЦ «Професійне зростання QA спеціаліста»
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT Professionals
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 

Featured

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 

Featured (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

Getting Started with Docker and Kubernetes 101

  • 2. Docker concepts Container ● An extremely lightweight VM holding code, libraries needed to run apps ● Uses certain linux utilities to provide isolation (namespaces, cgroups) ● Fast start, hyper dense, and portable Image A read-only template format used to create docker containers from a spec (Dockerfile) Registry Docker registry holds images, just like S3. Example: Dockerhub, AWS ECR, GCP GCR, etc... Dockerfile to Docker Image > docker build -t demo . Sending build context to Docker daemon 365.6kB Step 1/14 : FROM ruby:2.4-slim-jessie ---> aef69a49c1cd ... > docker run alpine echo Hello World Unable to find image 'alpine:latest' locally latest: Pulling from library/alpine Digest: sha256:769fddc7cc2f0a1c35abb2f91432e8beecf83916c421420e6a6da9f8975464b6 Status: Downloaded newer image for alpine:latest Hello World
  • 3. Docker CLI docker --help Usage: docker [OPTIONS] COMMAND A self-sufficient runtime for containers Commands: build Build an image from a Dockerfile cp Copy files/folders between a container and the local filesystem exec Run a command in a running container images List images inspect Return low-level information on Docker objects kill Kill one or more running containers logs Fetch the logs of a container pull Pull an image or a repository from a registry push Push an image or a repository to a registry restart Restart one or more containers rm Remove one or more containers rmi Remove one or more images run Run a command in a new container wait Block until one or more containers stop, then print their exit codes Run 'docker COMMAND --help' for more information on a command.
  • 4. Challenges with multiple containers ● How to scale? ● How to avoid port conflicts? ● How to manage them in multiple hosts? ● What happens if a host has a trouble? ● How to keep them running? ● How to update them? ● Where are my containers? - Configuration - Scaling & Health - Monitoring - Scheduling - Discovery - Security
  • 5. Meet kubernetes Kubernetes is a an open source system for automating containerized applications. Manage applications, not machines ● Very Powerful and huge community ● Manages containers at scale ● Run everywhere (supports multiple cloud and bare-metal environments) ● Self healing ● Get more out of hardware ● Platform for Platform (distributed systems)
  • 6. What can it do ? ● Start 5 containers using image demo/api:v1 ● Place an internal load balancer in front of those containers ● Start 10 containers using image demo/web:v1 ● Place a public load balancer in front of those containers ● If traffic spikes, grow those out cluster and add containers ● New release! replace my container with new version demo/web:v2 ● Basic Auto-Scaling/Monitoring ● Long running processes ( Job, Cronjobs) ● Stateful services (databases, caches) ● Resources & Capacity planning ● Storing configurations/secrets ● etc ...
  • 7. Architecture -Cluster The cluster is made of two types of Nodes - Master and Worker K8S Control plane (api, etcd, scheduler) runs on master nodes, which manages entire thing Your apps run on worker nodes
  • 8. Interacting with Cluster Kubectl - a rich CLI to talk to Kubernetes API > alias kc = kubectl kc get nodes kc get nodes -o yaml kc edit node ip-xx-xx > kubectl get nodes NAME STATUS ROLES AGE VERSION ip-172-20-107-197.ec2.internal Ready node 170d v1.10.11 ip-172-20-107-51.ec2.internal Ready master 170d v1.10.11 ip-172-20-114-41.ec2.internal Ready node 170d v1.10.11 ip-172-20-52-179.ec2.internal Ready node 64d v1.10.11 ip-172-20-60-229.ec2.internal Ready master 170d v1.10.11 ip-172-20-69-22.ec2.internal Ready node 170d v1.10.11 ip-172-20-86-122.ec2.internal Ready master 170d v1.10.11
  • 9. Pod Small group of tightly coupled containers The smallest deployed object Shared namespace (IP, disk) Not durable and ephemeral in nature example: data-puller and web-service
  • 10. Deployment Represent an application deployment and controls number of pods. It handles: ● Scaling ● Updating software versions ● Rolling updates ● Pod health checking and healing ● Rollback apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment labels: app: nginx spec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9 ports: - containerPort: 80
  • 11. Services ● Acts as a load-balancer for pods ● Persistent endpoint ● exposes the pods (internal and external) ● Service is associate with pod through label selector - ClusterIP – exposed on cluster-internal IP - NodePort – exposed on nodes IP .via static port - LoadBalancer – exposed externally on providers NLB - ExternalName – map service to DNS name apiVersion: v1 kind: Service metadata: name: my-service spec: selector: app: my-app ports: - name: http protocol: TCP port: 80 targetPort: 9376 - name: https protocol: TCP port: 443 targetPort: 9377
  • 12. YAML Manifests YAML file to declare desired state of Kubernetes object types ● Define Kubernetes type ● Define type specification ● Labels / Annotations ● Metadata Use kubectl to apply them against cluster apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment annotations: app/instance: “nginx” labels: app: nginx spec: replicas: 3 selector: matchLabels: app: nginx
  • 13. Advance Objects ConfigMap, Secrets Volume, PersistentVolume, PVC DaemonSets, StatefulSets Jobs, CronJobs Third Party extensions (CRD)
  • 14. Demo (101) Shipping images to registry Running application on Kubernetes Scaling out demo app Rolling upgrades
  • 15. Demo (advance) Here is the source code - Github DockerCoins is made of 5 services: - rng = web service generating random bytes - hasher = web service computing hash of POSTed data - worker = background process calling rng and hasher - webui = web interface to watch progress - redis = data store (holds a counter updated by worker)
  • 16. Deploy ● Deploy Redis kubectl create deployment redis --image=redis ● Deploy everything else for SERVICE in hasher rng webui worker; do kubectl create deployment $SERVICE --image=$REGISTRY/$SERVICE:$TAG Done ● Expose deployments kubectl expose deployment redis --port 6379 kubectl expose deployment rng --port 80 kubectl expose deployment hasher --port 80 kubectl expose deploy/webui --type=NodePort --port=80
  • 17. We are always available to talk about your challenges moving forward towards microservices and containers. Dinesh Yadav (dinesh@razorops.com) https://razorops.com