Automatically Rotating Webhook TLS Credentials

    By default, when Linkerd is installed with the Linkerd CLI or with the Linkerd Helm chart, TLS credentials are automatically generated for all of the webhooks. If these certificates expire or need to be regenerated for any reason, performing a Linkerd upgrade (using the Linkerd CLI or using Helm) will regenerate them.

    This workflow is suitable for most users. However, if you need these webhook certificates to be rotated automatically on a regular basis, it is possible to use cert-manager to automatically manage them.

    As a first step, and create the namespace that cert-manager will use to store its webhook-related resources. For simplicity, we suggest the default Linkerd control plane namespace:

    Save the signing key pair as a Secret

    Next, we will use the tool, to create a signing key pair which will be used to sign each of the webhook certificates:

    1. step certificate create webhook.linkerd.cluster.local ca.crt ca.key \
    2. --profile root-ca --no-password --insecure --san webhook.linkerd.cluster.local &&
    3. kubectl create secret tls \
    4. webhook-issuer-tls \
    5. --cert=ca.crt \
    6. --key=ca.key \
    7. --namespace=linkerd

    Issuing certificates and writing them to a secret

    Finally, we can create cert-manager “Certificate” resources which use the Issuer to generate the desired certificates:

    1. cat <<EOF | kubectl apply -f -
    2. apiVersion: cert-manager.io/v1alpha3
    3. kind: Certificate
    4. metadata:
    5. name: linkerd-proxy-injector
    6. namespace: linkerd
    7. spec:
    8. secretName: linkerd-proxy-injector-k8s-tls
    9. duration: 24h
    10. issuerRef:
    11. name: webhook-issuer
    12. kind: Issuer
    13. commonName: linkerd-proxy-injector.linkerd.svc
    14. keyAlgorithm: ecdsa
    15. usages:
    16. - server auth
    17. ---
    18. apiVersion: cert-manager.io/v1alpha3
    19. kind: Certificate
    20. metadata:
    21. name: linkerd-sp-validator
    22. namespace: linkerd
    23. spec:
    24. secretName: linkerd-sp-validator-k8s-tls
    25. duration: 24h
    26. renewBefore: 1h
    27. issuerRef:
    28. name: webhook-issuer
    29. kind: Issuer
    30. commonName: linkerd-sp-validator.linkerd.svc
    31. keyAlgorithm: ecdsa
    32. usages:
    33. - server auth
    34. apiVersion: cert-manager.io/v1alpha3
    35. kind: Certificate
    36. metadata:
    37. name: linkerd-tap
    38. namespace: linkerd
    39. spec:
    40. secretName: linkerd-tap-k8s-tls
    41. duration: 24h
    42. renewBefore: 1h
    43. issuerRef:
    44. name: webhook-issuer
    45. kind: Issuer
    46. commonName: linkerd-tap.linkerd.svc
    47. isCA: false
    48. keyAlgorithm: ecdsa
    49. usages:
    50. - server auth
    51. EOF

    At this point, cert-manager can now use these Certificate resources to obtain TLS credentials, which are stored in the linkerd-proxy-injector-k8s-tls, linkerd-sp-validator-k8s-tls, and linkerd-tap-k8s-tls secrets respectively.

    Now we just need to inform Linkerd to consume these credentials.

    To configure Linkerd to use the credentials from cert-manager rather than generating its own, we generate a supplemental config file:

      Installing with Helm

      For Helm installation, we can configure the Helm values directly:

      Note

      When installing Linkerd with Helm, you must also provide the issuer trust root and issuer credentials as described in Installing Linkerd with Helm.

      Note