SlideShare una empresa de Scribd logo
1 de 80
training@container-solutions.com
www.container-solutions.com
Kubernetes Fundamentals
in 3 hours
7.02.2019
Introduction
● very hands-on workshop
● fundamental concepts and features of Kubernetes
Over the course of multiple exercises we walk you through taking a
sample application from a simple first deployment to improving it step by
step, implementing best practices.
Our Journey
1. Review of Kubernetes Architecture
2. Deploy hello-world app
3. Play with pod
4. Services - How to expose the app
5. Zero Downtime Deployment
6. Information used by the containers
7. Useful tools & Commons Problems
Who's Who
Who are we? Who are you?
Container Solutions
We are a Cloud Native consultancy based in Amsterdam, Berlin, London,
Montreal, Zurich and Warsaw.
Kubernetes Certified Service Provider (KCSP) and experts in Cloud Native
strategy and technology.
https://container-solutions.com/
We are hiring!
Who am I?
Piotr Perzyna
Who are you? What brings your here today?
1. Developer? Ops? Architect?
2. Where do you work?
3. Experience with Containers? Kubernetes?
Who are you?
● Pair-up with your neighbour and support each other
● If you do get stuck, please let us know
Collaboration is Key
16:00 - 16:20 Introduction
16:20 - 17:40 Theory in practice on core components
17:40 - 17:50 Break
17:50 - 19:00 Managing Resources
19:00 - 19:10 Break
19:10 - 19:50 Lifecycles and Troubleshooting
19:50 - 20:00 Q&A
Agenda
Your Own Environment
● Up and a running Kubernetes cluster via minikube
$ minikube status
● Installed kubectl
A Little History
Kubernetes’ Backstory
● Automation
● Scheduling
● Resilience
● Scalability
● Secrets
Plus many more ...
Key Features
● Open-source container orchestrator
● Based on Google’s experience with Borg and now Omega
● Maintained by the Cloud Native Computing Foundation
● Most cloud providers now offer managed Kubernetes
○ Google Kubernetes Engine
○ Amazon Elastic Container Service for Kubernetes
○ Azure Kubernetes Service
Background
Adoption 2018
Architecture
Kubernetes client-server architecture
Architecture
● Nodes
○ Master
○ Worker
● Pods
● Containers
Master
● API Server
● etcd
● Control Manager
● Scheduler
Worker
● kubelet
● kube-proxy
● Container Runtime
○ e.g. Docker
● Pods
Container > Pod > Node > Cluster
POD
NODE
Interaction
Working with the cluster
kubectl get <resources>
List all resources in the current namespace
kubectl describe <resource> <resource-name>
Verbose output of a particular resource
kubectl apply -f <filename>
Create or update a resource from a file
Useful verbs and commands
Step #1
Run a simple “hello world” application
$ kubectl run hello-world 
--image=containersol/k8s-in-3h:v1 --port=8080
What just happened?!
View the resources created
$ kubectl get pods
$ kubectl get pods -o wide
$ kubectl get deployments
$ kubectl get replicasets
$ kubectl get all
Step #2
Deployment
● Encapsulates ReplicaSet
● Controlled change from current
state to desired state
● Can rollback to a previous state
due to a deployment error
ReplicaSet
● Ensures a specified number of
pod replicas are running at any
given time
● Automatically created in
Deployment (usually)
Step #3
View more detail about a resource
$ kubectl describe pod <pod_name>
$ kubectl describe deployment <deployment_name>
$ kubectl describe replicaset <replicaset_name>
Step #4
Can i login into the pod? Yes, you can!
$ kubectl exec -it <pod_name> /bin/sh
Step #5
Scale the pods
$ kubectl scale deployment hello-world --replicas=4
Verify
$ kubectl get pod
$ kubectl get rs
Services
Stable endpoints
● Forward traffic to pod or a group of pods that work together
○ Grouped by a Label Selector
● Stable end-point that can be addressed by name
● Different types:
○ ClusterIP
○ NodePort
○ LoadBalancer
What’s a Service?
● Default type
● Creates an internal IP
● Assigns Service to
internal ClusterIP
● Only reachable within cluster
ClusterIP
● Exposes a port on all of the
nodes of the cluster
● Allocated in range of 30,000 -
32,767
● Same port on every host
NodePort
Step #1
Use a NodePort Service to expose the deployment
$ kubectl expose deployment hello-world 
--name=hello-world-svc 
--type=NodePort 
--port=8080
Step #2
View the new Service
$ kubectl get svc
$ kubectl describe svc <svc_name>
Can we access the service on the Cluster IP?
$ kubectl get svc -o wide
$ curl <CLUSTER-IP>:<NODE-PORT>
No, we cannot
How about on the Node IP?
$ minikube ip
$ curl <MINIKUBE-IP>:<NODE-PORT>
Check the hostname
$ curl --silent <MINIKUBE-IP>:<NODE-PORT> | grep Hostname
<repeat a few times>
Step #3
You can do it via browser also!
http://<MINIKUBE-IP>:<NODE-PORT>
Check the logs:
$ kubectl logs -f <pod_name>
Step #4
Do you want Zero Downtime Deployment!?
Run check on different terminal
$ while true; do curl --silent <MINIKUBE-IP>:<NODE-PORT> | grep
Version; sleep 0.1; done;
Deploy!
$ kubectl set image deployment/hello-world 
hello-world=containersol/k8s-in-3h:v2
Step #5
When deploying a new application, the switch from the old to the new
version can impact end users. This module will help you to use the right
deployment strategy depending on your use case.
● RollingUpdate
● Recreate
● Rolling Back
● Blue/Green
● Canary
● A/B
Deployment Strategies
RollingUpdate
BREAK
Namespace
Namespaces
Namespaces are intended for use in environments with many users
spread across multiple teams, or projects, such that cluster resources can
be divided over multiple users
Working with Namespaces
List all namespaces
$ kubectl get ns
Create a new namespace
$ kubectl create ns <namespace-name>
List all in all namespaces
$ kubectl get all --all-namespaces
Standard Namespaces
● default - empty, default namespace
● kube-public - readable by all users, contains CA as a ConfigMap
● kube-system - for object created by kubernetes system
Managing Resources
Imperative vs Declarative
Imperative
● Manage resources using the CLI
Declarative
● Manage resources using the prepared files
● GitOps?
Imperative vs Declarative
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-world
spec:
replicas: 4
selector:
matchLabels:
run: hello-world
template:
metadata:
labels:
run: hello-world
spec:
containers:
- name: hello-world
image: pperzyna/hello-world:v2
ports:
- containerPort: 8080
Deployment
Manifest
● Deploy hello-world pods
● Starts 4 Pods
$ kubectl get deployment -o yaml
apiVersion: v1
kind: Service
metadata:
name: hello-world-svc
spec:
type: NodePort
ports:
- name: http
port: 8080
targetPort: 8080
selector:
run: hello-world
Service
Manifest
● Matches objects with label of
“run: hello-world”
● Exposes application listening on
port 8080
$ kubectl get svc -o yaml
Setup a sample application
You will find a sample application here:
https://github.com/ContainerSolutions/ws-kubernetes-essentials-app
Start by cloning the repository to your environment:
$ mkdir cs-k8sin3h
$ cd cs-k8sin3h
$ git clone https://tinyurl.com/y7jbczea .
Instructions
1. Create a Deployment using the “app-deployment.yaml” manifest
2. Create the Service specified in the “app-service.yaml” manifest
3. Find the IP and Port of the NodePort Service
4. Open the application in your browser
Attempt it on your own, if you get stuck refer to the next 3 slides.
You have 10 minutes...
Step #1
Deploy the application using the manifest file:
$ kubectl apply -f manifests/app-deployment.yaml
What happened? What was created?
$ kubectl get deploy
$ kubectl describe deploy sample-app
$ kubectl get pods
Expose the application using the manifest file:
$ kubectl apply -f manifests/app-service.yaml
What happened? What was created?
$ kubectl get svc sample-app-svc -o wide
$ kubectl describe svc sample-app-svc
Access the application:
$ curl <MINIKUBE-IP>:<NODE-PORT>
Step #2
ConfigMaps &
Secrets
Introduction
Any reasonable web application has information that needs to be kept
from prying eyes and decoupled from the application. This has become
more complicated with microservices. Ephemeral nature of
services/containers means we need automation.
Kubernetes encourages Configuration Management best practices by
offering:
● ConfigMaps
● Secrets
Configuration in Kubernetes
Creating ConfigMaps
ConfigMaps can be created directly from the CLI:
$ kubectl create configmap ...
Or through Manifests:
$ kubectl apply -f configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: webapp-config
data:
timeout: 3600
loglevel: debug
Property-like
● Property-like keys represent
smaller, individual pieces of
Configuration data.
● Typically used to populate
Environment Variables for
application properties or
command line arguments.
...
spec:
containers:
- name: test-container
...
env:
- name: TITLE
valueFrom:
configMapKeyRef:
name: workshop-config
key: TITLE
Environmental
Variables
The key from the ConfigMap becomes
the environment variable name in the
Pod.
We want to use a ConfigMap to supply details to our application.
1. Apply the ConfigMap in “manifests/app-configmap.yaml”
2. Update the “app-deployment” with ENVs from the ConfigMap
a. Look at the config map for naming
3. Apply the updated deployment
4. View the results
You have 10 minutes...
Instructions
Bonus
Readiness
● Do your Pods have a
readiness probe?
● Is your Pod “Ready”?
Liveness
● Do your Pods have a liveness
probe?
● Is it successful or failing?
containers:
- name: app-frontend
image: containersol/k8s-sample-app:1.0
ports:
- containerPort: 9292
readinessProbe:
httpGet:
path: /readiness
port: 9292
scheme: HTTP
initialDelaySeconds: 5
timeoutSeconds: 1
livenessProbe:
httpGet:
path: /liveness
port: 9292
scheme: HTTP
initialDelaySeconds: 5
periodSeconds: 15
timeoutSeconds: 5
BREAK
Useful Tools
Kubectl Autocomplete
Kubectl includes autocompletion support, which can save a lot of typing!
Follow the Instructions here:
https://kubernetes.io/docs/tasks/tools/install-kubectl/#enabling-shell-
autocompletion
● Simple Web User Interface
● Decent high-level overview of the
cluster
● Can drill down into details
● Useful for debugging
Dashboard
$ minikube dashboard
● Port-forwarding is a useful debugging tool
● Map a local port to a port inside a Pod
● Meant for testing services that are not exposed
$ kubectl port-forward <pod_name> 8080 &
$ curl 0.0.0.0:8080
Port-Forward
kubectx
github.com/ahmetb/kubectx
kubens
github.com/ahmetb/kubectx
kubetail
github.com/johanhaleby/kubetail
Common Issues
What could possibly go wrong?
Pod Status = “ImagePullBackoff”
Check the image exists on the Registry (e.g. hub.docker.com)
$ docker pull <image-name>
Check for permission issues
$ kubectl describe po <failing-pod>
Review the Pod’s “Events”
Problem Pulling Image
Pod Status = “Pending”
Means your Pod cannot be Sheduled onto a Node. Maybe because your
Nodes are overloaded, you only have a single node cluster or your
Deployment is asking for too much CPU or Memory.
Check your nodes with
$ kubectl get nodes
$ kubectl describe node <node-name>
Pod Cannot Be Scheduled
A Pod is Behaving “weirdly”
Check the Status and Events
$ kubectl describe pod <pod_name>
Check the Logs
$ kubectl logs <pod_name> <container_name>
Run a shell into the container
$ kubectl exec -it <pod_name> -- /bin/bash
What Selector is your Service using?
$ kubectl describe svc <svc_name> -o wide
Are any of the Pods ready?
$ kubectl get pods -l <selector_key>=<selector_value> --
show-labels
My Service Doesn’t Work
Check how many containers are there in a Pod:
$ kubectl get pods
Check the Containers section in the Pod description:
$ kubectl describe pod <pod_name>
Access logs of a specific Container:
$ kubectl logs <pod_name> -c <container_name>
Multiple Pods & Containers
Hands-on
The Final Exercise
Apply a badly written Deployment and Service to your cluster
$ kubectl apply -f manifests/bad-deployment.yaml
$ kubectl apply -f manifests/bad-service.yaml
Good luck!
Homework
Any Questions?
What else would you like to know?
One Last Thing
Just before you leave
Give us your Feedback
Your feedback is really important to us. We use it to continually improve
our training (we want it to kick-ass). We value your positive and
constructive comments.
Your feedback will be kept anonymous and used to improve our
workshops.
To help us, please spend 2 minutes completing the feedback card
provided by your trainer.
Thank You!
Keep calm and try Kubernetes!

