Kubernetes Kops - Automation Night

64
MAKE MONEY MATTER. Kubernetes Operations By Kasper Nissen (@phennex), DevOps Engineer @thelunarway

Transcript of Kubernetes Kops - Automation Night

Page 1: Kubernetes Kops - Automation Night

MAKEMONEYMATTER.

Kubernetes Operations

By Kasper Nissen (@phennex), DevOps Engineer @thelunarway

Page 2: Kubernetes Kops - Automation Night

MAKEMONEYMATTER.

Kubernetes Operations

By Kasper Nissen (@phennex), DevOps Engineer @thelunarway

Page 3: Kubernetes Kops - Automation Night

Vision

We're living in the era of mobile/digital only – we believe banking and commerce should to.

Therefore, our vision is to rethink the interaction with money and defining a complete new category - by introducing a new money app.

It’s the complex coordination between banking services and commerce use:

– How I save money. – How I get money. – How I spend money.

Page 4: Kubernetes Kops - Automation Night

Product “We own the data.

Page 5: Kubernetes Kops - Automation Night

Kasper NissenDevOps & Infrastructure Engineer @thelunarway

Experience

DevOps & Infrastructure Engineer @ LEGO (CITMABIS) (oursourced by IT Minds) for 5 months

Senior/Software Engineer @ IT Minds (~4 years part time)

Master thesis: KubeCloud - A Small-Scale Tangible Cloud Computing Environment.Interview with Software Engineering Daily: bit.ly/2paZ5lg

Blogging about Cloud Native Tech @ www.kubecloud.io

M. Eng. Computer Technology from Aarhus University - Department of Engineering.

B. Eng. Information and Communication Technology from Aarhus University - School of Engineering

Page 6: Kubernetes Kops - Automation Night

WHAT IS KUBERNETES?

Page 7: Kubernetes Kops - Automation Night

Written by: Matt Butcher Illustrated by: Bailey Beougher

Page 8: Kubernetes Kops - Automation Night
Page 9: Kubernetes Kops - Automation Night
Page 10: Kubernetes Kops - Automation Night
Page 11: Kubernetes Kops - Automation Night
Page 12: Kubernetes Kops - Automation Night
Page 13: Kubernetes Kops - Automation Night
Page 14: Kubernetes Kops - Automation Night
Page 15: Kubernetes Kops - Automation Night
Page 16: Kubernetes Kops - Automation Night
Page 17: Kubernetes Kops - Automation Night

WHAT DOES IT DO?

Node Node Node Node Node

Node Node Node Node Node

big dataapp Bapp A database

datacenter

Cluster Manager

Page 18: Kubernetes Kops - Automation Night

WHY ARE WE USING IT AT LUNAR WAY?

Freedom Squads can deploy and more or less implement how they see fit

Autonomous services Squads can work independent of other squads

Continuous Delivery Kubernetes allows us to deploy multiple times a day. It’s easy to rollback in case something went wrong

Flexibility We run many different type of workloads in the cluster. Gives us mobility to become cloud agnostic

Scalable infrastructure Scaling the infrastructure is easy, both on node and container level

High availability Kubernetes takes care of container failures, AWS Auto Scaling groups takes care of node failures

Easy maintenance We are using Kubernetes Operations to help us spin up our clusters, and maintain them.

👍🎉

Page 19: Kubernetes Kops - Automation Night

THAT’S GREAT,BUT HOW DO I GET STARTED? 🤓

Page 20: Kubernetes Kops - Automation Night

KUBERNETES OPERATIONS AKA. KOPS

Page 21: Kubernetes Kops - Automation Night

WHAT IS THAT? 😱

Page 22: Kubernetes Kops - Automation Night

THINK OF IT AS KUBECTL FOR CLUSTERS 👏

Page 23: Kubernetes Kops - Automation Night

kubectl get pods

Page 24: Kubernetes Kops - Automation Night

NAME READY STATUS RESTARTS AGE dns-controller 1/1 Running 0 13d etcd-server-events-ip 1/1 Running 0 13d etcd-server-ip 1/1 Running 0 13d kube-apiserver-ip 1/1 Running 0 13d kube-controller-manager 1/1 Running 0 13d

Page 25: Kubernetes Kops - Automation Night

kops get cluster

Page 26: Kubernetes Kops - Automation Night

$ kops get cluster NAME CLOUD ZONES private-k8s-cluster aws eu-west-1a,eu-west-1b,eu-west-1c

Page 27: Kubernetes Kops - Automation Night

WHAT CAN I DO WITH IT?

Page 28: Kubernetes Kops - Automation Night

kops helps you create, destroy, upgrade and maintain production-grade, highly available, Kubernetes clusters from the command line

Page 29: Kubernetes Kops - Automation Night

WHERE?

Page 30: Kubernetes Kops - Automation Night

AWS (Officially supported) GCP (alpha) VMWARE vSPHERE (alpha)

Page 31: Kubernetes Kops - Automation Night

FEATURES?

Page 32: Kubernetes Kops - Automation Night

• Automates the provisioning of Kubernetes clusters in (AWS)

