Kubernetes on AWS at Europe's Leading Online Fashion Platform

38
Kubernetes on AWS AT EUROPE’S LEADING ONLINE FASHION PLATFORM HENNING JACOBS @try_except_ 2017-03-27

Transcript of Kubernetes on AWS at Europe's Leading Online Fashion Platform

Page 1: Kubernetes on AWS at Europe's Leading Online Fashion Platform

Kubernetes on AWS

AT EUROPE’S LEADING

ONLINE FASHION PLATFORM

HENNING JACOBS

@try_except_

2017-03-27

Page 2: Kubernetes on AWS at Europe's Leading Online Fashion Platform

2

Please write the title in all capital letters

Put images in the grey dotted box "unsupported placeholder"

ZALANDO

15 markets

6 fulfillment centers

20 million active customers

3.6 billion € net sales 2016

165 million visits per month

12,000 employees in Europe

Page 3: Kubernetes on AWS at Europe's Leading Online Fashion Platform

3

Please write the title in all capital letters

Put images in the grey dotted box "unsupported placeholder"

ZALANDO TECHNOLOGY

HOME-BREWED,CUTTING-EDGE& SCALABLEtechnology solutions

>1,600employees from

tech locations+ HQs in Berlin6

77nations

help our brand toWIN ONLINE

Page 4: Kubernetes on AWS at Europe's Leading Online Fashion Platform

4

Please write the title in all capital letters

Put images in the grey dotted box "unsupported placeholder"

Use bullet points to summarize information rather than writing long paragraphs in the text box

KUBERNETES ON AWS: CONTEXT

200 engineering teams

30 prod. clusters

AWS

Dockerized apps

No manual operations

Reliability

Autoscaling

Seamless migration

Page 5: Kubernetes on AWS at Europe's Leading Online Fashion Platform

5

Put images in the grey dotted box "unsupported placeholder" - behind the orange box (left side stays white)

Write the quote in all capital letters

ARCHITECTURE

Page 6: Kubernetes on AWS at Europe's Leading Online Fashion Platform

6

Please write the title in all capital letters

ISOLATED AWS ACCOUNTS

Internet

*.abc.example.org *.xyz.example.org

Product ABC Product XYZ

EC2

LBLB

Page 7: Kubernetes on AWS at Europe's Leading Online Fashion Platform

7

Please write the title in all capital letters

KUBERNETES ON AWS

Page 8: Kubernetes on AWS at Europe's Leading Online Fashion Platform

8

Please write the title in all capital letters

Put images in the grey dotted box "unsupported placeholder"

Use bullet points to summarize information rather than writing long paragraphs in the text box

ARCHITECTURE DECISIONS

• API server behind SSL ELB• Webhook for authn & authz

• OAuth Bearer token• Group membership lookup

• Read only access to production• CI/CD for write access• etcd running separately on EC2• Multi AZ clusters

Page 9: Kubernetes on AWS at Europe's Leading Online Fashion Platform

9

Please write the title in all capital letters

CLUSTER PROVISIONING

Page 10: Kubernetes on AWS at Europe's Leading Online Fashion Platform

10

Please write the title in all capital letters

Put images in the grey dotted box "unsupported placeholder"

Use bullet points to summarize information rather than writing long paragraphs in the text box

CLUSTER PROVISIONING

• Two Cloud Formation stacks

• Master & worker ASGs + etcd

• Nodes w/ Container Linux

• K8s manifests applied separately

• kube-system Deployments

• DaemonSets

Page 11: Kubernetes on AWS at Europe's Leading Online Fashion Platform

11

Put images in the grey dotted box "unsupported placeholder" - behind the orange box (left side stays white)

Write the quote in all capital letters

DEPLOYMENT

Page 12: Kubernetes on AWS at Europe's Leading Online Fashion Platform

12

Please write the title in all capital letters

Put images in the grey dotted box "unsupported placeholder"

Use bullet points to summarize information rather than writing long paragraphs in the text box

DEPLOYMENT CONFIGURATION

.├── apply│ ├── credentials.yaml # K8s TPR│ ├── ingress.yaml # K8s Ingress│ ├── redis-deployment.yaml # K8s Deployment│ ├── redis-service.yaml # K8s Service│ └── service.yaml # K8s Service├── deployment.yaml # K8s Deployment└── pipeline.yaml # proprietary config

Page 13: Kubernetes on AWS at Europe's Leading Online Fashion Platform

13

Please write the title in all capital letters

Put images in the grey dotted box "unsupported placeholder"

Use bullet points to summarize information rather than writing long paragraphs in the text box

JENKINS DEPLOY PIPELINE