Más contenido relacionado

La actualidad más candente

Kubernetes Workshop
Kubernetes WorkshopKubernetes Workshop
Kubernetes Workshoploodse
 
Kubernetes 101 for Beginners
Kubernetes 101 for BeginnersKubernetes 101 for Beginners
Kubernetes 101 for BeginnersOktay Esgul
 
Kubernetes
KubernetesKubernetes
Kuberneteserialc_w
 
Kubernetes internals (Kubernetes 해부하기)
Kubernetes internals (Kubernetes 해부하기)Kubernetes internals (Kubernetes 해부하기)
Kubernetes internals (Kubernetes 해부하기)DongHyeon Kim
 
Kubernetes: A Short Introduction (2019)
Kubernetes: A Short Introduction (2019)Kubernetes: A Short Introduction (2019)
Kubernetes: A Short Introduction (2019)Megan O'Keefe
 
Open shift 4 infra deep dive
Open shift 4    infra deep diveOpen shift 4    infra deep dive
Open shift 4 infra deep diveWinton Winton
 
Gitops: the kubernetes way
Gitops: the kubernetes wayGitops: the kubernetes way
Gitops: the kubernetes waysparkfabrik
 
An Introduction to Kubernetes
An Introduction to KubernetesAn Introduction to Kubernetes
An Introduction to KubernetesImesh Gunaratne
 
