Zum Inhalt springen
Trainingslager IT-Trainingslager

Anhang A: Spickzettel

Die wichtigsten Befehle und Schnipsel aus Tag 0 bis 18, nach Thema geordnet. Die Tage stehen in Klammern. Platzhalter in spitzen Klammern ersetzt du; IPs sind die des Labors (cp1 172.16.0.126, west 172.16.0.182). Werte wie lab-key-123 sind Laborwerte. Alle Befehle laufen auf cp1, ohne --context gegen den Cluster ost.

Messen (Tag 0, 4)

Erfolgsquote aus dem Lastgenerator – das Messgerät des ganzen Buchs:

kubectl -n notes logs deploy/last -c last --since=55s | awk '{print $2, $3}' \
  | sort | uniq -c
kubectl -n notes logs deploy/last --since=60s | awk '{print $2, $3}' | sort | uniq -c
kubectl --context west -n tag15 logs deploy/last -c last \
  --since-time=$(cat start.txt) | awk '{print $2, $3}' | sort | uniq -c

Prometheus von cp1 aus abfragen:

kubectl -n monitoring port-forward svc/kps-kube-prometheus-stack-prometheus 9090 \
  >/dev/null 2>&1 &
Q='sum by (dst_deployment) (rate(response_total{namespace="notes",
 deployment="web", direction="outbound", classification="success"}[5m]))
 / sum by (dst_deployment) (rate(response_total{namespace="notes",
 deployment="web", direction="outbound"}[5m]))'
curl -s localhost:9090/api/v1/query --data-urlencode "query=$Q" \
  | jq -r '.data.result[] | .metric.dst_deployment + " " + .value[1]'
kill %1

Installation und Check (Tag 1)

CLI architekturneutral holen und gegen den Digest der GitHub-API prüfen:

ARCH=$(dpkg --print-architecture)
V=edge-26.11.2
curl -fsSLO \
  https://github.com/linkerd/linkerd2/releases/download/$V/linkerd2-cli-$V-linux-$ARCH
sha256sum linkerd2-cli-$V-linux-$ARCH
curl -fsSL https://api.github.com/repos/linkerd/linkerd2/releases/tags/$V \
  | grep -o '"digest": "sha256:[0-9a-f]*"'
sudo install -m 0755 linkerd2-cli-$V-linux-$ARCH /usr/local/bin/linkerd
linkerd version --client

Erst CRDs, dann Control Plane:

linkerd check --pre
kubectl get crd httproutes.gateway.networking.k8s.io -o \
  jsonpath='{.metadata.annotations.gateway\.networking\.k8s\.io/bundle-version}{"\n"}'
linkerd install --crds > crds.yaml
kubectl apply -f crds.yaml
linkerd install > control-plane.yaml
kubectl apply -f control-plane.yaml
kubectl -n linkerd rollout status deploy --timeout=300s
linkerd check
linkerd version --short
linkerd install --ha --ignore-cluster > ha.yaml   # nur zum Vergleichen
Befehl Prüft Tag
linkerd check --pre Cluster vor der Installation 1
linkerd check Control Plane, Zertifikate, Webhooks 1, 5
linkerd check --proxy -n <ns> Proxys eines Namespace 2, 6
linkerd check --proxy -n <ns> --wait 30s dasselbe, ohne 5 min zu hängen 16
linkerd viz check viz-Extension 4
linkerd multicluster check Extension und Links 12
  • Die Gateway-API-CRDs bringt Linkerd nicht mit (im Labor: Cilium bzw. k3s).
  • Die Control Plane: linkerd-identity (CA), linkerd-destination (Discovery und Policy), linkerd-proxy-injector (Webhook). Der Proxy läuft als nativer Sidecar (Init-Container mit restartPolicy: Always).

Injection (Tag 2)

kubectl annotate namespace notes linkerd.io/inject=enabled
kubectl -n notes rollout restart deploy/notes-api deploy/helper deploy/web deploy/last
kubectl -n notes rollout restart statefulset/postgres
kubectl -n notes get pods                     # 2/2 = Proxy dabei
kubectl -n notes get pods -o custom-columns=\
NAME:.metadata.name,PROXY:.metadata.annotations.linkerd\\.io/proxy-version
linkerd version --proxy -n notes
kubectl -n notes annotate service postgres config.linkerd.io/opaque-ports=5432
linkerd inject plain.yaml                     # nur Annotation setzen
linkerd inject --manual plain.yaml            # Proxy-Container direkt einfügen
kubectl -n tag02 patch deploy ohne -p \
  '{"spec":{"template":{"metadata":{"annotations":{"linkerd.io/inject":"disabled"}}}}}'

