Linkerd 2.10 (Step by Step)—Install Multi-Cluster Components

Linkerd 2.10 (Step by Step)—Install Multi-Cluster Components

[[406693]]

The Linkerd 2.10 Chinese manual is being continuously revised and updated:

  • https://linkerd.hacker-linner.com

Multicluster support in Linkerd requires additional installation and configuration on top of the default control plane installation. This guide will cover this installation and configuration as well as common issues you might encounter.

Require

  • Two clusters.
  • The control plane installations in each cluster share a common trust anchor.
  • Each of these clusters should be configured as kubectl contexts.
  • Elevated permissions on both clusters. We will be creating the service account and granting extended permissions, so you need to be able to do this on the test cluster.
  • Support for LoadBalancer type services in the east cluster. See the documentation for your cluster provider or look at inlets. This is what the west cluster will use to communicate with east through the gateway.

Step 1: Install the multicluster control plane

On each cluster, run:

  1. linkerd multicluster install | \
  2. kubectl apply -f -

To verify that everything started successfully, run:

  1. linkerd multicluster check  

Step 2: Link Cluster

Each cluster must be linked. This involves installing several resources in the source cluster, including a secret containing a kubeconfig that allows access to the target cluster's Kubernetes API, a service mirror control for mirroring services, and a Link custom resource to hold the configuration. To connect cluster west to cluster east, you would run:

  1. linkerd --context=east multicluster link --cluster-name east |  
  2. kubectl --context=west apply -f -  

To verify that the credentials were successfully created and the clusters can access each other, run:

  1. linkerd --context=west multicluster check  

You should also see a list of gateways by running the following command. Note that you need to install Linkerd's Viz extension in your source cluster to get the list of gateways:

  1. linkerd --context=west multicluster gateways  

For detailed instructions on this step, see the Linking Clusters section.

Step 3: Expose services

Services are not automatically mirrored in linked clusters. By default, only services with the mirror.linkerd.io/exported label are mirrored. For each service you want to mirror to the linked cluster, run:

  1. kubectl label svc foobar mirror.linkerd.io/exported= true  

You can configure a different label selector by using the --selector flag on the linkerd multicluster link command or by editing the link resource created by the linkerd multicluster link command.

Leverage Ambassador

The bundled Linkerd gateway is not required. In fact, if you have an existing Ambassador installation, it's easy to use it! By using your existing Ambassador installation, you don't need to manage multiple ingress gateways and pay for additional cloud load balancers. This guide assumes that Ambassador has already been installed into the ambassador namespace.

First, you need to inject the ambassador deployment with Linkerd:

  1. kubectl -n ambassador get deploy ambassador -o yaml | \
  2. linkerd inject \
  3. --skip-inbound-ports 80,443 \  
  4. --require-identity-on-inbound-ports 4183 - | \  
  5. kubectl apply -f -

This will add the Linkerd proxy, skipping the port that Ambassador handles for public traffic and requiring identity on the gateway port. Next, you need to add some configuration so that Ambassador knows how to handle the request:

  1. cat <<EOF | kubectl --context=${ctx} apply -f -  
  2. ---  
  3. apiVersion: getambassador.io/v2
  4. kind: Module
  5. metadata:
  6. name : ambassador
  7. namespace: ambassador
  8. spec:
  9. config:
  10. add_linkerd_headers: true  
  11. ---  
  12. apiVersion: getambassador.io/v2
  13. kind: Host
  14. metadata:
  15. name : wildcard
  16. namespace: ambassador
  17. spec:
  18. hostname: "*"  
  19. selector:
  20. matchLabels:
  21. nothing: nothing
  22. acmeProvider:
  23. authority: none
  24. requestPolicy:
  25. insecure:
  26. action : Route
  27. ---  
  28. apiVersion: getambassador.io/v2
  29. kind: Mapping
  30. metadata:
  31. name : public -health- check  
  32. namespace: ambassador
  33. spec:
  34. prefix: /-/ambassador/ready
  35. rewrite: /ambassador/v0/check_ready
  36. service: localhost:8877
  37. bypass_auth: true  
  38. EOF

