Add mock identity service (#10)
Motivation
The mock destination server has been particuarly useful in benchmarking changes to
linkerd2-proxy. This is because a single proxy can run without needing thelinkerd2control plane running; it sends all destination requests to the server and uses the responses to send requests to the correct destinations.A current limitation is that identity must be disabled on the proxy as seen here. This is because similar to the destination service, the identity service is also run as part of the control plane; without that there is way to get identity for a specific service.
Solution
Run an identity service that returns pre-signed certificates for specific identity names.
A new
LINKERD2_MOCK_DST_IDENTITIES_DIRenvironment variable can be set which points to a directory that contains subdirectories–each corresponding to an identity that should be served by the identity service.When the identity service is created, it looks at each subdirectory which should contain at least a
crt.pem. (It’s likely that it will also contain acsr.derandkey.p8which will be used by the proxy’sENV_IDENTITY_DIR.)Taking the subdirectory name as the identity name, it will serve the certificates in
crt.pemfor that directory name.For example, for the
foo-ns1-ca1identity, I have directory with the following::; ls /path/to/identities/ ca-config.json ca1-key.pem ca1.pem foo-ns1-ca1/ :; ls /path/to/identities/foo-ns1-ca1/ crt.pem csr.der key.p8When a request is made for the
foo-ns1-ca1identity, the certifcates incrt.pemare returned.Generating files
These all contain valid values and were generated similar to the proxy’s test harness
gen-certs.shscript.I lean towards including this script as part of the
l2-proxy-harnessproject where these certificates, CSRs, and keys will actually be used.Testing
This was tested with a gRPC client that sends a
CertifyRequestfor thefoo-ns1-ca1identity to the identity server running locally on:8080.Gist here
Signed-off-by: Kevin Leimkuhler kevin@kleimkuhler.com
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802032778号
linkerd2-mock-dst
This repository contains a mock implementation of Linkerd 2’s Destination service, intended for proxy testing and benchmarking.
Unlike the real Destination service, which serves service discovery requests from proxies based on information in the Kubernetes API, the mock implementation currently serves a fixed set of destinations and endpoints. In the future, it will also support simulating changes in cluster state for testing purposes.
The mock Destination service may be run in a standalone process as a command-line application. Additionally, it can also be used as a Rust library, to embed a mock Destination service in Rust tests.
Usage
Examples
Mock destinations for the
foo.ns.svc.cluster.localservice:Mock identity for the
foo-ns1-ca1identity name: