SlideShare a Scribd company logo
1 of 27
Download to read offline
Learn Kubernetes in 90 minutes
Larry Cai <larry.caiyu@gmail.com>
Agenda
 Introduction
 Exercise 1: First web service in kubernetes
 Exercise 2: Revisit pod, deployment and service
 Exercise 3: Controller – Deployment (scale)
 Exercise 4: Deploy with YAML file
 Exercise 5: install Microservice: Guestbook
 Reference
Learn kubernetes in 90 minutes2 10/2/2017
Minikube environment setup is in appendix
Environment using k8s playground
 Three nodes in http://labs.play-with-k8s.com (master + 2 workers)
 Node 1 (master node): follow guideline step 1/2/3
If dashboard doesn’t work, use https://git.io/vdc52
instead of https://git.io/kube-dashboard
 Node 2/Node 3
kubeadm join –token … # check the console log in Node 1
 Node 1:
kubectl get nodes
 Click the port to open dashboard
Learn kubernetes in 90 minutes3 10/2/2017
Try to use Ctrl-Ins & Shift-Ins for copy/paste
Background – Container/Docker
 Container technology offers an alternative method
for virtualization in cloud, with more efficiency & fast
 New era for packaging and delivering software
 Docker is one execution engine for container
 docker pull nginx
 docker run --name web -d -p 8080:80 nginx
 docker exec -it web bash
 docker build -t larrycai/whoami .
Learn kubernetes in 90 minutes4 10/2/2017
See more in CodingWithMe Docker
https://www.slideshare.net/larrycai/learn-docker-in-90-
minutes
What is kubernetes ?
 Kubernetes is an open source container
orchestration platform that helps manage
distributed, containerized applications at massive
scale.
 Kubernetes (k8s) comes from google
 kubernetes is a product platform to run container (Docker
is one type of container execution engine)
 k8s to container likes openstack to virtual machine.
 Key features (list partly):
 Auto-scaling
 Self-healing infrastructure
 Application lifecycle management
Learn kubernetes in 90 minutes5 10/2/2017
K8s Architecture
 Master and Work Node (multi or single)
 Container is executed in Work Node as default
Learn kubernetes in 90 minutes6 10/2/2017
Source: https://thenewstack.io/kubernetes-an-overview/
Exer 1: running first web service
 Let’s start one web server in k8s (cloud)
 Nginx is webserver like apache
 Start the service from official docker image
https://hub.docker.com/_/nginx/
 kubectl run nginx --image=nginx --port=80
 kubectl expose deployment nginx --type=NodePort
 Check what happens
 Check dashboard
 Access the nginx web service (click new port)
 kubectl get pods
 kubectl get pods –o wide # check node
 kubectl get all
 kubectl describe nodes
 docker ps # in different node
 Kill the pod ! And check again
 kubectl delete pods nginx-<xxx>
Learn kubernetes in 90 minutes7 10/2/2017
Overall for running service
Learn kubernetes in 90 minutes8 10/2/2017
Image source https://kubernetes.io/images/hellonode/image_13.
What is Pod ?
 A pod is a group of one or more containers (such as
Docker containers), the shared storage for those
containers
 Minimal element in kubernetes, run in one Node
 Command
kubectl run pods
kubectl get pods
kubectl delete pods
kubectl describe pods <pod>
kubectl exec -it <pod> -- bash
Learn kubernetes in 90 minutes9 10/2/2017
What is Deployment ?
 The Deployment is responsible for creating and
updating instances of your application (using
controller)
 Once the application instances are created, a Kubernetes
Deployment Controller continuously monitors those
instances
 Default is one instance and keep active
 Review the command
 kubectl run nginx --image=nginx --port=80 --replicas=1
 Download docker image nginx (from hub.docker.com) as internal port is
80
 Run docker image inside pod named “nginx-xxx” with 1 instance
 Deployment with name “nginx”
 If pod is deleted, deployment control create new one
Learn kubernetes in 90 minutes10 10/2/2017
What is Service ?
 Service is an abstraction which defines a logical set
of Pods and a policy by which to access them
 sometimes called a micro-service
 Service could be selected by label (skipped here)
Learn kubernetes in 90 minutes11 10/2/2017
 ServiceTypes defines how to
expose a Service, The
default is ClusterIP (internal)
 NodeType : expose port in
Kubernetes Master
kubectl expose deployment xxx –
type=NodePort
 Load Balancer (need support
in k8s infra)Image source: http://wso2.com/whitepapers/a-reference-architecture-for-deploying-wso2-middleware-on-
kubernetes/
Exer 2: Revisit pod, deployment and service
 Enter into container inside pod
 kubectl exec -it nginx-xxx -- bash
 Start pod only without deployment
 kubectl run nginx --image=nginx --port=80 --restart=Never
 kubectl run -i --tty busybox --image=busybox -- sh
 Expose to another service
 kubectl expose --name nginx2 deploy nginx
 kubectl get service
 curl <cluster ip>
 kubectl expose --name nginx3 deploy nginx --type=NodePort
 Clean up the deployment and service
 kubectl delete service xxx
 kubectl delete deployment xxx # check pod removed or not
Learn kubernetes in 90 minutes12 10/2/2017
Deployment more
 Deployment describe the desired state in a
Deployment object, and the Deployment controller
will change the actual state to the desired state at a
controlled rate for you
 Scale to wanted size (replicas)
 $ kubectl scale --replicas=2 deployment/nginx
$ kubectl scale --replicas=10 deployment/nginx
deployment "nginx" scaled
$ kubectl rollout status deployment/nginx
Waiting for rollout to finish: 2 of 10 updated replicas are available...
….
Waiting for rollout to finish: 9 of 10 updated replicas are available...
deployment "nginx" successfully rolled out
$ kubectl get pods
 Patch, Upgrade, Rollback ..
 Autoscale : grow when needed
Learn kubernetes in 90 minutes13 10/2/2017
One example: Canary release
 Kubernetes support to define own deploy strategy.
 User takes care of the service and what it wants to
expose
 The k8s platform do the rest
Learn kubernetes in 90 minutes14 10/2/2017
Source http://blog.kubernetes.io/2017/04/multi-stage-canary-deployments-with-kubernetes-in-the-cloud-onprem
Exer 3 : Deployment with Scale
 Show hostname ( image: larrycai/whoami )
kubectl run whoami --image=larrycai/whoami --port=5000
kubectl expose deploy whoami --type=NodePort
 Check the webpage
 Delete
kubectl delete pods whoami-xxxx
 Check the webpage (reload)
 Scale
kubectl scale --replicas=5 deployment/whoami
kubectl rollout status deployment/whoami
kubectl get pods
 Check the webpage (reload)
Learn kubernetes in 90 minutes15 10/2/2017
YAML descriptors
 Kubectl command line to deal with objects with
limited set of properties
 Difficult to maintain and version control
 YAML file is used to manage the object
kubectl create -f node-pod.yaml
kubectl create –f http://example.com/nginx-pod.yaml
 Get full descriptions of the object in YAML
kubectl get pods nginx2 -o yaml
Learn kubernetes in 90 minutes16 10/2/2017
Exer 4: deploy from YAML file
 Create whoami deploy yaml file (use pod as
reference)
kubectl get deploy whoami -o yaml
 Download and create
https://github.com/larrycai/codingwithme-
k8s/blob/master/whoami.yaml
curl -L -o whoami.yaml https://git.io/v7yd8
kubectl delete service whoami
kubectl delete deploy whoami
kubectl create -f whoami.yaml
 Change the ReplicaSet to 5 and run it again
kubectl apply -f whoami.yaml
Learn kubernetes in 90 minutes17 10/2/2017
Microservices in Kubernetes
 Kubernetes is a great tool for microservices clustering
and orchestration.
 It is still a quite new and under active development
 Kubernetes provides lots of features to be used to deploy
microservices
 Declare in YAML to deploy them
 Kubernetes official tutorial Guestbook
https://kubernetes.io/docs/tutorials/stateless-application/guestbook/
Learn kubernetes in 90 minutes18 10/2/2017
Image source: https://netmark.jp/wp-content/uploads/2014/12/guestbook-kubernetes.pn
Exer 5: Install Guestbook
 Deploy all in one
kubectl create -f https://git.io/v7ytR # shorturl to guestbook-all-in-one.yaml
 Check dashboards
 Expose service to NodePort
kubectl expose svc frontend --name f2 --type=NodePort
Learn kubernetes in 90 minutes19 10/2/2017
Summary
 Kubernetes: a platform to run container (docker)
 Concept:
 A Node is a worker machine in Kubernetes
 A Pod is the basic building block of Kubernetes, which
has a group of containers
 Deployment controls the state of the pod (scale, replicate)
 Service is an abstraction which defines a logical set of
Pods and a policy by which to access them. (micro
service ..)
 Kubernetes grows very fast, follow it.
Learn kubernetes in 90 minutes20 10/2/2017
Reference
 K8s doc: https://kubernetes.io/docs/home/
 Code: https://github.com/larrycai/codingwithme-k8s
 Minikube: https://github.com/kubernetes/minikube
 Blog: multi stage deployment with kubernetes:
http://blog.kubernetes.io/2017/04/multi-stage-canary-deployments-
with-kubernetes-in-the-cloud-onprem.html
 Video: The Illustrated Children's Guide to Kubernetes
 Sandbox online: http://labs.play-with-k8s.com/
 Book: Kubernetes in Action (Manning)
Learn kubernetes in 90 minutes21 10/2/2017
ChangeLog
 2017/07/23: first version
 2017/08/11: use k8s playground
 2017/10/2: fix dashboard url
Learn kubernetes in 90 minutes22 10/2/2017
Appendix
Learn kubernetes in 90 minutes23 10/2/2017
Minikube
 Minikube is all-in-one local kubernetes environment
 Works on Linux/Mac/Unix using virtual machine
Learn kubernetes in 90 minutes24 10/2/2017
Minikube VM
Kubernetes
(master + work
node)
VirtualBox
Windows
Environment Preparation (Win)
 Using unix env in windows (if not, install Git Windows)
 Minikube + Kubectl
 Minikube is local installation of kubernetes using VM
 Kubectl is the client of kubernetes
 Configure PATH (%USERPROFILE% => /c/Users/<id>)
 Download
 curl -L -o minikube.exe
https://storage.googleapis.com/minikube/releases/latest/minikube-windows-
amd64.exe
 curl -LO https://storage.googleapis.com/kubernetes-
release/release/v1.7.0/bin/windows/amd64/kubectl.exe
 mv minikube.exe kubectl.exe /c/Users/$LOGNAME/bin #$PATH
 Installation
 minikube start --kubernetes-version=v1.7.0
 kubectl version
 minikube config set kubernetes-version v1.7.0
 minikube stop
Learn kubernetes in 90 minutes25 10/2/2017
 Forward the local port to the pods without involving