The Ambassador service and deployment definitions require some minor patching. This will add the metadata required by the service mirror controller. To patch these resources, run:

  1. kubectl --context=${ctx} -n ambassador patch deploy ambassador -p='  
  2. spec:
  3. template:
  4. metadata:
  5. annotations:
  6. config.linkerd.io/enable-gateway: "true"  
  7. '
  8. kubectl --context=${ctx} -n ambassador patch svc ambassador --type='json' -p='[  
  9. { "op" : "add" , "path" : "/spec/ports/-" , "value" :{ "name" : "mc-gateway" , "port" : 4143}},
  10. { "op" : "replace" , "path" : "/spec/ports/0" , "value" :{ "name" : "mc-probe" , "port" : 80, "targetPort" : 8080}}
  11. ]'
  12. kubectl --context=${ctx} -n ambassador patch svc ambassador -p='  
  13. metadata:
  14. annotations:
  15. mirror.linkerd.io/gateway-identity: ambassador.ambassador.serviceaccount.identity.linkerd.cluster.local  
  16. mirror.linkerd.io/multicluster-gateway: "true"  
  17. mirror.linkerd.io/probe-path: /-/ambassador/ready
  18. mirror.linkerd.io/probe-period: "3"  
  19. '

Now you can install the Linkerd multicluster components onto your target cluster. Since we are using Ambassador as our gateway, we need to skip installing the Linkerd gateway using the --gateway=false flag:

  1. linkerd --context=${ctx} multicluster install --gateway=false | kubectl --context=${ctx} apply -f -  

Once all setup and configuration is complete, you can link your source cluster to the Ambassador gateway. Run the link command, specifying the name and namespace of the Ambassador service:

  1. linkerd --context=${ctx} multicluster link --cluster-name=${ctx} --gateway-name=ambassador --gateway-namespace=ambassador \  
  2. | kubectl --context=${src_ctx} apply -f -  

From the source cluster (the one not running Ambassador), you can verify that everything is working correctly by running:

  1. linkerd multicluster check  

Additionally, the ambassador gateway is shown when listing active gateways:

  1. Linkerd multicluster gateways

Trust Anchor Bundle

To secure connections between clusters, Linkerd needs to have a shared trust anchor. This allows the control plane to encrypt requests passing between clusters and verify the identity of those requests. This identity is used to control access to the cluster, so a shared trust anchor is critical.

The simplest approach is to share a single trust anchor certificate between multiple clusters. If you have an existing Linkerd installation and discarded your trust anchor key, you may not be able to provide a single certificate for the trust anchor. Fortunately, a trust anchor can also be a bunch of certificates!

To get the trust anchor for an existing cluster, run:

  1. kubectl -n linkerd get cm linkerd-config -ojsonpath= "{.data.values}" | \
  2. yq e .identityTrustAnchorsPEM -> trustAnchor.crt

This command requires yq. If you don't have yq, feel free to use the tool of your choice to extract the certificate from the identityTrustAnchorsPEM field.`

Now you need to create a new trust anchor and issuer for the new cluster:

  1. step certificate create root.linkerd.cluster. local root.crt root. key \
  2. --profile root-ca --no-password --insecure  
  3. step certificate create identity.linkerd.cluster. local issuer.crt issuer. key \
  4. --profile intermediate-ca --not-after 8760h --no-password --insecure \  
  5. --ca root.crt --ca-key root.key  

We used step cli to generate the certificates. openssl should work just as well!

Using the trust anchor of the old cluster and the trust anchor of the new cluster, you can create a bundle by running the following command:

  1. cat trustAnchor.crt root.crt > bundle.crt

