Skip to content

Commit

Permalink
part 5-2
Browse files Browse the repository at this point in the history
  • Loading branch information
mluukkai committed May 24, 2024
1 parent 456624d commit 5f88592
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
Binary file added data/img/wikipedia.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 25 additions & 21 deletions data/part-5/3-service-mesh.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,29 @@ hidden: false

<text-box variant='learningObjectives' name='Learning Objectives'>

After this section you can
After this section, you can

- Setup a service mesh and use it to monitor network traffic

</text-box>

Very often you'll hear about a concept "Service Mesh". Service meshes are quite complex and have a large feature set. During parts 1 to 4 we have implemented a few features that service meshes would have offered out of the box. The following video by Microsoft Developer is an excellent walkthrough of all of the features a service mesh has.
You'll hear quite often about a concept called _Service Mesh_. Service meshes are quite complex animals that provide a large feature set for apps. During parts 1 to 4 we have implemented a few features that service meshes would have offered out of the box. The following video by Microsoft Developer is an excellent walkthrough of all of the features a service mesh has.

<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/izVWk7rYqWI" frameborder="0" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

For incoming and outgoing traffic and for communication between services it can:
It might also be worthwhile to read the article [What is a service mesh?](https://linkerd.io/what-is-a-service-mesh/) by Linkerd.

- Secure the communication
- Manage traffic
- Monitor traffic, sending logs and metrics to e.g. Prometheus
For incoming and outgoing traffic and for communication between services a service mesh can:

So a service mesh is an **extremely** powerful tool. If we started using service mesh like Istio in part 1 we may have been able to skip using traefik, skip some of our DIY monitoring solutions, and achieved canary releases without Argo Rollouts. On the other hand, we did do all that without a service meshes.
- secure the communication
- manage traffic
- monitor traffic, sending logs and metrics to e.g. Prometheus

Let's install a service mesh and test the features. Our choice will be [Linkerd](https://linkerd.io/), mainly because it's lightweight compared to Istio. Once again they have their own CLI tool to help us, follow the [getting started](https://linkerd.io/2/getting-started/) guide until Step 4.
So a service mesh is an **extremely** powerful tool. If we started using service mesh like [Istio](https://istio.io/) in part 1 we may have been able to skip using [Traefik](https://doc.traefik.io/traefik/providers/kubernetes-ingress/), skip some of our DIY monitoring solutions, and achieve canary releases without [Argo Rollouts](https://argoproj.github.io/rollouts/). On the other hand, we managed to do all that without a service meshes.

Let's install a service mesh and test the features. Our choice will be [Linkerd](https://linkerd.io/), mainly because it's lightweight compared to [Istio](https://istio.io/).

Linkerd has a CLI tool to help us, follow now the [getting started](https://linkerd.io/2/getting-started/) guide until Step 4.

<text-box name="Alternate sources" variant="hint">
We are actually simply following through the whole gettings started guide, so you can read through it if you wish.
Expand Down Expand Up @@ -94,7 +98,7 @@ $ linkerd viz install | kubectl apply -f -
$ linkerd viz dashboard
```
it should open your browser window. Click the "emojivoto" namespace (to reach /namespaces/emojivoto) we'll notice that the resources in emojivoto namespace are not in the service mesh yet. This is due to the fact that they do not have the `sidecar container` in the pods. Sidecar containers are a commonly used pattern where a new container is added to the pod to add more functionality to the pod. Let's add Linkerd sidecars to emojivoto.
it should open your browser window. Click the "emojivoto" namespace (to reach /namespaces/emojivoto) we'll notice that the resources in emojivoto namespace are not in the service mesh yet. This is due to the fact that they do not have the `sidecar container` in the pods. [Sidecar containers](https://kubernetes.io/docs/concepts/workloads/pods/sidecar-containers/) are a commonly used pattern where a new container is added to the pod to add more functionality to the pod. Let's add Linkerd sidecars to emojivoto.
The state of the pods before:
Expand All @@ -107,15 +111,15 @@ $ kubectl get po -n emojivoto
vote-bot-69754c864f-g24jt 1/1 Running 0 10m
```
The spell to add linkerd to the deployments and then apply the deployments.
The spell to add Linkerd to the deployments and then apply the deployments.
```
$ kubectl get -n emojivoto deploy -o yaml \
| linkerd inject - \
| kubectl apply -f -
```
You can run the rows independently to see what they do. The first, `kubectl get -n emojivoto deploy -o yaml`, will output all deployments in emojivoto namespace. The `linkerd inject -` will add an annotation to instruct Linkerd to add the sidecar proxy container. Finally the kubectl apply will apply the modified deployments. Now the pods look like this:
You can run the rows independently to see what they do. The first, `kubectl get -n emojivoto deploy -o yaml`, will output all deployments in the emojivoto namespace. The `linkerd inject -` will add an annotation to instruct Linkerd to add the sidecar proxy container. Finally, the _kubectl apply_ will apply modified deployments. Now the pods look like this:
```
kubectl get po -n emojivoto
Expand All @@ -126,29 +130,29 @@ emoji-696d9d8f95-sgzqs 2/2 Running 0 3m17s
voting-ff4c54b8d-sf99j 2/2 Running 0 3m18s
```
Also, if you now look at the dashboard you'll see a lot more information as the old deployments were replaced by the meshed ones. We also notice that success rate is less than stellar.
Two services have success rate below 100%. As the _web_ is most likely just propagating the error from _voting_ we can click either of the services and you should quickly see which request is failing.
Also, if you now look at the dashboard you'll see a lot more information as the old deployments were replaced by the meshed ones. We also notice that the success rate is less than stellar.
Service meshes can be powerful tools as they can help you connect and observe your services.
Two services have a success rate below 100%. As the _web_ is most likely just propagating the error from _voting_ we can click either of the services and you should quickly see which request is failing.
<exercise name='Exercise 5.02: Project: Service Mesh Edition'>
Service meshes can be powerful tools as they can help you connect and observe your services. Read now
[this](https://linkerd.io/2.15/tasks/debugging-your-service/) to see how Linkerd can be used to debug the issues in the emoji voting app.
Deployments are mostly trivial to move to Linkerd. As we already did with emojivoto you can do with the project
<exercise name='Exercise 5.02: Project, the Service Mesh Edition'>
Read: https://linkerd.io/2/tasks/adding-your-service/ and move you project to Linkerd.
Enable the Linkerd service mesh for _The Project_.
Add the modified manifests (through linkerd inject) to the repository for submission.
Deployments are mostly trivial to move to Linkerd. Read [this](https://linkerd.io/2/tasks/adding-your-service/), and add the modified manifests (through Linkerd inject) to the repository for submission.
</exercise>
<exercise name='Exercise 5.03: Learn from external material'>
To illustrate how canary releases work in Service Meshes follow through the task here: https://linkerd.io/2/tasks/canary-release/
To illustrate how canary releases work in Service Meshes follow through task here: https://linkerd.io/2/tasks/canary-release/
During the task note how the `kubectl -k` is used with github repository.
During the task note how the `kubectl -k` is used with GitHub repository.
Use <a href="https://man7.org/linux/man-pages/man1/script.1.html">script</a> command during the exercise to have something to submit. Or just take a screenshot at the end.
</exercise>
Ok, we are done for now. Do you need a server mesh for your app? Most likely not... unless you are working with a enterprise-level setting.

0 comments on commit 5f88592

Please sign in to comment.