10 kube commandments...public cloud datacenter your desktop • gke on google cloud • aks on azure...

65
10 Kube Commandments

Upload: others

Post on 25-Jul-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

10 Kube Commandments

Page 2: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

We've been in the game for years

Page 3: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

That in itself is admirable

Page 4: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

There's rules to this biz

Page 5: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

We wrote y'all a manual

Page 6: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

A step-by-step conf talk for you to get...

Page 7: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Your clusters on track

Page 8: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

And not your releases pushed back

Page 9: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Staff Software Engineer Heptio

Lots of years Years of Experience @bryanl

Bryan Liles

Page 10: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Senior Software Engineer DigitalOcean

Observability Cloud Compute Services Systems Engineering @cagedmantis

Carlos Amedee

Page 11: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Rule Number Uno To go fast, you must start slow

Page 12: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Rule Number Uno To go fast, you must start

deliberately

Page 13: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Public Cloud Datacenter Your Desktop

Page 14: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Public Cloud Datacenter Your Desktop

• GKE on Google Cloud • AKS on Azure • *lots of vendors*

• kubeadm • *lots of vendors*

• Minikube • Minik8s • Docker for Mac or Windows

Page 15: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Public Cloud Datacenter

• GKE on Google Cloud • AKS on Azure • *lots of vendors*

• kubeadm • *lots of vendors*X X

Not Declarative

Page 16: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Cluster API

Page 17: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Number Two Always let them know your next move

Page 18: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Your next move is the images you'll deploy to your cluster

Page 19: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Build Image Host Image

Page 20: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

docker build

Page 21: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

docker build

•buildah •img •GCP Container Builder

Page 22: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Why are you still building your containers with root privileges?

Page 23: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Rule Number Three Never trust nobody: Hookup up

that Pod Security Policy

Page 24: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

apiVersion: extensions/v1beta1 kind: PodSecurityPolicy metadata: name: how-not-to-get-robbed spec: privileged: false runAsUser: rule: MustRunAsNonRoot seLinux: rule: RunAsAny fsGroup: rule: RunAsAny supplementalGroups: rule: RunAsAny volumes: - nfs

Page 25: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Number Four I know you heard this before: Never

get high off what Kube supplies

Page 26: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Custom Resource Definition

CRD Custom Controller

Page 27: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Custom Resources Pattern

CRD Custom Controller

K8s External

Resource

Native Resource

Page 28: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Custom Resources Pattern

CRD Custom Controller Operator

Page 29: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Custom Resources Pattern

CRD Custom Controller

Native Resource

Native Resource

Native Resource

Page 30: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Rule Number Five Communicating With Pods

Never Mix Internal and External Traffic

Page 31: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Ingress Traffic

Page 32: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Cluster IP

apiVersion: v1kind: Servicemetadata: name: sample-servicespec: selector: app: sample-app type: ClusterIP ports: - name: http port: 80 targetPort: 80 protocol: TCP

PodPod Pod

Service

Proxy

Page 33: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Node Port

apiVersion: v1kind: Servicemetadata: name: my-nodeport-servicespec: selector: app: my-app type: NodePort ports: - name: http port: 80 targetPort: 80 nodePort: 30036 protocol: TCP

PodPod Pod

Service

Pod

Page 34: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Load Balancer

apiVersion: v1kind: Servicemetadata: name: sample-lbspec: selector: app: some-app type: LoadBalancer ports: - name: http port: 80 targetPort: 80 protocol: TCP

PodPod Pod

Service

Load Balancer

Page 35: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

IngressapiVersion: extensions/v1beta1kind: Ingressmetadata: name: my-ingressspec: backend: serviceName: other servicePort: 8080 rules: - host: foo.mydomain.com http: paths: - backend: serviceName: foo servicePort: 8080 - host: mydomain.com http: paths: - path: /bar/* backend: serviceName: bar servicePort: 8080

PodPod Pod

Service

Ingress

PodPod Pod

Service

Page 36: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Egress Traffic

Page 37: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Egress

apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata: name: sample-network-policyspec: podSelector: matchLabels: role: my-app policyTypes: - Egress egress: - to: - ipBlock: cidr: 10.0.0.0/24

Page 38: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Service Mesh

Page 39: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Rule Number Six If You Think You Know What’s

Happening In Your Cluster… Forget it.

Page 40: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Observability

What’s happening in your cluster?

Page 41: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

What’s happening on your cluster?

Page 42: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Metrics and Alerting

Page 43: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Logging

Page 44: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Distributed Tracing

Page 45: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Observability Dashboard

Page 46: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Horizontal Pod Autoscaler

Page 47: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Rule Number Seven Keep your storage and the business

rules to manage it completely separated.

Page 48: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Storage

Page 49: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Easily create your own storage implementation

Page 50: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Persistent Volume Snapshots

Page 51: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Number 8: Using Tools

Page 52: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Package Management

Configuration Management

Page 53: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

• Helm 2 • Bounds of YAML

Package Management

Page 54: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Configuration Management

• ksonnet • Pulumi • Ballerina

Page 55: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s
Page 56: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Other types of tools?

• skaffold • kustomize

Page 57: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Number 9: Extending Kubernetes

Page 58: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

What happens if you get an API for free?

Page 59: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

What happens when you outgrow the Kubernetes API?

Page 60: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Number 10: A live word called refinement -- Building On

Kubernetes

Page 61: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Cluster

App 1 App 2 App 3

"On top of Kubernetes"

Page 62: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Cluster

App 1 App 2 App 3

"On Kubernetes"

Page 63: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

Follow these rules

Page 64: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

You'll have mad bread to break up

Page 65: 10 Kube Commandments...Public Cloud Datacenter Your Desktop • GKE on Google Cloud • AKS on Azure • *lots of vendors* • kubeadm • *lots of vendors* • Minikube • Minik8s

If not, 24 hours of on-call with constant wake ups.