Eine Identität pro Dienst – über eigene ServiceAccounts:

for a in web notes-api helper last postgres; do
  kubectl -n notes create serviceaccount $a
done
for d in web notes-api helper last; do
  kubectl -n notes set serviceaccount deploy/$d $d
done
kubectl -n notes set serviceaccount statefulset/postgres postgres
kubectl -n notes logs deploy/web -c linkerd-proxy | grep 'Local identity'
  • Die Annotation am Namespace wirkt erst bei neuen Pods: rollout restart.
  • Mit nativem Sidecar laufen Init-Container im Mesh. Mit config.beta.linkerd.io/proxy-enable-native-sidecar: "false" laufen sie vor dem Proxy und damit ohne mTLS – unter Default-Deny scheitern sie (Tag 6).
  • Server-first-Protokolle (SMTP, MySQL) und Postgres brauchen opaque-ports; bei Server-first wartet sonst die Protokollerkennung 10 s (Tag 16).

Identität und mTLS (Tag 3)

linkerd identity -n notes -l app=web | grep -E 'POD|Issuer|Not |Subject:|DNS:'
kubectl -n notes logs deploy/web -c linkerd-proxy | grep 'Certified identity'
kubectl -n linkerd logs deploy/linkerd-identity -c identity | grep issued | tail -1
kubectl -n linkerd get configmap linkerd-config -o jsonpath='{.data.values}' \
  | grep -E 'issuanceLifetime|clockSkewAllowance'
linkerd diagnostics proxy-metrics -n notes deploy/web | grep '^control_identity_cert'

Wer spricht mit mTLS, wer im Klartext (client_id, no_tls_reason):

linkerd diagnostics proxy-metrics -n notes pod/postgres-0 \
  | grep '^tcp_open_total{direction="inbound",peer="src"' \
  | grep -oE '(target_port|client_id|no_tls_reason)="[^"]*"|[0-9]+$' | paste - - -

Auf dem Draht nachsehen (Ephemeral Container mit tcpdump):

P=$(kubectl -n notes get pod -l app=notes-api -o jsonpath='{.items[0].metadata.name}')
kubectl -n notes debug $P --image=docker.io/nicolaka/netshoot:v0.15 \
  --profile=netadmin -c sniff -- sleep 1800
kubectl -n notes exec $P -c sniff -- timeout 10 \
  tcpdump -i eth0 -nn -A 'tcp port 4143' 2>/dev/null | grep -c 'lab-key'
  • Meshed Verkehr kommt auf Port 4143 an, TLS 1.3, SNI = Ziel-Identität.
  • Identität: <sa>.<ns>.serviceaccount.identity.linkerd.cluster.local.
  • kubectl debug geht nur auf Pods, nicht auf deploy/….

viz und Grafana (Tag 4)

P=http://kps-kube-prometheus-stack-prometheus.monitoring.svc.cluster.local:9090
linkerd viz install --set prometheus.enabled=false --set prometheusUrl=$P \
  --set grafana.url=kps-grafana.monitoring.svc.cluster.local > viz.yaml
kubectl apply -f viz.yaml
linkerd viz check
Befehl Zeigt Tag
linkerd viz stat -n notes deploy Erfolgsquote, RPS, Latenz 4
linkerd viz stat -n notes deploy/helper --from deploy/web eine Kante 4
linkerd viz tap -n notes deploy/helper --path /unstable Requests live 4
linkerd viz top -n notes deploy/web häufigste Pfade (braucht TTY) 4
linkerd viz edges -n notes deploy Kanten mit Identitäten 4
linkerd viz routes -n notes deploy/web Routen 4
linkerd viz authz -n notes deploy/helper Treffer pro Server/Regel 6
linkerd viz stat-outbound -n tag07 deploy/web $PROM pro Route und Backend 7
linkerd viz dashboard --show url Web-Oberfläche 4
ssh -L 50750:localhost:50750 [email protected] linkerd viz dashboard --show url
PROM=--prometheusURL=http://localhost:9090    # stat-outbound/-inbound mit Port-Forward
kubectl -n monitoring create configmap linkerd-deployment-dashboard \
  --from-file=linkerd-deployment.json
