Customizing Linkerd’s Configuration with Kustomize

Instead of forking the Linkerd install and upgrade process, Kustomize can be used to patch the output of linkerd install in a consistent way. This allows customization of the install to add functionality specific to installations.

Customizing Linkerd’s Configuration with Kustomize - 图1

Linkerd Production Tip

This page contains best-effort instructions by the open source community. Production users with mission-critical applications should familiarize themselves with Linkerd production resources and/or connect with a commercial Linkerd provider.

To get started, save the output of linkerd install to a YAML file. This will be the base resource that Kustomize uses to patch and generate what is added to your cluster.

  1. linkerd install > linkerd.yaml

Customizing Linkerd’s Configuration with Kustomize - 图2

Note

When upgrading, make sure you populate this file with the content from linkerd upgrade. Using the latest kustomize releases, it would be possible to automate this with an exec plugin.

Next, create a kustomization.yaml file. This file will contain the instructions for Kustomize listing the base resources and the transformations to do on those resources. Right now, this looks pretty empty:

  1. resources:
  2. - linkerd.yaml

Now, let’s look at how to do some example customizations.

Customizing Linkerd’s Configuration with Kustomize - 图3

Note

Kustomize allows as many patches, transforms and generators as you’d like. These examples show modifications one at a time but it is possible to do as many as required in a single kustomization.yaml file.

Add PriorityClass

There are a couple components in the control plane that can benefit from being associated with a critical PriorityClass. While this configuration isn’t currently supported as a flag to linkerd install, it is not hard to add by using Kustomize.

First, create a file named priority-class.yaml that will create define a PriorityClass resource.

  1. apiVersion: scheduling.k8s.io/v1
  2. description: Used for critical linkerd pods that must run in the cluster, but
  3. can be moved to another node if necessary.
  4. kind: PriorityClass
  5. metadata:
  6. name: linkerd-critical
  7. value: 1000000000

Customizing Linkerd’s Configuration with Kustomize - 图4

Note

1000000000 is the max. allowed user-defined priority, adjust accordingly.

Next, create a file named patch-priority-class.yaml that will contain the overlay. This overlay will explain what needs to be modified.

  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. name: linkerd-identity
  5. namespace: linkerd
  6. spec:
  7. template:
  8. spec:
  9. priorityClassName: linkerd-critical

Then, add this as a strategic merge option to kustomization.yaml:

  1. resources:
  2. - priority-class.yaml
  3. - linkerd.yaml
  4. patchesStrategicMerge:
  5. - patch-priority-class.yaml

Applying this to your cluster requires taking the output of kustomize and piping it to kubectl apply. For example, you can run:

  1. # install the Linkerd CRDs
  2. linkerd install --crds | kubectl apply -f -
  3. # install the Linkerd control plane manifests using Kustomize
  4. kubectl kustomize . | kubectl apply -f -