Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linkerd check should check for PodSecurityPolicy admission controller #2849

Closed
siggy opened this issue May 24, 2019 · 4 comments
Closed

linkerd check should check for PodSecurityPolicy admission controller #2849

siggy opened this issue May 24, 2019 · 4 comments

Comments

@siggy
Copy link
Member

siggy commented May 24, 2019

Background

Linkerd user @jamessthompson reported a failing linkerd check --pre, due to PodSecurityPolicy:

$ linkerd check --pre --verbose
...
pre-kubernetes-capability
-------------------------
× has NET_ADMIN capability
    found 7 PodSecurityPolicies, but none provide NET_ADMIN
    see https://linkerd.io/checks/#pre-k8s-cluster-net-admin for hints

Despite the failed check, Linkerd successfully installed. This is likely due to the PodSecurityPolicy admission controller not running.

Reproduction

gcloud beta container clusters create psp-test --enable-pod-security-policy

Proposal

Modify linkerd check --pre to validate whether the PodSecurityPolicy is running, in addition to check the actual PodSecurityPolicy's.

If the admission controller is not running, but PodSecurityPolicy's still exist that would disallow NET_ADMIN, issue a warning.

Additionally, if the admission controller is running, and no PodSecurityPolicy's are found, this check should fail. This is not the case in the current implementation.

Relevant code:

// if PodSecurityPolicies are found, validate one exists that:
// 1) permits usage
// AND
// 2) provides NET_ADMIN

@ihcsim
Copy link
Contributor

ihcsim commented May 24, 2019

@jamessthompson Can you take a look at the Linkerd deployments to see whether the kubernetes.io/psp: annotation has been added. If the PSP admission controller is running, and the service account has the right RBAC to use the policy, this annotation will show you the policy that is in-effect.

Also speaking of RBAC, I think you need to make sure all the Linkerd service accounts have the correct RBAC to use the PSP policy(ies), because when it comes to non-pod workloads like Deployment, the service accounts are the ones creating the pods. See example here.

@jamessthompson
Copy link

jamessthompson commented May 25, 2019

That annotation does not exist, which matches what we determined yesterday. This ticket is more about providing clarity during installs for people like me that have never used the PSP admissions controller but have 3rd party charts installed that added PSPs. I thought I had a broken install and reached out on slack looking for an example of a valid linkerd PSP.

@alpeb
Copy link
Member

alpeb commented Jun 11, 2019

When #2920 merges, we'll provide a PSP for Linkerd's control plane that will grant the NET_ADMIN capability for non-CNI installs, which will probably render this particular check moot.

@siggy siggy self-assigned this Jun 18, 2019
siggy added a commit that referenced this issue Jun 18, 2019
The change in #2920 introduced a PodSecurityPolicy, providing
`NET_ADMIN` capability to Linkerd. This eliminated the need for a
`NET_ADMIN` capability check in `linkerd check`, as the default
`linkerd install` now guarantees `NET_ADMIN` capability. At the same
time, this added a requirement on that `linkerd install` create a
PodSecurityPolicy.

Remove the `NET_ADMIN` capability check from `linkerd check`. Introduce
a check to validate the user can create a PodSecurityPolicy.

Fixes #2884, #2849.

Signed-off-by: Andrew Seigner <[email protected]>
siggy added a commit that referenced this issue Jun 18, 2019
The change in #2920 introduced a PodSecurityPolicy, providing
`NET_ADMIN` capability to Linkerd. This eliminated the need for a
`NET_ADMIN` capability check in `linkerd check`, as the default
`linkerd install` now guarantees `NET_ADMIN` capability. At the same
time, this added a requirement that `linkerd install` create a
PodSecurityPolicy.

Remove the `NET_ADMIN` capability check from `linkerd check`. Introduce
a check to validate the user can create a PodSecurityPolicy.

Fixes #2884, #2849.

Signed-off-by: Andrew Seigner <[email protected]>
siggy added a commit that referenced this issue Jun 18, 2019
The change in #2920 introduced a PodSecurityPolicy, providing
`NET_ADMIN` capability to Linkerd. This eliminated the need for a
`NET_ADMIN` capability check in `linkerd check`, as the default
`linkerd install` now guarantees `NET_ADMIN` capability. At the same
time, this added a requirement that `linkerd install` create a
PodSecurityPolicy.

Remove the `NET_ADMIN` capability check from `linkerd check`. Introduce
a check to validate the user can create a PodSecurityPolicy.

Fixes #2884, #2849.

Signed-off-by: Andrew Seigner <[email protected]>
siggy added a commit that referenced this issue Jun 18, 2019
The change in #2920 introduced a PodSecurityPolicy, providing
`NET_ADMIN` capability to Linkerd. This eliminated the need for a
`NET_ADMIN` capability check in `linkerd check`, as the default
`linkerd install` now guarantees `NET_ADMIN` capability. At the same
time, this added a requirement that `linkerd install` create a
PodSecurityPolicy.

Remove the `NET_ADMIN` capability check from `linkerd check`. Introduce
a check to validate the user can create a PodSecurityPolicy.

Fixes #2884, #2849

Signed-off-by: Andrew Seigner <[email protected]>
siggy added a commit that referenced this issue Jun 19, 2019
`linkerd check` validates whether PSP's exist, and if the caller has the
`NET_ADMIN` capability. This check was previously failing if `NET_ADMIN`
was not found, even in the case where the PSP admission controller was
not running. Related, `linkerd install` now includes a PSP, so
`linkerd check` should also validate that the caller can create PSP's.

Modify the `NET_ADMIN` check to warn, but not fail, if PSP's are found
but the caller does not have `NET_ADMIN`. Update the warning message to
mention that this is only a problem if the PSP admission controller is
running (and will only be a problem during injection, since #2920
handles control plane installation by adding its own PSP).

Also introduce a check to validate the caller can create PSP's.

Fixes #2884, #2849

Signed-off-by: Andrew Seigner <[email protected]>
siggy added a commit that referenced this issue Jun 20, 2019
`linkerd check` validates whether PSP's exist, and if the caller has the
`NET_ADMIN` capability. This check was previously failing if `NET_ADMIN`
was not found, even in the case where the PSP admission controller was
not running. Related, `linkerd install` now includes a PSP, so
`linkerd check` should also validate that the caller can create PSP's.

Modify the `NET_ADMIN` check to warn, but not fail, if PSP's are found
but the caller does not have `NET_ADMIN`. Update the warning message to
mention that this is only a problem if the PSP admission controller is
running (and will only be a problem during injection, since #2920
handles control plane installation by adding its own PSP).

Also introduce a check to validate the caller can create PSP's.

Fixes #2884, #2849

Signed-off-by: Andrew Seigner <[email protected]>
@siggy
Copy link
Member Author

siggy commented Jun 20, 2019

Closed via #2958.

@siggy siggy closed this as completed Jun 20, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants