Kubernetes technical overview and our experience at Restorando :: Buenos Aires AWS Meetup

21
Kubernetes Technical overview y nuestra experiencia en Restorando

Transcript of Kubernetes technical overview and our experience at Restorando :: Buenos Aires AWS Meetup

Page 1: Kubernetes technical overview and our experience at Restorando :: Buenos Aires AWS Meetup

KubernetesTechnical overview y nuestra experiencia en Restorando

Page 2: Kubernetes technical overview and our experience at Restorando :: Buenos Aires AWS Meetup

Agenda

● Intro● Kubernetes concepts● K8s en la práctica

○ Demo!

● K8s Features● No free meal● Links útiles

Page 3: Kubernetes technical overview and our experience at Restorando :: Buenos Aires AWS Meetup

Intro

Page 4: Kubernetes technical overview and our experience at Restorando :: Buenos Aires AWS Meetup

La idea es desacoplar

● Desacoplar apps de servers○ Así los podemos tratar como ganado y no como mascotas○ Más uptime y fácil escalar○ Aprovechar mejor los recursos (varias apps en un server)○ La gente de infra se encarga de la infra, la gente de la app se encarga de su app

● Linux desacopla software de las arquitecturas de HW (x86, arm, etc.)○ Kubernetes la aplicación de la infraestructura

● Provee una capa sobre la que las aplicaciones corren○ No importa el cloud provider (AWS, Azure, etc.) ni si es bare-metal○ La aplicación no se entera de lo que hay debajo○ Puede correr federado entre distintos cloud providers y bare-metal

Page 5: Kubernetes technical overview and our experience at Restorando :: Buenos Aires AWS Meetup

NodeKubelet

Pod Pod Pod

Container Container Container

NodeKubelet

Pod Pod Pod

Container Container Container

Kubernetes basic architecture

NodeKubelet

Pod Pod Pod

Container Container Container

Kubernetes Master

Page 6: Kubernetes technical overview and our experience at Restorando :: Buenos Aires AWS Meetup

Solo importa el desired state

Desired State Current State

Reconciliation loop

Container A y B corriendo Container A, B y C corriendo

Borrar C

Page 7: Kubernetes technical overview and our experience at Restorando :: Buenos Aires AWS Meetup

¿Qué es un Pod?

● (no es así realmente, ya veremos bien)● Pensemos en un pod como un container al que le definimos cosas● Al que le definimos:

○ La imagen de docker y versión a correr○ La memoria que puede usar○ El CPU que tiene disponible○ El usuario que lo va a correr, etc.

Page 8: Kubernetes technical overview and our experience at Restorando :: Buenos Aires AWS Meetup

Deployments

● Se usa en lugar de pods● Encargado de que haya la cantidad que queremos

○ Si un nodo muere, levanta el container en otro○ Si un nodo levanta con ese pod corriendo, lo matará

● Sabe cuándo los “pods” están listos○ Hay checkeos “standard” que vamos a ver para esto

● Nos maneja los deploy sin downtime○ Ya vemos a ver cómo

● Desired state: típicamente se especifica en un yaml/json

Page 9: Kubernetes technical overview and our experience at Restorando :: Buenos Aires AWS Meetup

- name: nginx image: <registry>/nginx:v1.0 readinessProbe: initialDelaySeconds: 5 httpGet: path: /health port: 80 livenessProbe: initialDelaySeconds: 5 httpGet: path: /health port: 80 lifecycle: preStop: exec: command: ["nginx", "-s", "quit"]

apiVersion: extensions/v1beta1kind: Deploymentmetadata: name: wido-webspec: replicas: 1 template: metadata: labels: project: wido role: web containers: - name: app image: <registry>/wido:1.0

Ejemplo de deployment

Page 10: Kubernetes technical overview and our experience at Restorando :: Buenos Aires AWS Meetup

Hacer un deploy

● Se baja un pod viejo● Se levanta un pod nuevo● No se sigue hasta que está listo para recibir tráfico. Cuando está listo, se

repite hasta N● El nodo lo elige k8s automáticamente, se pueden poner restricciones

○ O hasta crear nuestro propio scheduler y usarlo en su lugar!

Page 11: Kubernetes technical overview and our experience at Restorando :: Buenos Aires AWS Meetup

Servicios: exponer los pods

● Selecciona en base a labels, los pods que se van a exponer○ Todos los pods con label “project: myapp”

● Se crea entonces (generalmente):○ Una IP estática que apuntará a los pods que correspondan (load balancing)○ Un nombre de dns para service discovery○ Crea load balancer del cloud provider si queremos también○ Solo se exponen pods que pasen el readiness check

