Let's start by a definition, what's a "Mesh Service" ?
...is a way to control how different parts of an application share data with one another. Unlike other systems for managing this communication, a service mesh is a dedicated infrastructure layer built right into an app. This visible infrastructure layer can document how well (or not) different parts of an app interact, so it becomes easier to optimize communication and avoid downtime as an app grows...
Context
Imagine, you have an application built on many services calls, and you want to know how services communicate inside your cluster, you want to monitor your request/response time and verify your request tracing and routing, you need a mesh service tools.
There are several solution who offering many features, but all this popular tools need a complex configuration to work and redefining of yours deployments and it's not available for ARM architecture.
So i purpose to you "SMS", it's a very simple mesh service for Kubernetes and dedicated to Rest Service (but can work with all HTTP services) and configured to work on ARM (like Raspberry ARMv7) and Amd64 .
Simple Mesh Service - Install
Simple way , with Helm package :
helm repo add medinvention-dev https://mmohamed.github.io/kubernetes-charts
Create your own values file "myvalues.yaml" (optional) :
Caution: Helm package is configured by default to work on ARM architecture, if you want to use it on AMD architecture (AWS, GCP, ...), you must add to all release option "-amd64"
db:
reuse: false # delete db on install or update
release: 5.6 # 5.6-amd64
api:
release: v0.1.0 # v0.1.0-amd64
ingress:
host: your ingress host for api...
ui:
release: v0.1.0 # v0.1.0-amd64
ingress:
host: your ingress host for ui...
sidecar:
release: v0.1.0 # v0.1.0-amd64
logger:
release: v0.1.0 # v0.1.0-amd64
master:
release: v0.1.0 # v0.1.0-amd64
controller:
release: v0.1.0 # v0.1.0-amd64
processor:
release: v0.1.0 # v0.1.0-amd64
Install (you can create your namespace before, for example kube-sms)
helm install -f myvalues.yaml kube-sms -n kube-sms medinvention-dev/sms
Now, you can view your dashboard on accessing web view (if you have configure an ingress for ui/api) with your credentials defined in your values file (default: admin@sms.dev /admin)
For testing, you can use sample files (from source) to test your install
kubectl apply -f /Sample
You will see your 4 services groups without any connetion
So, to see how it's work, you must execute same request on services, you can use this simple script (inside cluster, from any container)
for i in {1..50}
do
curl http://product-service.sample-sms.svc.cluster.local:5000/v3
curl http://product-service.sample-sms.svc.cluster.local:5000/v2
curl http://product-service.sample-sms.svc.cluster.local:5000/v1
curl http://product-service.sample-sms.svc.cluster.local:5000
curl http://product-service.sample-sms.svc.cluster.local:5000/notfound
done
After max 5 minutes (processor run every 5 min), you can see how your services communicate like this
If you have any problem during deployment, you can see logs
kubectl logs -n kube-sms -l "run=controller,app.kubernetes.io/name=SMS,app.kubernetes.io/instance=kube-sms"
kubectl logs -n kube-sms -l "run=master,app.kubernetes.io/name=SMS,app.kubernetes.io/instance=kube-sms"
kubectl logs -n kube-sms -l "run=logger,app.kubernetes.io/name=SMS,app.kubernetes.io/instance=kube-sms"
kubectl logs -n kube-sms -l "run=processor,app.kubernetes.io/name=SMS,app.kubernetes.io/instance=kube-sms"
kubectl logs -n kube-sms -l "run=db,app.kubernetes.io/name=SMS,app.kubernetes.io/instance=kube-sms"
kubectl logs -n kube-sms -l "run=api,app.kubernetes.io/name=SMS,app.kubernetes.io/instance=kube-sms"
Simple Mesh Service - How to
Let's see the V1 of the Review deployment (it's a part of sample) :
...
apiVersion: apps/v1
kind: Deployment
metadata:
name: deployment-review-v1
namespace: sample-sms
annotations:
medinvention.dev/sms.group: review
medinvention.dev/sms.port: "5000"
medinvention.dev/sms.service: review-v1-service
spec:
selector:
matchLabels:
app: review-v1
replicas: 1
template:
metadata:
labels:
app: review-v1
spec:
containers:
- name: server
image: python:3
command: ['sh', '-c', 'pip install flask && python /var/static/server']
ports:
- containerPort: 5000
volumeMounts:
- name: review-v1-server
mountPath: /var/static
volumes:
- name: review-v1-server
configMap:
name: review-v1-server
...
For our sample we need just 3 annotations :
medinvention.dev/sms.group: review
It's to specify the group of service, for Review services we have 3 version (v1, v2 and v3): we type "review" as group unique name, and they will be used to associate deployment to the services group. Finally it's will be the title in "Review bloc" header in Dashboard interface.
medinvention.dev/sms.port: "5000"
It's a container port who expose your service. In this sample it's 5000 et it will be accepting HTTP request only. This annotation it's not mandatory and by default, 80 will be used.
medinvention.dev/sms.service: review-v1-service
it's the name of service that expose your container port, this annotation is optional for SMS but, you must use service if you want to use same port. For sample "review-v1-service" bind 80 to 5000, so after applying SMS the service will be updated for only target port and you can continue calling service on 80.
if service is defined in another namespace that deployment, you can use this annotation to specify it.
medinvention.dev/sms.servicenamespace: sample-sms
It's done, you can delete sample and start using SMS with your services :)
Simple Mesh Service - Features
Using SMS Dashboard,
In Right pane, you can view some metadata of your services group, like his name, his status and how many services is contained.
You can have statistical data, like request and response Avg time for selected group and success/error request rate.
In bottom, you can see a request status statistic.
In Top bar view, you can filter by date or by namespace. And finally, this view is auto refreshed every 30 second, but you can force a refresh using reload button.
Enjoy
Nota: this is a development release of SMS project available here, it's can have bugs and may doses not work correctly with very big services.