Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 33

How it works, what we can monitor with it and why is it

different

By João Esperancinha (2024/03/31)


Who am I?
João Esperancinha
● Java
● Kotlin
Overview
● Groovy
Understanding
● Scala the problems
Project objective
● Software Engineer 10+ years
Target audience
● JESPROTECH owner for 1 year
Cycle
● diagram
Kong
Market Champion
trends
● Java Professional
● Spring Professional
Intro

What is Kuma?
Intro - What is Kuma?

Kuma is a platform agnostic open-


source control plane for service
mesh and microservices
management, with support for
Kubernetes, VM, and bare metal
environments.

https://kuma.io/docs/2.6.x/introduction/overview-of-kuma/
Chapter I

Getting the services


up and running
Chapter I - Summary
Before even beginning exploring Kuma we need a complete
cluster and a functional application system

01 | Our application

02 | Installing all commands

03 | Creating a Cluster

04 | Creating a local docker registry

05 | Going through the code


06 | Making the deploy scripts

07 | Running the Demo application


Chapter I

Step 1
Our application

https://github.com/jesperancinha/wild-life-safety-monitor
Chapter I - Our Application

Albatross picture by chrispearson72 Flickr stream CC BY 2.0 DEED / https://nl.wikipedia.org/wiki/Albatrossen#/media/Bestand:Black_Browed_Albatross_gnd.jpg


Chapter I - Our Application

Albatross picture by chrispearson72 Flickr stream CC BY 2.0 DEED / https://nl.wikipedia.org/wiki/Albatrossen#/media/Bestand:Black_Browed_Albatross_gnd.jpg


Chapter I

Step 2
Installing all
commands
Chapter I - Our Application

What do we need in general


A cluster to get our pods running. A way to manage and configure our pods.
1 3

This will be achieved with kind. (kubernetes This will be achieved with kubectl
in docker)

A local registry that we can access inside our A command to allow Kuma to install the
2
deployment environment. 4
environment and inject the sidecars.

This will be achieved with kind This will be achieved with kumactl.
Chapter I

Step 3
Creating
a Cluster
Chapter I - Our Application

Creating a Cluster

kind create cluster --name=wlsm-mesh-zone


kubectl cluster-info --context kind-wlsm-mesh-zone
Chapter I - Our Application

Creating a Cluster - Control Plane GUI

helm repo add kuma https://kumahq.github.io/charts


helm repo update
helm upgrade -i kuma kuma/kuma
helm install --create-namespace --namespace kuma-system kuma kuma/kuma
Chapter I

Step 4
Creating a
local docker
registry
Chapter I - Our Application

Creating a local docker registry

./kind-with-registry.sh
Chapter I - Our Application

Creating a local docker registry

docker build . --tag localhost:5001/wlsm-listener-service;


docker push localhost:5001/wlsm-listener-service;
Chapter I

Step 5
Going
through
the code
Chapter I - Our Application

Going through the code


Listener Service

wslm.url.collector=http://wlsm-collector-deployment.wlsm-namespace.svc.cluster.local:8081/api/v1/collector

Collector Service

spring.r2dbc.url=r2dbc:postgresql://wlsm-database-deployment.wlsm-namespace.svc.cluster.local:5432/wlsm
Chapter I

Step 6
Making
the deploy
scripts
Chapter I - Our Application

Making the deploy scripts


apiVersion: v1 apiVersion: apps/v1 ---
kind: Namespace kind: Deployment apiVersion: v1
metadata: metadata: kind: Service
name: wlsm-namespace name: wlsm-listener metadata:
labels: namespace: wlsm-namespace name: wlsm-listener-deployment
kuma.io/sidecar-injection: enabled spec: spec:
--- replicas: 1 selector:
selector: app: wlsm-listener
matchLabels: ports:
app: wlsm-listener - protocol: TCP
template: appProtocol: http
metadata: port: 8080
labels:
app: wlsm-listener
spec:
containers:
- name: wlsm-listener-service
image: localhost:5001/wlsm-listener-service:latest
imagePullPolicy: Always
ports:
- containerPort: 8080
Chapter I

Step 7
Running
the application
Chapter I - Our Application

Running the application

kubectl apply -f listener-deployment.yaml --force;


Chapter II

Exploring
Kuma features
Chapter II - Exploring Kuma features

MeshTrafficPermission
echo "apiVersion: kuma.io/v1alpha1
kind: MeshTrafficPermission
metadata:
namespace: kuma-system
name: mtp
spec:
targetRef:
kind: Mesh
from:
- targetRef:
kind: Mesh
default:
action: Allow" | kubectl apply -f -
Chapter II - Exploring Kuma features

Mesh
echo "apiVersion: kuma.io/v1alpha1
kind: Mesh
metadata:
name: default
spec:
mtls:
enabledBackend: ca-1
backends:
- name: ca-1
type: builtin" | kubectl apply -f -
Chapter II - Exploring Kuma features

MeshTrafficPermission (Deny)
apiVersion: kuma.io/v1alpha1
kind: MeshTrafficPermission
metadata:
namespace: kuma-system
name: mtp
spec:
targetRef:
kind: Mesh
from:
- targetRef:
kind: Mesh
default:
action: Deny" | kubectl apply -f -
Chapter II - Exploring Kuma features
MeshTrafficPermission (Specific)
echo "
apiVersion: kuma.io/v1alpha1
kind: MeshTrafficPermission
metadata:
namespace: kuma-system
name: wlsm-database
spec:
targetRef:
kind: MeshService
name: wlsm-database-deployment_wlsm-namespace_svc_5432
from:
- targetRef:
kind: MeshService
name: wlsm-collector-deployment_wlsm-namespace_svc_8081
default:
action: Allow" | kubectl apply -f -
Chapter II - Exploring Kuma features
MeshFaultInjection (Specific)
echo "
apiVersion: kuma.io/v1alpha1
kind: MeshFaultInjection
metadata:
name: default
namespace: kuma-system
labels:
kuma.io/mesh: default # optional, defaults to `default` if it isn't configured
spec:
targetRef:
kind: MeshService
name: wlsm-collector-deployment_wlsm-namespace_svc_8081
from:
- targetRef:
kind: MeshService
name: wlsm-listener-deployment_wlsm-namespace_svc_8080
default:
http:
- abort:
httpStatus: 500
percentage: 50" | kubectl apply -f -
Project Location
● Source Repository
○ https://github.com/jesperancinha/wild-life-safety-monitor

Use git clone from the command prompt to download the full code base:

> git clone https://github.com/jesperancinha/wild-life-safety-monitor.git

You’ll be prompted for a username and password which should be your github account.

The easy way: The manual way:


> make b > gradle build
> make run > ./gradlew run
Resources:
● K9s
● https://support.konghq.com/support/s/article/How-to-enable-debug-logging-for-kuma-sidecar-without-using-port-forw
ard
● https://spacelift.io/blog/kubectl-logs
● https://docs.konghq.com/mesh/latest/policies/meshtrafficpermission/
● https://kuma.io/features/
Questions?
Thank you.

You might also like