Kubernetes for Beginners: An Introductory Guide
Kubernetes for Beginners: An Introductory GuideKubernetes for Beginners: An Introductory Guide
Kubernetes for Beginners: An Introductory GuideBytemark
 
Kubernetes Concepts And Architecture Powerpoint Presentation Slides
Kubernetes Concepts And Architecture Powerpoint Presentation SlidesKubernetes Concepts And Architecture Powerpoint Presentation Slides
Kubernetes Concepts And Architecture Powerpoint Presentation SlidesSlideTeam
 
Kubernetes Introduction
Kubernetes IntroductionKubernetes Introduction
Kubernetes IntroductionPeng Xiao
 
(Draft) Kubernetes - A Comprehensive Overview
(Draft) Kubernetes - A Comprehensive Overview(Draft) Kubernetes - A Comprehensive Overview
(Draft) Kubernetes - A Comprehensive OverviewBob Killen
 
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCD
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCDKubernetes GitOps featuring GitHub, Kustomize and ArgoCD
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCDSunnyvale
 
Evolution of containers to kubernetes
Evolution of containers to kubernetesEvolution of containers to kubernetes
Evolution of containers to kubernetesKrishna-Kumar
 
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
 

La actualidad más candente (20)

Gitops Hands On
Gitops Hands OnGitops Hands On
Gitops Hands On
 
Kubernetes Workshop
Kubernetes WorkshopKubernetes Workshop
Kubernetes Workshop
 
Kubernetes PPT.pptx
Kubernetes PPT.pptxKubernetes PPT.pptx
Kubernetes PPT.pptx
 
Kubernetes 101 for Beginners
Kubernetes 101 for BeginnersKubernetes 101 for Beginners
Kubernetes 101 for Beginners
 
Kubernetes
KubernetesKubernetes
Kubernetes
 
Kubernetes internals (Kubernetes 해부하기)
Kubernetes internals (Kubernetes 해부하기)Kubernetes internals (Kubernetes 해부하기)
Kubernetes internals (Kubernetes 해부하기)
 
Kubernetes 101
Kubernetes 101Kubernetes 101
Kubernetes 101
 
Kubernetes: A Short Introduction (2019)
Kubernetes: A Short Introduction (2019)Kubernetes: A Short Introduction (2019)
Kubernetes: A Short Introduction (2019)
 
Open shift 4 infra deep dive
Open shift 4    infra deep diveOpen shift 4    infra deep dive
Open shift 4 infra deep dive
 
