21
Using Kubernetes to build a PaaS Tanmai Gopal

KUBERNETES AS A FRAMEWORK FOR WRITING DEVOPS & MICROSERVICES TOOLING

Embed Size (px)

Citation preview

Page 1: KUBERNETES AS A FRAMEWORK FOR WRITING DEVOPS & MICROSERVICES TOOLING

Using Kubernetes to build a PaaSTanmai Gopal

Page 2: KUBERNETES AS A FRAMEWORK FOR WRITING DEVOPS & MICROSERVICES TOOLING

Tanmai GopalHead Engineering, Hasura

@tanmaigo

● Building applications for 8 years

● Machine Learning/Computer Vision

● Software engineering, functional

programming, distributed systems

http://hasura.io

@HasuraHQ

Page 3: KUBERNETES AS A FRAMEWORK FOR WRITING DEVOPS & MICROSERVICES TOOLING

HASURAPaaS + BaaS built on:

nginx + redis + postgres

CoreOS + Docker + Kubernetes

Components primarily written in

Haskell.

Page 4: KUBERNETES AS A FRAMEWORK FOR WRITING DEVOPS & MICROSERVICES TOOLING

The Kubernetes way1. Pods

2. Replicasets

3. Deployments

4. Services

5. PersistentVolumes

6. Configmaps

Page 5: KUBERNETES AS A FRAMEWORK FOR WRITING DEVOPS & MICROSERVICES TOOLING

The Kubernetes way

You don’t actually ever manage a resource.

You manage the definition of the resource.

Kubernetes makes the resource arrive at

that definition, eventually.

Page 6: KUBERNETES AS A FRAMEWORK FOR WRITING DEVOPS & MICROSERVICES TOOLING

Examples to understand the Kubernetes way● Run a process

● Processes communicating with each other

● Configure a process

● Restart a process with configuration changes

● Set up an API gateway to upstream services

● Run a one-off script

● Stop/delete a process

Page 7: KUBERNETES AS A FRAMEWORK FOR WRITING DEVOPS & MICROSERVICES TOOLING

Examples to understand the Kubernetes way

Pod

Service

Pod

Service

Deployment

Page 8: KUBERNETES AS A FRAMEWORK FOR WRITING DEVOPS & MICROSERVICES TOOLING

Setting context - HasuraA demo to show Hasura features

1. Collection of microservices to give you BaaS APIs

2. Easy to deploy custom code or packaged code (PaaS)

Page 9: KUBERNETES AS A FRAMEWORK FOR WRITING DEVOPS & MICROSERVICES TOOLING

Desired application architecture*.myapp.com

data.myapp.com auth.myapp.com

Page 10: KUBERNETES AS A FRAMEWORK FOR WRITING DEVOPS & MICROSERVICES TOOLING

Let’s build some PaaS tooling1. Deploy a docker image backed service

a. Run the process

b. Configure a API gateway rule to reach the process

2. Add a new domain for the API gateway

3. TCP access via SSH tunneling

4. Single point of configuration for my application

5. Initialise and manage state (Postgres)

Page 11: KUBERNETES AS A FRAMEWORK FOR WRITING DEVOPS & MICROSERVICES TOOLING

Deploy docker image1. Demo

Client (console/kubectl)

kubernetes

Deployment

Service

Pod

Service

Page 12: KUBERNETES AS A FRAMEWORK FOR WRITING DEVOPS & MICROSERVICES TOOLING

“Expose” via API gateway1. Demo

Pod

API Gateway

Service

Page 13: KUBERNETES AS A FRAMEWORK FOR WRITING DEVOPS & MICROSERVICES TOOLING

“Expose” via API gateway1. Create a new

configmap

Client (console/kubectl)

Pod

API Gateway

Service

nginx.conf (configmap)

Page 14: KUBERNETES AS A FRAMEWORK FOR WRITING DEVOPS & MICROSERVICES TOOLING

“Expose” via API gateway1. Listen to the service

2. Update the configmap

API Gateway

Service

configmap

operator

Page 15: KUBERNETES AS A FRAMEWORK FOR WRITING DEVOPS & MICROSERVICES TOOLING

“Expose” via API gateway1. Update the configmap

a. Wait for it to sync to the deployment?

2. Configmap hash

3. Update gateway deployment with a

new configmap hash

4. Rollbacks!

API Gateway

Service

configmap

operator

1

2

3

Page 16: KUBERNETES AS A FRAMEWORK FOR WRITING DEVOPS & MICROSERVICES TOOLING

“Expose” via API gateway1. But which service should the

operator expose?

Service(annotation)

operatorOperator (configmap)

Page 17: KUBERNETES AS A FRAMEWORK FOR WRITING DEVOPS & MICROSERVICES TOOLING

Deploy docker image, finally!

Client (console/kubectl)

kubernetesDeployment

Service

Pod

Service

Operator Configmap

API Gateway

Page 18: KUBERNETES AS A FRAMEWORK FOR WRITING DEVOPS & MICROSERVICES TOOLING

New domains for API gateway

Client (console/kubectl)

kubernetes

Configmap

API Gateway

Page 19: KUBERNETES AS A FRAMEWORK FOR WRITING DEVOPS & MICROSERVICES TOOLING

Authorized keys for an SSH container

Client (console/kubectl)

kubernetes

Configmap

AuthorizedKeys(configmap)

SSH deployment

Page 20: KUBERNETES AS A FRAMEWORK FOR WRITING DEVOPS & MICROSERVICES TOOLING

Single point of configurationClient

(console/kubectl)

kubernetesConfigmap operator

API gateway SSHD

Configmap

Page 21: KUBERNETES AS A FRAMEWORK FOR WRITING DEVOPS & MICROSERVICES TOOLING

Questions