Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

2 + Whoami + Estratégias de Deploy + Estratégias de Deploy no Kubernetes + Service Mesh (Istio) + Demo + Referências

Slide 3

Slide 3 text

3 Sysadmin há 13 anos (3 anos de DevOPS) Bacharel em CCP / Mestre em Eng. Comp. TechLead na Mandic Apaixonado por OpenSource, IAC, Agile, Lean, DevOps. Movido a café!

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

5 + HighLander + Rollout + Blue/Green + Canary + A/B + Shadow + Feature Toggle + Objetivo comum: Reduzir o downtime e os riscos de uma alteração de versão para uma nova aplicação ou sistema em produção.

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

7 Service --- apiVersion: v1 kind: Service metadata: name: myservice spec: ... selector: app: myapp ... type:LoadBalancer Pod --- apiVersion: v1 kind: pod metadata: name: myapp labels: app: myapp spec: ... image: nginx ... containerport:80 Pod --- apiVersion: v1 kind: pod metadata: name: myapp labels: app: myapp spec: ... image: nginx ... containerport:80 Pod --- apiVersion: v1 kind: pod metadata: name: myapp labels: app: myapp spec: ... image: nginx ... containerport:80

Slide 8

Slide 8 text

8 + Virada de chave + Pods da nova versão são criados. + Pods da versão antiga são removidos + Virada do Service ocorre de uma vez. Deployment --- ... kind: Deployment metadata: name: myapp spec: ... replicas: 5 strategy: type: recreate ...

Slide 9

Slide 9 text

9 v1 v1 v1 v1 v1 Service

Slide 10

Slide 10 text

10 v1 v1 v1 v1 v1 Service v2 v2 v2 v2 v2

Slide 11

Slide 11 text

11 v2 v2 v2 v2 v2 Service v1 v1 v1 v1 v1

Slide 12

Slide 12 text

12 + Opção padrão em Deployments no Kubernetes + Atualiza gradativamente os Pods na proporção definida para nova versão + Conforme Pods são validados, tráfego é direcionado para Pods da nova versão. + Health-Check + LivenessProbe + ReadinessProbe Deployment --- ... kind: Deployment metadata: name: myapp spec: ... replicas: 5 strategy: type: RollingUpdate rollingUpdate: maxSurge: 45% maxUnavailable: 15% ...

Slide 13

Slide 13 text

13 v1 v1 v1 v1 v1 Service

Slide 14

Slide 14 text

14 v2 v2 v1 v1 v1 Service

Slide 15

Slide 15 text

15 v2 v2 v2 v2 v1 Service

Slide 16

Slide 16 text

16 v2 v2 v2 v2 v2 Service

Slide 17

Slide 17 text

17 v2 v2 v2 v2 v2 Service

Slide 18

Slide 18 text

18 + Uma nova estrutura completa (Services + Deploy) é criada. + Testes são realizados na nova estrutura + Caso passe nos testes, selector do Service de Prod (blue) é alterado para o label do Deployment da nova estrutura (green) Service --- apiVersion: v1 kind: Service metadata: name: green spec: ... selector: app: myapp-v2 ... type:LoadBalancer Deployment --- ... kind: Deployment metadata: name: myapp labels: app: myapp-v2 spec: ... replicas: 3 image: myapp:v2 Service --- apiVersion: v1 kind: Service metadata: name: blue spec: ... selector: app: myapp-v1 ... type:LoadBalancer Deployment --- ... kind: Deployment metadata: name: myapp labels: app: myapp-v1 spec: ... replicas: 3 image: myapp:v1

Slide 19

Slide 19 text

19 v1 v1 v1 v1 v1 Service Prod v1

Slide 20

Slide 20 text

20 v1 v1 v1 v2 v2 Service QA v2 Service Prod Testes

Slide 21

Slide 21 text

21 v1 v1 v1 v2 v2 Service QA v2 Service Prod Service --- apiVersion: v1 kind: Service metadata: name: blue spec: ... selector: app: myapp-v2 ... type:LoadBalancer

Slide 22

Slide 22 text

22

Slide 23

