orchestrating microservices with kubernetes

43
Orchestrating Microservices with Kubernetes Jeff Hoffer, Developer Experience github.com/eudaimos

Upload: weaveworks

Post on 22-Jan-2018

335 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Orchestrating Microservices with Kubernetes

Orchestrating Microservices with Kubernetes

Jeff Hoffer, Developer Experiencegithub.com/eudaimos

Page 2: Orchestrating Microservices with Kubernetes

What does Weave do?

Weave helps devops iterate faster with: • observability &

monitoring • continuous delivery • container networks

& firewalls

Kubernetes is our #1 platform

Page 3: Orchestrating Microservices with Kubernetes

Agenda1. Concepts 2. Containers, Pods, Deployments, Services 3. Installing Kubernetes 4. Demos of Pods, Deployments, Services 5. Microservices sample app 6. What’s next?

Page 4: Orchestrating Microservices with Kubernetes

Kubernetes: all you need to know

Pods

containers

Services

Deployments

Page 5: Orchestrating Microservices with Kubernetes

Concepts

Computer

Page 6: Orchestrating Microservices with Kubernetes

Concepts

Node

Page 7: Orchestrating Microservices with Kubernetes

Concepts

nginx Containerimage: nginx:1.7.9

Node

Page 8: Orchestrating Microservices with Kubernetes

web

Concepts

nginx ContainerPod

logger

Node

Page 9: Orchestrating Microservices with Kubernetes

web

Concepts

nginx ContainerPod

logger

IP addr

Node

Page 10: Orchestrating Microservices with Kubernetes

web

Concepts

Pod nginx

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

Node

Page 11: Orchestrating Microservices with Kubernetes

Recap: all you need to know

Pods containers

Container Image

Docker container image, contains your application code in an isolated environment.

Pod A set of containers, sharing network namespace and local volumes, co-scheduled on one machine. Mortal. Has pod IP. Has labels.

Page 12: Orchestrating Microservices with Kubernetes

Motivation for Deployments

Node 1

Podweb

nginx

Node 2

Page 13: Orchestrating Microservices with Kubernetes

Motivation for Deployments

Podweb

nginx

Node 1 Node 2

Page 14: Orchestrating Microservices with Kubernetes

Motivation for Deployments

Podweb

nginx

Node 1 Node 2

Page 15: Orchestrating Microservices with Kubernetes

Deployment

web

nginx

apiVersion: extensions/v1beta1 kind: Deployment metadata: name: nginx-deployment spec: replicas: 1 template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9

Node 1

Page 16: Orchestrating Microservices with Kubernetes

Deployment

web

nginx

apiVersion: extensions/v1beta1 kind: Deployment metadata: name: nginx-deployment spec: replicas: 1 template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9

Node 1

Page 17: Orchestrating Microservices with Kubernetes

Deployment

web

nginx

Node 1 Node 2

Page 18: Orchestrating Microservices with Kubernetes

Deployment

web

nginx

Node 1 Node 2

Page 19: Orchestrating Microservices with Kubernetes

Deployment

web

nginx

Node 1 Node 2

Page 20: Orchestrating Microservices with Kubernetes

Deployment

web

nginx

apiVersion: extensions/v1beta1 kind: Deployment metadata: name: nginx-deployment spec: replicas: 1 template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9

Node 1

Page 21: Orchestrating Microservices with Kubernetes

Deployment

web

nginx

apiVersion: extensions/v1beta1 kind: Deployment metadata: name: nginx-deployment spec: replicas: 2 template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9

Node 1

Page 22: Orchestrating Microservices with Kubernetes

Deployment

web

nginx

web

nginx

Node 1 Node 2

Page 23: Orchestrating Microservices with Kubernetes

Recap: all you need to know

Pods containers

Deployments

Container Image

Docker container image, contains your application code in an isolated environment.

Pod A set of containers, sharing network namespace and local volumes, co-scheduled on one machine. Mortal. Has pod IP. Has labels.

Deployment Specify how many replicas of a pod should run in a cluster. Then ensures that many are running across the cluster.

Page 24: Orchestrating Microservices with Kubernetes

Service discovery• Kubernetes provides DNS for service

discovery

Page 25: Orchestrating Microservices with Kubernetes

Service discovery• Kubernetes provides DNS for service

discovery

WAIT! You said “service”.

What is a service?

Page 26: Orchestrating Microservices with Kubernetes