Page 14: Kubernetes on AWS at Europe's Leading Online Fashion Platform

14

Put images in the grey dotted box "unsupported placeholder" - behind the orange box (left side stays white)

Write the quote in all capital letters

INGRESS

Page 15: Kubernetes on AWS at Europe's Leading Online Fashion Platform

15

Please write the title in all capital letters

Put images in the grey dotted box "unsupported placeholder"

Use bullet points to summarize information rather than writing long paragraphs in the text box

INGRESS.YAML

apiVersion: extensions/v1beta1kind: Ingressmetadata: name: "{{ application }}" annotations: # optional: SSL certificate ARN to use for the ALB (auto discovery for ACM) zalando.org/aws-load-balancer-ssl-cert: "arn:aws:iam:..:..:..1a"spec: rules: # DNS name your application should be exposed on - host: "myapp.foo.example.org" http: paths: - backend: serviceName: "{{ application }}" servicePort: 80

Page 16: Kubernetes on AWS at Europe's Leading Online Fashion Platform

16

Please write the title in all capital letters

Put images in the grey dotted box "unsupported placeholder"

Use bullet points to summarize information rather than writing long paragraphs in the text box

INGRESS CONTROLLER

Page 17: Kubernetes on AWS at Europe's Leading Online Fashion Platform

17

Put images in the grey dotted box "unsupported placeholder" - behind the orange box (left side stays white)

Write the quote in all capital letters

AWS INTEGRATION

Page 18: Kubernetes on AWS at Europe's Leading Online Fashion Platform

18

Please write the title in all capital letters

Put images in the grey dotted box "unsupported placeholder"

Use bullet points to summarize information rather than writing long paragraphs in the text box

CLOUD FORMATION VIA CI/CD

.├── apply│ ├── cf-iam-role.yaml # AWS IAM Role│ ├── cf-rds.yaml # AWS RDS Database│ ├── kube-ingress.yaml # K8s Ingress│ ├── kube-secret.yaml # K8s Secret│ └── kube-service.yaml # K8s Service├── deployment.yaml # K8s Deployment└── pipeline.yaml # CI/CD config

Page 19: Kubernetes on AWS at Europe's Leading Online Fashion Platform

19

Please write the title in all capital letters

Put images in the grey dotted box "unsupported placeholder"

Use bullet points to summarize information rather than writing long paragraphs in the text box

ASSIGNING AWS IAM ROLE TO POD

kind: Deploymentspec: template: metadata: annotations: # annotation for kube2iam iam.amazonaws.com/role: "app-{{ application }}-1" spec: containers: - name: ... ...

Page 20: Kubernetes on AWS at Europe's Leading Online Fashion Platform

20

Put images in the grey dotted box "unsupported placeholder" - behind the orange box (left side stays white)

Write the quote in all capital letters

CLUSTERAUTOSCALING

Page 21: Kubernetes on AWS at Europe's Leading Online Fashion Platform

21

Please write the title in all capital letters

Put images in the grey dotted box "unsupported placeholder"

Use bullet points to summarize information rather than writing long paragraphs in the text box

CLUSTER AUTOSCALING

Control # of worker nodes in ASG:

• Satisfy all resource requests

• One spare node per AZ

• No manual config “tweaking”

• Scale down, but not too fast

Page 22: Kubernetes on AWS at Europe's Leading Online Fashion Platform

22

Please write the title in all capital letters

Put images in the grey dotted box "unsupported placeholder"

Use bullet points to summarize information rather than writing long paragraphs in the text box

CURRENT SETUP

• https://github.com/hjacobs/kube-aws-autoscaler

• Node draining via systemd unit

Open topic: node “readiness” during scale out

Page 23: Kubernetes on AWS at Europe's Leading Online Fashion Platform
Page 24: Kubernetes on AWS at Europe's Leading Online Fashion Platform

24

Put images in the grey dotted box "unsupported placeholder" - behind the orange box (left side stays white)

Write the quote in all capital letters

OAUTH / IAMINTEGRATION

Page 25: Kubernetes on AWS at Europe's Leading Online Fashion Platform

25

Please write the title in all capital letters

Put images in the grey dotted box "unsupported placeholder"

Use bullet points to summarize information rather than writing long paragraphs in the text box

DECLARING NEEDED CREDENTIALS

# apply/credentials.yamlapiVersion: "zalando.org/v1"kind: PlatformCredentialsSetmetadata: name: "{{ application }}"spec: application: "{{ application }}" tokens: # OAuth service tokens mytok: # the token name used in application code privileges: - com.zalando::foobar.write clients: # OAuth clients implicit: grant: implicit # grant type according to RFC-6749 realm: users redirectUri: https://myapp.foo.example.org/oauth