service
 One simple way to get access to container
 kubectl port-forward nginx 8080:80
Access Pod: Port forwarding
Learn kubernetes in 90 minutes26 10/2/2017
curl
Local machine
(kubectl/windows)
kubectl
port-forward
service
Port 8080
Kubernetes inside VM (Virtualbox)
Pod
nginx
Port 80
Exer 2: simple pod to access
 Create the pod nginx2 without deployment
 kubectl run nginx2 --image=nginx --port=80 --restart=Never
 kubectl describe pods nginx2
 Check docker container
 docker ps
 Access it by using port-forwarding
 kubectl port-forward nginx2 8080:80
 Use browser to http://localhost:8080
 curl http://localhost:8080
 Dashboard
 minikube dashboard # check pods/nodes
 Delete
 kubectl delete pods nginx2
Learn kubernetes in 90 minutes27 10/2/2017

More Related Content

What's hot

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
 
Curso Kubernetes CodeURJC
Curso Kubernetes CodeURJCCurso Kubernetes CodeURJC
Curso Kubernetes CodeURJCMicael Gallego
 
Kubernetes on AWS with Amazon EKS
Kubernetes on AWS with Amazon EKSKubernetes on AWS with Amazon EKS
Kubernetes on AWS with Amazon EKSAmazon Web Services
 
Kubernetes Helm: Why It Matters
Kubernetes Helm: Why It MattersKubernetes Helm: Why It Matters
Kubernetes Helm: Why It MattersPlatform9
 
AWS VPN Solutions (NET304) - AWS re:Invent 2018
AWS VPN Solutions (NET304) - AWS re:Invent 2018AWS VPN Solutions (NET304) - AWS re:Invent 2018
AWS VPN Solutions (NET304) - AWS re:Invent 2018Amazon Web Services
 
Microservice vs. Monolithic Architecture
Microservice vs. Monolithic ArchitectureMicroservice vs. Monolithic Architecture
Microservice vs. Monolithic ArchitecturePaul Mooney
 
Build a Hybrid Cloud Architecture Using AWS Landing Zones (ENT304-R1) - AWS r...
Build a Hybrid Cloud Architecture Using AWS Landing Zones (ENT304-R1) - AWS r...Build a Hybrid Cloud Architecture Using AWS Landing Zones (ENT304-R1) - AWS r...
Build a Hybrid Cloud Architecture Using AWS Landing Zones (ENT304-R1) - AWS r...Amazon Web Services
 
Getting Started on Amazon EKS
Getting Started on Amazon EKSGetting Started on Amazon EKS
Getting Started on Amazon EKSMatthew Barlocker
 
Introduction to AWS VPC, Guidelines, and Best Practices
Introduction to AWS VPC, Guidelines, and Best PracticesIntroduction to AWS VPC, Guidelines, and Best Practices
Introduction to AWS VPC, Guidelines, and Best PracticesGary Silverman
 
VMware Tanzu Kubernetes Connect
VMware Tanzu Kubernetes ConnectVMware Tanzu Kubernetes Connect
VMware Tanzu Kubernetes ConnectVMware Tanzu
 
An Architectural Deep Dive With Kubernetes And Containers Powerpoint Presenta...
An Architectural Deep Dive With Kubernetes And Containers Powerpoint Presenta...An Architectural Deep Dive With Kubernetes And Containers Powerpoint Presenta...
An Architectural Deep Dive With Kubernetes And Containers Powerpoint Presenta...SlideTeam
 
Releasing Software Quickly and Reliably with AWS CodePipline
Releasing Software Quickly and Reliably with AWS CodePiplineReleasing Software Quickly and Reliably with AWS CodePipline
Releasing Software Quickly and Reliably with AWS CodePiplineAmazon Web Services
 
Continuous Delivery to Kubernetes with Jenkins and Helm
Continuous Delivery to Kubernetes with Jenkins and HelmContinuous Delivery to Kubernetes with Jenkins and Helm
Continuous Delivery to Kubernetes with Jenkins and HelmDavid Currie
 
Virtualization Vs. Containers
Virtualization Vs. ContainersVirtualization Vs. Containers
Virtualization Vs. Containersactualtechmedia
 
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
 
Best Practices with Azure Kubernetes Services
Best Practices with Azure Kubernetes ServicesBest Practices with Azure Kubernetes Services
Best Practices with Azure Kubernetes ServicesQAware GmbH
 

What's hot (20)

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
 
Curso Kubernetes CodeURJC
Curso Kubernetes CodeURJCCurso Kubernetes CodeURJC
Curso Kubernetes CodeURJC
 
Kubernetes on AWS with Amazon EKS
Kubernetes on AWS with Amazon EKSKubernetes on AWS with Amazon EKS
Kubernetes on AWS with Amazon EKS
 
Kubernetes Helm: Why It Matters
Kubernetes Helm: Why It MattersKubernetes Helm: Why It Matters
Kubernetes Helm: Why It Matters
 
AWS VPN Solutions (NET304) - AWS re:Invent 2018
AWS VPN Solutions (NET304) - AWS re:Invent 2018AWS VPN Solutions (NET304) - AWS re:Invent 2018
AWS VPN Solutions (NET304) - AWS re:Invent 2018
 
Microservice vs. Monolithic Architecture
Microservice vs. Monolithic ArchitectureMicroservice vs. Monolithic Architecture
Microservice vs. Monolithic Architecture
 