kubectl -n monitoring label configmap linkerd-deployment-dashboard grafana_dashboard=1
  • Ohne prometheusUrl bricht viz install ab, wenn prometheus.enabled=false.
  • Proxy-Metriken kommen per PodMonitor linkerd-proxy (Port linkerd-admin, 4191) nach Prometheus.
  • tap braucht neu gestartete Pods (viz.linkerd.io/tap-enabled) und zeigt abgelehnte (403) Requests nicht.

Zertifikate (Tag 5)

Trust Anchor (10 Jahre) und Issuer (1 Jahr) mit step:

step certificate create root.linkerd.cluster.local ca.crt ca.key \
  --profile root-ca --no-password --insecure --not-after 87600h
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
step certificate verify issuer.crt --roots ca.crt && echo verify-ok
step certificate fingerprint ca.crt
kubectl -n linkerd get configmap linkerd-identity-trust-roots \
  -o jsonpath='{.data.ca-bundle\.crt}' | step certificate inspect --short -

Anchor-Rotation in drei Runden, nach jeder Runde CP, viz und Workloads neu starten:

step certificate bundle ca.crt original-trust.crt bundle.crt
linkerd upgrade --identity-trust-anchors-file=./bundle.crt > upgrade-1.yaml
linkerd upgrade --identity-issuer-certificate-file=./issuer.crt \
  --identity-issuer-key-file=./issuer.key > upgrade-2.yaml
linkerd upgrade --identity-trust-anchors-file=./ca.crt > upgrade-3.yaml
kubectl get events -n linkerd --field-selector reason=IssuerUpdated

cert-manager und trust-manager übernehmen:

helm install trust-manager oci://quay.io/jetstack/charts/trust-manager \
  --version v0.26.0 -n cert-manager --set app.trust.namespace=cert-manager --wait
kubectl -n cert-manager create secret tls linkerd-trust-anchor \
  --cert=ca.crt --key=ca.key
linkerd upgrade --set identity.externalCA=true \
  --set identity.issuer.scheme=kubernetes.io/tls > upgrade-4.yaml
cmctl renew -n linkerd linkerd-identity-issuer
kubectl -n linkerd get certificate linkerd-identity-issuer \
  -o jsonpath='{.status.notAfter} {.status.renewalTime}{"\n"}'
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata: {name: linkerd-identity-issuer}
spec:
  ca: {secretName: linkerd-trust-anchor}
---
apiVersion: trust.cert-manager.io/v1alpha1
kind: Bundle
metadata: {name: linkerd-identity-trust-roots}
spec:
  sources:
  - secret: {name: linkerd-trust-anchor, key: tls.crt}
  target:
    configMap: {key: ca-bundle.crt}
    namespaceSelector:
      matchLabels: {linkerd.io/is-control-plane: "true"}
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata: {name: linkerd-identity-issuer, namespace: linkerd}
spec:
  issuerRef: {name: linkerd-identity-issuer, kind: ClusterIssuer}
  secretName: linkerd-identity-issuer
  isCA: true
  commonName: identity.linkerd.cluster.local
  duration: 48h0m0s
  renewBefore: 25h0m0s
  privateKey: {rotationPolicy: Always, algorithm: ECDSA}
  • ca.key gut aufheben: Tag 12 und 14 signieren damit die Issuer für west.
  • Scheitert linkerd upgrade nach dem Umstieg auf externalCA, stehen in linkerd-config-overrides noch die alten Issuer-Werte – entfernen, dann erneut.
  • Warnung „issuer cert is valid for at least 60 days“ ist bei 48 h erwartet.

Policies (Tag 6)

apiVersion: policy.linkerd.io/v1beta3
kind: Server
metadata: {name: notes-api-http, namespace: notes}
spec:
  podSelector: {matchLabels: {app: notes-api}}
  port: http
  proxyProtocol: HTTP/1
  accessPolicy: deny          # audit zum Beobachten, all-unauthenticated (Tag 8)
---
apiVersion: policy.linkerd.io/v1alpha1
kind: MeshTLSAuthentication
metadata: {name: web, namespace: notes}
spec:
  identityRefs: [{kind: ServiceAccount, name: web}]
