31
Kubernetes @ nanit Chen Fisher, VP Engineering

Kubernetes @ Nanit

Embed Size (px)

Citation preview

Page 1: Kubernetes @ Nanit

Kubernetes @ nanitChen Fisher, VP Engineering

Page 2: Kubernetes @ Nanit

nanitSmart baby monitor

Page 3: Kubernetes @ Nanit
Page 4: Kubernetes @ Nanit

API

Clipper

Focus

Gateway

Grant

Mailman

RTMPRabbitMQ

S3

Stampa

State Department

Timeline

Taper

Algorithms

Communication

Page 5: Kubernetes @ Nanit

MicroservicesDocker

Page 6: Kubernetes @ Nanit

docker-compose up -d

Page 7: Kubernetes @ Nanit

Orchestration

Page 8: Kubernetes @ Nanit

Orchestration

- Service Discovery

- High Availability

- Resource Management

- Port Management

API

Clipper

Focus

Gateway

Grant

Mailman

RTMPRabbitMQ

S3

Stampa

State Department

Timeline

Taper

Algorithms

Page 9: Kubernetes @ Nanit

ECS vs Kubernetes

Page 11: Kubernetes @ Nanit

Service Discovery / ECS

- Offers no service discovery

- One can use external tools like Consul

(https://aws.amazon.com/blogs/compute/service-discovery-via-consul-with-amazon-ecs/)

Page 12: Kubernetes @ Nanit

Service Discovery / Kubernetes

- Has built-in service discovery (http://kubernetes.io/docs/user-guide/services/)

- One can simply refer to a service by its name

- Can group and isolate services by namespaces

Page 13: Kubernetes @ Nanit

High Availability / ECS

- Uses ELB health checks

- Limited to HTTP/TCP health checks

- If not using ELB then only recovers on container exit

- Must create ELB for every service to get health checks

Page 14: Kubernetes @ Nanit

High Availability / Kubernetes

- Offers exec health check in addition to http

- One can perform application level health check

Page 15: Kubernetes @ Nanit

Port Management / ECS

- Maps an ELB to a service which exposes a container port on host

- Cannot have more than one container with same exposed port on same host

- Must manually manage container ports

Page 16: Kubernetes @ Nanit

- Assigns random port for every container

- Maps ELB to the container’s random port

Port Management / Kubernetes

Page 17: Kubernetes @ Nanit

Kubernetes

- AWS

- Kube 1.2.2

- Two clusters: Staging & Production

- 20+ m4-large instances on production (pre-launch)

- 100+ pods

- RDS, DynamoDB outside of cluster

Page 18: Kubernetes @ Nanit

From Dev to Prod

Page 19: Kubernetes @ Nanit

Dev and test locallyclojure, ruby, go, c/c++, elixir

Page 20: Kubernetes @ Nanit

Push to Githubpull requests

Page 21: Kubernetes @ Nanit

Jenkins picks up and testsmarks commit on Github

Page 22: Kubernetes @ Nanit

Manual merge to master

Page 23: Kubernetes @ Nanit

Deployment via Slack

Page 24: Kubernetes @ Nanit
Page 25: Kubernetes @ Nanit

Deployment / directory structure

● nanit/

○ api/■ app/

■ Dockerfile■ code...

■ kube/■ dep.yml

■ Makefile

Page 26: Kubernetes @ Nanit

apiVersion: extensions/v1beta1kind: Deploymentmetadata: name: {{APP_NAME}}spec: replicas: {{REPLICAS}} template: metadata: labels: app: {{APP_NAME}} spec: volumes: - name: some-secret secret: secretName: some-secret containers: - name: {{APP_NAME}} image: {{IMAGE_NAME}}...

Deployment / kube yaml file

Page 27: Kubernetes @ Nanit

Deployment / Makefile

APP_NAME=apiIMAGE_TAG=$(shell git log -n 1 --pretty=format:%h app)IMAGE_NAME=nanit/$(APP_NAME):$(IMAGE_TAG)

define generate-dep sed -e 's/{{IMAGE_NAME}}/$(IMAGE_NAME)/g' kube/dep.ymlendef

docker: sudo docker pull $(IMAGE_NAME) || (sudo docker build -t $(IMAGE_NAME) app && sudo docker push $(IMAGE_NAME))

deploy: docker $(call generate-dep) | kubectl apply -f -

migrate: …

test:...

Page 28: Kubernetes @ Nanit

Deployment / config

from Makefile:REPLICAS?=$(shell curl -s config/$(NANIT_ENV)/api/replicas)

from kube yaml file:spec: replicas: {{REPLICAS}}

Page 29: Kubernetes @ Nanit

Post deployment(Monitoring & Alerts)

Page 30: Kubernetes @ Nanit

Post deployment (Monitoring & Alerting)

- Currently using built in Kibana & Grafana

- Alerting to Slack using proprietary service

Page 31: Kubernetes @ Nanit

Thank You!