Gitops: the kubernetes way
Gitops: the kubernetes wayGitops: the kubernetes way
Gitops: the kubernetes way
 
An Introduction to Kubernetes
An Introduction to KubernetesAn Introduction to Kubernetes
An Introduction to Kubernetes
 
Kubernetes for Beginners: An Introductory Guide
Kubernetes for Beginners: An Introductory GuideKubernetes for Beginners: An Introductory Guide
Kubernetes for Beginners: An Introductory Guide
 
Kubernetes Concepts And Architecture Powerpoint Presentation Slides
Kubernetes Concepts And Architecture Powerpoint Presentation SlidesKubernetes Concepts And Architecture Powerpoint Presentation Slides
Kubernetes Concepts And Architecture Powerpoint Presentation Slides
 
Kubernetes Introduction
Kubernetes IntroductionKubernetes Introduction
Kubernetes Introduction
 
(Draft) Kubernetes - A Comprehensive Overview
(Draft) Kubernetes - A Comprehensive Overview(Draft) Kubernetes - A Comprehensive Overview
(Draft) Kubernetes - A Comprehensive Overview
 
Kubernetes 101 Workshop
Kubernetes 101 WorkshopKubernetes 101 Workshop
Kubernetes 101 Workshop
 
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCD
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCDKubernetes GitOps featuring GitHub, Kustomize and ArgoCD
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCD
 
Evolution of containers to kubernetes
Evolution of containers to kubernetesEvolution of containers to kubernetes
Evolution of containers to kubernetes
 
01. Kubernetes-PPT.pptx
01. Kubernetes-PPT.pptx01. Kubernetes-PPT.pptx
01. Kubernetes-PPT.pptx
 
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
 

Similar a K8s in 3h - Kubernetes Fundamentals Training

Getting started with kubernetes
Getting started with kubernetesGetting started with kubernetes
Getting started with kubernetesBob Killen
 
Kubernetes workshop -_the_basics
Kubernetes workshop -_the_basicsKubernetes workshop -_the_basics
Kubernetes workshop -_the_basicsSjuul Janssen
 
Kubernetes - training micro-dragons without getting burnt
Kubernetes -  training micro-dragons without getting burntKubernetes -  training micro-dragons without getting burnt
Kubernetes - training micro-dragons without getting burntAmir Moghimi
 
Docker on docker leveraging kubernetes in docker ee
Docker on docker leveraging kubernetes in docker eeDocker on docker leveraging kubernetes in docker ee
Docker on docker leveraging kubernetes in docker eeDocker, Inc.
 
Scaling docker with kubernetes
Scaling docker with kubernetesScaling docker with kubernetes
Scaling docker with kubernetesLiran Cohen
 
CI/CD Across Multiple Environments
CI/CD Across Multiple EnvironmentsCI/CD Across Multiple Environments
CI/CD Across Multiple EnvironmentsKarl Isenberg
 
Kubernetes: training micro-dragons for a serious battle
Kubernetes: training micro-dragons for a serious battleKubernetes: training micro-dragons for a serious battle
Kubernetes: training micro-dragons for a serious battleAmir Moghimi
 
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 - how to orchestrate containers
Kubernetes - how to orchestrate containersKubernetes - how to orchestrate containers
Kubernetes - how to orchestrate containersinovex GmbH
 
Kuberenetes - From Zero to Hero
Kuberenetes  - From Zero to HeroKuberenetes  - From Zero to Hero
Kuberenetes - From Zero to HeroOri Stoliar
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetesRishabh Indoria
 
Kubernetes #1 intro
Kubernetes #1   introKubernetes #1   intro
Kubernetes #1 introTerry Cho
 
Deploy Application on Kubernetes
Deploy Application on KubernetesDeploy Application on Kubernetes
Deploy Application on KubernetesOpsta
 
Making kubernetes simple for developers
Making kubernetes simple for developersMaking kubernetes simple for developers
Making kubernetes simple for developersSuraj Deshmukh
 
Kubernetes - Sailing a Sea of Containers
Kubernetes - Sailing a Sea of ContainersKubernetes - Sailing a Sea of Containers
Kubernetes - Sailing a Sea of ContainersKel Cecil
 
DevEx | there’s no place like k3s
DevEx | there’s no place like k3sDevEx | there’s no place like k3s
DevEx | there’s no place like k3sHaggai Philip Zagury
 
An intro to Kubernetes operators
An intro to Kubernetes operatorsAn intro to Kubernetes operators
An intro to Kubernetes operatorsJ On The Beach
 
Cluster management with Kubernetes
Cluster management with KubernetesCluster management with Kubernetes
Cluster management with KubernetesSatnam Singh
 
KubeCI - Cloud Native Continuous Delivery for Kubernetes
KubeCI - Cloud Native Continuous Delivery for KubernetesKubeCI - Cloud Native Continuous Delivery for Kubernetes
KubeCI - Cloud Native Continuous Delivery for KubernetesTobias Schneck
 
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
 

Similar a K8s in 3h - Kubernetes Fundamentals Training (20)

Getting started with kubernetes
Getting started with kubernetesGetting started with kubernetes
Getting started with kubernetes
 
Kubernetes workshop -_the_basics
Kubernetes workshop -_the_basicsKubernetes workshop -_the_basics
Kubernetes workshop -_the_basics
 
Kubernetes - training micro-dragons without getting burnt
Kubernetes -  training micro-dragons without getting burntKubernetes -  training micro-dragons without getting burnt
Kubernetes - training micro-dragons without getting burnt
 
Docker on docker leveraging kubernetes in docker ee
Docker on docker leveraging kubernetes in docker eeDocker on docker leveraging kubernetes in docker ee
Docker on docker leveraging kubernetes in docker ee
 
Scaling docker with kubernetes
Scaling docker with kubernetesScaling docker with kubernetes
Scaling docker with kubernetes
 
CI/CD Across Multiple Environments
CI/CD Across Multiple EnvironmentsCI/CD Across Multiple Environments
CI/CD Across Multiple Environments
 
Kubernetes: training micro-dragons for a serious battle
Kubernetes: training micro-dragons for a serious battleKubernetes: training micro-dragons for a serious battle
Kubernetes: training micro-dragons for a serious battle
 
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 !
 
Kubernetes - how to orchestrate containers
Kubernetes - how to orchestrate containersKubernetes - how to orchestrate containers
Kubernetes - how to orchestrate containers
 
Kuberenetes - From Zero to Hero
Kuberenetes  - From Zero to HeroKuberenetes  - From Zero to Hero
Kuberenetes - From Zero to Hero
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetes
 
Kubernetes #1 intro
Kubernetes #1   introKubernetes #1   intro
Kubernetes #1 intro
 
Deploy Application on Kubernetes
Deploy Application on KubernetesDeploy Application on Kubernetes
Deploy Application on Kubernetes
 
Making kubernetes simple for developers
Making kubernetes simple for developersMaking kubernetes simple for developers
Making kubernetes simple for developers
 
Kubernetes - Sailing a Sea of Containers
Kubernetes - Sailing a Sea of ContainersKubernetes - Sailing a Sea of Containers
Kubernetes - Sailing a Sea of Containers
 
DevEx | there’s no place like k3s
DevEx | there’s no place like k3sDevEx | there’s no place like k3s
DevEx | there’s no place like k3s
 
An intro to Kubernetes operators
An intro to Kubernetes operatorsAn intro to Kubernetes operators
An intro to Kubernetes operators
 
Cluster management with Kubernetes
Cluster management with KubernetesCluster management with Kubernetes
Cluster management with Kubernetes
 
KubeCI - Cloud Native Continuous Delivery for Kubernetes
KubeCI - Cloud Native Continuous Delivery for KubernetesKubeCI - Cloud Native Continuous Delivery for Kubernetes
KubeCI - Cloud Native Continuous Delivery for Kubernetes
 
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
 

Más de Piotr Perzyna

Pact - Contract Testing
Pact - Contract TestingPact - Contract Testing
Pact - Contract TestingPiotr Perzyna
 
Deployment Strategies
Deployment StrategiesDeployment Strategies
Deployment StrategiesPiotr Perzyna
 
Helm - Package manager in K8S
Helm - Package manager in K8SHelm - Package manager in K8S
Helm - Package manager in K8SPiotr Perzyna
 
Is a ORCHESTRATION a new milestone?
Is a ORCHESTRATION  a new milestone?Is a ORCHESTRATION  a new milestone?
Is a ORCHESTRATION a new milestone?Piotr Perzyna
 
Analise NetFlow in Real Time
Analise NetFlow in Real TimeAnalise NetFlow in Real Time
Analise NetFlow in Real TimePiotr Perzyna
 
Wizualizacja dancyh - graphite/grafana/kibana
Wizualizacja dancyh - graphite/grafana/kibanaWizualizacja dancyh - graphite/grafana/kibana
Wizualizacja dancyh - graphite/grafana/kibanaPiotr Perzyna
 

Más de Piotr Perzyna (7)

Pact - Contract Testing
Pact - Contract TestingPact - Contract Testing
Pact - Contract Testing
 
Deployment Strategies
Deployment StrategiesDeployment Strategies
Deployment Strategies
 
Helm - Package manager in K8S
Helm - Package manager in K8SHelm - Package manager in K8S
Helm - Package manager in K8S
 
Is a ORCHESTRATION a new milestone?
Is a ORCHESTRATION  a new milestone?Is a ORCHESTRATION  a new milestone?
Is a ORCHESTRATION a new milestone?
 
Analise NetFlow in Real Time
Analise NetFlow in Real TimeAnalise NetFlow in Real Time
Analise NetFlow in Real Time
 
Wizualizacja dancyh - graphite/grafana/kibana
Wizualizacja dancyh - graphite/grafana/kibanaWizualizacja dancyh - graphite/grafana/kibana
Wizualizacja dancyh - graphite/grafana/kibana
 
What is Linux?
What is Linux?What is Linux?
What is Linux?
 

Último

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
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
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
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
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
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoordharasingh5698
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
Intro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdfIntro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdfrs7054576148
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfRagavanV2
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 

Último (20)

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
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
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
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
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
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Intro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdfIntro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdf
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
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
 

