SlideShare a Scribd company logo
1 of 65
Download to read offline
Before We Begin
Requirements:
● Minikube:
https://github.com/kubernetes/minikube
● Virtualbox*:
https://www.virtualbox.org/wiki/Downloads
● kubectl:
https://kubernetes.io/docs/tasks/tools/install-kubectl/
● k8s-intro-tutorials repo:
https://github.com/mrbobbytables/k8s-intro-tutorials
Getting Started
with
Kubernetes v1.10 05/2018
CC-BY 4.0
Kubernetes
$ whoami - Bob
Bob Killen
rkillen@umich.edu
Senior Research Cloud Administrator
CNCF Ambassador
Github: @mrbobbytables
Twitter: @mrbobbytables
$ whoami - Jeff
Jeffrey Sica
jsica@umich.edu
Senior Research Database Administrator
Github: @jeefy
Twitter: @jeefy
What is
Kubernetes?
What Does “Kubernetes” Mean?
Greek for “pilot” or
“Helmsman of a ship”
Image Source
What is Kubernetes?
● Originally sprung out of decades of container
experience from inside Google (Borg, Omega,
LMCTFY, etc.)
● Independent OSS project within the CNCF
● Production ready since July 2015.
● Automates deployment, scaling, and management of
application containers
Kubernetes Stats
What Does Kubernetes do?
● The “linux kernel of distributed systems”
● Abstracts away the underlying hardware
● You declare a state, and Kubernetes’ main purpose is
to make that happen
● Handles placement and scheduling of containers on
nodes
● Provides basic monitoring, logging, and health checking
● Enables containers to discover each other (important!)
Decouples Infrastructure and Scaling
● All services within Kubernetes are natively
Load Balanced.
● Can scale up and down dynamically.
● Used both to enable self-healing and
seamless upgrading or rollback of
applications.
Self Healing
Kubernetes will ALWAYS try and steer the cluster to its
desired state.
● Me: “I want 3 healthy instances of redis to always be
running.”
● Kubernetes: “Okay, I’ll ensure there are always 3
instances up and running.”
● Kubernetes: “Oh look, one has died. I’m going to
attempt to spin up a new one.”
Most Importantly...
Use the SAME API
across bare metal and
EVERY cloud provider!!!
A Few
Key Concepts...
Pods
● A pod is the atomic unit of
Kubernetes.
● Foundational building block of
Kubernetes Workloads.
● Pods are one or more containers
that share volumes, a network
namespace, and are a part of a
single context.
Pods
They are
also
Ephemeral!
(higher level objects manage replicas, fault-tolerance etc)
Services
● Services within Kubernetes are the unified method of
accessing the exposed workloads of Pods.
● They are a durable resource (unlike Pods)
● Given a static cluster-unique IP, and in conjunction with
kube-dns a static DNS name following the format of:
<service name>.<namespace>.svc.cluster.local
Architecture
Overview
Control Plane Components
● kube-apiserver
● etcd
● kube-controller-manager
● kube-scheduler
Node Components
● kubelet
● kube-proxy
● Container Runtime Engine
Kubernetes Networking
● Pod Network - Cluster-wide network used
for pod-to-pod communication managed by a
CNI (Container Network Interface) plugin.
● Service Network - Cluster-wide range of
Virtual IPs managed by kube-proxy for
service discovery.
Fundamental Networking Rules
● All containers within a pod can communicate with each
other unimpeded.
● All Pods can communicate with all other Pods without
NAT.
● All nodes can communicate with all Pods (and
vice-versa) without NAT.
● The IP that a Pod sees itself as is the same IP that
others see it as.
Concepts and Resources
The API
and
Object Model
API Overview
The REST API is the true
keystone of Kubernetes.
Everything within the
Kubernetes platform is
treated as an API Object
and has a corresponding
entry in the API itself.
Image Source
Object Model
● Objects within Kubernetes are a “record of intent”
○ Persistent entity that represent the desired state of
the object within the cluster.
● At a minimum all objects MUST have an apiVersion,
kind, and poses the nested fields metadata.name,
metadata.namespace, and metadata.uid.
Object Model Requirements
● apiVersion: Kubernetes API version of the Object
● kind: Type of Kubernetes Object
● metadata.name: Unique name of the Object
● metadata.namespace: Scoped environment name that the object
belongs to (will default to current).
● metadata.uid: The (generated) uid for an object.
apiVersion: v1
kind: Pod
metadata:
name: pod-example
namespace: default
uid: f8798d82-1185-11e8-94ce-080027b3c7a6
Lab
Using the API
(aka, using the CLI)
Concepts and Resources
Core
Objects
● Namespaces
● Pods
● Labels
● Selectors
● Services
Core Concepts
Kubernetes has several core building blocks
that make up the foundation of their higher
level components.
Namespaces
Pods
Selectors
Services
Labels
Namespaces
Namespaces are a logical cluster or environment, and are
the primary method of partitioning a cluster or scoping
access.
apiVersion: v1
kind: Namespace
metadata:
name: prod
labels:
app: MyBigWebApp
$ kubectl get ns --show-labels
NAME STATUS AGE LABELS
default Active 11h <none>
kube-public Active 11h <none>
kube-system Active 11h <none>
prod Active 6s app=MyBigWebApp
Default Namespaces
$ kubectl get ns --show-labels
NAME STATUS AGE LABELS
default Active 11h <none>
kube-public Active 11h <none>
kube-system Active 11h <none>
● default: The default
namespace for any object
without a namespace.
● kube-system: Acts as the
the home for objects and resources created by
Kubernetes itself.
● kube-public: A special namespace; readable by all
users that is reserved for cluster bootstrapping and
configuration.
Pods
● A pod is the atomic unit of
Kubernetes.
● It is the foundational building block
of Kubernetes Workloads.
● Pods are one or more containers
that share volumes, a network
namespace, and are a part of a
single context.
Pod Examples
apiVersion: v1
kind: Pod
metadata:
name: multi-container-example
spec:
containers:
- name: nginx
image: nginx:stable-alpine
volumeMounts:
- name: html
mountPath: /usr/share/nginx/html
- name: content
image: alpine:latest
command: ["/bin/sh", "-c"]
args:
- while true; do
date >> /html/index.html;
sleep 5;
done
volumeMounts:
- name: html
mountPath: /html
volumes:
- name: html
emptyDir: {}
apiVersion: v1
kind: Pod
metadata:
name: pod-example
spec:
containers:
- name: nginx
image: nginx:stable-alpine
ports:
- containerPort: 80
Labels
● Labels are key-value pairs that
are used to identify, describe and
group together related sets of
objects or resources.
Label Example
apiVersion: v1
kind: Pod
metadata:
name: pod-label-example
labels:
app: nginx
env: prod
spec:
containers:
- name: nginx
image: nginx:stable-alpine
ports:
- containerPort: 80
Selectors
Selectors use labels to filter
or select objects, and are
used throughout
Kubernetes.
apiVersion: v1
kind: Pod
metadata:
name: pod-label-example
labels:
app: nginx
env: prod
spec:
containers:
- name: nginx
image: nginx:stable-alpine
ports:
- containerPort: 80
nodeSelector:
gpu: nvidia
apiVersion: v1
kind: Pod
metadata:
name: pod-label-example
labels:
app: nginx
env: prod
spec:
containers:
- name: nginx
image: nginx:stable-alpine
ports:
- containerPort: 80
nodeSelector:
gpu: nvidia
Selector Example
Selector Types
Equality based selectors allow for
simple filtering (=,==, or !=).
Set-based selectors are supported
on a limited subset of objects.
However, they provide a method of
filtering on a set of values, and
supports multiple operators including:
in, notin, and exist.
selector:
matchLabels:
gpu: nvidia
selector:
matchExpressions:
- key: gpu
operator: in
values: [“nvidia”]
Service Types
There are 4 major service types:
● ClusterIP (default)
● NodePort
● LoadBalancer
● ExternalName
ClusterIP Service
● ClusterIP services
exposes a service on a
strictly cluster-internal
virtual IP.
apiVersion: v1
kind: Service
metadata:
name: example-prod
spec:
selector:
app: nginx
env: prod
ports:
- protocol: TCP
port: 80
targetPort: 80
Cluster IP Service
Name: example-prod
Selector: app=nginx,env=prod
Type: ClusterIP
IP: 10.96.28.176
Port: <unset> 80/TCP
TargetPort: 80/TCP
Endpoints: 10.255.16.3:80,
10.255.16.4:80
/ # nslookup example-prod.default.svc.cluster.local
Name: example-prod.default.svc.cluster.local
Address 1: 10.96.28.176 example-prod.default.svc.cluster.local
NodePort Service
apiVersion: v1
kind: Service
metadata:
name: example-prod
spec:
type: NodePort
selector:
app: nginx
env: prod
ports:
- nodePort: 32410
protocol: TCP
port: 80
targetPort: 80
● NodePort services extend the
ClusterIP service and
additionally exposes a port on
every node.
NodePort Service
Name: example-prod
Selector: app=nginx,env=prod
Type: NodePort
IP: 10.96.28.176
Port: <unset> 80/TCP
TargetPort: 80/TCP
NodePort: <unset> 32410/TCP
Endpoints: 10.255.16.3:80,
10.255.16.4:80
LoadBalancer Service
apiVersion: v1
kind: Service
metadata:
name: example-prod
spec:
type: LoadBalancer
selector:
app: nginx
env: prod
ports:
protocol: TCP
port: 80
targetPort: 80
● LoadBalancer services
extend NodePort and
works in conjunction
with an external system
to map a cluster external
IP to the exposed
service.
LoadBalancer Service
Name: example-prod
Selector: app=nginx,env=prod
Type: LoadBalancer
IP: 10.96.28.176
LoadBalancer
Ingress: 172.17.18.43
Port: <unset> 80/TCP
TargetPort: 80/TCP
NodePort: <unset> 32410/TCP
Endpoints: 10.255.16.3:80,
10.255.16.4:80
ExternalName Service
apiVersion: v1
kind: Service
metadata:
name: example-prod
spec:
type: ExternalName
externalName: example.com
● ExternalName is used
to reference endpoints
OUTSIDE the cluster.
● It creates an internal
CNAME DNS entry that
aliases another.
Lab
Exploring
the Core
Lab
Exploring
the Core
Concepts and Resources
Workloads ● ReplicaSet
● Deployment
Workloads
Workloads within Kubernetes are higher level
objects that manage Pods or other higher level
objects.
In ALL CASES a Pod Template is included,
and acts the base tier of management.
Pod Template
● Workload Controllers manage instances of Pods based
off a provided template
● Pod Templates are Pod specs with limited metadata
● Controllers use
Pod Templates to
make actual pods
apiVersion: v1
kind: Pod
metadata:
name: pod-example
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ReplicaSet
● Primary method of managing pod replicas and their
lifecycle
● Includes their scheduling, scaling, and deletion
● Their job is simple: Always ensure the desired
number of pods are running
ReplicaSet
● replicas: The desired
number of instances of the Pod.
● selector:The label selector
for the ReplicaSet will manage
ALL Pod instances that it
targets; whether it’s desired or
not.
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: rs-example
spec:
replicas: 3
selector:
matchLabels:
app: nginx
env: prod
template:
<pod template>
ReplicaSet
$ kubectl describe rs rs-example
Name: rs-example
Namespace: default
Selector: app=nginx,env=prod
Labels: app=nginx
env=prod
Annotations: <none>
Replicas: 3 current / 3 desired
Pods Status: 3 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
Labels: app=nginx
env=prod
Containers:
nginx:
Image: nginx:stable-alpine
Port: 80/TCP
Environment: <none>
Mounts: <none>
Volumes: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal SuccessfulCreate 16s replicaset-controller Created pod: rs-example-mkll2
Normal SuccessfulCreate 16s replicaset-controller Created pod: rs-example-b7bcg
Normal SuccessfulCreate 16s replicaset-controller Created pod: rs-example-9l4dt
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: rs-example
spec:
replicas: 3
selector:
matchLabels:
app: nginx
env: prod
template:
metadata:
labels:
app: nginx
env: prod
spec:
containers:
- name: nginx
image: nginx:stable-alpine
ports:
- containerPort: 80
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
rs-example-9l4dt 1/1 Running 0 1h
rs-example-b7bcg 1/1 Running 0 1h
rs-example-mkll2 1/1 Running 0 1h
Deployment
● Declarative method of managing Pods via ReplicaSets
● Provide rollback functionality and update control
● Updates are managed through the pod-template-hash
label.
● Each iteration creates a unique label that is assigned to
both the ReplicaSet and subsequent Pods
Deployment
● revisionHistoryLimit: The number of
previous iterations of the Deployment to
retain.
● strategy: Describes the method of
updating the Pods based on the type. Valid
options are RollingUpdate or Recreate.
○ RollingUpdate: Cycles through
updating the Pods according to the
parameters: maxSurge and
maxUnavailable.
○ Recreate: All existing Pods are killed
before the new ones are created.
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-example
spec:
replicas: 3
revisionHistoryLimit: 3
selector:
matchLabels:
app: nginx
env: prod
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
<pod template>
RollingUpdate Deployment
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
mydep-6766777fff-9r2zn 1/1 Running 0 5h
mydep-6766777fff-hsfz9 1/1 Running 0 5h
mydep-6766777fff-sjxhf 1/1 Running 0 5h
R1 pod-template-hash: 2322333999
R1 safe pod-template-hash: 676677fff
R2 pod-template-hash: 1093993828
R2 safe pod-template-hash: 54f7ff7d6d
$ kubectl get replicaset
NAME DESIRED CURRENT READY AGE
mydep-6766777fff 3 3 3 5h
Updating pod template generates a
new ReplicaSet revision.
RollingUpdate Deployment
$ kubectl get replicaset
NAME DESIRED CURRENT READY AGE
mydep-54f7ff7d6d 1 1 1 5s
mydep-6766777fff 2 3 3 5h
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
mydep-54f7ff7d6d-9gvll 1/1 Running 0 2s
mydep-6766777fff-9r2zn 1/1 Running 0 5h
mydep-6766777fff-hsfz9 1/1 Running 0 5h
mydep-6766777fff-sjxhf 1/1 Running 0 5h
R1 pod-template-hash: 2322333999
R1 safe pod-template-hash: 676677fff
R2 pod-template-hash: 1093993828
R2 safe pod-template-hash: 54f7ff7d6d
New ReplicaSet is initially scaled up
based on maxSurge.
RollingUpdate Deployment
R1 pod-template-hash: 2322333999
R1 safe pod-template-hash: 676677fff
R2 pod-template-hash: 1093993828
R2 safe pod-template-hash: 54f7ff7d6d
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
mydep-54f7ff7d6d-9gvll 1/1 Running 0 5s
mydep-54f7ff7d6d-cqvlq 1/1 Running 0 2s
mydep-6766777fff-9r2zn 1/1 Running 0 5h
mydep-6766777fff-hsfz9 1/1 Running 0 5h
$ kubectl get replicaset
NAME DESIRED CURRENT READY AGE
mydep-54f7ff7d6d 2 2 2 8s
mydep-6766777fff 2 2 2 5h
Phase out of old Pods managed by
maxSurge and maxUnavailable.
RollingUpdate Deployment
$ kubectl get replicaset
NAME DESIRED CURRENT READY AGE
mydep-54f7ff7d6d 3 3 3 10s
mydep-6766777fff 0 1 1 5h
R1 pod-template-hash: 2322333999
R1 safe pod-template-hash: 676677fff
R2 pod-template-hash: 1093993828
R2 safe pod-template-hash: 54f7ff7d6d
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
mydep-54f7ff7d6d-9gvll 1/1 Running 0 7s
mydep-54f7ff7d6d-cqvlq 1/1 Running 0 5s
mydep-54f7ff7d6d-gccr6 1/1 Running 0 2s
mydep-6766777fff-9r2zn 1/1 Running 0 5h
Phase out of old Pods managed by
maxSurge and maxUnavailable.
RollingUpdate Deployment
$ kubectl get replicaset
NAME DESIRED CURRENT READY AGE
mydep-54f7ff7d6d 3 3 3 13s
mydep-6766777fff 0 0 0 5h
R1 pod-template-hash: 2322333999
R1 safe pod-template-hash: 676677fff
R2 pod-template-hash: 1093993828
R2 safe pod-template-hash: 54f7ff7d6d
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
mydep-54f7ff7d6d-9gvll 1/1 Running 0 10s
mydep-54f7ff7d6d-cqvlq 1/1 Running 0 8s
mydep-54f7ff7d6d-gccr6 1/1 Running 0 5s
Phase out of old Pods managed by
maxSurge and maxUnavailable.
RollingUpdate Deployment
R1 pod-template-hash: 2322333999
R1 safe pod-template-hash: 676677fff
R2 pod-template-hash: 1093993828
R2 safe pod-template-hash: 54f7ff7d6d
$ kubectl get replicaset
NAME DESIRED CURRENT READY AGE
mydep-54f7ff7d6d 3 3 3 15s
mydep-6766777fff 0 0 0 5h
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
mydep-54f7ff7d6d-9gvll 1/1 Running 0 12s
mydep-54f7ff7d6d-cqvlq 1/1 Running 0 10s
mydep-54f7ff7d6d-gccr6 1/1 Running 0 7s
Updated to new deployment revision
completed.
Lab
Using Workloads
Where to go
From Here
Links
● Free Kubernetes Courses
https://www.edx.org/
● Interactive Kubernetes Tutorials
https://www.katacoda.com/courses/kubernetes
● Learn Kubernetes the Hard Way
https://github.com/kelseyhightower/kubernetes-the-hard-way
● Official Kubernetes Youtube Channel
https://www.youtube.com/channel/UCZ2bu0qutTOM0tHYa_jkIwg
● Official CNCF Youtube Channel
https://www.youtube.com/channel/UCvqbFHwN-nwalWPjPUKpvTA
● Track to becoming a CKA/CKAD (Certified Kubernetes Administrator/Application Developer)
https://www.cncf.io/certification/expert/
● Awesome Kubernetes
https://www.gitbook.com/book/ramitsurana/awesome-kubernetes/details