● Comunicación intra-cluster puede ver una IP estática○ Atrás se hace load balancing y deploys sin downtime fácilmente○ Los pods se pueden mover de un nodo a otro Y el servicio re-routea○ Es decir, desacopla

Page 12: Kubernetes technical overview and our experience at Restorando :: Buenos Aires AWS Meetup

Servicios y deploy

my-appVer: 0.1Labels:project: my-app

my-appVer: 0.1Labels:project: my-app

Deployment: My appversion=0.1, replicas=2

Service: My appmatchLabels: project:myapp

Page 13: Kubernetes technical overview and our experience at Restorando :: Buenos Aires AWS Meetup

Servicios y deploy

my-appVer: 0.1Labels:project: my-app

my-appVer: 0.1Labels:project: my-app

Deployment: My appversion=0.2, replicas=2

Service: My appmatchLabels: project:myapp

my-appVer: 0.2Labels:project: my-app

my-appVer: 0.2Labels:project: my-app

Page 14: Kubernetes technical overview and our experience at Restorando :: Buenos Aires AWS Meetup

¿Qué son los pods realmente?

● Conjunto de 1 o más containers, mínima unidad de deployment● Modela grupo de apps que se corren en un host

○ SIEMPRE en un mismo nodo○ Misma IP, namespace de red, IPC entre ellos, etc.

● Idea: desacoplar○ Tambien separation of concerns, reusable, != CPU/mem limits, monitoreo preciso

● Ejemplos○ File puller + web server: comparten volumen para los archivos○ Mysql + adapter de phometheus○ App + interfaz con “el mundo exterior”○ En Restorando: nginx, heka y app

Page 15: Kubernetes technical overview and our experience at Restorando :: Buenos Aires AWS Meetup

Demo

Page 16: Kubernetes technical overview and our experience at Restorando :: Buenos Aires AWS Meetup
Page 17: Kubernetes technical overview and our experience at Restorando :: Buenos Aires AWS Meetup

Kubernetes features

● Automatic binpacking● Horizontal autoscaling● Cluster autoscaling● Automated rollouts and rollbacks● Storage orchestration

○ Dynamic volume provisioning● Self-healing● Service discovery and load balancing● Secret and configuration management● Batch and scheduled execution● Canary deployments● Container runtime independant

○ Docker, Rocket, Hyper, etc.

● Run Stateful and stateless apps● Federated● Extensible (3rd party API)● Operators (recién anunciados por CoreOS)● Hosted on Google cloud and Azure● Minikube para correr local● Partners y enterprise support

○ Training, certification and KMSP program● Kubernetes on kubernetes (kaboom!)● Viene con UI!● Integraciones con todo lo que

necesitamos nosotros○ SignalFX, Samson, AWS, etc.

Page 18: Kubernetes technical overview and our experience at Restorando :: Buenos Aires AWS Meetup

No free meal

● Un layer de abstracción más○ Hay que entenderlo, etc.

● Containers (docker o cualquiera) se meten mucho con el OS○ Problemas en esa capa probablemente implican lidiar con el kernel○ Todo bien cuando funcionan, pero cuando no? No es tan fácil

● Resolver el monitoreo○ Prometheus, Integraciones con servicios hosted. Viene con cadvisor○ Más cosas para monitorear: hosts, containers, kubernetes, cantidad de pods app X, etc.

● Cambia, quizás, la forma de deploy○ Nosotros usabamos una interfaz web, open source, que agregó soporte○ En general MUCHAS cosas tienen soporte para k8s

Page 19: Kubernetes technical overview and our experience at Restorando :: Buenos Aires AWS Meetup

Links interesantes

● Borg, Omega, and Kubernetes: Lessons learned from three container-management systems over a decade

○ http://queue.acm.org/detail.cfm?id=2898444● Curso online (muy básico, pero simple y rápido de hacer)

○ https://www.udacity.com/course/scalable-microservices-with-kubernetes--ud615○ https://training.linuxfoundation.org/linux-courses/system-administration-training/kuberne

tes-fundamentals● Operators

○ https://coreos.com/blog/introducing-operators.html○ https://coreos.com/blog/introducing-the-etcd-operator.html

● KubeCon EU 2016 (viejo ya, tipo 3 releases desde eso)○ https://www.youtube.com/watch?v=Wyl4O3CHzV0

Page 20: Kubernetes technical overview and our experience at Restorando :: Buenos Aires AWS Meetup

¿Preguntas?

¡Gracias!Nos encantaría compartir experiencias con kubernetes:

Rodrigo Campos: [email protected], [email protected]

Juan Barreneche: [email protected]

Page 21: Kubernetes technical overview and our experience at Restorando :: Buenos Aires AWS Meetup

Una última cosa...

We are hiring!

https://engineering.restorando.com