K8s in 3h - Kubernetes Fundamentals Training

  • 2. Introduction ● very hands-on workshop ● fundamental concepts and features of Kubernetes Over the course of multiple exercises we walk you through taking a sample application from a simple first deployment to improving it step by step, implementing best practices.
  • 3. Our Journey 1. Review of Kubernetes Architecture 2. Deploy hello-world app 3. Play with pod 4. Services - How to expose the app 5. Zero Downtime Deployment 6. Information used by the containers 7. Useful tools & Commons Problems
  • 4. Who's Who Who are we? Who are you?
  • 5. Container Solutions We are a Cloud Native consultancy based in Amsterdam, Berlin, London, Montreal, Zurich and Warsaw. Kubernetes Certified Service Provider (KCSP) and experts in Cloud Native strategy and technology. https://container-solutions.com/ We are hiring!
  • 6. Who am I? Piotr Perzyna
  • 7. Who are you? What brings your here today? 1. Developer? Ops? Architect? 2. Where do you work? 3. Experience with Containers? Kubernetes? Who are you?
  • 8. ● Pair-up with your neighbour and support each other ● If you do get stuck, please let us know Collaboration is Key
  • 9. 16:00 - 16:20 Introduction 16:20 - 17:40 Theory in practice on core components 17:40 - 17:50 Break 17:50 - 19:00 Managing Resources 19:00 - 19:10 Break 19:10 - 19:50 Lifecycles and Troubleshooting 19:50 - 20:00 Q&A Agenda
  • 10. Your Own Environment ● Up and a running Kubernetes cluster via minikube $ minikube status ● Installed kubectl
  • 12. ● Automation ● Scheduling ● Resilience ● Scalability ● Secrets Plus many more ... Key Features
  • 13. ● Open-source container orchestrator ● Based on Google’s experience with Borg and now Omega ● Maintained by the Cloud Native Computing Foundation ● Most cloud providers now offer managed Kubernetes ○ Google Kubernetes Engine ○ Amazon Elastic Container Service for Kubernetes ○ Azure Kubernetes Service Background
  • 16. Architecture ● Nodes ○ Master ○ Worker ● Pods ● Containers
  • 17. Master ● API Server ● etcd ● Control Manager ● Scheduler
  • 18. Worker ● kubelet ● kube-proxy ● Container Runtime ○ e.g. Docker ● Pods
  • 19. Container > Pod > Node > Cluster POD NODE
  • 21. kubectl get <resources> List all resources in the current namespace kubectl describe <resource> <resource-name> Verbose output of a particular resource kubectl apply -f <filename> Create or update a resource from a file Useful verbs and commands
  • 22. Step #1 Run a simple “hello world” application $ kubectl run hello-world --image=containersol/k8s-in-3h:v1 --port=8080 What just happened?!
  • 23. View the resources created $ kubectl get pods $ kubectl get pods -o wide $ kubectl get deployments $ kubectl get replicasets $ kubectl get all Step #2
  • 24. Deployment ● Encapsulates ReplicaSet ● Controlled change from current state to desired state ● Can rollback to a previous state due to a deployment error
  • 25. ReplicaSet ● Ensures a specified number of pod replicas are running at any given time ● Automatically created in Deployment (usually)
  • 26. Step #3 View more detail about a resource $ kubectl describe pod <pod_name> $ kubectl describe deployment <deployment_name> $ kubectl describe replicaset <replicaset_name>
  • 27. Step #4 Can i login into the pod? Yes, you can! $ kubectl exec -it <pod_name> /bin/sh
  • 28. Step #5 Scale the pods $ kubectl scale deployment hello-world --replicas=4 Verify $ kubectl get pod $ kubectl get rs
  • 30. ● Forward traffic to pod or a group of pods that work together ○ Grouped by a Label Selector ● Stable end-point that can be addressed by name ● Different types: ○ ClusterIP ○ NodePort ○ LoadBalancer What’s a Service?
  • 31. ● Default type ● Creates an internal IP ● Assigns Service to internal ClusterIP ● Only reachable within cluster ClusterIP
  • 32. ● Exposes a port on all of the nodes of the cluster ● Allocated in range of 30,000 - 32,767 ● Same port on every host NodePort
  • 33. Step #1 Use a NodePort Service to expose the deployment $ kubectl expose deployment hello-world --name=hello-world-svc --type=NodePort --port=8080
  • 34. Step #2 View the new Service $ kubectl get svc $ kubectl describe svc <svc_name> Can we access the service on the Cluster IP? $ kubectl get svc -o wide $ curl <CLUSTER-IP>:<NODE-PORT> No, we cannot
  • 35. How about on the Node IP? $ minikube ip $ curl <MINIKUBE-IP>:<NODE-PORT> Check the hostname $ curl --silent <MINIKUBE-IP>:<NODE-PORT> | grep Hostname <repeat a few times> Step #3
  • 36. You can do it via browser also! http://<MINIKUBE-IP>:<NODE-PORT> Check the logs: $ kubectl logs -f <pod_name> Step #4
  • 37. Do you want Zero Downtime Deployment!? Run check on different terminal $ while true; do curl --silent <MINIKUBE-IP>:<NODE-PORT> | grep Version; sleep 0.1; done; Deploy! $ kubectl set image deployment/hello-world hello-world=containersol/k8s-in-3h:v2 Step #5
  • 38. When deploying a new application, the switch from the old to the new version can impact end users. This module will help you to use the right deployment strategy depending on your use case. ● RollingUpdate ● Recreate ● Rolling Back ● Blue/Green ● Canary ● A/B Deployment Strategies
  • 40. BREAK
  • 42. Namespaces Namespaces are intended for use in environments with many users spread across multiple teams, or projects, such that cluster resources can be divided over multiple users
  • 43. Working with Namespaces List all namespaces $ kubectl get ns Create a new namespace $ kubectl create ns <namespace-name> List all in all namespaces $ kubectl get all --all-namespaces
  • 44. Standard Namespaces ● default - empty, default namespace ● kube-public - readable by all users, contains CA as a ConfigMap ● kube-system - for object created by kubernetes system
  • 46. Imperative ● Manage resources using the CLI Declarative ● Manage resources using the prepared files ● GitOps? Imperative vs Declarative
  • 47. apiVersion: apps/v1 kind: Deployment metadata: name: hello-world spec: replicas: 4 selector: matchLabels: run: hello-world template: metadata: labels: run: hello-world spec: containers: - name: hello-world image: pperzyna/hello-world:v2 ports: - containerPort: 8080 Deployment Manifest ● Deploy hello-world pods ● Starts 4 Pods $ kubectl get deployment -o yaml
  • 48. apiVersion: v1 kind: Service metadata: name: hello-world-svc spec: type: NodePort ports: - name: http port: 8080 targetPort: 8080 selector: run: hello-world Service Manifest ● Matches objects with label of “run: hello-world” ● Exposes application listening on port 8080 $ kubectl get svc -o yaml
  • 49. Setup a sample application You will find a sample application here: https://github.com/ContainerSolutions/ws-kubernetes-essentials-app Start by cloning the repository to your environment: $ mkdir cs-k8sin3h $ cd cs-k8sin3h $ git clone https://tinyurl.com/y7jbczea .
  • 50. Instructions 1. Create a Deployment using the “app-deployment.yaml” manifest 2. Create the Service specified in the “app-service.yaml” manifest 3. Find the IP and Port of the NodePort Service 4. Open the application in your browser Attempt it on your own, if you get stuck refer to the next 3 slides. You have 10 minutes...
  • 51. Step #1 Deploy the application using the manifest file: $ kubectl apply -f manifests/app-deployment.yaml What happened? What was created? $ kubectl get deploy $ kubectl describe deploy sample-app $ kubectl get pods
  • 52. Expose the application using the manifest file: $ kubectl apply -f manifests/app-service.yaml What happened? What was created? $ kubectl get svc sample-app-svc -o wide $ kubectl describe svc sample-app-svc Access the application: $ curl <MINIKUBE-IP>:<NODE-PORT> Step #2
  • 54. Introduction Any reasonable web application has information that needs to be kept from prying eyes and decoupled from the application. This has become more complicated with microservices. Ephemeral nature of services/containers means we need automation.
  • 55. Kubernetes encourages Configuration Management best practices by offering: ● ConfigMaps ● Secrets Configuration in Kubernetes
  • 56. Creating ConfigMaps ConfigMaps can be created directly from the CLI: $ kubectl create configmap ... Or through Manifests: $ kubectl apply -f configmap.yaml
  • 57. apiVersion: v1 kind: ConfigMap metadata: name: webapp-config data: timeout: 3600 loglevel: debug Property-like ● Property-like keys represent smaller, individual pieces of Configuration data. ● Typically used to populate Environment Variables for application properties or command line arguments.
  • 58. ... spec: containers: - name: test-container ... env: - name: TITLE valueFrom: configMapKeyRef: name: workshop-config key: TITLE Environmental Variables The key from the ConfigMap becomes the environment variable name in the Pod.
  • 59. We want to use a ConfigMap to supply details to our application. 1. Apply the ConfigMap in “manifests/app-configmap.yaml” 2. Update the “app-deployment” with ENVs from the ConfigMap a. Look at the config map for naming 3. Apply the updated deployment 4. View the results You have 10 minutes... Instructions
  • 60. Bonus Readiness ● Do your Pods have a readiness probe? ● Is your Pod “Ready”? Liveness ● Do your Pods have a liveness probe? ● Is it successful or failing? containers: - name: app-frontend image: containersol/k8s-sample-app:1.0 ports: - containerPort: 9292 readinessProbe: httpGet: path: /readiness port: 9292 scheme: HTTP initialDelaySeconds: 5 timeoutSeconds: 1 livenessProbe: httpGet: path: /liveness port: 9292 scheme: HTTP initialDelaySeconds: 5 periodSeconds: 15 timeoutSeconds: 5
  • 61. BREAK
  • 63. Kubectl Autocomplete Kubectl includes autocompletion support, which can save a lot of typing! Follow the Instructions here: https://kubernetes.io/docs/tasks/tools/install-kubectl/#enabling-shell- autocompletion
  • 64. ● Simple Web User Interface ● Decent high-level overview of the cluster ● Can drill down into details ● Useful for debugging Dashboard $ minikube dashboard
  • 65. ● Port-forwarding is a useful debugging tool ● Map a local port to a port inside a Pod ● Meant for testing services that are not exposed $ kubectl port-forward <pod_name> 8080 & $ curl 0.0.0.0:8080 Port-Forward
  • 69. Common Issues What could possibly go wrong?
  • 70. Pod Status = “ImagePullBackoff” Check the image exists on the Registry (e.g. hub.docker.com) $ docker pull <image-name> Check for permission issues $ kubectl describe po <failing-pod> Review the Pod’s “Events” Problem Pulling Image
  • 71. Pod Status = “Pending” Means your Pod cannot be Sheduled onto a Node. Maybe because your Nodes are overloaded, you only have a single node cluster or your Deployment is asking for too much CPU or Memory. Check your nodes with $ kubectl get nodes $ kubectl describe node <node-name> Pod Cannot Be Scheduled
  • 72. A Pod is Behaving “weirdly” Check the Status and Events $ kubectl describe pod <pod_name> Check the Logs $ kubectl logs <pod_name> <container_name> Run a shell into the container $ kubectl exec -it <pod_name> -- /bin/bash
  • 73. What Selector is your Service using? $ kubectl describe svc <svc_name> -o wide Are any of the Pods ready? $ kubectl get pods -l <selector_key>=<selector_value> -- show-labels My Service Doesn’t Work
  • 74. Check how many containers are there in a Pod: $ kubectl get pods Check the Containers section in the Pod description: $ kubectl describe pod <pod_name> Access logs of a specific Container: $ kubectl logs <pod_name> -c <container_name> Multiple Pods & Containers
  • 76. Apply a badly written Deployment and Service to your cluster $ kubectl apply -f manifests/bad-deployment.yaml $ kubectl apply -f manifests/bad-service.yaml Good luck! Homework
  • 77. Any Questions? What else would you like to know?
  • 78. One Last Thing Just before you leave
  • 79. Give us your Feedback Your feedback is really important to us. We use it to continually improve our training (we want it to kick-ass). We value your positive and constructive comments. Your feedback will be kept anonymous and used to improve our workshops. To help us, please spend 2 minutes completing the feedback card provided by your trainer.
  • 80. Thank You! Keep calm and try Kubernetes!