Build a Hybrid Cloud Architecture Using AWS Landing Zones (ENT304-R1) - AWS r...
Build a Hybrid Cloud Architecture Using AWS Landing Zones (ENT304-R1) - AWS r...Build a Hybrid Cloud Architecture Using AWS Landing Zones (ENT304-R1) - AWS r...
Build a Hybrid Cloud Architecture Using AWS Landing Zones (ENT304-R1) - AWS r...
 
Getting Started on Amazon EKS
Getting Started on Amazon EKSGetting Started on Amazon EKS
Getting Started on Amazon EKS
 
Introduction to AWS VPC, Guidelines, and Best Practices
Introduction to AWS VPC, Guidelines, and Best PracticesIntroduction to AWS VPC, Guidelines, and Best Practices
Introduction to AWS VPC, Guidelines, and Best Practices
 
Introduction to Amazon EKS
Introduction to Amazon EKSIntroduction to Amazon EKS
Introduction to Amazon EKS
 
VMware Tanzu Kubernetes Connect
VMware Tanzu Kubernetes ConnectVMware Tanzu Kubernetes Connect
VMware Tanzu Kubernetes Connect
 
Microservices, Containers and Docker
Microservices, Containers and DockerMicroservices, Containers and Docker
Microservices, Containers and Docker
 
Deep Dive - CI/CD on AWS
Deep Dive - CI/CD on AWSDeep Dive - CI/CD on AWS
Deep Dive - CI/CD on AWS
 
An Architectural Deep Dive With Kubernetes And Containers Powerpoint Presenta...
An Architectural Deep Dive With Kubernetes And Containers Powerpoint Presenta...An Architectural Deep Dive With Kubernetes And Containers Powerpoint Presenta...
An Architectural Deep Dive With Kubernetes And Containers Powerpoint Presenta...
 
Releasing Software Quickly and Reliably with AWS CodePipline
Releasing Software Quickly and Reliably with AWS CodePiplineReleasing Software Quickly and Reliably with AWS CodePipline
Releasing Software Quickly and Reliably with AWS CodePipline
 
Getting Started with Amazon EC2
Getting Started with Amazon EC2Getting Started with Amazon EC2
Getting Started with Amazon EC2
 
Continuous Delivery to Kubernetes with Jenkins and Helm
Continuous Delivery to Kubernetes with Jenkins and HelmContinuous Delivery to Kubernetes with Jenkins and Helm
Continuous Delivery to Kubernetes with Jenkins and Helm
 
Virtualization Vs. Containers
Virtualization Vs. ContainersVirtualization Vs. Containers
Virtualization Vs. Containers
 
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
 
Best Practices with Azure Kubernetes Services
Best Practices with Azure Kubernetes ServicesBest Practices with Azure Kubernetes Services
Best Practices with Azure Kubernetes Services
 

Similar to Learn kubernetes in 90 minutes

Kubernetes - Sailing a Sea of Containers
Kubernetes - Sailing a Sea of ContainersKubernetes - Sailing a Sea of Containers
Kubernetes - Sailing a Sea of ContainersKel Cecil
 
5 Painless Demos to Get You Started with Kubernetes
5 Painless Demos to Get You Started with Kubernetes5 Painless Demos to Get You Started with Kubernetes
5 Painless Demos to Get You Started with KubernetesAmartus
 
kubeadm Cluster Creation Internals_ From Self-Hosting to Upgradability and HA...
kubeadm Cluster Creation Internals_ From Self-Hosting to Upgradability and HA...kubeadm Cluster Creation Internals_ From Self-Hosting to Upgradability and HA...
kubeadm Cluster Creation Internals_ From Self-Hosting to Upgradability and HA...ssuser92b4be
 
OSS Japan 2019 service mesh bridging Kubernetes and legacy
OSS Japan 2019 service mesh bridging Kubernetes and legacyOSS Japan 2019 service mesh bridging Kubernetes and legacy
OSS Japan 2019 service mesh bridging Kubernetes and legacySteve Wong
 
Run K8s on Local Environment
Run K8s on Local EnvironmentRun K8s on Local Environment
Run K8s on Local EnvironmentGanesh Pol
 
Kubernetes Introduction
Kubernetes IntroductionKubernetes Introduction
Kubernetes IntroductionEric Gustafson
 
Kubernetes extensibility
Kubernetes extensibilityKubernetes extensibility
Kubernetes extensibilityDocker, Inc.
 
Build Your Own CaaS (Container as a Service)
Build Your Own CaaS (Container as a Service)Build Your Own CaaS (Container as a Service)
Build Your Own CaaS (Container as a Service)HungWei Chiu
 
Kubernetes installation
Kubernetes installationKubernetes installation
Kubernetes installationAhmed Mekawy
 
Container Deployment and Management with kubernetes
Container Deployment and Management with kubernetesContainer Deployment and Management with kubernetes
Container Deployment and Management with kubernetessiuyin
 
Deploy the blockchain network using kubernetes ap is on google cloud
Deploy the blockchain network using kubernetes ap is on google cloudDeploy the blockchain network using kubernetes ap is on google cloud
Deploy the blockchain network using kubernetes ap is on google cloudAjeet Singh
 
Kubernetes cheetsheet.pdf
Kubernetes cheetsheet.pdfKubernetes cheetsheet.pdf
Kubernetes cheetsheet.pdfEswar378637
 
K8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals TrainingK8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals TrainingPiotr Perzyna
 
