Commit Graph

1112 Commits

Author SHA1 Message Date
Steve Jenson 309e8d1210
Validate CNI configurations during pod startup (#9678)
When users use CNI, we want to ensure that network rewriting inside the pod is setup before allowing linkerd to start. When rewriting isn't happening, we want to exit with a clear error message and enough information in the container log for the administrator to either file a bug report with us or fix their configuration.

This change adds a validator initContainer to all injected workloads, when linkerd is installed with "cniEnabled=false". The validator replaces the noop init container, and will prevent pods from starting up if iptables is not configured.

Part of #8120

Signed-off-by: Steve Jenson <stevej@buoyant.io>
2022-10-26 11:14:45 +01:00
Alejandro Pedraza e6fa5a7156
Replace usage of io/ioutil package (#9613)
`io/ioutil` has been deprecated since go 1.16 and the linter started to
complain about it.
2022-10-13 12:10:58 -05:00
Alex Leong 5cb6755ebe
Add noop init container when the cni plugin is enabled (#9504)
Add a "noop" init container which uses the proxy image and runs `/bin/sleep 0` to injected pods.  This init container is only added when the linkerd-cni-plugin is enabled.  The idea here is that by running an init container, we trigger kubernetes to update the pod status.  In particular, this ensures that the pod status IP is populated, which is necessary in certain cases where other CNIs such as Calico are involved.

Therefore, this may fix https://github.com/linkerd/linkerd2/issues/9310, but I don't have a reproduction and therefore am not able to verify.

Signed-off-by: Alex Leong <alex@buoyant.io>
2022-10-11 11:31:45 -07:00
Alex Leong dc6b6e9ed5
Add diagnostics policy command (#9513)
Fixes: #9163

We add a new diagnostics command to the CLI which queries the policy controller for the inbound policy for a given pod and port.

```console
> linkerd diagnostics policy -n linkerd-viz metrics-api-cbb5cdd44-8z6mh 4191
{
  "protocol": {
    "Kind": {
      "Http1": {
        "routes": [
          {
            "metadata": {
              "Kind": {
                "Default": "default"
              }
            },
            "rules": [
              {
                "matches": [
                  {
                    "path": {
                      "Kind": {
                        "Prefix": "/"
                      }
                    }
                  }
                ]
              }
            ]
          },
          {
            "metadata": {
              "Kind": {
                "Default": "probe"
              }
            },
            "authorizations": [
              {
                "networks": [
                  {
                    "net": {
                      "ip": {
                        "Ip": {
                          "Ipv4": 0
                        }
                      }
                    }
                  }
                ],
                "authentication": {
                  "Permit": {
                    "Unauthenticated": {}
                  }
                },
                "labels": {
                  "group": "",
                  "kind": "default",
                  "name": "probe"
                },
                "metadata": {
                  "Kind": {
                    "Default": "probe"
                  }
                }
              }
            ],
            "rules": [
              {
                "matches": [
                  {
                    "path": {
                      "Kind": {
                        "Exact": "/live"
                      }
                    },
                    "method": {
                      "Type": {
                        "Registered": 0
                      }
                    }
                  },
                  {
                    "path": {
                      "Kind": {
                        "Exact": "/ready"
                      }
                    },
                    "method": {
                      "Type": {
                        "Registered": 0
                      }
                    }
                  }
                ]
              }
            ]
          }
        ]
      }
    }
  },
  "authorizations": [
    {
      "networks": [
        {
          "net": {
            "ip": {
              "Ip": {
                "Ipv4": 0
              }
            }
          }
        },
        {
          "net": {
            "ip": {
              "Ip": {
                "Ipv6": {}
              }
            }
          }
        }
      ],
      "authentication": {
        "Permit": {
          "Unauthenticated": {}
        }
      },
      "labels": {
        "group": "policy.linkerd.io",
        "kind": "authorizationpolicy",
        "name": "proxy-admin"
      },
      "metadata": {
        "Kind": {
          "Resource": {
            "group": "policy.linkerd.io",
            "kind": "authorizationpolicy",
            "name": "proxy-admin"
          }
        }
      }
    }
  ],
  "labels": {
    "group": "policy.linkerd.io",
    "kind": "server",
    "name": "proxy-admin"
  }
}
```

Signed-off-by: Alex Leong <alex@buoyant.io>
2022-10-07 16:43:24 -07:00
Martin Odstrčilík 89c5729264
Add PodMonitor resources to the Helm chart (#9113)
Add PodMonitor resources to the Helm chart

With an external Prometheus setup installed using prometheus-operator the Prometheus instance scraping can be configured using Service/PodMonitor resources.

By adding PodMonitor resource into Linkerd Helm chart we can mimic the configuration of bundled Prometheus, see https://github.com/linkerd/linkerd2/blob/main/viz/charts/linkerd-viz/templates/prometheus.yaml#L47-L151, that comes with linkerd-viz extension. The PodMonitor resources are based on https://github.com/linkerd/website/issues/853#issuecomment-913234295 which are proven to be working. The only problem we face is that bundled Grafana charts will need to look at different jobs when querying metrics.

When enabled by `podMonitor.enabled` value in the Helm chart, PodMonitor for Linkerd resources should be installed alongside the Linkerd and Linkerd metrics should be present in the Prometheus.

Fixes #6596

Signed-off-by: Martin Odstrcilik <martin.odstrcilik@gmail.com>
2022-10-04 06:19:23 -05:00
Alejandro Pedraza cded70a923
Added missing proxy annotations in docs (#9440)
Updated `cli/cmd/doc.go` to include missing annotations, used to render https://linkerd.io/2.12/reference/proxy-configuration/
2022-09-23 16:32:34 -05:00
Takumi Sue 5e5e4e675a
Fix --api-addr flag to be respected (#9270)
Fixes #9054

Signed-off-by: Takumi Sue <u630868b@alumni.osaka-u.ac.jp>
2022-09-23 13:28:27 -07:00
Alejandro Pedraza 8afe36e6e9
Fix jaeger injector interfering with upgrades to 2.12.0 (#9429)
Fixes issue described in [this comment](https://github.com/linkerd/linkerd2/issues/9310#issuecomment-1247201646)
Rollback #7382

Should be cherry-picked back into 2.12.1

For 2.12.0, #7382 removed the env vars `_l5d_ns` and `_l5d_trustdomain` from the proxy manifest because they were no longer used anywhere. In particular, the jaeger injector used them when injecting the env var `LINKERD2_PROXY_TAP_SVC_NAME=tap.linkerd-viz.serviceaccount.identity.$(_l5d_ns).$(_l5d_trustdomain)` but then started using values.yaml entries instead of these env vars.

The problem is when upgrading the core control plane (or anything else) to 2.12.0, the 2.11 jaeger extension will still be running and will attempt to inject the old env var into the pods, making reference to `l5d_ns` and `_l5d_trustdomain` which the new proxy container won't offer anymore. This will put the pod in an error state.

This change restores back those env vars. We will be able to remove them at last in 2.13.0, when presumably the jaeger injector would already have already been upgraded to 2.12 by the user.

Replication steps:
```bash
$ curl -sL https://run.linkerd.io/install | LINKERD2_VERSION=stable-2.11.4 sh
$ linkerd install | k apply -f -
$ linkerd jaeger install | k apply -f -
$ linkerd check
$ curl -sL https://run.linkerd.io/install | LINKERD2_VERSION=stable-2.12.0 sh
$ linkerd upgrade --crds | k apply -f -
$ linkerd upgrade | k apply -f -
$ k get po -n linkerd
NAME                                      READY   STATUS               RESTARTS     AGE
linkerd-identity-58544dfd8-jbgkb          2/2     Running              0            2m19s
linkerd-destination-764bf6785b-v8cj6      4/4     Running              0            2m19s
linkerd-proxy-injector-6d4b8c9689-zvxv2   2/2     Running              0            2m19s
linkerd-identity-55bfbf9cd4-4xk9g         0/2     CrashLoopBackOff     1 (5s ago)   32s
linkerd-proxy-injector-5b67589678-mtklx   0/2     CrashLoopBackOff     1 (5s ago)   32s
linkerd-destination-ff9b5f67b-jw8w5       0/4     PostStartHookError   0 (8s ago)   32s
```
2022-09-20 10:41:34 -07:00
Oliver Gould b9ecbcb521
Remove needless RBAC on the identity controller (#9368)
The identity controller requires access to read all deployments. This
isn't necessary.

When these permissions were added in #3600, we incorrectly assumed that
we must pass a whole Deployment resource as a _parent_ when recording
events. The [EventRecorder docs] say:

> 'object' is the object this event is about. Event will make a
> reference--or you may also pass a reference to the object directly.

We can confirm this by reviewing the source for [GetReference]: we can
simply construct an ObjectReference without fetching it from the API.

This change lets us drop unnecessary privileges in the identity
controller.

[EventRecorder docs]: https://pkg.go.dev/k8s.io/client-go/tools/record#EventRecorder
[GetReference]: ab826d2728/tools/reference/ref.go (L38-L45)

Signed-off-by: Oliver Gould <ver@buoyant.io>
2022-09-13 12:36:14 -07:00
Virko Püss 377b0fa51e
Update destination.yaml PodDisruptionBudget api 'policy/v1beta1' to 'policy/v1' (#9305)
policy/v1beta1 PodDisruptionBudget is deprecated in K8s v1.21+ and unavailable in v1.25+.
This change updates the API version to policy/v1.

Signed-off-by: Oliver Gould <ver@buoyant.io>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Co-authored-by: Oliver Gould <ver@buoyant.io>
Co-authored-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
2022-09-12 08:45:27 -07:00
Oliver Gould c8348b3ab4
helm: Restore `namespace` field in templates (#9351)
In #6635 (f9f3ebe), we removed the `Namespace` resources from the
linkerd Helm charts. But this change also removed the `namespace` field
from all generated metadata, adding conditional logic to only include it
when being installed via the CLI.

This conditional logic currently causes spurious whitespace in output
YAML. This doesn't cause problems but is aesthetically
inconsistent/distracting.

This change removes the `partials.namespace` helper and instead inlines
the value in our templates. This makes our CLI- and Helm-generated
manifests slightly more consistent and removes needless indirection.

Signed-off-by: Oliver Gould <ver@buoyant.io>
2022-09-10 10:18:02 -07:00
Kevin Leimkuhler b7387820c3
Add trust-root-sha256 annotation to injected workloads (#9361)
Closes #9312

#9118 introduced the `linkerd.io/trust-root-sha256` annotation which is
automatically added to control plane components.

This change ensures that all injected workloads also receive this annotation.

Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
2022-09-08 22:22:57 -06:00
Eliza Weisman 04520b3e08
add `config.linkerd.io/access-log` to CLI docs (#9246)
Turns out we were missing this one. Whoops!
2022-08-23 16:05:55 -07:00
William Morgan 75d0651b24
fix doc for proxy wait-before-exit-seconds (#9241)
Signed-off-by: William Morgan <william@buoyant.io>

<!--  Thanks for sending a pull request!

If you already have a well-structured git commit message, chances are GitHub
set the title and description of this PR to the git commit message subject and
body, respectively. If so, you may delete these instructions and submit your PR.

If this is your first time, please read our contributor guide:
https://github.com/linkerd/linkerd2/blob/main/CONTRIBUTING.md

The title and description of your Pull Request should match the git commit
subject and body, respectively. Git commit messages are structured as follows:

```
Subject

Problem

Solution

Validation

Fixes #[GitHub issue ID]

DCO Sign off
```

Example git commit message:

```
Introduce Pull Request Template

GitHub's community guidelines recommend a pull request template, the repo was
lacking one.

Introduce a `PULL_REQUEST_TEMPLATE.md` file.

Once merged, the
[Community profile checklist](https://github.com/linkerd/linkerd2/community)
should indicate the repo now provides a pull request template.

Fixes #3321

Signed-off-by: Jane Smith <jane.smith@example.com>
```

Note the git commit message subject becomes the pull request title.

For more details around git commits, see the section on Committing in our
contributor guide:
https://github.com/linkerd/linkerd2/blob/main/CONTRIBUTING.md#committing
-->

Signed-off-by: William Morgan <william@buoyant.io>
2022-08-23 09:57:53 -07:00
Kevin Leimkuhler 4b5ab072d6
Prep chart versions for `stable-2.12.0` (#9236)
Closes #9230 

#9202 prepped the release candidate for `stable-2.12.0` by removing the `-edge`
suffix and adding the `-rc2` suffix.

This preps the chart versions for the stable release by removing that `-rc2`
suffix.

Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
2022-08-23 10:17:38 -06:00
Alex Leong 1a3a80d71a
Update authz help text to indicate that it shows all authorizations (#9235)
The `linkerd authz` command help indicates that it shows server authorizations, but it shows authorization policies too.  

We update the help text to indicate that all authorizations are shown.

Signed-off-by: Alex Leong <alex@buoyant.io>

<!--  Thanks for sending a pull request!

If you already have a well-structured git commit message, chances are GitHub
set the title and description of this PR to the git commit message subject and
body, respectively. If so, you may delete these instructions and submit your PR.

If this is your first time, please read our contributor guide:
https://github.com/linkerd/linkerd2/blob/main/CONTRIBUTING.md

The title and description of your Pull Request should match the git commit
subject and body, respectively. Git commit messages are structured as follows:

```
Subject

Problem

Solution

Validation

Fixes #[GitHub issue ID]

DCO Sign off
```

Example git commit message:

```
Introduce Pull Request Template

GitHub's community guidelines recommend a pull request template, the repo was
lacking one.

Introduce a `PULL_REQUEST_TEMPLATE.md` file.

Once merged, the
[Community profile checklist](https://github.com/linkerd/linkerd2/community)
should indicate the repo now provides a pull request template.

Fixes #3321

Signed-off-by: Jane Smith <jane.smith@example.com>
```

Note the git commit message subject becomes the pull request title.

For more details around git commits, see the section on Committing in our
contributor guide:
https://github.com/linkerd/linkerd2/blob/main/CONTRIBUTING.md#committing
-->

Signed-off-by: Alex Leong <alex@buoyant.io>
2022-08-22 15:01:36 -07:00
Alejandro Pedraza b65364704b
Add config proxyInit.runAsUser to facilitate 2.11.x->2.12.0 upgrade (#9201)
In 2.11.x, proxyInit.runAsRoot was true by default, which caused the
proxy-init's runAsUser field to be 0. proxyInit.runAsRoot is now
defaulted to false in 2.12.0, but runAsUser still isn't
configurable, and when following the upgrade instructions
here, helm doesn't change runAsUser and so it conflicts with the new value
for runAsRoot=false, resulting in the pods erroring with this message:
Error: container's runAsUser breaks non-root policy (pod: "linkerd-identity-bc649c5f9-ckqvg_linkerd(fb3416d2-c723-4664-acf1-80a64a734561)", container: linkerd-init)

This PR adds a new default for runAsUser to avoid this issue.
2022-08-19 09:07:13 -05:00
Alejandro Pedraza 0404c22e9e
Change notes for stable-2.12.0-rc2 (#9202)
This release is the second release candidate for stable-2.12.0.

At this point the Helm charts can be retrieved from the stable repo:

```
helm repo add linkerd https://helm.linkerd.io/stable
helm repo up
helm install linkerd-crds -n linkerd --create-namespace linkerd/linkerd-crds
helm install linkerd-control-plane \
  -n linkerd \
  --set-file identityTrustAnchorsPEM=ca.crt \
  --set-file identity.issuer.tls.crtPEM=issuer.crt \
  --set-file identity.issuer.tls.keyPEM=issuer.key \
  linkerd/linkerd-control-plane
```

The following lists all the changes since edge-22.8.2:

* Fixed inheritance of the `linkerd.io/inject` annotation from Namespace to
  Workloads when its value is `ingress`
* Added the `config.linkerd.io/default-inbound-policy: all-authenticated`
  annotation to linkerd-multicluster’s Gateway deployment so that all clients
  are required to be authenticated
* Added a `ReadHeaderTimeout` of 10s to all the go `http.Server` instances, to
  avoid being vulnerable to "slowrolis" attacks
* Added check in `linkerd viz check --proxy` to warn in case namespace have the
  `config.linkerd.io/default-inbound-policy: deny` annotation, which would not
  authorize scrapes coming from the linkerd-viz Prometheus instance
* Added validation for accepted values for the `--default-inbound-policy` flag
* Fixed invalid URL in the `linkerd install --help` output
* Added `--destination-pod` flag to `linkerd diagnostics endpoints` subcommand
* Added `proxyInit.runAsUser` in `values.yaml` defaulting to non-zero, to
  complement the new default `proxyInit.runAsRoot: false` that was rencently
  changed
2022-08-18 19:50:09 -05:00
Eliza Weisman f6c6ff965c
inject: fix --default-inbound-policy not setting annotation (#9197)
Depends on #9195

Currently, `linkerd inject --default-inbound-policy` does not set the
`config.linkerd.io/default-inbound-policy` annotation on the injected
resource(s).

The `inject` command does _try_ to set that annotation if it's set in
the `Values` generated by `proxyFlagSet`:
14d1dbb3b7/cli/cmd/inject.go (L485-L487)

...but, the flag in the proxy `FlagSet` doesn't set
`Values.Proxy.DefaultInboundPolicy`, it sets
`Values.PolicyController.DefaultAllowPolicy`:
7c5e3aaf40/cli/cmd/options.go (L375-L379)

This is because the flag set is shared across `linkerd inject` and
`linkerd install` subcommands, and in `linkerd install`, we want to set
the default policy for the whole cluster by configuring the policy
controller. In `linkerd inject`, though, we want to add the annotation
to the injected pods only.

This branch fixes this issue by changing the flag so that it sets the
`Values.Proxy.DefaultInboundPolicy` instead of the
`Values.PolicyController.DefaultAllowPolicy` value. In `linkerd
install`, we then set `Values.PolicyController.DefaultAllowPolicy` based
on the value of `Values.Proxy.DefaultInboundPolicy`, while in `inject`,
we will now actually add the annotation.

This branch is based on PR #9195, which adds validation to reject
invalid values for `--default-inbound-policy`, rather than on `main`.
This is because the validation code added in that PR had to be moved
around a bit, since it now needs to validate the
`Values.Proxy.DefaultInboundPolicy` value rather than the
`Values.PolicyController.DefaultAllowPolicy` value. I thought using
#9195 as a base branch was better than basing this on `main` and then
having to resolve merge conflicts later. When that PR merges, this can 
be rebased onto `main`.

Fixes #9168
2022-08-18 17:16:27 -07:00
Kevin Leimkuhler 8c3fcc4d62
Add `--destination-pod flag` to `linkerd diagnostics endpoints` subcommand (#9200)
Closes #9141

This introduces the `--destination-pod` flag to the `linkerd diagnostics
endpoints` command which allows users to target a specific destination Pod when
there are multiple running in a cluster.

This can be useful for issues like #8956, where Linkerd HA is installed and
there seem to be stale endpoints in the destination service. Being able to run
this command and identity which destination Pod (if not all) have an incorrect
view of the cluster.

Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
2022-08-18 15:37:29 -06:00
Kevin Leimkuhler 464e83f5cd
Fix `linkerd install --help` config values URL (#8917)
Closes #8911 

Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
2022-08-18 09:56:54 -06:00
Kevin Leimkuhler ddc214acdf
Validate `--default-inbound-policy` values (#9195)
Closes #9148

With this change, the value of `—default-inbound-policy` is verified to be one
of the accepted values. 

When the value is not an accepted value we now error

```shell $ linkerd install --default-inbound-policy=everybody Error:
--default-inbound-policy must be one of: all-authenticated, all-unauthenticated,
cluster-authenticated, cluster-unauthenticated, deny (got everybody) Usage:
  linkerd install [flags]
... ```

A unit test has also been added.

Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
2022-08-17 19:42:01 -06:00
Matei David 75673f7922
Bump proxy-init to v2.0.0 (#9179)
* Bump proxy-init to v2.0.0

New release of proxy-init.

Updated:

* Helm values to use v2.0.0 of proxy-init
* Helm docs
* Tests

Note: go dependencies have not been updated since the new version will
break API compatibility with older versions (source files have been
moved, see issue for more details).

Closes #9164

Signed-off-by: Matei David <matei@buoyant.io>
Signed-off-by: Oliver Gould <ver@buoyant.io>

Signed-off-by: Matei David <matei@buoyant.io>
Signed-off-by: Oliver Gould <ver@buoyant.io>
Co-authored-by: Oliver Gould <ver@buoyant.io>
2022-08-17 11:48:27 +01:00
Alex Leong 2e01fa8089
Set default inbound policy in policy-controller flags (#9129)
When Linkerd is installed with the `--default-inbound-policy` flag, this value gets propagated to the `proxy.defaultInboundPolicy` value which sets the `LINKERD2_PROXY_INBOUND_DEFAULT_POLICY` proxy env var, but not to the `policyController.defaultAllowPolicy` value which sets the `--default-policy` flag on the policy-controller.

Since the policy-controller returns default servers when a server resource does not exist, this causes the `--default-inbound-policy` value to be effectively ignored.  We update this to set the `PolicyController.DefaultAllowPolicy` value which is used by the proxy as the default when `proxy.defaultInboundPolicy` is not set.

Signed-off-by: Alex Leong <alex@buoyant.io>
2022-08-11 15:49:59 -07:00
Alex Leong 1a52055f74
Add trust root checksum annotation (#9118)
Fixes #9022

When updating the Linkerd trust root, for example by running a command like `linkerd upgrade --identity-trust-anchors-file=./bundle.crt | kubectl apply -f -` as described in the [trust root rotation docs](https://linkerd.io/2.11/tasks/manually-rotating-control-plane-tls-credentials/#rotating-the-trust-anchor), the trust root is updated in the Linkerd config, but the identity controller does not restart and does not pick up the new root.

We add a trust root checksum annotation which causes the control plane deployments to change when the trust anchor changes, and thus causes them to restart.

Signed-off-by: Alex Leong <alex@buoyant.io>
2022-08-09 13:31:34 -07:00
Dani Baeyens 074f5e6cdf
Allows RSA signed trust anchors on linkerd cli (#7771) (#8868)
* Allows RSA signed trust anchors on linkerd cli (#7771)

Linkerd currently forces using an ECDSA P-256
issuer certificate along with a ECDSA trust
anchor. Still, it's still cryptographically valid
to have an ECDSA P-256 issuer certificate issued
by an RSA signed CA.

CheckCertAlgoRequirements checks if CA cert uses
ECDSA or RSA 2048/4096 signing algorithm.

Fixes #7771

Signed-off-by: Baeyens, Daniel <daniel.baeyens@gmail.com>
Co-authored-by: Alejandro Pedraza <alejandro@buoyant.io>
2022-08-08 08:04:24 -05:00
Matei David e4f7788c14
Change default iptables mode to legacy (#9097)
Some hosts may not have 'nft' modules available. Currently, proxy-init
defaults to using 'iptables-nft'; if the host does not have support for
nft modules, the init container will crash, blocking all injected
workloads from starting up.

This change defaults the 'iptablesMode' value to 'legacy'.

* Update linkerd-control-plane/values file default
* Update proxy-init partial to default to 'legacy' when no mode is
  specified
* Change expected values in 'pkg/charts/linkerd2/values_test.go' and in
  'cli/cmd/install_test'
* Update golden files

Fixes #9053

Signed-off-by: Matei David <matei@buoyant.io>
2022-08-05 10:45:29 -06:00
Kevin Leimkuhler c6693a5ae3
Add `policyController.probeNetworks` configuration value (#9091)
Closes #8945 

This adds the `policyController.probeNetworks` configuration value so that users
can configure the networks from which probes are expected to be performed.

By default, we allow all networks (`0.0.0.0/0`). Additionally, this value
differs from `clusterNetworks` is that it is a list of networks, and thus we
have to join the values in the Helm templating.

Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
2022-08-05 10:43:22 -06:00
Kevin Leimkuhler c006f7b4a2
Allow disabling `linkerd-await` on control plane pods (#9059)
> In some circumstances, the lifecycle.postStart hook can cause the linkerd-proxy
> container to get stuck waiting for identity verification. After the
> linkerd-await timeout, the container will be restarted and the proxy starts
> without further incident. The linkerd-control-plane helm chart currently has a
> way to disable the lifecycle hook for injected proxies, but not for proxies on
> the control plane pods.
>
> This commit adds a new value to the linkerd-control-plane chart of
> proxy.controlPlaneAwait that can be used to disable the postStart lifecycle hook
> on the destination and proxy-injector pods. This is defaulted to true to
> maintain current behavior.
> 
> The linkerd-control-plane chart was templated, setting proxy.controlPlaneAwait
> to true and false, verifying that the postStart lifecycle hook was either
> present or absent depending on the proxy.controlPlaneAwait value.
> 
> Fixes #8738

This continues the now stale #8739 and removes the version bumps that were
requested.

Signed-off-by: Jacob Lambert [calrisian777@gmail.com](mailto:calrisian777@gmail.com)
Co-authored-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
2022-08-03 16:09:42 -04:00
Alex Leong 9e99985bce
Update linkerd authz command to support authorizationpolicy and httproute (#9037)
Previously, the `linkerd authz` command would list all ServerAuthorization resources which targeted the specified resource.  With the addition of AuthorizationPolicies, we update this command to also show all AuthorizationPolicies which target the specified resource.  In cases where the AuthorizationPolicy targets an HTTPRoute which belongs to the resource, we also print the HTTPRoute name.

Sample output:

```
linkerd authz -n emojivoto po           
ROUTE            SERVER         AUTHORIZATION_POLICY   SERVER_AUTHORIZATION   
*                emoji-grpc     emoji-grpc                                    
linkerd-metrics  linkerd-admin  linkerd-metrics                               
linkerd-probes   linkerd-admin  linkerd-probes                                
*                prom           prom                                          
*                voting-grpc    voting-grpc                                   
*                web-http       web-public
```

Signed-off-by: Alex Leong <alex@buoyant.io>
2022-08-03 10:48:17 -07:00
Alex Leong e02b420e6e
Update CRD chart version in golden file (#9038)
* Update CRD chart version in golden file

Signed-off-by: Alex Leong <alex@buoyant.io>

* Run go tests on charts or golden changes

Signed-off-by: Alex Leong <alex@buoyant.io>
2022-07-28 18:42:34 -07:00
Matei David 9dd51d3897
Add `iptablesMode` flag to proxy-init (#8887)
This change introduces a new value to be used at install (or upgrade)
time. The value (`proxyInit.iptablesMode=nft|legacy`) is responsible
for starting the proxy-init container in nft or legacy mode.

By default, the init container will use iptables-nft. When the mode is set to
`nft`, it will instead use iptables-nft. Most modern Linux distributions
support both, but a subset (such as RHEL based families) only support
iptables-nft and nf_tables.

Signed-off-by: Matei David <matei@buoyant.io>
2022-07-27 21:45:19 -07:00
Oliver Gould 5491aec246
Update Go to 1.18 (#9019)
Go 1.18 features a number of important chanages, notably removing client
support for defunct TLS versions: https://tip.golang.org/doc/go1.18

This change updates our Go version in CI and development.

Signed-off-by: Oliver Gould <ver@buoyant.io>
2022-07-27 16:10:39 -07:00
Oliver Gould f580203a17
Revert "Add CPU, memory and storage config options for identity controller and proxy-injector (#8954)" (#9004)
This reverts commit 4ba36988b1.
2022-07-26 07:34:50 -07:00
Táskai Dominik 4ba36988b1
Add CPU, memory and storage config options for identity controller and proxy-injector (#8954)
There are several undocumented Helm values that configure control
plane resource constraints. This change fixes the default values to
include this missing documentation.

Fixes #8933 

Signed-off-by: Dominik Táskai <dtaskai@pm.me>
2022-07-25 21:12:30 -07:00
Eliza Weisman c854b10da7
policy: Remove `gateway.networking.k8s.io` `HTTPRoute` CRD (#8959)
As discussed in #8944, Linkerd's current use of the
`gateway.networking.k8s.io` `HTTPRoute` CRD is not a spec-compliant use
of the Gateway API, because we don't support some "core" features of the
Gateway API that don't make sense in Linkerd's use-case. Therefore,
we've chosen to replace the `gateway.networking.k8s.io` `HTTPRoute` CRD
with our own `HTTPRoute` CRD in the `policy.linkerd.io` API group, which
removes the unsupported features.

PR #8949 added the Linkerd versions of those CRDs, but did not remove
support for the Gateway API CRDs. This branch removes the Gateway API
CRDs from the policy controller and `linkerd install`/Helm charts.

The various helper functions for converting the Gateway API resource
binding types from `k8s-gateway-api` to the policy controller's internal
representation is kept in place, but the actual use of that code in the
indexer is disabled. This way, we can add support for the Gateway API
CRDs again easily. Similarly, I've kept the validation code for Gateway
API types in the policy admission controller, but the admission
controller no longer actually tries to validate those resources.

Depends on #8949
Closes #8944

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2022-07-25 13:23:02 -07:00
Matei David 59734271d3
Bump proxy-init to v1.6.2 (#8989)
This change bumps the proxy-init version from v1.6.1 to the latest
version, v1.6.2. As part of the new release, proxy-init now adds
net_admin and net_raw sys caps to xtables-nft-multi so that nftables
mode can be used without requiring root privileges.

* Bump go.mod
* Bump version in helm values
* Bump version in misc files
* Bump version in code

Signed-off-by: Matei David <matei@buoyant.io>
2022-07-25 18:40:06 +03:00
Eliza Weisman 753c73e0a0
policy: add `policy.linkerd.io` `HTTPRoute` CRD (#8949)
Our use of the `gateway.networking.k8s.io` types is not compliant with
the gateway API spec in at least a few ways:

1. We do not support the `Gateway` types. This is considered a "core"
   feature of the `HTTPRoute` type.
2. We do not currently update `HTTPRoute` status fields as dictated by
   the spec.
3. Our use of Linkerd-specific `parentRef` types may not work well with
   the gateway project's admission controller (untested).

Issue #8944 proposes solving this by replacing our use of
`gateway.networking.k8s.io`'s `HTTPRoute` type with our own
`policy.linkerd.io` version of the same type. That issue suggests that
the new `policy.linkerd.io` types be added separately from the change
that removes support for the `gateway.networking.k8s.io` versions, so
that the migration can be done incrementally.

This branch does the following:

* Add new `HTTPRoute` CRDs. These are based on the
  `gateway.networking.k8s.io` CRDs, with the following changes:
   - The group is `policy.linkerd.io`,
   - The API version is `v1alpha1`,
   - `backendRefs` fields are removed, as Linkerd does not support them,
   - filter types Linkerd does not support (`RequestMirror` and
     `ExtensionRef`), are removed.
* Add Rust bindings for the new `policy.linkerd.io` versions of
  `HTTPRoute` types in `linkerd-policy-controller-k8s-api`.

  The Rust bindings define their own versions of the `HttpRoute`,
  `HttpRouteRule`, and `HttpRouteFilter` types, because these types'
  structures are changed from the Gateway API versions (due to the
  removal of unsupported filter types and fields). For other types,
  which are identical to the upstream Gateway API versions (such as the
  various match types and filter types), we re-export the existing
  bindings from the `k8s-gateway-api`crate to minimize duplication.
* Add conversions to `InboundRouteBinding` from the `policy.linkerd.io`
  `HTTPRoute` types.

  When possible, I tried to factor out the code that was shared between
  the conversions for Linkerd's `HTTPRoute` types and the upstream
  Gateway API versions.

* Implement `kubert`'s `IndexNamespacedResource` trait for
  `linkerd_policy_controller_k8s_api::policy::HttpRoute`, so that the
  policy controller can index both versions of the `HTTPRoute` CRD.

* Adds validation for `policy.linkerd.io` `HTTPRoute`s to  the policy
  controller's validating admission webhook.

* Updated the policy controller tests to test both versions of
  `HTTPRoute`.

## Notes

A couple questions I had about this approach:
 - Is re-using bindings from the `k8s-gateway-api` crate appropriate
   here, when the type has not changed from the Gateway API version? If
   not, I can change this PR to vendor those types as well, but it will
   result in a lot more code duplication.
 - Right now, the indexer stores all `HTTPRoute`s in the same index.
   This means that applying a `policy.linkerd.io` version of `HTTPRoute`
   and then applying the Gateway API version with the same ns/name will
   update the same value in the index. Is this what we want? I wasn't
   entirely sure...

See #8944.
2022-07-22 13:35:23 -07:00
Oliver Gould b0712ebdf6
policy: Enable controller logs at INFO level (#8958)
Dependencies like `kubert` may emit INFO level logs that are useful to
see (e.g., when the serviceaccount has insufficient RBAC). This change
updates the default policy controller log level to simply be `info`.

Signed-off-by: Oliver Gould <ver@buoyant.io>
2022-07-22 11:09:17 -07:00
Alex Leong 692311ee1b
edge-22.7.2 (#8947)
This release adds support for per-route authorization policy using the
AuthorizationPolicy and HttpRoute resources. It also adds a configurable
shutdown grace period to the proxy which can be used to ensure that proxy
graceful shutdown completes within a certain time, even if there are outstanding
open connections.

* Removed kube-system exclusions from watchers to fix service discovery for
  workloads in the kube-system namespace (thanks @JacobHenner)
* Added annotations to allow Linkerd extension deployments to be evicted by the
  autoscaler when necessary
* Added missing port in the Linkerd viz chart documentation (thanks @haswalt)
* Added support for per-route policy by supporting AuthorizationPolicy resources
  which target HttpRoute resources
* Fixed the `linkerd check` command crashing when unexpected pods are found in
  a Linkerd namespace
* Added a `config.linkerd.io/shutdown-grace-period` annotation to configure the
  proxy's maximum grace period for graceful shutdown

Signed-off-by: Alex Leong <alex@buoyant.io>
2022-07-21 14:16:31 -07:00
Eliza Weisman 85e5ab3b38
inject: add `config.linkerd.io/shutdown-grace-period` annotation (#8923)
PR linkerd/linkerd2-proxy#1815 added support for a
`LINKERD2_PROXY_SHUTDOWN_GRACE_PERIOD` environment variable that
configures the proxy's maximum grace period for graceful shutdown. This
is intended to ensure that if a proxy is shut down, it will eventually
terminate in a relatively timely manner, even if some stubborn
connections don't close gracefully.

This branch adds support for a `config.linkerd.io/shutdown-grace-period`
annotation that can be used to override the default grace period
duration.

Hopefully I've added this everywhere it needs to be added --- please let
me know if I've missed anything!
2022-07-19 14:43:38 -07:00
Matei David b3ec9111d2
Bump proxy-init version to v1.6.1 (#8913)
Release v1.6.1 of proxy-init adds support for iptables-nft. This change
bumps up the proxy-init version used in code, chart values, and golden
files.

* Update go.mod dep
* Update CNI plugin with new opts
* Update proxy-init ref in golden files and chart values
* Update policy controller CI workflow

Signed-off-by: Matei David <matei@buoyant.io>
2022-07-18 13:03:26 -07:00
Alex Leong f04edae759
policy: Add HTTPRoute indexing (#8795)
linkerd2-proxy-api v0.6.0 adds support for inbound proxies to discover
route configurations based on the Gateway API HTTPRoute types. This
change updates the policy controller to index
`gateway.networking.k8s.io/v1beta` `HTTPRoute` types to discover these
policies from the Kubernetes API.

`HTTPRoute` resources may target `Server` resources (as a `parentRef`)
to attach policies to an inbound proxy. When no routes are configured,
a default route is synthesized to allow traffic; but when at least one
route attaches to a server, only requests that match a route are
permitted (other requests are failed with a 404).

Only the *core* subset of the `HTTPRoute` filters are supported:
`RequestRedirect` and `RequestHeaderModifier`. Backends may *not* be
configured on these routes (since they may only apply to inbound/server-
side proxies). No `status` updates are currently performed on these
`HTTPRoute` resources.

This change does not yet allow `AuthorizationPolicy` resources to target
`HTTPRoute` resources. This will be added in a follow-up change.

Signed-off-by: Alex Leong <alex@buoyant.io>
Co-authored-by: Oliver Gould <ver@buoyant.io>
2022-07-14 09:04:48 -07:00
Kevin Leimkuhler d6c33e9743
Unset `policyValidator.keyPEM` in `linkerd-config` (#8827)
Closes #8823 

Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
2022-07-07 20:53:37 -06:00
Alex Leong 120f91ca2c
Add validation for HTTPRoute (#8730)
Fixes #8665

We add validation for HTTPRoute resources to the policy admission controller.  We validate that for any HTTPRoute which has a Server as a parent_ref, that it doesn't have unsupported filters.  For the moment we do not support any HTTP filters.  As we add support for HTTP filter types, we should update the validator accordingly.

Signed-off-by: Alex Leong <alex@buoyant.io>

Co-authored-by: Oliver Gould <ver@buoyant.io>
2022-07-07 16:14:26 -07:00
Alex Leong e84a27506a
Relax Server proxyProtocol validation (#8655)
Fixes #8564

Removes the enum of allowed values from the proxyProtocol field in the Server CRD.  Instead, we rely on the admission controller to validate this field.

Before:

```
The Server "myserver" is invalid: spec.proxyProtocol: Unsupported value: "invalid": supported values: "unknown", "HTTP/1", "HTTP/2", "gRPC", "opaque", "TLS"
```

After:

```
k apply -f myserver.yml                              
Error from server: error when creating "myserver.yml": admission webhook "linkerd-policy-validator.linkerd.io" denied the request: unknown variant `invalid`, expected one of `unknown`, `HTTP/1`, `HTTP/2`, `gRPC`, `opaque`, `TLS`
```

Signed-off-by: Alex Leong <alex@buoyant.io>
2022-07-01 18:51:03 -07:00
Alex Leong df177e67eb
Add HttpRoute CRD (#8675)
Fixes #8660

We add the HttpRoute CRD to the CRDs installed with `linkerd install --crds` and `linkerd upgrade --crds`.  You can use the `--set installHttpRoute=false` to skip installing this CRD.

Signed-off-by: Alex Leong <alex@buoyant.io>
2022-06-29 09:50:23 -07:00
dependabot[bot] aaff8a74e9
build(deps): bump github.com/spf13/cobra from 1.4.0 to 1.5.0 (#8717)
* build(deps): bump github.com/spf13/cobra from 1.4.0 to 1.5.0

Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.4.0 to 1.5.0.
- [Release notes](https://github.com/spf13/cobra/releases)
- [Commits](https://github.com/spf13/cobra/compare/v1.4.0...v1.5.0)

---
updated-dependencies:
- dependency-name: github.com/spf13/cobra
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Relax completion tests

Signed-off-by: Alex Leong <alex@buoyant.io>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alex Leong <alex@buoyant.io>
2022-06-24 10:47:28 -07:00
Kevin Leimkuhler 7e8167b7b8
Fix Docker runtime check to happen only during install (#8667)
Closes #8583 

Even though #7468 removed the Docker container runtime check from `linkerd check --pre` to `linkerd install` runtime error, we still do a dry run of the installation so that we can render the control plane manifests. Therefore, we still hit this check which results in not being able to run `linkerd check --pre` when nodes are using the Docker container runtime. This fixes the issue by introducing a `dryRun` flag that we check beforehand.

```shell
❯ kubectl get nodes docker-desktop -o jsonpath='{.status.nodeInfo.containerRuntimeVersion}'
docker://20.10.16

❯ bin/linkerd check --pre
Linkerd core checks
===================
...
```

Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
2022-06-22 08:04:24 -06:00
Alex Leong b7a0b8adb4
Bump minimum kubernetes version to 1.21 (#8647)
Fixes #8592

Increase the minimum supported kubernetes version from 1.20 to 1.21.  This allows us to drop support for batch/v1beta1/CronJob and discovery/v1beta1/EndpointSlices, instead using only v1 of those resources.  This fixes deprecation warnings about these warnings printed by the CLI.

Signed-off-by: Alex Leong <alex@buoyant.io>
2022-06-14 15:15:28 -07:00