Slide 1

Slide 1 text

K8s Operators & Open APIs Como Kubernetes Operators pode me ajudar na criação e testes de APIs usando Open API Specification

Slide 2

Slide 2 text

Claudio E. de Oliveira Sr. Software Engineer @ZUP Innovation Java & Golang K8s, Docker & Mesh

Slide 3

Slide 3 text

1 - Open API Spec 4 - Putting all together 3 - k8s Operator 2 - API First Principle Agenda Agenda

Slide 4

Slide 4 text

Microservices Explosion Microservices Explosion

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

Things to think about... ▰ Microservices are developed by != teams (communication) ▰ Many interactions between services ▰ Ecosystem turns to complex and hard to understand

Slide 7

Slide 7 text

Documentation should be the way that teams “talking”

Slide 8

Slide 8 text

Do it using Open API Spec… for REST APIs

Slide 9

Slide 9 text

The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for REST APIs, which allows both humans and computers to discover and understand the capabilities of a service without requiring access to source code What is Open API Spec

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

API First Design API First Design

Slide 13

Slide 13 text

What API First Means??? An API-first approach means that for any given development project, your APIs are treated as “first-class citizens.”

Slide 14

Slide 14 text

Your API should be designed with with users in mind. Think in consumption in first place.

Slide 15

Slide 15 text

How it works??? An API-first approach involves developing APIs that are consistent and reusable, which can be accomplished by using an API description language to establish a contract for how the API is supposed to behave

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

Advantages ▰ Increase the speed to market ▰ Ensures good developer experiences Development teams can work in parallel How to achieve it???

Slide 18

Slide 18 text

API Mocks can be a good way to deliver API consumption for other teams

Slide 19

Slide 19 text

For Contract Tests Consumption Tests Test API Design

Slide 20

Slide 20 text

How we can create automatization for it???

Slide 21

Slide 21 text

Open API has a example section that make our service clearer to consumption also we can use some tool to help with mocks

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

k8s Controllers

Slide 24

Slide 24 text

Everything in kubernetes are events

Slide 25

Slide 25 text

Kubernetes Controllers Kubernetes controllers receive these events and then we can extend kubernetes features It is a program that can react a k8s events golang, python, java...etc

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

wait...what is Desired State???

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

Custom Resource A resource is an endpoint in the Kubernetes API that stores a collection of API objects of a certain kind POD is built-in Kind Deployment is built-in Kind Service is built-in Kind APIMock is not a built-in kind is a Custom Resource

Slide 31

Slide 31 text

Custom Resource Definition C - Custom R - Resource D - Definition

Slide 32

Slide 32 text

CRD is the way to tell instructions to kubernetes some Custom Resources properties like “template”

Slide 33

Slide 33 text

k8s Operator “An Operator is a Controller that uses a CRD to encapsulate operational knowledge for a specific application in an algorithmic and automated form. The Operator pattern allows us to extend the Controller pattern from the preceding chapter for more flexibility and greater expressiveness.” from Kubernetes Patterns Book

Slide 34

Slide 34 text

Let’s put everything together Let’s put everything together

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

Obrigad_!