Slide 23 text

23 + Novo Deploy com nova versão é criado, com mesmo label do “selector” do Service de produção + Novo Deploy se vale do algoritmo de roteamento padrão do Service (round-robin) para receber tráfego. + Caso análise dos testes seja positiva, novos PODs (replicas) são iniciados gradativamente.

Slide 24

Slide 24 text

24 Service --- apiVersion: v1 kind: Service metadata: name: myservice spec: ... selector: app: myapp ... type:LoadBalancer Pod --- apiVersion: v1 kind: pod metadata: name: myapp labels: app: myapp spec: ... image: nginx ... containerport:80 Pod --- apiVersion: v1 kind: pod metadata: name: myapp labels: app: myapp spec: ... image: nginx ... containerport:80 Pod --- apiVersion: v1 kind: pod metadata: name: myapp labels: app: myapp spec: ... image: nginx:1.8 ... containerport:80

Slide 25

Slide 25 text

25 v1 v1 v1 v1 v1 Service Prod v1 v1 v1 v1 v2 90% 10%

Slide 26

Slide 26 text

26 v1 v1 v1 v1 v1 Service Prod v1 v1 v1 v2 v2 80% 20%

Slide 27

Slide 27 text

27 Agora 99% e 1%

Slide 28

Slide 28 text

28 Agora 99% e 1%

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

30 + “A service mesh is a configurable infrastructure layer for a microservices application. It makes communication between service instances flexible, reliable, and fast. The mesh provides service discovery, load balancing, encryption, authentication and authorization, support for the circuit breaker pattern, and other capabilities.“ * * Retirado do site oficial Nginx Blog.

Slide 31

Slide 31 text

31 Istio + v1.1 (stable) + Google, Redhat, Lyft + Suporta não apenas Kubernetes + Complexo.

Slide 32

Slide 32 text

32 Serviços importantes + Pilot: Responsável pelas configurações de todos os Envoys na Mesh. Configura, entre várias outras coisas, a políticas de roteamento para dentro e fora das aplicações. + Mixer: Responsável pela telemetria de toda a Mesh. Tem backend configurável para vários outputs.

Slide 33

Slide 33 text

33 Seus novos amigos da vizinhança! (CRD) + Gateway + VirtualService + DestinationRule + Serviceentry

Slide 34

Slide 34 text

34 Pod K8S Service (srv-1) LoadBalancer Container Istio Ingress POD K8S Service K8S Service (srv-1) LoadBalancer ClusterIP Pod Envoy Container

Slide 35

Slide 35 text

35 Seus novos amigos da vizinhança! (CRD) + Gateway: Configura o Ingress Controller para aceitar comunicação de um certo domínio e porta. + VirtualService: Faz o roteamento e conexão entre o domínio configurado no Gateway e um Service do Kubernetes (pode usar um DestinationRule para isso ou não) + DestinationRule: Cria grupos (subsets) de versões de uma aplicação e define a política de tráfego para elas. + Serviceentry: Expande a Mesh para um serviço externo ao ControlPlane. Mais utilizado para liberar acesso a aplicações externas a Mesh.

Slide 36

Slide 36 text

36 Istio Ingress POD K8S Service K8S Service (srv-1) Gateway VirtualService DestinationRule LoadBalancer ClusterIP Pod Envoy Container + LB que vai expor as aplicações, agora aponta para o Istio-Ingress primeiro. + Oh! Ingress! Psiu! Aceita conexão desse domínio srv-1.istio-demo.intra.net agora ok? + O Gateway! Conexão para srv-1-istio-demo.intra.net vai para o serviço Kubernetes srv-1 + Oh VirtualService! Se quiser opções mais avançadas de roteamento, COLA EM MIM!

Slide 37

Slide 37 text

37 Cenário: -> Kubernetes + AWS cluster + Provisionado com Kops 1.11 + Versão 1.11.9 + 1 master (m5.xlarge) + 3 nodes (m5.xlarge) - Multi AZ + AdmissionControl + Route53 interno (istio-demo.intra.net) + Istio 1.0.7

Slide 38

Slide 38 text