Page 26: Kubernetes on AWS at Europe's Leading Online Fashion Platform

26

Please write the title in all capital letters

Put images in the grey dotted box "unsupported placeholder"

Use bullet points to summarize information rather than writing long paragraphs in the text box

MOUNTING THE OAUTH CREDENTIALS

kind: Deploymentspec: template: spec: containers: - name: ... ... volumeMounts: - name: "{{ application }}-credentials" mountPath: /meta/credentials readOnly: true volumes: - name: "{{ application }}-credentials" secret: secretName: "{{ application }}"

Page 27: Kubernetes on AWS at Europe's Leading Online Fashion Platform

27

Please write the title in all capital letters

Put images in the grey dotted box "unsupported placeholder"

Use bullet points to summarize information rather than writing long paragraphs in the text box

USING THE OAUTH CREDENTIALS

#!/bin/bash

type=$(cat /meta/credentials/read-only-token-type)

secret=$(cat /meta/credentials/read-only-token-secret)

curl -H "Authorization: $type $secret" \

https://resource-server.example.org/protected

Page 28: Kubernetes on AWS at Europe's Leading Online Fashion Platform

28

Put images in the grey dotted box "unsupported placeholder" - behind the orange box (left side stays white)

Write the quote in all capital letters

OPERATIONS&

MONITORING

Page 29: Kubernetes on AWS at Europe's Leading Online Fashion Platform

29

Please write the title in all capital letters

Put images in the grey dotted box "unsupported placeholder"

Use bullet points to summarize information rather than writing long paragraphs in the text box

OPERATIONS

• Cluster updates automatic via CLM

• CronJob is great, but needs cleanup

• Docker can be PITA

Page 30: Kubernetes on AWS at Europe's Leading Online Fashion Platform

30

Please write the title in all capital letters

Put images in the grey dotted box "unsupported placeholder"

Use bullet points to summarize information rather than writing long paragraphs in the text box

CLUSTER UPDATES

Page 31: Kubernetes on AWS at Europe's Leading Online Fashion Platform

31

Please write the title in all capital letters

Put images in the grey dotted box "unsupported placeholder"

Use bullet points to summarize information rather than writing long paragraphs in the text box

LIMIT RANGE

kubectl describe limitrange

Name: limits

Namespace: default

Type Resource Min Max Default Req Default Limit Max Limit/Request Ratio

---- -------- --- --- ----------- ------------- -----------------------

Container memory - 64Gi 100Mi 1Gi -

Container cpu - 16 100m 3 -

Page 32: Kubernetes on AWS at Europe's Leading Online Fashion Platform

32

Please write the title in all capital letters

Put images in the grey dotted box "unsupported placeholder"

Use bullet points to summarize information rather than writing long paragraphs in the text box

MONITORING

Page 33: Kubernetes on AWS at Europe's Leading Online Fashion Platform

33

Please write the title in all capital letters

Put images in the grey dotted box "unsupported placeholder"

Use bullet points to summarize information rather than writing long paragraphs in the text box

SIMPLE ZMON CHECK/ALERT EXAMPLE

Page 34: Kubernetes on AWS at Europe's Leading Online Fashion Platform

34

Please write the title in all capital letters

Put images in the grey dotted box "unsupported placeholder"

Use bullet points to summarize information rather than writing long paragraphs in the text box

MONITORING

• Each cluster contains ZMON appliance

• K8s resources are available as ZMON entities

• Users can create app checks/alerts via UI

Page 36: Kubernetes on AWS at Europe's Leading Online Fashion Platform

36

Put images in the grey dotted box "unsupported placeholder" - behind the orange box (left side stays white)

Write the quote in all capital letters

OPEN SOURCE

Page 37: Kubernetes on AWS at Europe's Leading Online Fashion Platform

37

Please write the title in all capital letters

Put images in the grey dotted box "unsupported placeholder"

Use bullet points to summarize information rather than writing long paragraphs in the text box

OPEN SOURCE

Kube AWS Ingress Controllerhttps://github.com/zalando-incubator/kube-ingress-aws-controller

External DNShttps://github.com/kubernetes-incubator/external-dns

Zalando Cluster Config & Docshttps://github.com/zalando-incubator/kubernetes-on-aws

more to come...

Page 38: Kubernetes on AWS at Europe's Leading Online Fashion Platform

Please write contact name, department and position in all capital letters

QUESTIONS?

HENNING JACOBS

TECH INFRASTRUCTURE

CLOUD ENGINEER

[email protected]

@try_except_

Please write contact name, department and position in all capital letters