@rob_rich
 
PPAI Tech Summit

 

 

Kubernetes Test Drive

by Rob Richardson

@rob_rich

https://robrich.org/

About Me

Rob Richardson is a software craftsman building web properties in ASP.NET and Node, React and Vue. He's a frequent speaker at conferences, user groups, and community events, and a diligent teacher and student of high quality software development. You can find this and other talks on his blog at https://robrich.org/presentations and follow him on twitter at @rob_rich.

What is Kubernetes?

Industry standard container orchestration engine
by Google
best known for rolling updates and auto scaling

What is an Orchestration Engine?

Given a cluster of machine(s)
We specify containers' desired state
The engine makes it happen

We don't specify which machine does what

Kubernetes

Hosts containers

Either Docker containers or ...
are there any others really?

What is Docker?

Docker is an ecosystem around Container Virtualization

What are Containers?

Light-weight kernel virtualization

What is Docker?

A suite of command-line tools for creating, running, and managing containers

Containers vs VMs

vm vs container

Source: http://www.zdnet.com/article/what-is-docker-and-why-is-it-so-darn-popular/

Containers

Containers virtualize and share the host kernel

Containers must run on the kernel for which they were built:

  • Linux
  • Windows Server

Host Docker in a VM

docker nested in a vm

Ephemeral, Isomorphic, Deterministic Hardware

  • Each copy is identical
  • Don't upgrade, replace
  • Many instances from one file
  • Built the same each time
  • Saved in a small configuration file

Docker: Dev & Ops Communication

Inside the Container:

  • A machine
  • Unique IP, hostname
  • Build your perfect snowflake
 

Outside the Container:

  • A process
  • Plug in power and internet
  • Restart quickly
  • Scale by launching more

The Ecosystem

docker ecosystem

Download: https://robrich.org/slides/welcome-to-docker/docker-ecosystem.pdf

docker ecosystem changed

Docker -> Kubernetes

K8s: "Given a Docker image ..."

Keep

  • docker build
  • docker registry
  • docker push

Replace

  • docker-compose
  • docker swarm

Kubernetes Scenario

kubernetes ecosystem

source: https://vitalflux.com/quick-glance-at-kubernetes-architectural-building-blocks/

Kubernetes gets microservices

Installing Kubernetes

Kubernetes elements

Elements

Pod

work details

Deployment

scale / restart details

Service

inbound traffic
others ingress, replica set, stateful set,
job, cron job, secret, etc.

Pod

apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  containers:
  - name: nginx
    image: nginx:1.7.9
    ports:
    - containerPort: 80

source: https://kubernetes.io/docs/user-guide/walkthrough/

Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80

source: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/

Deployment apiVersion

v1.9+ apiVersion: apps/v1
v1.8 apiVersion: apps/v1beta2
v1.7 & 1.6 apiVersion: apps/v1beta1
< 1.6 apiVersion: extensions/v1beta1

Service

apiVersion: v1
kind: Service
metadata:
  name: nginx-service
  labels:
    app: nginx
spec:
  selector:
    app: nginx
  type: NodePort
  ports:
  - port: 80
    protocol: TCP

source: https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/

Service Types

no service no traffic into pod

ClusterIP

internal port on cluster

NodePort

public port on each worker node

LoadBalancer

cloud's native load balancer

Mapping Service to Pod

Service.yaml

kind: Service
...
spec:
  selector:
    app: nginx
...

Pod.yaml (or template in Deployment.yaml)

kind: Pod
metadata:
  labels:
    app: nginx
...

DEMO: yaml config files

Kubernetes cli

DEMO: launch apps

DEMO: upgrade apps

kubectl UI

kubernetes dashboard

source: https://github.com/kubernetes/dashboard

kubectl UI

Warning

It's really easy to change things.

Next time you deploy
your changes will be lost.