38 Istio install: (helm) curl -LO https://github.com/istio/istio/releases/download/1.0.7/istio-1.0.7-linux.tar.gz tar zxvf istio-1.0.7-linux.tar.gz cd istio-1.0.7/install/kubernetes/helm/ helm template ./istio --name istio --namespace istio-system --set grafana.enabled=true --set kiali.enabled=true > /root/istio-install-v1.yaml kubectl create ns istio-system kubectl apply -f /root/istio-install-v1.yaml prepare-se para muitas linhas...

Slide 39

Slide 39 text

39 Istio install: (helm) kubectl -n istio-system get pods (snipped...) NAME READY STATUS RESTARTS AGE grafana-7f6cd4bf56-4phwp 1/1 Running 0 1d istio-citadel-7dd558dcf-mb8qz 1/1 Running 0 1d istio-egressgateway-88887488d-wc28w 1/1 Running 0 1d istio-galley-787758f7b8-5267v 1/1 Running 0 1d istio-ingressgateway-58c77897cc-gnj2s 1/1 Running 0 1d istio-pilot-868cdfb5f7-r7qdk 2/2 Running 0 1d istio-policy-56c4579578-tvsrs 2/2 Running 0 1d istio-sidecar-injector-d7f98d9cb-q8fpj 1/1 Running 0 1d istio-telemetry-7fb48dc68b-hg87q 2/2 Running 0 1d istio-telemetry-7fb48dc68b-qvtk2 2/2 Running 0 23m kiali-58bf795c96-bbhxm 1/1 Running 0 1d prometheus-76db5fddd5-jcb69 1/1 Running 0 1d

Slide 40

Slide 40 text

40 Pontos de atenção! kubectl label namespace default istio-injection=enabled labels: app: version: Service: Vira ClusterIP Nome das portas dos Services das aplicações! protocol[-sufix] ex: http (OK) ex: http-myport (OK) ex: lalaland (NOT OK)

Slide 41

Slide 41 text

41 Pontos de atenção!

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

43 https://github.com/drequena/istio-app/tree/dev

Slide 44

Slide 44 text

44

Slide 45

Slide 45 text

45 SRV-1 DB Remote API SRV-2 SRV-4 SRV-3 K8S Service

Slide 46

Slide 46 text

46 SRV-1 DB Remote API SRV-2 SRV-4 SRV-3

Slide 47

Slide 47 text

47 SRV-1 v1 DB Remote API SRV-2 SRV-4 SRV-3 SRV-1 v2

Slide 48

Slide 48 text

48 SRV-1 v1 DB Remote API SRV-2 v1 SRV-4 SRV-3 SRV-1 v2 90% 10% SRV-2 v2

Slide 49

Slide 49 text

49 SRV-1 v1 DB Remote API SRV-2 v1 SRV-4 SRV-3 SRV-1 v2 90% 10% SRV-2 v2 30%

Slide 50

Slide 50 text

50 Features + Dynamic service discovery + Load balancing + TLS termination + HTTP/2 and gRPC proxies + Circuit breakers + Health checks + Staged rollouts with %-based traffic split + Fault injection + Rich metrics + mutual-TLS + E muitas, muitas mais...

Slide 51

Slide 51 text

51

Slide 52

Slide 52 text

52 ❖ https://istio.io/ ❖ https://istio.io/docs/ ❖ https://istio.io/docs/setup/kubernetes/platform-setup/aws/ (ADMISSIONCONTROL) ❖ https://istio.io/docs/reference/config/ ❖ https://istio.io/docs/concepts/traffic-management/ ❖ https://youtu.be/JdqFy7ykPuQ ❖ http://github.com/drequena/istio-app/ ❖ https://github.com/kubernetes/kops/ ❖ t.me/istiobr (Grupo de Telegram) ❖ https://www.nginx.com/blog/what-is-a-service-mesh/

Slide 53

Slide 53 text

Perguntas? Obrigado!

Slide 54

Slide 54 text

You can find me at @Daniel_Requena (twitter) www.linkedin.com/in/danielrequena/ [email protected] [email protected] Daniel Requena