---
apiVersion: policy.linkerd.io/v1alpha1
kind: AuthorizationPolicy
metadata: {name: notes-api-von-web, namespace: notes}
spec:
  targetRef: {group: policy.linkerd.io, kind: Server, name: notes-api-http}
  requiredAuthenticationRefs:
  - {group: policy.linkerd.io, kind: MeshTLSAuthentication, name: web}

Für Clients ohne Proxy (Prometheus, Kubelet, Cilium-Gateway) per Netz:

apiVersion: policy.linkerd.io/v1alpha1
kind: NetworkAuthentication
metadata: {name: pod-netz, namespace: notes}
spec:
  networks:
  - cidr: 10.0.0.0/16
kubectl annotate namespace notes config.linkerd.io/default-inbound-policy=deny
kubectl -n notes get server,authorizationpolicy,meshtlsauthentication,\
networkauthentication
kubectl -n notes get pod -l app=helper -o yaml | grep -m1 -A1 INBOUND_DEFAULT_POLICY
linkerd diagnostics policy -n notes po/<pod> 8080 -o json \
  | jq -r '.authorizations[].labels.name'
kubectl -n notes logs deploy/helper -c linkerd-proxy --since=2m \
  | grep -m1 'Request denied' | grep -oE 'server.name=[^ ]*|Name\("[^"]*'
linkerd diagnostics proxy-metrics -n notes po/postgres-0 \
  | grep '^inbound_tcp_authz_deny_total' | grep -oE '(client_id|tls)="[^"]*"'
  • Vorgehen: Server mit audit, Regeln anlegen, Audit auswerten, auf deny stellen, zuletzt Default-Deny für den Namespace (Pods neu starten).
  • Default-Deny sperrt auch Prometheus auf 4191: Server proxy-admin (podSelector: {}, Port linkerd-admin) mit NetworkAuthentication erlauben.
  • Ohne HTTPRoute am Server sind Probes automatisch erlaubt. Hängt eine Route am Server, brauchen die Probes eine eigene Route samt Regel für die Kubelet-IPs.
  • Abgelehnt: HTTP mit 403, Opaque mit geschlossener Verbindung.

Routen, Retries und Timeouts (Tag 7)

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: helper-unstable
  namespace: tag07
  annotations:
    retry.linkerd.io/http: 5xx
    retry.linkerd.io/limit: "2"
spec:
  parentRefs:
  - {group: core, kind: Service, name: helper, port: 80}
  rules:
  - matches:
    - path: {type: PathPrefix, value: /unstable}
      method: GET             # POST nicht wiederholen
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: helper-delay
  namespace: tag07
  annotations:
    timeout.linkerd.io/request: 1s
spec:
  parentRefs:
  - {group: core, kind: Service, name: helper, port: 80}
  rules:
  - matches:
    - path: {type: PathPrefix, value: /delay}
kubectl -n tag07 get httproute helper-unstable -o yaml | grep -E 'controllerName|reason'
kubectl -n tag07 annotate httproute helper-unstable retry.linkerd.io/limit=3 --overwrite
kubectl -n tag07 patch httproute helper-delay --type=json \
  -p '[{"op":"add","path":"/spec/rules/0/timeouts","value":{"request":"3s"}}]'
linkerd diagnostics proxy-metrics -n tag07 deploy/last \
  | grep -E '^outbound_http_route_retry_(requests|limit_exceeded)_total' \
  | sed -E 's/\{.*\}//'
  • Erste Route am Service: Alle anderen Pfade bekommen 404. Catch-all-Route mit PathPrefix / anlegen.
  • Retries gelten auch für POST, wenn die Route keine Methode einschränkt.
  • Kein Retry-Budget, nur limit; ein ServiceProfile für denselben Service hebelt die Annotationen aus. Die Timeout-Annotation schlägt rules[].timeouts.request.
  • Ein Request-Timeout wird nicht wiederholt; retry.linkerd.io/timeout macht langsame Versuche wiederholbar.

Circuit Breaking und Rate Limiting (Tag 8)

kubectl -n tag08 annotate service helper \
  balancer.linkerd.io/failure-accrual=consecutive \
  balancer.linkerd.io/failure-accrual-consecutive-max-failures=3 \
  balancer.linkerd.io/failure-accrual-consecutive-min-penalty=10s \
  balancer.linkerd.io/failure-accrual-consecutive-max-penalty=1m
