ballerina and kubernetes microservice in practice with · microservice in practice with ballerina...

31
Lakmal Warusawithana | @lakwarus Microservice in Practice with Ballerina and Kubernetes

Upload: others

Post on 16-Jul-2020

14 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps

Lakmal Warusawithana | @lakwarus

Microservice in Practice with Ballerina and Kubernetes

Page 2: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps
Page 3: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps

Everything is An Endpoint

Functions

APIs

Data

SaaS apps

Legacy apps

Devices

Page 4: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps

TransactionsCircuit Breaking

ProtocolsPayloads

EventsSecurity

WorkflowStreams

Compensation

Page 5: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps

+

Page 6: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps

Optimized for Writing Network Distributed Applications

Page 7: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps

Let’s write a Microservice

Page 8: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps

● Ballerina supports high level network abstractions.

● Ballerina natively understands data types like JSON and XML.

● Ballerina has self documentation which can generate sequence diagram out of your code.

● Ballerina protects sensitive data by default.

Page 9: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps

Let’s deploy the Microservice

Page 10: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps
Page 11: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps

FROM ballerina/ballerina

COPY hello.balx /home/ballerina

EXPOSE 9090

CMD ballerina run hello.balx

Page 12: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps

$> docker build -t hello .

Sending build context to Docker daemon 7.168kB

Step 1/4 : from ballerina/ballerina

---> a65975411327

Step 2/4 : COPY hello.balx /home/ballerina

---> 3b4e481bef57

Step 3/4 : EXPOSE 9090

---> d95a1292b232

Step 4/4 : CMD ballerina run hello.balx

---> 2698c40bdadd

Successfully built 2698c40bdadd

Successfully tagged hello:latest

Page 13: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps

$> docker images

REPOSITORY TAG IMAGE ID CREATED SIZE

hello latest 2698c40bdadd 1 minute ago 128MB

Page 14: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps
Page 15: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps

apiVersion: apps/v1kind: Deploymentmetadata: name: hello-deployment labels: app: hellospec: replicas: 1 selector: matchLabels: app: hello template: metadata: labels: app: hello spec: containers: - name: hello image: hello:latest imagePullPolicy: "IfNotPresent" ports: - containerPort: 9090

Page 16: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps

$>kubectl apply -f deployment.yaml

deployment.extensions "hello-deployment" created

$>kubectl get pods

NAME READY STATUS RESTARTS AGE

hello-666f4f4bbf 1/1 Running 0 50s

Page 17: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps

apiVersion: "v1"kind: "Service"metadata: labels: app: "hello" name: "hello"spec: ports: - port: 9090 protocol: "TCP" targetPort: 9090 selector: app: "hello" type: "NodePort"

Page 18: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps

$>kubectl apply -f hello-service.yaml

service "hello-service" created

$>kubectl get service

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE

hello NodePort 10.110.136.115 <none> 9090:31657/TCP 5m

Page 19: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps

$>kubectl create configmap hello \

--from-env-file=twitter.toml

configmap "hello" created

Update Deployment yaml with config-map

volumeMounts:

- mountPath: "/home/ballerina/conf/"

name: "hello"

Page 20: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps
Page 21: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps

Ballerina K8S Demo

Page 22: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps

A service mesh is a dedicated infrastructure layer that controls service-to-service communication over a network. It provides a method in which separate parts of an application can communicate with each other.

source:techtarget.com

Page 23: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps
Page 24: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps
Page 25: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps

Ballerina Istio Demo

Page 26: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps

● Kubernetes (K8s) is an open-source system for automating deployment, scaling, and management of containerized applications.

● Ballerina natively understand Cloud Native platforms like Docker, Kubernetes and Istio.

● Ballerina and Kubernetes support agile development to deployment and improve productivity.

Page 27: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps
Page 28: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps
Page 29: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps
Page 30: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps

Learn more

Open source

Get support

http://ballerina.io

http://github.com/ballerina-platform/

Stack Overflow #ballerina tag

Page 31: Ballerina and Kubernetes Microservice in Practice with · Microservice in Practice with Ballerina and Kubernetes. Everything is An Endpoint Functions APIs Data SaaS apps Legacy apps

THANK YOU