You need to upgrade your existing cluster with the new bundle. Make sure every pod that you want to communicate with the new cluster is restarted so that it can use this bundle. To upgrade your existing cluster with this new trust anchor bundle, run:

  1. linkerd upgrade --identity-trust-anchors-file=./bundle.crt | \  
  2. kubectl apply -f -

Finally, you’ll be able to install Linkerd on a new cluster using the trust anchor bundle you just created, along with the issuer certificate and key.

  1. linkerd install \
  2. --identity-trust-anchors-file bundle.crt \  
  3. --identity-issuer-certificate-file issuer.crt \  
  4. --identity-issuer-key-file issuer.key | \  
  5. kubectl apply -f -

Make sure to verify that the clusters started successfully by running check on each cluster.

  1. linkerd check  

Installing multi-cluster control plane components via Helm

Linkerd's multicluster components, namely Gateway and Service Mirror, can be installed via Helm instead of the linkerd multicluster install command.

Not only does this allow for advanced configuration, it also lets users bundle multi-cluster installations as part of their existing Helm-based installation pipelines.

Add Linkerd's Helm repository

First, let's add the Linkerd Helm repo by running

  1. # To   add the repo for Linkerd2 stable releases:
  2. helm repo add linkerd https://helm.linkerd.io/stable

Helm multi-cluster installation process

  1. helm install linkerd2-multicluster linkerd/linkerd2-multicluster

Chart values ​​will be picked from the chart's values.yaml file.

You can override values ​​in your own values.yaml file by providing it and using the -f option, or override specific values ​​using the --set series of flags.

The full set of configuration options can be found here

The installation can be verified by running the following command

  1. linkerd multicluster check  

The installation of a gateway can be disabled via the gateway setting. By default, this value is true.

Installing Additional Access Credentials

When you install multicluster components onto a target cluster using linkerd multicluster install, a service account is created that the source cluster will use to mirror services. Using a different service account for each source cluster can be beneficial because it enables you to revoke service mirroring access from a specific source cluster. Additional service accounts and associated RBAC can be generated through the CLI using the linkerd multicluster allow command.

The same functionality can also be accomplished through Helm by setting the remoteMirrorServiceAccountName value to list.

  1. helm install linkerd2-mc-source linkerd/linkerd2-multicluster --set remoteMirrorServiceAccountName={source1\,source2\,source3} --kube-context target  

【Editor's recommendation】

  1. Remote desktop developed by Chinese programmers is popular! Available for Mac, only 9MB, supports self-built repeaters
  2. 3 minutes to help you understand Kafka thoroughly
  3. How big is the bandwidth of Tik Tok's server to accommodate hundreds of millions of people watching at the same time?
  4. Github is hot! Can this so-called postmodern editor surpass Vim?
  5. The seven most dangerous attack techniques in 2021

<<:  Linkerd 2.10 (Step by Step)—Ingress Traffic

>>:  Mid-year review: 10 hottest web startups in 2021

Recommend

GTI releases 2.3GHz spectrum industry joint statement

As 5G accelerates globalization, it will unlock u...

This article teaches you to understand the TCP/IP protocol

It's the golden March and April again, and I&...

Layer.ae: AMD Ryzen9 7950X series from $15/year, Singapore/US/UK data centers

Layer.ae was founded about three years ago and is...

Talk about my operating system and daily application software

operating system Manjaro is a distribution based ...

How to Understand and Evaluate Potential Colocation Data Center Providers?

Today, as demand for colocation and wholesale dat...

U.S. tech firms push new software to disrupt my country's 5G lead

Top U.S. technology companies are pushing a softw...

LuxVPS: €3/month KVM-4GB/30GB/1TB/Germany data center

The LuxVPS domain name was registered in June 202...

After running blindly, how much money did operators make from 5G?

[[347740]] Recently, China Mobile and China Unico...

How should NFV be deployed today?

Network Function Virtualization is maturing among...

CAN bus: operating principle, advantages and disadvantages

The CAN bus was originally designed by Bosch in t...