linkerd viz stat -n tag08 po -l app=helper --from deploy/web
linkerd diagnostics proxy-metrics -n tag08 deploy/web \
  | grep '^outbound_http_balancer_endpoints.*pending' | grep -oE '[0-9]+$'
apiVersion: policy.linkerd.io/v1alpha1
kind: HTTPLocalRateLimitPolicy
metadata: {name: helper-rl, namespace: tag08}
spec:
  targetRef: {group: policy.linkerd.io, kind: Server, name: helper-http}
  total:
    requestsPerSecond: 20
  identity:
    requestsPerSecond: 1
  overrides:
  - requestsPerSecond: 4
    clientRefs:
    - {kind: ServiceAccount, name: web}
kubectl -n tag08 get httplocalratelimitpolicy
kubectl -n tag08 logs deploy/helper -c linkerd-proxy --since=1m \
  | grep -o 'total rate limit exceeded: [0-9]*rps' | tail -1
linkerd diagnostics proxy-metrics -n tag08 deploy/helper \
  | grep '^inbound_http_local_ratelimit' \
  | grep -oE 'ratelimit_scope="[^"]*"|client_id="[a-z]+|\} [0-9]+' | paste - - -
  • Failure Accrual sperrt einzelne Pods; sind alle gesperrt, gibt es 503.
  • Rate Limits gelten pro Pod, Antwort 429. Auch per identity abgelehnte Requests verbrauchen den total-Topf – total großzügig wählen.

Traffic Shifting (Tag 9)

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata: {name: notes-api-canary, namespace: tag09}
spec:
  parentRefs:
  - {group: "", kind: Service, name: notes-api, port: 80}
  rules:
  - matches:
    - headers: [{name: x-canary, value: "true"}]
    backendRefs:
    - {name: notes-api-v2, port: 80}
  - backendRefs:
    - {name: notes-api, port: 80, weight: 90}
    - {name: notes-api-v2, port: 80, weight: 10}