Effective Building your Platform with Kubernetes == Keep it Simple
Effective Building your Platform with Kubernetes == Keep it Simple Effective Building your Platform with Kubernetes == Keep it Simple
Effective Building your Platform with Kubernetes == Keep it Simple Wojciech Barczyński
 
Mastering Kubernetes - Basics and Advanced Concepts using Example Project
Mastering Kubernetes - Basics and Advanced Concepts using Example ProjectMastering Kubernetes - Basics and Advanced Concepts using Example Project
Mastering Kubernetes - Basics and Advanced Concepts using Example Projectwajrcs
 
Kubernetes Architecture and Introduction
Kubernetes Architecture and IntroductionKubernetes Architecture and Introduction
Kubernetes Architecture and IntroductionStefan Schimanski
 
Social Connections 14 - Kubernetes Basics for Connections Admins
Social Connections 14 - Kubernetes Basics for Connections AdminsSocial Connections 14 - Kubernetes Basics for Connections Admins
Social Connections 14 - Kubernetes Basics for Connections Adminspanagenda
 
Kubernetes Basics for Connections Admins
Kubernetes Basics for Connections AdminsKubernetes Basics for Connections Admins
Kubernetes Basics for Connections AdminsLetsConnect
 
Kubernetes Architecture with Components
 Kubernetes Architecture with Components Kubernetes Architecture with Components
Kubernetes Architecture with ComponentsAjeet Singh
 

Similar to Learn kubernetes in 90 minutes (20)

Kubernetes - Sailing a Sea of Containers
Kubernetes - Sailing a Sea of ContainersKubernetes - Sailing a Sea of Containers
Kubernetes - Sailing a Sea of Containers
 
5 Painless Demos to Get You Started with Kubernetes
5 Painless Demos to Get You Started with Kubernetes5 Painless Demos to Get You Started with Kubernetes
5 Painless Demos to Get You Started with Kubernetes
 
kubeadm Cluster Creation Internals_ From Self-Hosting to Upgradability and HA...
kubeadm Cluster Creation Internals_ From Self-Hosting to Upgradability and HA...kubeadm Cluster Creation Internals_ From Self-Hosting to Upgradability and HA...
kubeadm Cluster Creation Internals_ From Self-Hosting to Upgradability and HA...
 
Kubernetes
KubernetesKubernetes
Kubernetes
 
OSS Japan 2019 service mesh bridging Kubernetes and legacy
OSS Japan 2019 service mesh bridging Kubernetes and legacyOSS Japan 2019 service mesh bridging Kubernetes and legacy
OSS Japan 2019 service mesh bridging Kubernetes and legacy
 
Run K8s on Local Environment
Run K8s on Local EnvironmentRun K8s on Local Environment
Run K8s on Local Environment
 
Kubernetes Introduction
Kubernetes IntroductionKubernetes Introduction
Kubernetes Introduction
 
Kubernetes extensibility
Kubernetes extensibilityKubernetes extensibility
Kubernetes extensibility
 
Build Your Own CaaS (Container as a Service)
Build Your Own CaaS (Container as a Service)Build Your Own CaaS (Container as a Service)
Build Your Own CaaS (Container as a Service)
 
Kubernetes installation
Kubernetes installationKubernetes installation
Kubernetes installation
 
Container Deployment and Management with kubernetes
Container Deployment and Management with kubernetesContainer Deployment and Management with kubernetes
Container Deployment and Management with kubernetes
 
Deploy the blockchain network using kubernetes ap is on google cloud
Deploy the blockchain network using kubernetes ap is on google cloudDeploy the blockchain network using kubernetes ap is on google cloud
Deploy the blockchain network using kubernetes ap is on google cloud
 
Kubernetes cheetsheet.pdf
Kubernetes cheetsheet.pdfKubernetes cheetsheet.pdf
Kubernetes cheetsheet.pdf
 
K8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals TrainingK8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals Training
 
Effective Building your Platform with Kubernetes == Keep it Simple
Effective Building your Platform with Kubernetes == Keep it Simple Effective Building your Platform with Kubernetes == Keep it Simple
Effective Building your Platform with Kubernetes == Keep it Simple
 
Mastering Kubernetes - Basics and Advanced Concepts using Example Project
Mastering Kubernetes - Basics and Advanced Concepts using Example ProjectMastering Kubernetes - Basics and Advanced Concepts using Example Project
Mastering Kubernetes - Basics and Advanced Concepts using Example Project
 
Kubernetes Architecture and Introduction
Kubernetes Architecture and IntroductionKubernetes Architecture and Introduction
Kubernetes Architecture and Introduction
 
Social Connections 14 - Kubernetes Basics for Connections Admins
Social Connections 14 - Kubernetes Basics for Connections AdminsSocial Connections 14 - Kubernetes Basics for Connections Admins
Social Connections 14 - Kubernetes Basics for Connections Admins
 
Kubernetes Basics for Connections Admins
Kubernetes Basics for Connections AdminsKubernetes Basics for Connections Admins
Kubernetes Basics for Connections Admins
 
Kubernetes Architecture with Components
 Kubernetes Architecture with Components Kubernetes Architecture with Components
Kubernetes Architecture with Components
 

More from Larry Cai

Learn jobDSL for Jenkins
Learn jobDSL for JenkinsLearn jobDSL for Jenkins
Learn jobDSL for JenkinsLarry Cai
 
Learn RabbitMQ with Python in 90mins
Learn RabbitMQ with Python in 90minsLearn RabbitMQ with Python in 90mins
Learn RabbitMQ with Python in 90minsLarry Cai
 
