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

Remove ignored namespaces check #53

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ribbybibby
Copy link

@ribbybibby ribbybibby commented Sep 25, 2020

What and why?

Fixes #44 and #52.

Remove the ignored namespaces check from the code in favour of a namespaceSelector in the webhook example. Not only does this allow users to inject into pods in kube-system if they want to, it also provides more protection against problems with the webhook as pods from ignored namespaces won't be forwarded to the webhook at all.

This PR also tweaks the logging in the mutate function to account for the fact that the object metadata may not contain name or namespace information.

Testing Steps

Please provide adequate testing steps (including screenshots if necessary).
Include any test fixtures or sample configurations in your commit.

  • Added unit tests for this feature (make test)

Reviewers

Required reviewers: @byxorna
Request reviews from other people you want to review this PR in the "Reviewers" section on the right.

⚠️ this PR must have at least 2 thumbs from the MAINTAINERS.md of the project before merging!

It's possible for metadata.namespace and metadata.name to be empty in
the objects passed to the webhook. This was causing the ignored
namespaces check to fail and the name and namespace of the pods was
empty in a number of logging statements.

Additionally, the name in the request may also be omitted, in which case
there is unfortunately no way to know the name of the pod.

I've addressed these issues by:
- Moving the namespaces check into the mutate method and using the
  Namespace field from the request to perform the check
- Removing the logging statements from
  `getSidecarConfigurationRequested` in favour of wrapping the errors it
  returns with the required information. The log statement in the mutate
  function can then log this information, along with the Namespace from
  the request.
- Replacing the pod name with an informative placeholder in cases where
  the pod name cannot be known.
And replace it with a namespaceSelector in the example.
@ribbybibby ribbybibby changed the title Use name and namespace from the request Remove ignored namespaces check Sep 28, 2020
@ribbybibby
Copy link
Author

Ping - just checking if anyone has had a chance to look at this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Question: Being able to inject in kube-system namespace
2 participants