Notas del editor

  1. Do: Welcome participants to the program.
  2. Do: Explain goal of this program - “Why are we here?” We will learn all the basic elements of Kubernetes, its architecture and experience hands-on. On day 2 you will learn how it is implemented in B.Platform. Say: Today you will learn about the architecture of Kubernetes and how to use it.
  3. Do: Tell participants what topics are going to be covered. Say: We have a separate module on Troubleshooting & debugging, but actually you will do this throughout these two days.
  4. WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  5. WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  6. Do: Introduce yourself. Get to know your audience. Ask them to raise their hands if DevOps/Engineer/? Experience with Docker? Made own Docker image? Experience with Kubernetes? Running Kubernetes in production? Respond appropriately to the messages and make connections between participants.
  7. WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  8. WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  9. WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  10. https://www.cncf.io/blog/2018/08/29/cncf-survey-use-of-cloud-native-technologies-in-production-has-grown-over-200-percent/ WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  11. WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  12. Say: Clusters have lot of machines, nodes. Master nodes and worker nodes, only the worker nodes are doing the work and Master nodes control the whole system. You will use your laptop and CLI tool to talk to the master. Different components on the Master and Worker nodes, who are all connected.
  13. WHAT SHOULD THE TRAINER SAY? API Server Main point of interaction with the cluster Etcd Distributed Key/Value store Storage for state of cluster Controller/Control Manager Checks API server for events and reacts Scheduler Calculate and schedule pod WHAT SHOULD THE TRAINER DO? Use the image.
  14. Do: Use the image. Say: Here you need Docker, Kubernetes needs CRI.
  15. Do: Use the image. Say: In this one picture we have all the components we just discussed. Kubernetes has two types of nodes; Master or Worker and the smallest piece of software we can schedule is a pod.
  16. WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  17. Say: Get and describe are the most used. Describe provides you variables output, it is a more human-readable way than get.
  18. WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  19. WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  20. Do: Use the image. Say: About the workload. Most of the time we will not create pods, but deployments. Deployments will not directly manage pods, but replicasets. This defined how much replicas (that is pods) you would like to have.
  21. Do: Use the image. Say: One pods dies, and the replicaset will create and use the new one.
  22. WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  23. WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  24. WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  25. WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  26. Say: We need an mechanism to address pods. You will have addressable names.
  27. Do: Use the image. Node 2 and Node 3 have ClusterIP’s, do not use the names because they can change when the pods are rescheduled. Therefore, use a ClusterIP, which is assigned to the service rather than the nodes. ClusterIP is an IP address, virtual, that belongs to the service name. Good for pod-to-pod communication.
  28. Do: Use the image for example. Say: Service is reachable from outside, use Service NodePort. Every load will reserve a port number, where the service will be available. Port allocation on each node. For outside communication.
  29. WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  30. WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  31. WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  32. WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  33. WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  34. WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  35. Say: Different way of exposing.
  36. WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  37. WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  38. Do: Use the commands and show in terminal.
  39. Do: Use the commands and show in terminal.
  40. WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  41. Say: Imperative: use commands e.g. run, declarative: define desired state and Kubernetes does it for you.
  42. Do: Use the example. Say: v1 = stable.
  43. Do: Use the example.
  44. WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  45. WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  46. WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  47. WHAT SHOULD THE TRAINER SAY? ? WHAT SHOULD THE TRAINER DO? ?
  48. Do: Use the example file. Say: New top-level property: data. Before we declared only spec and metadata. We have to keys (beast.color and beast.type) in the form of simple strings
  49. Do: Use the example file. Say: Volume belongs to pods, as containers do too. In the YAML file they are both at the same level. This code tells us the the volume points to the the VolumeMap and the VolumeMap points to the volume. Dot is not allowed in environmental variable names
  50. Introduce the exercise and tell participant that they have 5 minutes to solve it. Say: Keep in mind spacing. YAML only likes spaces and no tabs.
  51. Say: Different way of exposing.
  52. Use this. Be lazy. It gives you the list of available commands and completes names e.g. extensive names of your pods.
  53. Minikube has an add-ons. Use “minikube addons list” to see which are enabled and disabled. Dashboard consumes lot of CPU.
  54. It is very useful if you are working with Kubernetes that is far away. e.g from external laptop connecting to API Server, like ssh port forwarding
  55. It is very useful if you are working with Kubernetes that is far away. e.g from external laptop connecting to API Server, like ssh port forwarding
  56. It is very useful if you are working with Kubernetes that is far away. e.g from external laptop connecting to API Server, like ssh port forwarding
  57. It is very useful if you are working with Kubernetes that is far away. e.g from external laptop connecting to API Server, like ssh port forwarding
  58. Use logs. Difference between Docker logs and Kubectl logs. You have to specify the name of the container, or you get everything in the node.
  59. Say: The application is broken, look at the files and identify the problems. As motivation; if you are done, you can have lunch.