2 - 2 - Introduction To Kubernetes
2 - 2 - Introduction To Kubernetes
Kubernetes
© Copyright 2017 CoreOS. All rights reserved. Not to be reproduced without prior written consent. 1
Topics
• Container Orchestration and Kubernetes
• Kubernetes Architecture Introduction
• Deploying a Simple Application
© Copyright 2017 CoreOS. All rights reserved. Not to be reproduced without prior written consent. 2
Microservices Management Problems (1 of 2)
• Microservices are small and focused
by design
• This means that for every
application, there are more parts to
manage
• The number of parts and
interdependencies multiplies with:
• Horizontal scaling
• Continuous delivery (frequent version
updates)
• Development, staging, production… v1 v2
© Copyright 2017 CoreOS. All rights reserved. Not to be reproduced without prior written consent. 3
Microservices Management Problems (2 of 2)
• Because of all of these parts, there is a
need for:
• Automatic configuration
• Automatic discovery
• Load balancing and scaling resources v1 v2
© Copyright 2017 CoreOS. All rights reserved. Not to be reproduced without prior written consent. 5
Kubernetes
• Production-grade container orchestration
• Automated container deployment, scaling and management
• Application-centered management
• Decoupled/modular architecture
• Open-sourced by Google with large community involvement
• Based on Google’s container-centric production infrastructure
• Top 0.01% of all GitHub projects | 1000+ contributors | 43K+ commits
• Run anywhere
• On-premise
• Public cloud
• Hybrid
• Virtual machine or bare metal
https://kubernetes.io
© Copyright 2017 CoreOS. All rights reserved. Not to be reproduced without prior written consent. 6
Kubernetes- Automated Operations and
Development
• Operations provides and maintains a
modern platform for applications
• Don’t know or care about the specifics of the
applications
• Focuses on things like infrastructure,
security, utilization, backup, new service
offerings
• Developers deploy and manage their
applications on the platform
• Don’t know or care about the specifics of the
infrastructure
© Copyright 2017 CoreOS. All rights reserved. Not to be reproduced without prior written consent. 7
Topics
• Container Orchestration and Kubernetes
• Kubernetes Architecture Introduction
• Deploying a Simple Application
© Copyright 2017 CoreOS. All rights reserved. Not to be reproduced without prior written consent. 8
The Datacenter as a Computer
• Google manages complexity in a
datacenter by treating it logically
as one big computer with units of:
• Compute
• Storage
• Networking
• Kubernetes is an implementation
of that simple idea
http://www.morganclaypool.com/doi/abs/10.2200/S00516ED2V01Y201306CAC024
© Copyright 2017 CoreOS. All rights reserved. Not to be reproduced without prior written consent. 9
Clusters, Master Components and Nodes
• Cluster- A group of virtual or bare Cluster
metal machines
• There may be hundreds or thousands of
these
• Master Components/ Control Plane …
• Machine(s) that contain the logic that
runs Kubernetes
Master
• Node/Worker- A single virtual or Components
Nodes/
Workers
bare metal machine
• These contain the applications running
on Kubernetes
© Copyright 2017 CoreOS. All rights reserved. Not to be reproduced without prior written consent. 10
MiniKube
• MiniKube runs an entire simplified MiniKube
“cluster” inside a single virtual
machine on your laptop
• Great for trying out Kubernetes or
developing locally
• Contains a single worker node and
simplified master components Master
Components
Node
Virtual Machine
https://github.com/kubernetes/minikube
© Copyright 2017 CoreOS. All rights reserved. Not to be reproduced without prior written consent. 11
Pods
• A node contain pods …
• Pods are the minimum Pods
deployable unit in a
Kubernetes cluster Node
Storage
Pod
© Copyright 2017 CoreOS. All rights reserved. Not to be reproduced without prior written consent. 12
Characteristics of Pods
• A pod acts as a standalone host IP Address
• Has its own IP address
• Containers and storage see the
same localhost Container(s)
© Copyright 2017 CoreOS. All rights reserved. Not to be reproduced without prior written consent. 13
Topics
• Container Orchestration and Kubernetes
• Kubernetes Architecture Introduction
• Deploying a Simple Application
© Copyright 2017 CoreOS. All rights reserved. Not to be reproduced without prior written consent. 14
kubectl Command Line Interface (CLI)
Cluster
$ kubectl cluster-info
Kubernetes master is running at https://192.168.99.100:8443
KubeDNS is running at ...
kubernetes-dashboard is running at ...
© Copyright 2017 CoreOS. All rights reserved. Not to be reproduced without prior written consent. 15
Introduction to Deployments
• A deployment results in a running and managed application
on Kubernetes
• The kubectl run command deploys pod(s) with a single
container to the cluster
$ kubectl run hello-kube --image=gcr.io/google_containers/echoserver:1.4 --port=8080
$ kubectl get deployments
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
hello-kube 1 1 1 1 21h
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
hello-kube-2825702551-0bw69 1/1 Running 0 21h
$ kubectl describe pod hello-kube-2825702551-0bw69
Name: hello-kube-2825702551-0bw69
Namespace: default
Node: minikube/192.168.99.100 ...
© Copyright 2017 CoreOS. All rights reserved. Not to be reproduced without prior written consent. 16
Introduction to Services
• A service is an abstraction which represents pod(s) with a
single, fixed IP address and port
• Clients of the service use this IP address and port to connect to the
service
• This works independently of the specifics of the (mortal) pods
• If there are multiple pods, requests are load balanced
• The --type=NodePort parameter below exposes the service as a port
on the node (port 32701 in the example below)
$ kubectl expose deployment hello-kube --type=NodePort
service "hello-kube" exposed
$ kubectl get services
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello-kube 10.0.0.151 <nodes> 8080:32701/TCP 21h
kubernetes 10.0.0.1 <none> 443/TCP 14d
© Copyright 2017 CoreOS. All rights reserved. Not to be reproduced without prior written consent. 17
Lab
1. Install the kubectl command line interface (if necessary)
2. Set up a test Kubernetes environment (if necessary)
3. Deploy a hello-kube single container application
4. View the deployment using kubectl commands
5. Expose hello-kube as a service
© Copyright 2017 CoreOS. All rights reserved. Not to be reproduced without prior written consent. 18