W=/spec/rules/0/backendRefs
kubectl -n tag09 patch httproute notes-api-canary --type=json -p \
  "[{\"op\":\"replace\",\"path\":\"$W/0/weight\",\"value\":50},
    {\"op\":\"replace\",\"path\":\"$W/1/weight\",\"value\":50}]"
kubectl -n tag09 get httproute notes-api-canary \
  -o jsonpath='{.spec.rules[*].backendRefs[*].weight}{"\n"}'
kubectl -n tag09 delete httproute notes-api-canary      # Rollback in Sekunden
linkerd viz stat -n tag09 deploy --from deploy/last
kubectl -n tag09 delete endpointslice -l io.cilium.gateway/owning-gateway=notes-api
  • Die Route mit Service-Parent nehmen Linkerd und Cilium an: Meshed Clients teilt Linkerd auf, unmeshed Clients Cilium-Envoy (server: envoy).
  • Regel ohne backendRefs: Linkerd nimmt den Parent-Service, Ciliums Envoy antwortet unmeshed Clients mit 500 (Tag 18, Runde 1).
  • Abschließen: Service-Selector auf v2, Route löschen, v1 abskalieren.

Ingress (Tag 10)

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata: {name: notes, namespace: tag10}
spec:
  gatewayClassName: cilium
  listeners:
  - {name: http, protocol: HTTP, port: 80}
  - name: https
    protocol: HTTPS
    port: 443
    hostname: notes.lab.internal
    tls:
      mode: Terminate
      certificateRefs: [{name: notes-tls}]
NP=$(kubectl -n tag10 get svc cilium-gateway-notes \
  -o jsonpath='{.spec.ports[?(@.port==443)].nodePort}')
curl -s -w ' %{http_code}\n' --cacert lab-ca.crt \
  --resolve notes.lab.internal:$NP:172.16.0.126 https://notes.lab.internal:$NP/api/notes
kubectl get ciliumnodes \
  -o jsonpath='{range .items[*]}{.metadata.name} {.spec.ingress.ipv4}{"\n"}{end}'
cmctl renew -n tag10 notes-tls
Eingang Sicht des Mesh Regel in der Policy
Cilium-Gateway no_tls_from_remote, Ingress-IPs der Nodes NetworkAuthentication
nginx edge im Mesh mTLS mit Identität edge MeshTLSAuthentication

Egress (Tag 11)

apiVersion: policy.linkerd.io/v1alpha1
kind: EgressNetwork
metadata: {name: internet, namespace: tag11}
spec:
  trafficPolicy: Deny
---
apiVersion: gateway.networking.k8s.io/v1
kind: TLSRoute
metadata: {name: example-com, namespace: tag11}
spec:
  parentRefs:
  - {group: policy.linkerd.io, kind: EgressNetwork, name: internet, port: 443}
  hostnames: [example.com]
  rules:
  - backendRefs:
    - {group: policy.linkerd.io, kind: EgressNetwork, name: internet}
kubectl -n tag11 patch egressnetwork internet --type=merge \
  -p '{"spec":{"trafficPolicy":"Deny"}}'
kubectl -n tag11 patch tlsroute example-com --type=json \
  -p '[{"op":"add","path":"/spec/hostnames/-","value":"linkerd.io"}]'
kubectl -n tag11 get httproute,tlsroute
  • Ohne TLSRoute sieht der Proxy HTTPS nur als tcp mit IP, mit TLSRoute als tls mit SNI. HTTPRoutes am EgressNetwork filtern Klartext-HTTP nach Methode und Pfad.
  • Hostnamen in Metriken: config.linkerd.io/proxy-metrics-hostname-labels: "true".
  • Policy wirkt nur auf neue Verbindungen: Keep-Alive-Clients nach Deny neu starten.
  • Unmeshed Pods umgehen die Egress-Policy.

Multicluster (Tag 12, 13)

Zweiter Cluster mit gemeinsamem Trust Anchor:

step certificate create identity.linkerd.cluster.local \
  west-issuer.crt west-issuer.key \
  --profile intermediate-ca --not-after 8760h --no-password --insecure \
  --ca ../tag05/ca.crt --ca-key ../tag05/ca.key
linkerd --context west install --crds | kubectl --context west apply -f -
linkerd --context west install \
  --identity-trust-anchors-file ../tag05/ca.crt \
  --identity-issuer-certificate-file west-issuer.crt \
  --identity-issuer-key-file west-issuer.key > west-cp.yaml
kubectl --context west apply -f west-cp.yaml

Extension, Link, Export:

linkerd --context west multicluster install > mc-west.yaml
kubectl --context west apply -f mc-west.yaml
linkerd --context ost multicluster install -f mc-ost-values.yaml > mc-ost.yaml
kubectl --context ost apply -f mc-ost.yaml
linkerd --context west multicluster link-gen --cluster-name west > link-west.yaml
kubectl --context ost apply -f link-west.yaml
kubectl --context west -n tag12 label service helper mirror.linkerd.io/exported=true
linkerd --context ost multicluster gateways
linkerd --context ost viz stat -n tag12 deploy/last --to svc/helper-west
kubectl --context ost get svc -A -l mirror.linkerd.io/mirrored-service=true
gateway:
  enabled: false              # ost: kein Gateway, nur Controller
controllers:
- link:
    ref:
      name: west
Label am Service (Quellcluster) Ergebnis im Zielcluster Tag
mirror.linkerd.io/exported=true <svc>-west, Verkehr über Gateway 12
mirror.linkerd.io/exported=remote-discovery <svc>-west, direkt an Pod-IPs 13
mirror.linkerd.io/federated=member <svc>-federated aus allen Clustern 13
linkerd --context ost diagnostics endpoints echo-federated.tag13.svc.cluster.local:80
kubectl --context ost -n linkerd-multicluster delete link west
kubectl --context ost -n linkerd-multicluster delete secret cluster-credentials-west
kubectl --context ost -n linkerd delete secret cluster-credentials-west
  • Der Spiegel-Namespace muss im lesenden Cluster existieren.
  • NodePort-Gateway: controllers[].gateway.probe.port auf den Probe-NodePort setzen, bevor der Link entsteht.
  • remote-discovery und federated brauchen ein flaches Netz (Pod-IPs erreichbar).
  • linkerd multicluster unlink gibt es nicht mehr.
  • Gateway weg: Der Client-Proxy schaltet das Backend nach ~3 s auf failfast, der Controller leert die Endpunkte nach ~9 s. Die Rückkehr dauert länger (Backoff im Proxy des Controllers, bis 60 s zwischen zwei Versuchen).

Helm, HA und Upgrade (Tag 14, 15)

helm repo add linkerd-edge https://helm.linkerd.io/edge
helm search repo linkerd-edge/linkerd-control-plane --versions | head -4
kubectl --context west -n linkerd create configmap linkerd-identity-trust-roots \
  --from-file=ca-bundle.crt=../tag05/ca.crt
kubectl --context west -n linkerd create secret generic linkerd-identity-issuer \
  --type=kubernetes.io/tls --from-file=tls.crt=issuer.crt \
  --from-file=tls.key=issuer.key --from-file=ca.crt=../tag05/ca.crt
helm --kube-context west install linkerd-crds linkerd-edge/linkerd-crds \
  --version 2026.11.1 -n linkerd
helm --kube-context west install linkerd-control-plane \
  linkerd-edge/linkerd-control-plane --version 2026.11.1 -n linkerd \
  -f values-ha.yaml -f values-west.yaml
identity:
  externalCA: true            # Trust Anchor aus der ConfigMap
  issuer:
    scheme: kubernetes.io/tls # Issuer aus dem Secret
controllerReplicas: 2
enablePodAntiAffinity: false  # nur auf einem Node
identityTrustAnchorsPEM: |    # für multicluster check
  -----BEGIN CERTIFICATE-----
  ...

Upgrade: Release Notes, Vorschau, CRDs, Control Plane, Datenebene:

diff <(helm show values linkerd-edge/linkerd-control-plane --version 2026.11.1) \
  <(helm show values linkerd-edge/linkerd-control-plane --version 2026.11.2)
helm --kube-context west get manifest linkerd-control-plane -n linkerd > alt.yaml
helm --kube-context west upgrade linkerd-crds linkerd-edge/linkerd-crds \
  --version 2026.11.2 -n linkerd
helm --kube-context west upgrade linkerd-control-plane \
  linkerd-edge/linkerd-control-plane --version 2026.11.2 -n linkerd \
  -f ../tag14/values-ha.yaml -f ../tag14/values-west.yaml
kubectl --context west -n tag15 rollout restart deploy/helper
helm --kube-context west history linkerd-control-plane -n linkerd
helm --kube-context west rollback linkerd-control-plane 2 -n linkerd
  • Der Namespace linkerd muss vor der Helm-Installation mit den Labels der CLI existieren; das Issuer-Secret braucht tls.crt, tls.key und ca.crt.
  • values-ha.yaml (aus dem Chart) setzt harte Anti-Affinity, PDBs und Proxy-Requests für alle Workloads.
  • Control Plane weg: Bestehende Proxys arbeiten weiter. Injector weg: Neue Pods scheitern mit FailedCreate (Fail-Policy).
  • Per Helm installiert, per Helm ändern – nicht mehr mit linkerd upgrade.
  • Mit externalCA trotzdem identityTrustAnchorsPEM setzen (gleicher Inhalt wie die ConfigMap), sonst meldet linkerd multicluster check mit Link × clusters share trust anchors.
  • Proxy-Version pro Workload pinnen: config.linkerd.io/proxy-version.

Fehlersuche (Tag 16)

Von außen nach innen: Lastgenerator, linkerd check, Metriken, Policy des Proxys, zuletzt Logs.

linkerd diagnostics policy -n tag16 svc/helper 80 -o json \
  | jq -c '.protocol.Kind.Detect.http1.routes[].metadata.Kind'
linkerd diagnostics policy -n tag16 svc/banner 2525 -o json \
  | jq -c '.protocol.Kind | keys'
linkerd diagnostics endpoints helper.tag16.svc.cluster.local:80
linkerd viz edges -n tag16 deploy -o wide
kubectl -n tag16 get pod -l app=helper -o custom-columns=NAME:.metadata.name,\
PROXY-RESTARTS:.status.initContainerStatuses[1].restartCount,\
GRUND:.status.initContainerStatuses[1].lastState.terminated.reason
kubectl -n tag16 patch deploy web -p '{"spec":{"template":{"metadata":
  {"annotations":{"config.linkerd.io/proxy-log-level":"warn,linkerd=debug"}}}}}'
