Linkerd est un service mesh Kubernetes créé en 2016 par Buoyant (auteur : William Morgan). La version 2.x, entièrement réécrite en Rust (proxy) et Go (plan de contrôle), est fondamentalement différente du Linkerd 1.x original. Son proxy linkerd2-proxy, écrit en Rust, est l'un des proxies de service mesh les plus légers disponibles (~10 MB, latence ajoutée < 1 ms). Il fournit mTLS automatique, load balancing, retries, timeouts et observabilité sans configuration complexe.
Linkerd se positionne comme l'alternative simple à Istio : moins de fonctionnalités avancées, mais opérationnellement beaucoup plus accessible. Le code source reste Apache 2.0 ; Buoyant fournit des packages stables et un support entreprise (Buoyant Enterprise Linkerd).
Informations essentielles
Origine : Buoyant (États-Unis) · Licence : Apache 2.0 · Architectures : x86_64, ARM64
Liens : Site officiel · Documentation · GitHub · Releases
Support : Les versions stable et edge sont maintenues en parallèle. Les releases stables reçoivent des correctifs de sécurité pendant ~1 an.
Stack par défaut
| Composant | Valeur |
|---|---|
| Proxy de données | linkerd2-proxy (Rust, ~10 MB, injection automatique) |
| Plan de contrôle | linkerd-destination, linkerd-identity, linkerd-proxy-injector |
| Certificats | Trust anchor + issuer cert (rotation automatique SPIFFE) |
| Métriques | Prometheus (extension viz, optionnelle) |
| Dashboard | Linkerd Viz (optionnel, extension séparée) |
| Kubernetes minimum | 1.28+ |
Concepts clés
| Composant | Rôle |
|---|---|
| linkerd-proxy-injector | Webhook d'admission - injecte le proxy dans les pods |
| linkerd-destination | Service discovery, routage, politiques de trafic |
| linkerd-identity | Émission et rotation des certificats SPIFFE |
| Trust anchor | Certificat racine (CA) - ne change pas, doit être long-terme |
| Issuer certificate | Certificat intermédiaire - renouvellement automatique |
Extensions (packages séparés)
| Extension | Rôle |
|---|---|
| viz | Prometheus + dashboard + tap (inspection du trafic live) |
| multicluster | Trafic entre clusters |
| jaeger | Distributed tracing |
| smi | Compatibilité Service Mesh Interface |
Prérequis
| Ressource | Valeur |
|---|---|
| Kubernetes | 1.28+ |
| kubectl | Compatible avec le cluster cible |
| Droits | cluster-admin |
| Certificats | Trust anchor + issuer cert (générer avec step ou openssl) |
Linkerd ne génère pas les certificats racine pour vous - c'est un choix délibéré de sécurité. Il faut les fournir à l'installation.
Installation
1. Installer la CLI
curl --proto '=https' --tlsv1.2 -sSfL https://run.linkerd.io/install | sh
export PATH=$HOME/.linkerd2/bin:$PATH
# Vérifier
linkerd version
2. Vérifier les prérequis cluster
linkerd check --pre
3. Générer les certificats
Avec step (recommandé)
# Trust anchor (CA racine - longue durée)
step certificate create root.linkerd.cluster.local ca.crt ca.key \
--profile root-ca --no-password --insecure
# Issuer (CA intermédiaire - renouvelé automatiquement par Linkerd)
step certificate create identity.linkerd.cluster.local issuer.crt issuer.key \
--profile intermediate-ca --not-after 8760h \
--no-password --insecure \
--ca ca.crt --ca-key ca.key
Avec cert-manager (recommandé en production)
# Installer cert-manager si absent
helm install cert-manager jetstack/cert-manager \
-n cert-manager --create-namespace \
--set crds.enabled=true
# Puis utiliser les flags linkerd install --identity-external-issuer
4. Installer Linkerd
# CRDs
linkerd install --crds | kubectl apply -f -
# Plan de contrôle
linkerd install \
--identity-trust-anchors-file ca.crt \
--identity-issuer-certificate-file issuer.crt \
--identity-issuer-key-file issuer.key \
| kubectl apply -f -
# Attendre et vérifier
linkerd check
5. Installer Viz (dashboard + métriques)
linkerd viz install | kubectl apply -f -
linkerd viz check
# Ouvrir le dashboard
linkerd viz dashboard
Activer l'injection par namespace
# Injection automatique sur un namespace
kubectl annotate namespace production linkerd.io/inject=enabled
# Relancer les pods existants
kubectl rollout restart deployment -n production
# Vérifier (doit afficher "2/2" dans READY pour les pods injectés)
kubectl get pods -n production
mTLS et sécurité
Linkerd active mTLS automatiquement sur tout le trafic entre pods injectés. Pas de configuration supplémentaire nécessaire.
Vérifier que mTLS est actif
# Afficher les edges mTLS (connexions entre services)
linkerd viz edges deployment -n production
# Inspecter le trafic live d'un déploiement
linkerd viz tap deployment/mon-app -n production
# Vérifier les certificats d'identité d'un pod
linkerd identity -n production $(kubectl get pod -n production -l app=mon-app -o jsonpath='{.items[0].metadata.name}')
Politique d'autorisation (Server + HTTPRoute)
# Refuser tout le trafic entrant sur un Deployment par défaut
apiVersion: policy.linkerd.io/v1beta3
kind: Server
metadata:
name: backend-http
namespace: production
spec:
podSelector:
matchLabels:
app: backend
port: 8080
proxyProtocol: HTTP/2
---
# Autoriser uniquement le frontend
apiVersion: policy.linkerd.io/v1beta3
kind: AuthorizationPolicy
metadata:
name: allow-frontend
namespace: production
spec:
targetRef:
group: policy.linkerd.io
kind: Server
name: backend-http
requiredAuthenticationRefs:
- name: frontend
kind: MeshTLSAuthentication
group: policy.linkerd.io
Gestion du trafic
Retries et timeouts (via annotations)
# Sur un Service ou un Deployment
metadata:
annotations:
config.linkerd.io/proxy-enable-external-profiles: "true"
# ServiceProfile pour retries et timeouts
apiVersion: linkerd.io/v1alpha2
kind: ServiceProfile
metadata:
name: mon-service.production.svc.cluster.local
namespace: production
spec:
routes:
- name: GET /api/items
condition:
method: GET
pathRegex: /api/items.*
timeout: 3s
retryBudget:
retryRatio: 0.2
minRetriesPerSecond: 10
ttl: 10s
Traffic splitting (canary)
# SMI TrafficSplit (nécessite l'extension smi)
apiVersion: split.smi-spec.io/v1alpha1
kind: TrafficSplit
metadata:
name: mon-service-split
namespace: production
spec:
service: mon-service
backends:
- service: mon-service-v1
weight: 90
- service: mon-service-v2
weight: 10
Pour le canary avancé, utiliser Argo Rollouts ou Flagger qui s'intègrent nativement avec Linkerd.
Mise à jour
# Vérifier la version actuelle
linkerd version
# Télécharger la nouvelle CLI
curl --proto '=https' --tlsv1.2 -sSfL https://run.linkerd.io/install | sh
# Mettre à jour le plan de contrôle
linkerd upgrade | kubectl apply -f -
# Vérifier
linkerd check
# Relancer les pods pour mettre à jour les proxies
kubectl rollout restart deployment -n production
Le renouvellement des certificats issuer est automatique. Surveiller la date d'expiration du trust anchor (
ca.crt) car lui n'est pas renouvelé automatiquement - rotation manuelle requise avant expiration.
Troubleshooting
# Diagnostic global
linkerd check
# Vérifier l'état des pods du plan de contrôle
kubectl get pods -n linkerd
kubectl logs -n linkerd -l linkerd.io/control-plane-component=identity
# Inspecter le trafic entrant sur un pod
linkerd viz tap pod/<pod-name> -n production
# Voir les métriques d'un déploiement
linkerd viz stat deployment -n production
# Vérifier si un pod est injecté
kubectl get pod <pod> -n production -o jsonpath='{.spec.containers[*].name}'
# Doit inclure "linkerd-proxy"
# Logs du proxy Linkerd dans un pod
kubectl logs <pod> -c linkerd-proxy -n production
Pod non injecté
# Vérifier l'annotation sur le namespace
kubectl get namespace production -o jsonpath='{.metadata.annotations}'
# Vérifier si le pod a une annotation d'exclusion
kubectl get pod <pod> -n production -o yaml | grep "linkerd.io/inject"
# Si "disabled", l'injection est désactivée explicitement sur ce pod
Erreur de certificats
# Vérifier l'expiration des certificats
linkerd check --proxy
# Voir les certificats en cours
kubectl get secret -n linkerd linkerd-identity-issuer -o yaml
Commandes utiles
# Vue d'ensemble des déploiements (golden metrics : latence, taux de succès, req/s)
linkerd viz stat deployment -n production
linkerd viz stat deployment -n production --from deployment/frontend
# Top des routes les plus lentes
linkerd viz routes deployment/mon-app -n production
# Tap (inspection du trafic live, similaire à tcpdump)
linkerd viz tap deployment/mon-app -n production --to deployment/backend
# Vérification mTLS des edges
linkerd viz edges deployment -n production
# Identité TLS d'un pod
linkerd identity -n production <pod-name>
Ressources
- Documentation officielle : https://linkerd.io/2.15/overview/
- Getting started : https://linkerd.io/2.15/getting-started/
- Politique d'autorisation : https://linkerd.io/2.15/tasks/configuring-per-route-policy/
- ServiceProfile : https://linkerd.io/2.15/reference/service-profiles/
- GitHub : https://github.com/linkerd/linkerd2
- Releases : https://github.com/linkerd/linkerd2/releases
- Buoyant Enterprise Linkerd : https://buoyant.io/enterprise-linkerd