More Related Content

What's hot

Brief Introduction To Kubernetes
Brief Introduction To KubernetesBrief Introduction To Kubernetes
Brief Introduction To KubernetesAvinash Ketkar
 
The (mutable) config management showdown
The (mutable) config management showdownThe (mutable) config management showdown
The (mutable) config management showdownBob Killen
 
Evolution of containers to kubernetes
Evolution of containers to kubernetesEvolution of containers to kubernetes
Evolution of containers to kubernetesKrishna-Kumar
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetesRishabh Indoria
 
Kubernetes a comprehensive overview
Kubernetes   a comprehensive overviewKubernetes   a comprehensive overview
Kubernetes a comprehensive overviewGabriel Carro
 
Kubernetes presentation
Kubernetes presentationKubernetes presentation
Kubernetes presentationGauranG Bajpai
 
Kubernetes automation in production
Kubernetes automation in productionKubernetes automation in production
Kubernetes automation in productionPaul Bakker
 
Kubernetes: An Introduction to the Open Source Container Orchestration Platform
Kubernetes: An Introduction to the Open Source Container Orchestration PlatformKubernetes: An Introduction to the Open Source Container Orchestration Platform
Kubernetes: An Introduction to the Open Source Container Orchestration PlatformMichael O'Sullivan
 
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
 