Symptom Erster Befehl Häufige Ursache
Pod 1/1 statt 2/2 Spalte proxy-version der Pods nicht neu gestartet
Alles 403 Proxy-Log, grep 'Request denied' kein Server/keine Regel
Einzelner Client 403 linkerd viz edges -n <ns> deploy -o wide falscher ServiceAccount
Genau 10 s Wartezeit linkerd diagnostics policy svc/<name> <port> Opaque Port fehlt
Init:Error, DB zu proxy-metrics auf port_skipped Skip-Port, alter Sidecar
Retry/Timeout wirkt nicht linkerd diagnostics policy svc/<name> <port> falscher parentRef-Port
503 vom Client-Proxy linkerd diagnostics endpoints <fqdn>:<port> keine Endpunkte
Proxy startet neu lastState der Init-Container OOMKilled
Pod nicht Ready kubectl get events Route am Server (Tag 6)
TLS-Fehler, keine Identität linkerd check (Abschnitt identity) Issuer abgelaufen, Uhr
viz zeigt nur - Proxy-Log, linkerd diagnostics policy proxy-admin fehlt
Rollout hängt stumm kubectl get events (FailedCreate) Proxy-Request > Limit
Alles 504 Header l5d-proxy-error (curl -si) Timeout-Annotation zu knapp
429 für einen Client Proxy-Log rate limit exceeded Override mit falschem Namespace
wenige Prozent 5xx viz stat-outbound je Backend Retries verstecken Canary
  • Eine HTTPRoute mit falschem Port ist trotzdem Accepted.
  • linkerd check --proxy ohne --wait hängt bis 5 min, wenn keine Proxys laufen.
  • Ein Ephemeral Container erbt die Identität seines Pods.
  • Die drei letzten Zeilen stammen aus dem Wettkampf (Tag 18, Runde 4 bis 6).