Services: ClusterIP (internal things)

Computer 1

web

ruby

Computer 2

10.0.0.1db

pgsql

10.0.0.2

service VIP10.1.0.1DNS lookup “db”

returns A 10.1.0.1

Page 27: Orchestrating Microservices with Kubernetes

Services: ClusterIP (internal things)

Computer 1

web

ruby

Computer 2

10.0.0.1db

pgsql

10.0.0.2

service VIP10.1.0.1

Page 28: Orchestrating Microservices with Kubernetes

Services: NodePort (external)

Computer 1

web

nginx

web

nginx

10.0.0.1 10.0.0.2

81.23.64.18 81.23.64.19

requests requests

Computer 2

Page 29: Orchestrating Microservices with Kubernetes

Computer 1

web

nginx

web

nginx

10.0.0.1 10.0.0.2

81.23.64.18 81.23.64.19

requests requests

Computer 2

Services: NodePort (external)NodePort 30001service VIP10.1.0.1

NodePort 30001service VIP10.1.0.1

Page 30: Orchestrating Microservices with Kubernetes

Computer 1

web

nginx

web

nginx

10.0.0.1 10.0.0.2

81.23.64.18 81.23.64.19

requests requests

Computer 2

Services: NodePort (external)NodePort 30001service VIP10.1.0.1

NodePort 30001service VIP10.1.0.1

Page 31: Orchestrating Microservices with Kubernetes

kind: Deployment metadata: name: nginx-deployment spec: replicas: 2 template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9

kind: Service metadata: name: frontend spec: type: NodePort selector: app: nginx ports: - port: 80 targetPort: 80 nodePort: 30002

Using selectorsHow do services connect to deployments?

matches

Page 32: Orchestrating Microservices with Kubernetes

kind: Deployment metadata: name: nginx-deployment spec: replicas: 2 template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9

kind: Service metadata: name: frontend spec: type: NodePort selector: app: nginx ports: - port: 80 targetPort: 80 nodePort: 30002

How do you expose services to outside?Using NodePort

Page 33: Orchestrating Microservices with Kubernetes

Recap: all you need to know

Pods containers

ServicesDeployments

Container Image

Docker container image, contains your application code in an isolated environment.

Pod A set of containers, sharing network namespace and local volumes, co-scheduled on one machine. Mortal. Has pod IP. Has labels.

Deployment Specify how many replicas of a pod should run in a cluster. Then ensures that many are running across the cluster. Has labels.

Service Names things in DNS. Gets virtual IP. Two types: ClusterIP for internal services, NodePort for publishing to outside. Routes based on labels.

Page 34: Orchestrating Microservices with Kubernetes

Architecture of Kubernetes itself

Node 1 Node 2

Master

Page 35: Orchestrating Microservices with Kubernetes

API server

Architecture of Kubernetes itself

Node 1 Node 2

Master

API server etcd

kubeadm init

Page 36: Orchestrating Microservices with Kubernetes

API server

Architecture of Kubernetes itself

Node 1 Node 2

Master

API server etcd

kubeadm init

kubeadm join

kubelet

Page 37: Orchestrating Microservices with Kubernetes

API server

Architecture of Kubernetes itself

Node 1 Node 2

Master

API server etcd

kubeadm init

kubeadm join kubeadm join

kubelet kubelet

Page 38: Orchestrating Microservices with Kubernetes

API server

Architecture of Kubernetes itself

Node 1 Node 2

Master

API server etcd

kubeadm init

kubeadm join kubeadm join

kubelet kubelet

kubectl apply

Page 39: Orchestrating Microservices with Kubernetes

API server

Architecture of Kubernetes itself

Node 1 Node 2

Master

containersServices

containers

API server etcd

kubeadm init

kubeadm join kubeadm join

kubectl apply

kubelet kubelet

Page 40: Orchestrating Microservices with Kubernetes

Training!

Page 41: Orchestrating Microservices with Kubernetes

Join the Weave user group!

meetup.com/pro/Weave/ weave.works/help

Page 42: Orchestrating Microservices with Kubernetes

What’s next?

• Continuous delivery: hooking up my CI/CD pipeline to Kubernetes

• How do I monitor this stuff? • Network policy for security

Come to our Weave Cloud training to find out!

Page 43: Orchestrating Microservices with Kubernetes

Thanks! Questions?

We are hiring!DX in San Francisco

Engineers in London & SF

weave.works/weave-company/hiring