Rotating webhooks certificates

Linkerd uses the Kubernetes admission webhooks and extension API server to implement some of its core features like automatic proxy injection and service profiles validation.

Also, the viz extension uses a webhook to make pods tappable, as does the jaeger extension to turn on tracing on pods.

To secure the connections between the Kubernetes API server and the webhooks, all the webhooks are TLS-enabled. The x509 certificates used by these webhooks are issued by the self-signed CA certificates embedded in the webhooks configuration.

By default, these certificates have a validity period of 365 days. They are stored in the following secrets:

  • In the linkerd namespace: linkerd-proxy-injector-k8s-tls and linkerd-sp-validator-k8s-tls
  • In the linkerd-viz namespace: tap-injector-k8s-tls
  • In the linkerd-jaeger namespace: jaeger-injector-k8s-tls

The rest of this documentation provides instructions on how to renew these certificates.

Renewing the webhook certificates

To check the validity of all the TLS secrets (using step):

  1. # assuming you have viz and jaeger installed, otherwise trim down these arrays
  2. # accordingly
  3. SECRETS=("linkerd-proxy-injector-k8s-tls" "linkerd-sp-validator-k8s-tls" "tap-injector-k8s-tls" "jaeger-injector-k8s-tls")
  4. NS=("linkerd" "linkerd" "linkerd-viz" "linkerd-jaeger")
  5. for idx in "${!SECRETS[@]}"; do \
  6. kubectl -n "${NS[$idx]}" get secret "${SECRETS[$idx]}" -ojsonpath='{.data.tls\.crt}' | \
  7. base64 --decode - | \
  8. step certificate inspect - | \
  9. grep -iA2 validity; \
  10. done

Manually delete these secrets and use upgrade/install to recreate them:

  1. for idx in "${!SECRETS[@]}"; do \
  2. kubectl -n "${NS[$idx]}" delete secret "${SECRETS[$idx]}"; \
  3. done
  4. linkerd upgrade | kubectl apply -f -
  5. linkerd viz install | kubectl apply -f -
  6. linkerd jaeger install | kubectl apply -f -

The above command will recreate the secrets without restarting Linkerd.

Note

For Helm users, use the helm upgrade command to recreate the deleted secrets.

If you render the helm charts externally and apply them with kubectl apply (e.g. in a CI/CD pipeline), you do not need to delete the secrets manually, as they wil be overwritten by a new cert and key generated by the helm chart.

Confirm that the secrets are recreated with new certificates:

  1. for idx in "${!SECRETS[@]}"; do \
  2. kubectl -n "${NS[$idx]}" get secret "${SECRETS[$idx]}" -ojsonpath='{.data.crt\.pem}' | \
  3. base64 --decode - | \
  4. step certificate inspect - | \
  5. grep -iA2 validity; \
  6. done

Ensure that Linkerd remains healthy:

  1. linkerd check

Restarting the pods that implement the webhooks and API services is usually not necessary. But if the cluster is large, or has a high pod churn, it may be advisable to restart the pods manually, to avoid cascading failures.

If you observe certificate expiry errors or mismatched CA certs, restart their pods with:

  1. kubectl -n linkerd rollout restart deploy \
  2. linkerd-proxy-injector \
  3. linkerd-sp-validator \
  4. kubectl -n linkerd-viz rollout restart deploy tap tap-injector
  5. kubectl -n linkerd-jaeger rollout restart deploy jaeger-injector