Learn flask in 90mins
Learn flask in 90minsLearn flask in 90mins
Learn flask in 90minsLarry Cai
 
Learn ELK in docker
Learn ELK in dockerLearn ELK in docker
Learn ELK in dockerLarry Cai
 
Software Engineer Talk
Software Engineer TalkSoftware Engineer Talk
Software Engineer TalkLarry Cai
 
Learn nginx in 90mins
Learn nginx in 90minsLearn nginx in 90mins
Learn nginx in 90minsLarry Cai
 
Learn basic ansible using docker
Learn basic ansible using dockerLearn basic ansible using docker
Learn basic ansible using dockerLarry Cai
 
Build service with_docker_in_90mins
Build service with_docker_in_90minsBuild service with_docker_in_90mins
Build service with_docker_in_90minsLarry Cai
 
Learn docker in 90 minutes
Learn docker in 90 minutesLearn docker in 90 minutes
Learn docker in 90 minutesLarry Cai
 
Learn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutesLearn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutesLarry Cai
 
Learn REST API with Python
Learn REST API with PythonLearn REST API with Python
Learn REST API with PythonLarry Cai
 
Jenkins Scriptler in 90mins
Jenkins Scriptler in 90minsJenkins Scriptler in 90mins
Jenkins Scriptler in 90minsLarry Cai
 
Python virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutesPython virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutesLarry Cai
 
Lead changes in software development
Lead changes in software developmentLead changes in software development
Lead changes in software developmentLarry Cai
 
Python in 90mins
Python in 90minsPython in 90mins
Python in 90minsLarry Cai
 
Practical way to experience of Specification by Example
Practical way to experience of Specification by ExamplePractical way to experience of Specification by Example
Practical way to experience of Specification by ExampleLarry Cai
 
Experience from specification_by_examples
Experience from specification_by_examplesExperience from specification_by_examples
Experience from specification_by_examplesLarry Cai
 
Write book in markdown
Write book in markdownWrite book in markdown
Write book in markdownLarry Cai
 
Continuous Integration Introduction
Continuous Integration IntroductionContinuous Integration Introduction
Continuous Integration IntroductionLarry Cai
 
Agile & ALM tools
Agile & ALM toolsAgile & ALM tools
Agile & ALM toolsLarry Cai
 

More from Larry Cai (20)

Learn jobDSL for Jenkins
Learn jobDSL for JenkinsLearn jobDSL for Jenkins
Learn jobDSL for Jenkins
 
Learn RabbitMQ with Python in 90mins
Learn RabbitMQ with Python in 90minsLearn RabbitMQ with Python in 90mins
Learn RabbitMQ with Python in 90mins
 
Learn flask in 90mins
Learn flask in 90minsLearn flask in 90mins
Learn flask in 90mins
 
Learn ELK in docker
Learn ELK in dockerLearn ELK in docker
Learn ELK in docker
 
Software Engineer Talk
Software Engineer TalkSoftware Engineer Talk
Software Engineer Talk
 
Learn nginx in 90mins
Learn nginx in 90minsLearn nginx in 90mins
Learn nginx in 90mins
 
Learn basic ansible using docker
Learn basic ansible using dockerLearn basic ansible using docker
Learn basic ansible using docker
 
Build service with_docker_in_90mins
Build service with_docker_in_90minsBuild service with_docker_in_90mins
Build service with_docker_in_90mins
 
Learn docker in 90 minutes
Learn docker in 90 minutesLearn docker in 90 minutes
Learn docker in 90 minutes
 
Learn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutesLearn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutes
 
Learn REST API with Python
Learn REST API with PythonLearn REST API with Python
Learn REST API with Python
 
Jenkins Scriptler in 90mins
Jenkins Scriptler in 90minsJenkins Scriptler in 90mins
Jenkins Scriptler in 90mins
 
Python virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutesPython virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutes
 
Lead changes in software development
Lead changes in software developmentLead changes in software development
Lead changes in software development
 
Python in 90mins
Python in 90minsPython in 90mins
Python in 90mins
 
Practical way to experience of Specification by Example
Practical way to experience of Specification by ExamplePractical way to experience of Specification by Example
Practical way to experience of Specification by Example
 
Experience from specification_by_examples
Experience from specification_by_examplesExperience from specification_by_examples
Experience from specification_by_examples
 
Write book in markdown
Write book in markdownWrite book in markdown
Write book in markdown
 
Continuous Integration Introduction
Continuous Integration IntroductionContinuous Integration Introduction
Continuous Integration Introduction
 
Agile & ALM tools
Agile & ALM toolsAgile & ALM tools
Agile & ALM tools
 