Kubernetes - introduction
Kubernetes - introductionKubernetes - introduction
Kubernetes - introductionSparkbit
 
A Peek Behind the Curtain: Managing the Kubernetes Contributor Community
A Peek Behind the Curtain: Managing the Kubernetes Contributor CommunityA Peek Behind the Curtain: Managing the Kubernetes Contributor Community
A Peek Behind the Curtain: Managing the Kubernetes Contributor CommunityBob Killen
 
Deploying your first application with Kubernetes
Deploying your first application with KubernetesDeploying your first application with Kubernetes
Deploying your first application with KubernetesOVHcloud
 
K8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals TrainingK8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals TrainingPiotr Perzyna
 
Kubernetes Introduction
Kubernetes IntroductionKubernetes Introduction
Kubernetes IntroductionEric Gustafson
 
Kubernetes for Beginners: An Introductory Guide
Kubernetes for Beginners: An Introductory GuideKubernetes for Beginners: An Introductory Guide
Kubernetes for Beginners: An Introductory GuideBytemark
 
Ansible, integration testing, and you.
Ansible, integration testing, and you.Ansible, integration testing, and you.
Ansible, integration testing, and you.Bob Killen
 

What's hot (20)

Brief Introduction To Kubernetes
Brief Introduction To KubernetesBrief Introduction To Kubernetes
Brief Introduction To Kubernetes
 
