32
Spreadshi rt Kubernetes at Spreadshirt First steps to production Jens Hadlich, Chief Architect

Kubernetes at Spreadshirt - First steps to production

Embed Size (px)

Citation preview

Page 1: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

Kubernetes at SpreadshirtFirst steps to production

Jens Hadlich, Chief Architect

Page 2: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

SpreadshirtWE PRINT IDEAS

Page 3: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

Not all that long ago …We want to build a

service with Ruby …Why?

… and the other team was allowed to build a service with Node.js …

Sure, I already forgot. Hmm … OK. Let‘s try.

Ruby is the right tool for the job ...

We could build it in Java but that would

be too much …

Other companies use it for years already …

It‘s a very simple service …

3

Page 4: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

Some time later …To run it, you just need some to install some

gems.

Didn‘t work.Sure not. You need Ruby in Version X.

X? You can only have Y.

What‘s a gem?

How about using Docker?

Ecosystem man.

4

Page 5: Kubernetes at Spreadshirt - First steps to production

Spreadshirt 5

Docker

Page 6: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

Docker is nice, but … *

Number ofRunningContainers

1 5 10 50 100

* without container orchestration or additional tooling

6

Page 7: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

Docker is nice, but … *

Number ofRunningContainers

1 5 10 50 100

* without container orchestration or additional tooling

7

Page 8: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

Docker is nice, but … *

Number ofRunningContainers

1 5 10 50 100

* without container orchestration or additional tooling

8

Page 9: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

Docker is nice, but … *

Number ofRunningContainers

1 5 10 50 100

* without container orchestration or additional tooling

9

Page 10: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

Docker is nice, but … *

Number ofRunningContainers

1 5 10 50 100

* without container orchestration or additional tooling

10

Page 11: Kubernetes at Spreadshirt - First steps to production

Spreadshirt 11

Docker is nice, but … *

Number ofRunningContainers

1 5 10 50 100

* without container orchestration or additional tooling

Page 12: Kubernetes at Spreadshirt - First steps to production

Spreadshirt 12

Kubernetes

Page 13: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

Kubernetes for Container Orchestration

The promise ...• Easily bring up new components and services

• Easily manage hundreds or thousands of containers

• Easily add capacity

• Better resource utilization

• (Auto-)scale

13

Page 14: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

Preparation

Think about …• Monitoring

• Logging

• Metrics

• Configuration management

• Build & Deployment pipelines

• Your application stack

14

Page 15: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

Tool Ecosystem at Spreadshirt

15

Page 16: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

Tool Ecosystem at Spreadshirt (cont’d)

16

VxLAN (and even more …)

Page 17: Kubernetes at Spreadshirt - First steps to production

Spreadshirt 17

Page 18: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

Build

git commitgit push

.gitlab-ci.yml

* io.fabric8/docker-maven-plugin

*

18

Page 19: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

Deploy

Manifest files

kubectl

Service IP

19

Page 20: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

Kuh (Kubernetes hiera)

• Homegrown preprocessor for k8s manifest files

• Why? Avoid yet another big project (change configuration management)

• Bridge between Puppet/hiera (our “old” world) and Kubernetes (the “new” world) – peaceful coexistence

20

Page 21: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

Puppet/hiera

21

Page 22: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

Kuh input structure

├── deployment

│ ├── data

│ │ ├── common.yaml

│ │ ├── ops.yaml

│ │ ├── qa.yaml

│ │ ├── <team>.yaml

│ │ └── ...

│ ├── src

│ │ ├── config

│ │ │ └── application-config.yaml

│ │ └── infra

│ │ └── k8s.yaml

hiera “data” files like with Puppet

add to your git project

22

k8s manifest templates

Page 23: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

Kubernetes manifest templates with Kuh

apiVersion: v1

kind: Service

metadata:

name: my-service

labels:

app: my-service

spec:

type: NodePort

clusterIP: 192.168.X.Y

ports:

- port: <%= scope().call_function('hiera',['my_service::http_port']) %>

name: http

...

Retrieve the value from hiera*

23

* yeah, we know this looks ugly …

Page 24: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

Kuh output

├── deployment

│ ├── data

│ ├── src

│ └── target

│ ├── config

│ │ └── application-config.yaml

│ └── k8s

│ ├── configmap

│ │ └── application-config.yaml

│ └── infra

│ └── k8s.yaml

24

Final k8s manifest files

Page 25: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

Kubernetes Manifests

• Deployment

• ConfigMap

• Secret

• Service

• (more to come)

25

Page 26: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

Docker registry & images

• Nexus 3 Java / Maven repository Own Docker registry

- Nice WebUI- Traffic*

• Docker images latest tag, override Other tags:

- ${git.commit.time}.${git.commit.id}e.g. 2017-03-

29.a5344e3501d591e4c7908d97a044d3d0f38ddb43

to be able to clean up old images and better readability

26

* pushing and pulling Docker images can generate significant network traffic

Page 27: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

Stateful Applications

• Not at the moment!

• Databases, Elasticsearch, … are “external”

• Avoid local storage

• Use Web-APIs (e.g. S3)

27

Page 28: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

Open issues

We are still in learning mode!

• Improve high availability for Kubernetes 2 separate Kubernetes clusters

- Single master: if it fails – restart- Clustered etcd

Puppetized => spin up a new cluster within minutes

• How to manage storage / stateful services? E.g. DB, Elasticsearch

28

Page 29: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

Open issues (cont’d)

• Security patches / lifecycle of Docker images / containers within k8s What’s running inside my container? Manage re-build / re-deploy after a certain time? Trust 3rd party base images?

• Reduce complexity

• Revisit custom HAProxy vs. built-in Ingress & Co.

29

Page 30: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

Nice tools

• sysdig / csysdig

30

Page 31: Kubernetes at Spreadshirt - First steps to production

Spreadshirt 31

Thank [email protected]

Page 32: Kubernetes at Spreadshirt - First steps to production

Spreadshirt

Links

• https://sysdig.com/blog/digging-into-kubernetes-with-sysdig/