Kosten messen (Tag 17)

Gleiche Anordnung ohne und mit Proxy, feste Rate, JSON nach stdout:

kubectl -n tag17 exec deploy/last-mit -- fortio load -qps 100 -t 60s -c 4 \
  -p 50,90,99 -json - http://server-mit/get 2>/dev/null > mit-100.json
jq -c '[(.ActualQPS|round),
  (.DurationHistogram.Percentiles[] | .Value*10000|round/10)]' mit-100.json
kubectl -n tag17 top pod --containers
kubectl -n tag17 get pods -o custom-columns=NAME:.metadata.name,QOS:.status.qosClass
kubectl -n tag17 logs deploy/server-mit -c linkerd-proxy | grep runtime
R='{"spec":{"template":{"metadata":{"annotations":{
  "config.linkerd.io/proxy-cpu-request":"200m",
  "config.linkerd.io/proxy-memory-request":"20Mi"}}}}}'
kubectl -n tag17 patch deploy server-mit -p "$R"
  • Ohne Requests ist der Proxy (und der ganze Pod) BestEffort – auf vollen Nodes steigt die Latenz stark.
  • Ein CPU-Limit ohne Request setzt den Request gleich dem Limit (Pod bleibt Pending). Das aufgerundete Limit bestimmt die Worker-Threads (LINKERD2_PROXY_CORES_MAX, höchstens CPUs des Nodes), der Request CORES_MIN und das veraltete CORES.
  • kubectl top zeigt das Working Set (3 Mi), der Proxy meldet seinen RSS (22 MB).

Wichtige Annotationen

Annotation An Wirkung Tag
linkerd.io/inject: enabled / disabled Namespace, Pod Proxy ja/nein 2
config.linkerd.io/opaque-ports Service, Pod keine Protokollerkennung 2, 16
config.beta.linkerd.io/proxy-enable-native-sidecar Pod "false": alter Sidecar 2, 6
config.linkerd.io/default-inbound-policy Namespace deny: Default-Deny 6
retry.linkerd.io/http, …/limit, …/timeout HTTPRoute Retries 7
timeout.linkerd.io/request (response, idle) HTTPRoute Timeout 7
balancer.linkerd.io/failure-accrual Service Circuit Breaking 8
config.linkerd.io/proxy-metrics-hostname-labels Pod Hostnamen in Metriken 11
config.linkerd.io/proxy-cpu-request Pod CPU-Request des Proxys 14, 17
config.linkerd.io/proxy-cpu-limit Pod CPU-Limit, Worker-Threads 17
config.linkerd.io/proxy-version Pod Proxy-Version pinnen 15
config.linkerd.io/skip-outbound-ports Pod Port am Proxy vorbei 16
config.linkerd.io/proxy-log-level Pod Log-Level des Proxys 16
config.linkerd.io/proxy-memory-limit, …-request Pod Speicher des Proxys 16

„Pod“ heißt: im Pod-Template des Deployments oder StatefulSets. Alle Proxy-Annotationen wirken erst nach einem Neustart der Pods.