The (mutable) config management showdown
The (mutable) config management showdownThe (mutable) config management showdown
The (mutable) config management showdown
 
Kubernetes Basics
Kubernetes BasicsKubernetes Basics
Kubernetes Basics
 
Evolution of containers to kubernetes
Evolution of containers to kubernetesEvolution of containers to kubernetes
Evolution of containers to kubernetes
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetes
 
DevOps with Kubernetes
DevOps with KubernetesDevOps with Kubernetes
DevOps with Kubernetes
 
Kubernetes a comprehensive overview
Kubernetes   a comprehensive overviewKubernetes   a comprehensive overview
Kubernetes a comprehensive overview
 
Kubernetes presentation
Kubernetes presentationKubernetes presentation
Kubernetes presentation
 
Kubernetes automation in production
Kubernetes automation in productionKubernetes automation in production
Kubernetes automation in production
 
Kubernetes: An Introduction to the Open Source Container Orchestration Platform
Kubernetes: An Introduction to the Open Source Container Orchestration PlatformKubernetes: An Introduction to the Open Source Container Orchestration Platform
Kubernetes: An Introduction to the Open Source Container Orchestration Platform
 
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
 
Kubernetes - introduction
Kubernetes - introductionKubernetes - introduction
Kubernetes - introduction
 
Intro to Kubernetes
Intro to KubernetesIntro to Kubernetes
Intro to Kubernetes
 
A Peek Behind the Curtain: Managing the Kubernetes Contributor Community
A Peek Behind the Curtain: Managing the Kubernetes Contributor CommunityA Peek Behind the Curtain: Managing the Kubernetes Contributor Community
A Peek Behind the Curtain: Managing the Kubernetes Contributor Community
 
Deploying your first application with Kubernetes
Deploying your first application with KubernetesDeploying your first application with Kubernetes
Deploying your first application with Kubernetes
 
Introduction to Kubernetes
Introduction to KubernetesIntroduction to Kubernetes
Introduction to Kubernetes
 
K8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals TrainingK8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals Training
 
Kubernetes Introduction
Kubernetes IntroductionKubernetes Introduction
Kubernetes Introduction
 
Kubernetes for Beginners: An Introductory Guide
Kubernetes for Beginners: An Introductory GuideKubernetes for Beginners: An Introductory Guide
Kubernetes for Beginners: An Introductory Guide
 
Ansible, integration testing, and you.
Ansible, integration testing, and you.Ansible, integration testing, and you.
Ansible, integration testing, and you.
 

Similar to Kubernetes Core Concepts

Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetesGabriel Carro
 
Kubernetes #1 intro
Kubernetes #1   introKubernetes #1   intro
Kubernetes #1 introTerry Cho
 
The path to a serverless-native era with Kubernetes
The path to a serverless-native era with KubernetesThe path to a serverless-native era with Kubernetes
The path to a serverless-native era with Kubernetessparkfabrik
 
DevJam 2019 - Introduction to Kubernetes
DevJam 2019 - Introduction to KubernetesDevJam 2019 - Introduction to Kubernetes
DevJam 2019 - Introduction to KubernetesRonny Trommer
 
Continuous Deployment with Kubernetes, Docker and GitLab CI
Continuous Deployment with Kubernetes, Docker and GitLab CIContinuous Deployment with Kubernetes, Docker and GitLab CI
Continuous Deployment with Kubernetes, Docker and GitLab CIalexanderkiel
 
4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes
4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes
4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetesJuraj Hantak
 
An intro to Kubernetes operators
An intro to Kubernetes operatorsAn intro to Kubernetes operators
An intro to Kubernetes operatorsJ On The Beach
 
Comparison of existing cni plugins for kubernetes
Comparison of existing cni plugins for kubernetesComparison of existing cni plugins for kubernetes
Comparison of existing cni plugins for kubernetesAdam Hamsik
 
Kubernetes workshop -_the_basics
Kubernetes workshop -_the_basicsKubernetes workshop -_the_basics
Kubernetes workshop -_the_basicsSjuul Janssen
 
