Linkerd: Install and Basic Ops
Published: 2020-11-01 01:59:27

Linkerd Installation, Basic Operations and My Thoughts About it. 

*Requirements(Works on Production too)*
 - *GKE or Minikube or kind*
 - *Kubernetes(1.16+)*
 - *kubectl(1.16+)*
 - *Linkerd 2.x*

1 - Install Linkerd CLI
``` 
- $ curl -sL https://run.linkerd.io/install | sh
- $ export PATH=$PATH:$HOME/.linkerd2/bin
- $ linkerd version
```
2 - Validate Kubernetes Cluster
```
- $ linkerd check --pre
OUTPUT:
..
pre-kubernetes-capability
-------------------------
‼ has NET_ADMIN capability
    found 1 PodSecurityPolicies.. 
‼ has NET_RAW capability
    found 1 PodSecurityPolicies..
```
<figcaption>(on GKE ignore this warnings. This is because there's no linkerd previously installation and the pods security policies are on. But, dont worry)
</figcaption>

3 - Deploy Linkerd
```
- $ linkerd install | kubectl apply -f -
- $ linkerd check
- $ kubectl get all -n linkerd 
``` 
<figcaption>(now the linkerd check command must have all green checks output)</figcaption>

4 - Access the Dashboard
```
- $ linkerd dashboard
OUTPUT:
Linkerd dashboard available at:
http://localhost:50750
Grafana dashboard available at:
http://localhost:50750/grafana
Opening Linkerd dashboard in the default browser
```
You can use port-forward to expose the dashboard. 
```
- $ kubectl port-forward --address 127.0.0.1 \
service/linkerd-web 5000:8084 -n linkerd
```
Dashboard is referenced by the linkerd-web service. If you are executing from a bastion, you can define the bastion IP editing the deployment.apps/linkerd-web
```
- $ kubectl edit deployment.apps/linkerd-web -n linkerd
# you must edit the address on the arg enforced-host:
# BEFORE EDIT:-enforced-host=^(localhost|127\.0\.0\.1|..
# AFTER  EDIT:-enforced-host=^(bastionhost|192\.168\.0\.9|..

- $ kubectl port-forward --address 0.0.0.0 \
service/linkerd-web 5000:8084 -n linkerd
``` 
Now you can open the Dashboard with bastion IP(192.168.0.9 as the example) and port 5000

![Linkerd Dashboard](https://dev-to-uploads.s3.amazonaws.com/i/q5wu7qdgh4mn0uii7cb1.png)

With dashboard we can visualize our microservices architecture in selected namespace

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/kn5kj195sijqkkue9dp3.png)

Clicking on the Grafana icon link at the pod line, we can see the pod stats on a template pre-configurated

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/tmtkvizcy0qjgoaxjqje.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/nrb68veiepq17716ck7q.png)
<figcaption>Each meshed pod will have a pre-configured Grafana Dashboard.</figcaption>

The Linkerd is a lightweight powerful service mesh plataform, and had the advantage to be strongly decoupled architecture. It can be added and removed without influencing your app.

Linkerd is unique in that it is part of the Cloud Native Foundation (CNCF), which is the organization responsible for Kubernetes.  

The CLI had a simple and intuitive user experience.

You can mesh your deployed microservice with simple commands
```
#add with linkerd inject command on a deployed app
- $ kubectl get -n YOUR_APP_NAMESPACE deploy -o yaml \
  | linkerd inject - \
  | kubectl apply -f -
```
or add few yaml instructions(two config lines on the app deployment yaml)
```
#example:
annotations:
  checksum/config: 37b064423157b6fe14ddeba6924195c1075bd17feb
  linkerd.io/inject: enabled

#this values are extract from the command
- $ kubectl get -n YOUR_APP_NAMESPACE deploy -o yaml \
  | linkerd inject -
```
To reverse the mesh on your app do:
``` 
- $ kubectl get -n YOUR_APP_NAMESPACE deploy -o yaml \
  | linkerd uninject - \
  | kubectl apply -f -
```
To uninstall Linkerd
``` 
- $ linkerd uninstall | kubectl apply -f -
```

###References
 - Linkerd Docs - https://linkerd.io/docs