linkerd2/viz
Kevin Leimkuhler 2442ca07bf
Parse Pod labels for owning Deployment instead of name (#8920)
Closes #8916

When a random Pod (meshed or not) is created in the `linkerd`, `linkerd-viz`, or
`linkerd-jaeger` namespaces their respective `check` subcommands can fail.

We parse Pod names for their owning Deployment by assuming the Pod name has a
randomized suffix. For example, the `linkerd-destination` Deployment creates the
`linkerd-destination-58c57dd675-7tthr` Pod. We split the name on `-` and take
the first two parts (`["linkerd", "destination"]`); those first two parts make
up the Deployment name.

Now, if a random Pod is created in the namespace with the name `test`, we apply
that same logic but hit a runtime error when trying to get the first two parts
of the split. `test` did not split at all since it contains no `-` and therefore
we error with `slice bounds out of range`.

To fix this, we now use the fact that all Linkerd components have a
`linkerd.io/control-plane-component` or `component` label with a value that is
the owning Deployment. This allows us to avoid any extra parsing logic and just
look at a single label value.

Additionally, some of these checks get all the Pods in a namespace with the
`GetPodsByNamespace` method but we don't always need something so general. In
the places where we are checking specifically for Linkerd components, we can
narrow this further by using the expected LabelSelector such as
`linkerd.io/extension=viz`.

Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
2022-07-19 12:14:55 -06:00
..
charts/linkerd-viz Add port to helm Values (#8855) 2022-07-13 08:22:23 -06:00
cmd Allow extension deployments to be evicted by autoscaler (#8828) 2022-07-12 10:46:31 -07:00
metrics-api Remove grpc-over-http (#8625) 2022-06-08 10:27:58 -07:00
pkg Parse Pod labels for owning Deployment instead of name (#8920) 2022-07-19 12:14:55 -06:00
static Remove old build constraints (#7392) 2021-12-08 14:36:24 -07:00
tap Generate ipv4 and ipv6 compat URL address for Linkerd2 (#8598) 2022-06-06 12:19:47 +01:00
main.go Report better errors for pods with tap disabled (#5799) 2021-02-24 12:32:46 -08:00