01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware
01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware
01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMwareVMUG IT
 
The App Developer's Kubernetes Toolbox
The App Developer's Kubernetes ToolboxThe App Developer's Kubernetes Toolbox
The App Developer's Kubernetes ToolboxNebulaworks
 
Kubernetes: від знайомства до використання у CI/CD
Kubernetes: від знайомства до використання у CI/CDKubernetes: від знайомства до використання у CI/CD
Kubernetes: від знайомства до використання у CI/CDStfalcon Meetups
 
Kubernetes - how to orchestrate containers
Kubernetes - how to orchestrate containersKubernetes - how to orchestrate containers
Kubernetes - how to orchestrate containersinovex GmbH
 
08 - kubernetes.pptx
08 - kubernetes.pptx08 - kubernetes.pptx
08 - kubernetes.pptxRanjithM61
 
Composing services with Kubernetes
Composing services with KubernetesComposing services with Kubernetes
Composing services with KubernetesBart Spaans
 

Similar to Kubernetes Core Concepts (20)

Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetes
 
Container Orchestration using kubernetes
Container Orchestration using kubernetesContainer Orchestration using kubernetes
Container Orchestration using kubernetes
 
Kubernetes #1 intro
Kubernetes #1   introKubernetes #1   intro
Kubernetes #1 intro
 
The path to a serverless-native era with Kubernetes
The path to a serverless-native era with KubernetesThe path to a serverless-native era with Kubernetes
The path to a serverless-native era with Kubernetes
 
DevJam 2019 - Introduction to Kubernetes
DevJam 2019 - Introduction to KubernetesDevJam 2019 - Introduction to Kubernetes
DevJam 2019 - Introduction to Kubernetes
 
Continuous Deployment with Kubernetes, Docker and GitLab CI
Continuous Deployment with Kubernetes, Docker and GitLab CIContinuous Deployment with Kubernetes, Docker and GitLab CI
Continuous Deployment with Kubernetes, Docker and GitLab CI
 
Kubernetes
KubernetesKubernetes
Kubernetes
 
4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes
4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes
4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes
 
An intro to Kubernetes operators
An intro to Kubernetes operatorsAn intro to Kubernetes operators
An intro to Kubernetes operators
 
Comparison of existing cni plugins for kubernetes
Comparison of existing cni plugins for kubernetesComparison of existing cni plugins for kubernetes
Comparison of existing cni plugins for kubernetes
 
Kubernetes workshop -_the_basics
Kubernetes workshop -_the_basicsKubernetes workshop -_the_basics
Kubernetes workshop -_the_basics
 
01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware
01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware
01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware
 
Kubernetes-Meetup
Kubernetes-MeetupKubernetes-Meetup
Kubernetes-Meetup
 
The App Developer's Kubernetes Toolbox
The App Developer's Kubernetes ToolboxThe App Developer's Kubernetes Toolbox
The App Developer's Kubernetes Toolbox
 
Kubernetes: від знайомства до використання у CI/CD
Kubernetes: від знайомства до використання у CI/CDKubernetes: від знайомства до використання у CI/CD
Kubernetes: від знайомства до використання у CI/CD
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetes
 
Kubernetes basics and hands on exercise
Kubernetes basics and hands on exerciseKubernetes basics and hands on exercise
Kubernetes basics and hands on exercise
 
Kubernetes - how to orchestrate containers
Kubernetes - how to orchestrate containersKubernetes - how to orchestrate containers
Kubernetes - how to orchestrate containers
 
08 - kubernetes.pptx
08 - kubernetes.pptx08 - kubernetes.pptx
08 - kubernetes.pptx
 
Composing services with Kubernetes
Composing services with KubernetesComposing services with Kubernetes
Composing services with Kubernetes
 

More from Bob Killen

Tackling New Challenges in a Virtual Focused Community
Tackling New Challenges in a Virtual Focused CommunityTackling New Challenges in a Virtual Focused Community
Tackling New Challenges in a Virtual Focused CommunityBob Killen
 
KubeCon EU 2021 Keynote: Shaping Kubernetes Community Culture
KubeCon EU 2021 Keynote: Shaping Kubernetes Community CultureKubeCon EU 2021 Keynote: Shaping Kubernetes Community Culture
KubeCon EU 2021 Keynote: Shaping Kubernetes Community CultureBob Killen
 
Intro to Kubernetes SIG Contributor Experience
Intro to Kubernetes SIG Contributor ExperienceIntro to Kubernetes SIG Contributor Experience
Intro to Kubernetes SIG Contributor ExperienceBob Killen
 
Intro to the CNCF Research User Group
Intro to the CNCF Research User GroupIntro to the CNCF Research User Group
Intro to the CNCF Research User GroupBob Killen
 
Kubernetes The New Research Platform
Kubernetes The New Research PlatformKubernetes The New Research Platform
Kubernetes The New Research PlatformBob Killen
 
Pluggable Infrastructure with CI/CD and Docker
Pluggable Infrastructure with CI/CD and DockerPluggable Infrastructure with CI/CD and Docker
Pluggable Infrastructure with CI/CD and DockerBob Killen
 

More from Bob Killen (6)

Tackling New Challenges in a Virtual Focused Community
Tackling New Challenges in a Virtual Focused CommunityTackling New Challenges in a Virtual Focused Community
Tackling New Challenges in a Virtual Focused Community
 
KubeCon EU 2021 Keynote: Shaping Kubernetes Community Culture
KubeCon EU 2021 Keynote: Shaping Kubernetes Community CultureKubeCon EU 2021 Keynote: Shaping Kubernetes Community Culture
KubeCon EU 2021 Keynote: Shaping Kubernetes Community Culture
 
Intro to Kubernetes SIG Contributor Experience
Intro to Kubernetes SIG Contributor ExperienceIntro to Kubernetes SIG Contributor Experience
Intro to Kubernetes SIG Contributor Experience
 
Intro to the CNCF Research User Group
Intro to the CNCF Research User GroupIntro to the CNCF Research User Group
Intro to the CNCF Research User Group
 
Kubernetes The New Research Platform
Kubernetes The New Research PlatformKubernetes The New Research Platform
Kubernetes The New Research Platform
 
Pluggable Infrastructure with CI/CD and Docker
Pluggable Infrastructure with CI/CD and DockerPluggable Infrastructure with CI/CD and Docker
Pluggable Infrastructure with CI/CD and Docker
 