• Deploys Highly Available (HA) Kubernetes Masters • Supports upgrading from kube-up • Built on a state-sync model for dry-runs and automatic

idempotenc • Ability to generate configuration files for AWS

CloudFormation and Terraform configuration • Supports custom Kubernetes add-ons • Command line autocompletion • Community supported!

Page 33: Kubernetes Kops - Automation Night

LET’S BUILD SOME CLUSTERS

Page 34: Kubernetes Kops - Automation Night

PREREQUISUITES.

Page 35: Kubernetes Kops - Automation Night

IAM USER AmazonEC2FullAccess AmazonRoute53FullAccess AmazonS3FullAccess IAMFullAccess AmazonVPCFullAccess

Page 36: Kubernetes Kops - Automation Night

ROUTE53 HOSTED ZONE SETUP Follow the guide:

https://github.com/kubernetes/kops/blob/master/docs/aws.md

Page 37: Kubernetes Kops - Automation Night

https://github.com/kaspernissen/kops-demo

Videos: http://bit.ly/2tmWOCF

Page 38: Kubernetes Kops - Automation Night

DEMO 1: SINGLE MASTER IN PUBLIC ZONE 3 NODES

Page 39: Kubernetes Kops - Automation Night

s3://phennex-state-store

VPC

api.public-single-master.phennex.com

kubectlkops

autoscaling group autoscaling group

eu-west-1a

pub

lic

Page 40: Kubernetes Kops - Automation Night

$ kops create cluster \ --name $KOPS_NAME \ --state $KOPS_STATE_STORE \ --dns-zone $PUBLIC_HOSTED_ZONE_ID \ --node-count 3 \ --zones eu-west-1a \ --master-zones eu-west-1a \ --cloud aws \ --node-size t2.medium \ --master-size t2.medium \ --yes

Page 41: Kubernetes Kops - Automation Night
Page 42: Kubernetes Kops - Automation Night

DEMO 2: MULTIPLE MASTERS IN PRIVATE ZONES 3 NODES

Page 43: Kubernetes Kops - Automation Night

s3://phennex-state-store VPC

api.private-multiple-masters.phennex.com

kubectlkops

autoscaling group

autoscaling group autoscaling group autoscaling group

bastion.private-multiple-masters.phennex.com

eu-west-1a eu-west-1b eu-west-1c

pri

vate

pub

lic

Page 44: Kubernetes Kops - Automation Night

$ kops create cluster \ --name $KOPS_NAME \ --state $KOPS_STATE_STORE \ --node-count 3 \ --dns-zone $PRIVATE_HOSTED_ZONE_ID \ --zones eu-west-1a,eu-west-1b,eu-west-1c \ --master-zones eu-west-1a,eu-west-1b,eu-west-1c \ --cloud aws \ --node-size t2.medium \ --master-size t2.medium \ --bastion \ --topology private \ --networking weave \ --yes

Page 45: Kubernetes Kops - Automation Night
Page 46: Kubernetes Kops - Automation Night

AWESOME! THAT WAS EASY… 👍

Page 47: Kubernetes Kops - Automation Night

WHAT IF YOU WANT YOUR CLUSTER TO RUN IN AN EXISTING VPC?

Page 49: Kubernetes Kops - Automation Night

MANY MORE CONFIGURATION OPTIONS TO CHOOSE FROM…

Page 50: Kubernetes Kops - Automation Night

--cloud-labels ”Team=Dev” --image some-image (Ubuntu, CentOS, RHEL7, CoreOS) --networking calico, flannel --node-security-groups --master-security-groups --admin-access <SOME IP> --ssh-public-key=/Users/.. --out=. \ --target=terraform

Page 51: Kubernetes Kops - Automation Night

WHAT ABOUT UPGRADING?

Page 52: Kubernetes Kops - Automation Night

$ kops upgrade cluster

Page 53: Kubernetes Kops - Automation Night

YOU CAN ALWAYS EDIT YOUR CLUSTER CONFIGURATION $ kops edit cluster $ kops edit ig --name=<CLUSTER> nodes

Page 54: Kubernetes Kops - Automation Night

ROLLING UPDATES(default pretty bad!) Use feature flag:

$ export KOPS_FEATURE_FLAGS="+DrainAndValidateRollingUpdate" $ kops rolling-update cluster

Page 55: Kubernetes Kops - Automation Night
Page 56: Kubernetes Kops - Automation Night

SCALING THE CLUSTER $ kops edit ig --name $KOPS_NAME nodes

Page 57: Kubernetes Kops - Automation Night
Page 58: Kubernetes Kops - Automation Night

EXTRA… (if we have time)

Page 59: Kubernetes Kops - Automation Night
Page 60: Kubernetes Kops - Automation Night

CLEAN UP!

Page 61: Kubernetes Kops - Automation Night
Page 62: Kubernetes Kops - Automation Night

OTHER SOLUTIONS

Page 63: Kubernetes Kops - Automation Night

COREOS TECHTONIC OPENSHIFT KISMATIC KUBERMATIC

Page 64: Kubernetes Kops - Automation Night

Thank you! Catch me on Twitter @phennex

Or in the Slack Community: Cloud Native DK (https://cloudnative-dk.herokuapp.com/ )