Ultralight, security-first service mesh for Kubernetes. Main repo for Linkerd 2.x.
Go to file
Alejandro Pedraza 4c634a3816
Have webhooks refresh their certs automatically (#5282)
* Have webhooks refresh their certs automatically

Fixes partially #5272

In 2.9 we introduced the ability for providing the certs for `proxy-injector` and `sp-validator` through some external means like cert-manager, through the new helm setting `externalSecret`.
We forgot however to have those services watch changes in their secrets, so whenever they were rotated they would fail with a cert error, with the only workaround being to restart those pods to pick the new secrets.

This addresses that by first abstracting out `FsCredsWatcher` from the identity controller, which now lives under `pkg/tls`.

The webhook's logic in `launcher.go` no longer reads the certs before starting the https server, moving that instead into `server.go` which in a similar way as identity will receive events from `FsCredsWatcher` and update `Server.cert`. We're leveraging `http.Server.TLSConfig.GetCertificate` which allows us to provide a function that will return the current cert for every incoming request.

### How to test

```bash
# Create some root cert
$ step certificate create linkerd-proxy-injector.linkerd.svc ca.crt ca.key \
  --profile root-ca --no-password --insecure --san linkerd-proxy-injector.linkerd.svc

# configure injector's caBundle to be that root cert
$ cat > linkerd-overrides.yaml << EOF
proxyInjector:
  externalSecret: true
    caBundle: |
      < ca.crt contents>
EOF

# Install linkerd. The injector won't start untill we create the secret below
$ bin/linkerd install --controller-log-level debug --config linkerd-overrides.yaml | k apply -f -

# Generate an intermediatery cert with short lifespan
step certificate create linkerd-proxy-injector.linkerd.svc ca-int.crt ca-int.key --ca ca.crt --ca-key ca.key --profile intermediate-ca --not-after 4m --no-password --insecure --san linkerd-proxy-injector.linkerd.svc

# Create the secret using that intermediate cert
$ kubectl create secret tls \
  linkerd-proxy-injector-k8s-tls \
   --cert=ca-int.crt \
   --key=ca-int.key \
   --namespace=linkerd

# start following the injector log
$ k -n linkerd logs -f -l linkerd.io/control-plane-component=proxy-injector -c proxy-injector

# Inject emojivoto. The pods should be injected normally
$ bin/linkerd inject https://run.linkerd.io/emojivoto.yml | kubectl apply -f -

# Wait about 5 minutes and delete a pod
$ k -n emojivoto delete po -l app=emoji-svc

# You'll see it won't be injected, and something like "remote error: tls: bad certificate" will appear in the injector logs.

# Regenerate the intermediate cert
$ step certificate create linkerd-proxy-injector.linkerd.svc ca-int.crt ca-int.key --ca ca.crt --ca-key ca.key --profile intermediate-ca --not-after 4m --no-password --insecure --san linkerd-proxy-injector.linkerd.svc

# Delete the secret and recreate it
$ k -n linkerd delete secret linkerd-proxy-injector-k8s-tls
$ kubectl create secret tls \
  linkerd-proxy-injector-k8s-tls \
   --cert=ca-int.crt \
   --key=ca-int.key \
   --namespace=linkerd

# Wait a couple of minutes and you'll see some filesystem events in the injector log along with a "Certificate has been updated" entry
# Then delete the pod again and you'll see it gets injected this time
$ k -n emojivoto delete po -l app=emoji-svc

```
2020-12-04 16:25:59 -05:00
.github Add automatic readme generation for charts (#5316) 2020-12-02 14:37:45 -05:00
bin Add automatic readme generation for charts (#5316) 2020-12-02 14:37:45 -05:00
charts Allow Multicluster Service to be non LoadBalancer ServiceType (#5307) 2020-12-03 13:03:49 -05:00
cli Fix namespace flag in install help text (#5322) 2020-12-03 14:33:15 -05:00
cni-plugin Updated debian image tags (#5249) 2020-11-18 10:51:15 -05:00
controller Have webhooks refresh their certs automatically (#5282) 2020-12-04 16:25:59 -05:00
grafana Fixed multicluster Grafana chart (#5114) 2020-10-21 10:06:37 -05:00
jaeger Add linkerd.io/extension label (#5311) 2020-12-02 13:17:06 -08:00
pkg Have webhooks refresh their certs automatically (#5282) 2020-12-04 16:25:59 -05:00
proto Remove dependency of linkerd-config for control plane components (#4915) 2020-10-06 22:19:18 +05:30
proxy-identity Print identity in destination client and fix proxy-identity log line (#4873) 2020-08-13 13:49:55 -07:00
test Consolidate integration tests under k3d (#5245) 2020-11-18 14:33:16 -05:00
testutil Remove logs comparisons in integration tests (#5223) 2020-11-13 16:00:16 -05:00
web Updated debian image tags (#5249) 2020-11-18 10:51:15 -05:00
.dockerignore Migrate CI to docker buildx and other improvements (#4765) 2020-07-22 14:27:45 -05:00
.editorconfig Spelling (#4872) 2020-08-12 21:59:50 -07:00
.gcp.json.enc Add docker builds and integration tests to CI (#1303) 2018-07-11 14:01:42 -07:00
.gitattributes remove the duplicate word (#3385) 2019-09-04 20:13:55 -07:00
.gitignore tracing: new jaeger independent helm chart (#5275) 2020-11-24 09:45:16 -08:00
.golangci.yml Upgrade golangci-lint to v1.23.8 (#4181) 2020-03-18 09:13:19 -05:00
.helmdocsignore Add automatic readme generation for charts (#5316) 2020-12-02 14:37:45 -05:00
.markdownlint.yaml Lint all markdown files in CI (#4402) 2020-05-19 23:03:50 -07:00
.proxy-version proxy: v2.124.0 (#5323) 2020-12-03 11:28:23 -08:00
ADOPTERS.md Update ADOPTERS.md (#5254) 2020-11-19 11:55:02 -08:00
BUILD.md Add automatic readme generation for charts (#5316) 2020-12-02 14:37:45 -05:00
CHANGES.md edge-20.12.1 (#5324) 2020-12-03 14:35:57 -08:00
CODE_OF_CONDUCT.md Lint all markdown files (#4403) 2020-05-19 09:59:26 -07:00
CONTRIBUTING.md Update CI and docs to reference `main` branch (#4662) 2020-06-24 12:39:22 -07:00
DCO Add contributing doc and DCO file (#88) 2017-12-22 14:54:27 -08:00
Dockerfile-debug Updated debian image tags (#5249) 2020-11-18 10:51:15 -05:00
Dockerfile-proxy Updated debian image tags (#5249) 2020-11-18 10:51:15 -05:00
GOVERNANCE.md Lint all markdown files (#4403) 2020-05-19 09:59:26 -07:00
LICENSE Introducing Conduit, the ultralight service mesh 2017-12-05 00:24:55 +00:00
MAINTAINERS.md Lint all markdown files (#4403) 2020-05-19 09:59:26 -07:00
README.md Spelling (#4872) 2020-08-12 21:59:50 -07:00
SECURITY.md Spelling (#4872) 2020-08-12 21:59:50 -07:00
SECURITY_AUDIT.pdf Add security audit (#3008) 2019-06-28 16:04:41 -07:00
TEST.md Consolidate integration tests under k3d (#5245) 2020-11-18 14:33:16 -05:00
go.mod Bump proxy-init to v1.3.8 (#5283) 2020-11-27 09:07:34 -05:00
go.sum Jaeger injector mutating webhook (#5276) 2020-11-27 12:25:28 -05:00
tools.go Upgrade to client-go 0.17.4 and smi-sdk-go 0.3.0 (#4221) 2020-04-01 10:07:23 -07:00

README.md

Linkerd

Linkerd

GitHub Actions Status GitHub license Go Report Card Slack Status

🎈 Welcome to Linkerd! 👋

Linkerd is an ultralight, security-first service mesh for Kubernetes. Linkerd adds critical security, observability, and reliability features to your Kubernetes stack with no code change required.

Linkerd is a Cloud Native Computing Foundation (CNCF) project.

Repo layout

This is the primary repo for the Linkerd 2.x line of development.

The complete list of Linkerd repos is:

Quickstart and documentation

You can run Linkerd on any modern Kubernetes cluster in a matter of seconds. See the Linkerd Getting Started Guide for how.

For more comprehensive documentation, start with the Linkerd docs. (The doc source code is available in the website repo.)

Working in this repo

BUILD.md includes general information on how to work in this repo.

We ❤️ pull requests! See CONTRIBUTING.md for info on contributing changes.

Get involved

Community meetings

We host regular online meetings for contributors, adopters, maintainers, and anyone else interested to connect in a synchronous fashion. These meetings usually take place the last Wednesday of the month at 9am Pacific / 4pm UTC.

We're a friendly group, so please feel free to join us!

Code of Conduct

This project is for everyone. We ask that our users and contributors take a few minutes to review our Code of Conduct.

Security

Security Audit

A third party security audit was performed by Cure53. You can see the full report here.

License

Copyright 2020 the Linkerd Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use these files except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.