Recently uploaded

Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 

Recently uploaded (20)

Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 

Kubernetes Core Concepts

  • 1. Before We Begin Requirements: ● Minikube: https://github.com/kubernetes/minikube ● Virtualbox*: https://www.virtualbox.org/wiki/Downloads ● kubectl: https://kubernetes.io/docs/tasks/tools/install-kubectl/ ● k8s-intro-tutorials repo: https://github.com/mrbobbytables/k8s-intro-tutorials
  • 2. Getting Started with Kubernetes v1.10 05/2018 CC-BY 4.0 Kubernetes
  • 3. $ whoami - Bob Bob Killen rkillen@umich.edu Senior Research Cloud Administrator CNCF Ambassador Github: @mrbobbytables Twitter: @mrbobbytables
  • 4. $ whoami - Jeff Jeffrey Sica jsica@umich.edu Senior Research Database Administrator Github: @jeefy Twitter: @jeefy
  • 6. What Does “Kubernetes” Mean? Greek for “pilot” or “Helmsman of a ship” Image Source
  • 7. What is Kubernetes? ● Originally sprung out of decades of container experience from inside Google (Borg, Omega, LMCTFY, etc.) ● Independent OSS project within the CNCF ● Production ready since July 2015. ● Automates deployment, scaling, and management of application containers
  • 9. What Does Kubernetes do? ● The “linux kernel of distributed systems” ● Abstracts away the underlying hardware ● You declare a state, and Kubernetes’ main purpose is to make that happen ● Handles placement and scheduling of containers on nodes ● Provides basic monitoring, logging, and health checking ● Enables containers to discover each other (important!)
  • 10. Decouples Infrastructure and Scaling ● All services within Kubernetes are natively Load Balanced. ● Can scale up and down dynamically. ● Used both to enable self-healing and seamless upgrading or rollback of applications.
  • 11. Self Healing Kubernetes will ALWAYS try and steer the cluster to its desired state. ● Me: “I want 3 healthy instances of redis to always be running.” ● Kubernetes: “Okay, I’ll ensure there are always 3 instances up and running.” ● Kubernetes: “Oh look, one has died. I’m going to attempt to spin up a new one.”
  • 12. Most Importantly... Use the SAME API across bare metal and EVERY cloud provider!!!
  • 14. Pods ● A pod is the atomic unit of Kubernetes. ● Foundational building block of Kubernetes Workloads. ● Pods are one or more containers that share volumes, a network namespace, and are a part of a single context.
  • 15. Pods They are also Ephemeral! (higher level objects manage replicas, fault-tolerance etc)
  • 16. Services ● Services within Kubernetes are the unified method of accessing the exposed workloads of Pods. ● They are a durable resource (unlike Pods) ● Given a static cluster-unique IP, and in conjunction with kube-dns a static DNS name following the format of: <service name>.<namespace>.svc.cluster.local
  • 18.
  • 19. Control Plane Components ● kube-apiserver ● etcd ● kube-controller-manager ● kube-scheduler
  • 20. Node Components ● kubelet ● kube-proxy ● Container Runtime Engine
  • 21. Kubernetes Networking ● Pod Network - Cluster-wide network used for pod-to-pod communication managed by a CNI (Container Network Interface) plugin. ● Service Network - Cluster-wide range of Virtual IPs managed by kube-proxy for service discovery.
  • 22. Fundamental Networking Rules ● All containers within a pod can communicate with each other unimpeded. ● All Pods can communicate with all other Pods without NAT. ● All nodes can communicate with all Pods (and vice-versa) without NAT. ● The IP that a Pod sees itself as is the same IP that others see it as.
  • 23. Concepts and Resources The API and Object Model
  • 24. API Overview The REST API is the true keystone of Kubernetes. Everything within the Kubernetes platform is treated as an API Object and has a corresponding entry in the API itself. Image Source
  • 25. Object Model ● Objects within Kubernetes are a “record of intent” ○ Persistent entity that represent the desired state of the object within the cluster. ● At a minimum all objects MUST have an apiVersion, kind, and poses the nested fields metadata.name, metadata.namespace, and metadata.uid.
  • 26. Object Model Requirements ● apiVersion: Kubernetes API version of the Object ● kind: Type of Kubernetes Object ● metadata.name: Unique name of the Object ● metadata.namespace: Scoped environment name that the object belongs to (will default to current). ● metadata.uid: The (generated) uid for an object. apiVersion: v1 kind: Pod metadata: name: pod-example namespace: default uid: f8798d82-1185-11e8-94ce-080027b3c7a6
  • 27. Lab Using the API (aka, using the CLI)
  • 28. Concepts and Resources Core Objects ● Namespaces ● Pods ● Labels ● Selectors ● Services
  • 29. Core Concepts Kubernetes has several core building blocks that make up the foundation of their higher level components. Namespaces Pods Selectors Services Labels
  • 30. Namespaces Namespaces are a logical cluster or environment, and are the primary method of partitioning a cluster or scoping access. apiVersion: v1 kind: Namespace metadata: name: prod labels: app: MyBigWebApp $ kubectl get ns --show-labels NAME STATUS AGE LABELS default Active 11h <none> kube-public Active 11h <none> kube-system Active 11h <none> prod Active 6s app=MyBigWebApp
  • 31. Default Namespaces $ kubectl get ns --show-labels NAME STATUS AGE LABELS default Active 11h <none> kube-public Active 11h <none> kube-system Active 11h <none> ● default: The default namespace for any object without a namespace. ● kube-system: Acts as the the home for objects and resources created by Kubernetes itself. ● kube-public: A special namespace; readable by all users that is reserved for cluster bootstrapping and configuration.
  • 32. Pods ● A pod is the atomic unit of Kubernetes. ● It is the foundational building block of Kubernetes Workloads. ● Pods are one or more containers that share volumes, a network namespace, and are a part of a single context.
  • 33. Pod Examples apiVersion: v1 kind: Pod metadata: name: multi-container-example spec: containers: - name: nginx image: nginx:stable-alpine volumeMounts: - name: html mountPath: /usr/share/nginx/html - name: content image: alpine:latest command: ["/bin/sh", "-c"] args: - while true; do date >> /html/index.html; sleep 5; done volumeMounts: - name: html mountPath: /html volumes: - name: html emptyDir: {} apiVersion: v1 kind: Pod metadata: name: pod-example spec: containers: - name: nginx image: nginx:stable-alpine ports: - containerPort: 80
  • 34. Labels ● Labels are key-value pairs that are used to identify, describe and group together related sets of objects or resources.
  • 35. Label Example apiVersion: v1 kind: Pod metadata: name: pod-label-example labels: app: nginx env: prod spec: containers: - name: nginx image: nginx:stable-alpine ports: - containerPort: 80
  • 36. Selectors Selectors use labels to filter or select objects, and are used throughout Kubernetes. apiVersion: v1 kind: Pod metadata: name: pod-label-example labels: app: nginx env: prod spec: containers: - name: nginx image: nginx:stable-alpine ports: - containerPort: 80 nodeSelector: gpu: nvidia
  • 37. apiVersion: v1 kind: Pod metadata: name: pod-label-example labels: app: nginx env: prod spec: containers: - name: nginx image: nginx:stable-alpine ports: - containerPort: 80 nodeSelector: gpu: nvidia Selector Example
  • 38. Selector Types Equality based selectors allow for simple filtering (=,==, or !=). Set-based selectors are supported on a limited subset of objects. However, they provide a method of filtering on a set of values, and supports multiple operators including: in, notin, and exist. selector: matchLabels: gpu: nvidia selector: matchExpressions: - key: gpu operator: in values: [“nvidia”]
  • 39. Service Types There are 4 major service types: ● ClusterIP (default) ● NodePort ● LoadBalancer ● ExternalName
  • 40. ClusterIP Service ● ClusterIP services exposes a service on a strictly cluster-internal virtual IP. apiVersion: v1 kind: Service metadata: name: example-prod spec: selector: app: nginx env: prod ports: - protocol: TCP port: 80 targetPort: 80
  • 41. Cluster IP Service Name: example-prod Selector: app=nginx,env=prod Type: ClusterIP IP: 10.96.28.176 Port: <unset> 80/TCP TargetPort: 80/TCP Endpoints: 10.255.16.3:80, 10.255.16.4:80 / # nslookup example-prod.default.svc.cluster.local Name: example-prod.default.svc.cluster.local Address 1: 10.96.28.176 example-prod.default.svc.cluster.local
  • 42. NodePort Service apiVersion: v1 kind: Service metadata: name: example-prod spec: type: NodePort selector: app: nginx env: prod ports: - nodePort: 32410 protocol: TCP port: 80 targetPort: 80 ● NodePort services extend the ClusterIP service and additionally exposes a port on every node.
  • 43. NodePort Service Name: example-prod Selector: app=nginx,env=prod Type: NodePort IP: 10.96.28.176 Port: <unset> 80/TCP TargetPort: 80/TCP NodePort: <unset> 32410/TCP Endpoints: 10.255.16.3:80, 10.255.16.4:80
  • 44. LoadBalancer Service apiVersion: v1 kind: Service metadata: name: example-prod spec: type: LoadBalancer selector: app: nginx env: prod ports: protocol: TCP port: 80 targetPort: 80 ● LoadBalancer services extend NodePort and works in conjunction with an external system to map a cluster external IP to the exposed service.
  • 45. LoadBalancer Service Name: example-prod Selector: app=nginx,env=prod Type: LoadBalancer IP: 10.96.28.176 LoadBalancer Ingress: 172.17.18.43 Port: <unset> 80/TCP TargetPort: 80/TCP NodePort: <unset> 32410/TCP Endpoints: 10.255.16.3:80, 10.255.16.4:80
  • 46. ExternalName Service apiVersion: v1 kind: Service metadata: name: example-prod spec: type: ExternalName externalName: example.com ● ExternalName is used to reference endpoints OUTSIDE the cluster. ● It creates an internal CNAME DNS entry that aliases another.
  • 49. Concepts and Resources Workloads ● ReplicaSet ● Deployment
  • 50. Workloads Workloads within Kubernetes are higher level objects that manage Pods or other higher level objects. In ALL CASES a Pod Template is included, and acts the base tier of management.
  • 51. Pod Template ● Workload Controllers manage instances of Pods based off a provided template ● Pod Templates are Pod specs with limited metadata ● Controllers use Pod Templates to make actual pods apiVersion: v1 kind: Pod metadata: name: pod-example labels: app: nginx spec: containers: - name: nginx image: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx
  • 52. ReplicaSet ● Primary method of managing pod replicas and their lifecycle ● Includes their scheduling, scaling, and deletion ● Their job is simple: Always ensure the desired number of pods are running
  • 53. ReplicaSet ● replicas: The desired number of instances of the Pod. ● selector:The label selector for the ReplicaSet will manage ALL Pod instances that it targets; whether it’s desired or not. apiVersion: apps/v1 kind: ReplicaSet metadata: name: rs-example spec: replicas: 3 selector: matchLabels: app: nginx env: prod template: <pod template>
  • 54. ReplicaSet $ kubectl describe rs rs-example Name: rs-example Namespace: default Selector: app=nginx,env=prod Labels: app=nginx env=prod Annotations: <none> Replicas: 3 current / 3 desired Pods Status: 3 Running / 0 Waiting / 0 Succeeded / 0 Failed Pod Template: Labels: app=nginx env=prod Containers: nginx: Image: nginx:stable-alpine Port: 80/TCP Environment: <none> Mounts: <none> Volumes: <none> Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal SuccessfulCreate 16s replicaset-controller Created pod: rs-example-mkll2 Normal SuccessfulCreate 16s replicaset-controller Created pod: rs-example-b7bcg Normal SuccessfulCreate 16s replicaset-controller Created pod: rs-example-9l4dt apiVersion: apps/v1 kind: ReplicaSet metadata: name: rs-example spec: replicas: 3 selector: matchLabels: app: nginx env: prod template: metadata: labels: app: nginx env: prod spec: containers: - name: nginx image: nginx:stable-alpine ports: - containerPort: 80 $ kubectl get pods NAME READY STATUS RESTARTS AGE rs-example-9l4dt 1/1 Running 0 1h rs-example-b7bcg 1/1 Running 0 1h rs-example-mkll2 1/1 Running 0 1h
  • 55. Deployment ● Declarative method of managing Pods via ReplicaSets ● Provide rollback functionality and update control ● Updates are managed through the pod-template-hash label. ● Each iteration creates a unique label that is assigned to both the ReplicaSet and subsequent Pods
  • 56. Deployment ● revisionHistoryLimit: The number of previous iterations of the Deployment to retain. ● strategy: Describes the method of updating the Pods based on the type. Valid options are RollingUpdate or Recreate. ○ RollingUpdate: Cycles through updating the Pods according to the parameters: maxSurge and maxUnavailable. ○ Recreate: All existing Pods are killed before the new ones are created. apiVersion: apps/v1 kind: Deployment metadata: name: deploy-example spec: replicas: 3 revisionHistoryLimit: 3 selector: matchLabels: app: nginx env: prod strategy: type: RollingUpdate rollingUpdate: maxSurge: 1 maxUnavailable: 0 template: <pod template>
  • 57. RollingUpdate Deployment $ kubectl get pods NAME READY STATUS RESTARTS AGE mydep-6766777fff-9r2zn 1/1 Running 0 5h mydep-6766777fff-hsfz9 1/1 Running 0 5h mydep-6766777fff-sjxhf 1/1 Running 0 5h R1 pod-template-hash: 2322333999 R1 safe pod-template-hash: 676677fff R2 pod-template-hash: 1093993828 R2 safe pod-template-hash: 54f7ff7d6d $ kubectl get replicaset NAME DESIRED CURRENT READY AGE mydep-6766777fff 3 3 3 5h Updating pod template generates a new ReplicaSet revision.
  • 58. RollingUpdate Deployment $ kubectl get replicaset NAME DESIRED CURRENT READY AGE mydep-54f7ff7d6d 1 1 1 5s mydep-6766777fff 2 3 3 5h $ kubectl get pods NAME READY STATUS RESTARTS AGE mydep-54f7ff7d6d-9gvll 1/1 Running 0 2s mydep-6766777fff-9r2zn 1/1 Running 0 5h mydep-6766777fff-hsfz9 1/1 Running 0 5h mydep-6766777fff-sjxhf 1/1 Running 0 5h R1 pod-template-hash: 2322333999 R1 safe pod-template-hash: 676677fff R2 pod-template-hash: 1093993828 R2 safe pod-template-hash: 54f7ff7d6d New ReplicaSet is initially scaled up based on maxSurge.
  • 59. RollingUpdate Deployment R1 pod-template-hash: 2322333999 R1 safe pod-template-hash: 676677fff R2 pod-template-hash: 1093993828 R2 safe pod-template-hash: 54f7ff7d6d $ kubectl get pods NAME READY STATUS RESTARTS AGE mydep-54f7ff7d6d-9gvll 1/1 Running 0 5s mydep-54f7ff7d6d-cqvlq 1/1 Running 0 2s mydep-6766777fff-9r2zn 1/1 Running 0 5h mydep-6766777fff-hsfz9 1/1 Running 0 5h $ kubectl get replicaset NAME DESIRED CURRENT READY AGE mydep-54f7ff7d6d 2 2 2 8s mydep-6766777fff 2 2 2 5h Phase out of old Pods managed by maxSurge and maxUnavailable.
  • 60. RollingUpdate Deployment $ kubectl get replicaset NAME DESIRED CURRENT READY AGE mydep-54f7ff7d6d 3 3 3 10s mydep-6766777fff 0 1 1 5h R1 pod-template-hash: 2322333999 R1 safe pod-template-hash: 676677fff R2 pod-template-hash: 1093993828 R2 safe pod-template-hash: 54f7ff7d6d $ kubectl get pods NAME READY STATUS RESTARTS AGE mydep-54f7ff7d6d-9gvll 1/1 Running 0 7s mydep-54f7ff7d6d-cqvlq 1/1 Running 0 5s mydep-54f7ff7d6d-gccr6 1/1 Running 0 2s mydep-6766777fff-9r2zn 1/1 Running 0 5h Phase out of old Pods managed by maxSurge and maxUnavailable.
  • 61. RollingUpdate Deployment $ kubectl get replicaset NAME DESIRED CURRENT READY AGE mydep-54f7ff7d6d 3 3 3 13s mydep-6766777fff 0 0 0 5h R1 pod-template-hash: 2322333999 R1 safe pod-template-hash: 676677fff R2 pod-template-hash: 1093993828 R2 safe pod-template-hash: 54f7ff7d6d $ kubectl get pods NAME READY STATUS RESTARTS AGE mydep-54f7ff7d6d-9gvll 1/1 Running 0 10s mydep-54f7ff7d6d-cqvlq 1/1 Running 0 8s mydep-54f7ff7d6d-gccr6 1/1 Running 0 5s Phase out of old Pods managed by maxSurge and maxUnavailable.
  • 62. RollingUpdate Deployment R1 pod-template-hash: 2322333999 R1 safe pod-template-hash: 676677fff R2 pod-template-hash: 1093993828 R2 safe pod-template-hash: 54f7ff7d6d $ kubectl get replicaset NAME DESIRED CURRENT READY AGE mydep-54f7ff7d6d 3 3 3 15s mydep-6766777fff 0 0 0 5h $ kubectl get pods NAME READY STATUS RESTARTS AGE mydep-54f7ff7d6d-9gvll 1/1 Running 0 12s mydep-54f7ff7d6d-cqvlq 1/1 Running 0 10s mydep-54f7ff7d6d-gccr6 1/1 Running 0 7s Updated to new deployment revision completed.
  • 65. Links ● Free Kubernetes Courses https://www.edx.org/ ● Interactive Kubernetes Tutorials https://www.katacoda.com/courses/kubernetes ● Learn Kubernetes the Hard Way https://github.com/kelseyhightower/kubernetes-the-hard-way ● Official Kubernetes Youtube Channel https://www.youtube.com/channel/UCZ2bu0qutTOM0tHYa_jkIwg ● Official CNCF Youtube Channel https://www.youtube.com/channel/UCvqbFHwN-nwalWPjPUKpvTA ● Track to becoming a CKA/CKAD (Certified Kubernetes Administrator/Application Developer) https://www.cncf.io/certification/expert/ ● Awesome Kubernetes https://www.gitbook.com/book/ramitsurana/awesome-kubernetes/details