Recently uploaded

Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
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
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Jeffrey Haguewood
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentMahmoud Rabie
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...amber724300
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfAarwolf Industries LLC
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
[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
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
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
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessWSO2
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFMichael Gough
 

Recently uploaded (20)

Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
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
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career Development
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdf
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
[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
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
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
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with Platformless
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDF
 

Learn kubernetes in 90 minutes

  • 1. Learn Kubernetes in 90 minutes Larry Cai <larry.caiyu@gmail.com>
  • 2. Agenda  Introduction  Exercise 1: First web service in kubernetes  Exercise 2: Revisit pod, deployment and service  Exercise 3: Controller – Deployment (scale)  Exercise 4: Deploy with YAML file  Exercise 5: install Microservice: Guestbook  Reference Learn kubernetes in 90 minutes2 10/2/2017 Minikube environment setup is in appendix
  • 3. Environment using k8s playground  Three nodes in http://labs.play-with-k8s.com (master + 2 workers)  Node 1 (master node): follow guideline step 1/2/3 If dashboard doesn’t work, use https://git.io/vdc52 instead of https://git.io/kube-dashboard  Node 2/Node 3 kubeadm join –token … # check the console log in Node 1  Node 1: kubectl get nodes  Click the port to open dashboard Learn kubernetes in 90 minutes3 10/2/2017 Try to use Ctrl-Ins & Shift-Ins for copy/paste
  • 4. Background – Container/Docker  Container technology offers an alternative method for virtualization in cloud, with more efficiency & fast  New era for packaging and delivering software  Docker is one execution engine for container  docker pull nginx  docker run --name web -d -p 8080:80 nginx  docker exec -it web bash  docker build -t larrycai/whoami . Learn kubernetes in 90 minutes4 10/2/2017 See more in CodingWithMe Docker https://www.slideshare.net/larrycai/learn-docker-in-90- minutes
  • 5. What is kubernetes ?  Kubernetes is an open source container orchestration platform that helps manage distributed, containerized applications at massive scale.  Kubernetes (k8s) comes from google  kubernetes is a product platform to run container (Docker is one type of container execution engine)  k8s to container likes openstack to virtual machine.  Key features (list partly):  Auto-scaling  Self-healing infrastructure  Application lifecycle management Learn kubernetes in 90 minutes5 10/2/2017
  • 6. K8s Architecture  Master and Work Node (multi or single)  Container is executed in Work Node as default Learn kubernetes in 90 minutes6 10/2/2017 Source: https://thenewstack.io/kubernetes-an-overview/
  • 7. Exer 1: running first web service  Let’s start one web server in k8s (cloud)  Nginx is webserver like apache  Start the service from official docker image https://hub.docker.com/_/nginx/  kubectl run nginx --image=nginx --port=80  kubectl expose deployment nginx --type=NodePort  Check what happens  Check dashboard  Access the nginx web service (click new port)  kubectl get pods  kubectl get pods –o wide # check node  kubectl get all  kubectl describe nodes  docker ps # in different node  Kill the pod ! And check again  kubectl delete pods nginx-<xxx> Learn kubernetes in 90 minutes7 10/2/2017
  • 8. Overall for running service Learn kubernetes in 90 minutes8 10/2/2017 Image source https://kubernetes.io/images/hellonode/image_13.
  • 9. What is Pod ?  A pod is a group of one or more containers (such as Docker containers), the shared storage for those containers  Minimal element in kubernetes, run in one Node  Command kubectl run pods kubectl get pods kubectl delete pods kubectl describe pods <pod> kubectl exec -it <pod> -- bash Learn kubernetes in 90 minutes9 10/2/2017
  • 10. What is Deployment ?  The Deployment is responsible for creating and updating instances of your application (using controller)  Once the application instances are created, a Kubernetes Deployment Controller continuously monitors those instances  Default is one instance and keep active  Review the command  kubectl run nginx --image=nginx --port=80 --replicas=1  Download docker image nginx (from hub.docker.com) as internal port is 80  Run docker image inside pod named “nginx-xxx” with 1 instance  Deployment with name “nginx”  If pod is deleted, deployment control create new one Learn kubernetes in 90 minutes10 10/2/2017
  • 11. What is Service ?  Service is an abstraction which defines a logical set of Pods and a policy by which to access them  sometimes called a micro-service  Service could be selected by label (skipped here) Learn kubernetes in 90 minutes11 10/2/2017  ServiceTypes defines how to expose a Service, The default is ClusterIP (internal)  NodeType : expose port in Kubernetes Master kubectl expose deployment xxx – type=NodePort  Load Balancer (need support in k8s infra)Image source: http://wso2.com/whitepapers/a-reference-architecture-for-deploying-wso2-middleware-on- kubernetes/
  • 12. Exer 2: Revisit pod, deployment and service  Enter into container inside pod  kubectl exec -it nginx-xxx -- bash  Start pod only without deployment  kubectl run nginx --image=nginx --port=80 --restart=Never  kubectl run -i --tty busybox --image=busybox -- sh  Expose to another service  kubectl expose --name nginx2 deploy nginx  kubectl get service  curl <cluster ip>  kubectl expose --name nginx3 deploy nginx --type=NodePort  Clean up the deployment and service  kubectl delete service xxx  kubectl delete deployment xxx # check pod removed or not Learn kubernetes in 90 minutes12 10/2/2017
  • 13. Deployment more  Deployment describe the desired state in a Deployment object, and the Deployment controller will change the actual state to the desired state at a controlled rate for you  Scale to wanted size (replicas)  $ kubectl scale --replicas=2 deployment/nginx $ kubectl scale --replicas=10 deployment/nginx deployment "nginx" scaled $ kubectl rollout status deployment/nginx Waiting for rollout to finish: 2 of 10 updated replicas are available... …. Waiting for rollout to finish: 9 of 10 updated replicas are available... deployment "nginx" successfully rolled out $ kubectl get pods  Patch, Upgrade, Rollback ..  Autoscale : grow when needed Learn kubernetes in 90 minutes13 10/2/2017
  • 14. One example: Canary release  Kubernetes support to define own deploy strategy.  User takes care of the service and what it wants to expose  The k8s platform do the rest Learn kubernetes in 90 minutes14 10/2/2017 Source http://blog.kubernetes.io/2017/04/multi-stage-canary-deployments-with-kubernetes-in-the-cloud-onprem
  • 15. Exer 3 : Deployment with Scale  Show hostname ( image: larrycai/whoami ) kubectl run whoami --image=larrycai/whoami --port=5000 kubectl expose deploy whoami --type=NodePort  Check the webpage  Delete kubectl delete pods whoami-xxxx  Check the webpage (reload)  Scale kubectl scale --replicas=5 deployment/whoami kubectl rollout status deployment/whoami kubectl get pods  Check the webpage (reload) Learn kubernetes in 90 minutes15 10/2/2017
  • 16. YAML descriptors  Kubectl command line to deal with objects with limited set of properties  Difficult to maintain and version control  YAML file is used to manage the object kubectl create -f node-pod.yaml kubectl create –f http://example.com/nginx-pod.yaml  Get full descriptions of the object in YAML kubectl get pods nginx2 -o yaml Learn kubernetes in 90 minutes16 10/2/2017
  • 17. Exer 4: deploy from YAML file  Create whoami deploy yaml file (use pod as reference) kubectl get deploy whoami -o yaml  Download and create https://github.com/larrycai/codingwithme- k8s/blob/master/whoami.yaml curl -L -o whoami.yaml https://git.io/v7yd8 kubectl delete service whoami kubectl delete deploy whoami kubectl create -f whoami.yaml  Change the ReplicaSet to 5 and run it again kubectl apply -f whoami.yaml Learn kubernetes in 90 minutes17 10/2/2017
  • 18. Microservices in Kubernetes  Kubernetes is a great tool for microservices clustering and orchestration.  It is still a quite new and under active development  Kubernetes provides lots of features to be used to deploy microservices  Declare in YAML to deploy them  Kubernetes official tutorial Guestbook https://kubernetes.io/docs/tutorials/stateless-application/guestbook/ Learn kubernetes in 90 minutes18 10/2/2017 Image source: https://netmark.jp/wp-content/uploads/2014/12/guestbook-kubernetes.pn
  • 19. Exer 5: Install Guestbook  Deploy all in one kubectl create -f https://git.io/v7ytR # shorturl to guestbook-all-in-one.yaml  Check dashboards  Expose service to NodePort kubectl expose svc frontend --name f2 --type=NodePort Learn kubernetes in 90 minutes19 10/2/2017
  • 20. Summary  Kubernetes: a platform to run container (docker)  Concept:  A Node is a worker machine in Kubernetes  A Pod is the basic building block of Kubernetes, which has a group of containers  Deployment controls the state of the pod (scale, replicate)  Service is an abstraction which defines a logical set of Pods and a policy by which to access them. (micro service ..)  Kubernetes grows very fast, follow it. Learn kubernetes in 90 minutes20 10/2/2017
  • 21. Reference  K8s doc: https://kubernetes.io/docs/home/  Code: https://github.com/larrycai/codingwithme-k8s  Minikube: https://github.com/kubernetes/minikube  Blog: multi stage deployment with kubernetes: http://blog.kubernetes.io/2017/04/multi-stage-canary-deployments- with-kubernetes-in-the-cloud-onprem.html  Video: The Illustrated Children's Guide to Kubernetes  Sandbox online: http://labs.play-with-k8s.com/  Book: Kubernetes in Action (Manning) Learn kubernetes in 90 minutes21 10/2/2017
  • 22. ChangeLog  2017/07/23: first version  2017/08/11: use k8s playground  2017/10/2: fix dashboard url Learn kubernetes in 90 minutes22 10/2/2017
  • 23. Appendix Learn kubernetes in 90 minutes23 10/2/2017
  • 24. Minikube  Minikube is all-in-one local kubernetes environment  Works on Linux/Mac/Unix using virtual machine Learn kubernetes in 90 minutes24 10/2/2017 Minikube VM Kubernetes (master + work node) VirtualBox Windows
  • 25. Environment Preparation (Win)  Using unix env in windows (if not, install Git Windows)  Minikube + Kubectl  Minikube is local installation of kubernetes using VM  Kubectl is the client of kubernetes  Configure PATH (%USERPROFILE% => /c/Users/<id>)  Download  curl -L -o minikube.exe https://storage.googleapis.com/minikube/releases/latest/minikube-windows- amd64.exe  curl -LO https://storage.googleapis.com/kubernetes- release/release/v1.7.0/bin/windows/amd64/kubectl.exe  mv minikube.exe kubectl.exe /c/Users/$LOGNAME/bin #$PATH  Installation  minikube start --kubernetes-version=v1.7.0  kubectl version  minikube config set kubernetes-version v1.7.0  minikube stop Learn kubernetes in 90 minutes25 10/2/2017
  • 26.  Forward the local port to the pods without involving service  One simple way to get access to container  kubectl port-forward nginx 8080:80 Access Pod: Port forwarding Learn kubernetes in 90 minutes26 10/2/2017 curl Local machine (kubectl/windows) kubectl port-forward service Port 8080 Kubernetes inside VM (Virtualbox) Pod nginx Port 80
  • 27. Exer 2: simple pod to access  Create the pod nginx2 without deployment  kubectl run nginx2 --image=nginx --port=80 --restart=Never  kubectl describe pods nginx2  Check docker container  docker ps  Access it by using port-forwarding  kubectl port-forward nginx2 8080:80  Use browser to http://localhost:8080  curl http://localhost:8080  Dashboard  minikube dashboard # check pods/nodes  Delete  kubectl delete pods nginx2 Learn kubernetes in 90 minutes27 10/2/2017