-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[RFE]: Add Support for Kubernetes NetworkPolicy Action #3644
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
Comments
ATM I see 2 ways how one could make an action for that: either command action with curl/whatever to REST API of k8s, or probably more favorably a pythonic action using kubernetes-client/python. |
Very interested in this! |
Since there was/is no action regarding this. Here is a working sample config:
with these other yaml requirements:
Sometimes there is a conflict when there are 2 applies at the same time. I haven't figured out yet how to make sure this doesn't happen. There probably will be some option in fail2ban to achieve this, but I need to look into it further. For now it works on my local cluster. I'll post updates if I need to change something |
Description
Add support for fail2ban to be used inside a kubernetes enviroment by modifying NetworkPolicy API
In a kubernetes enviroment the usage of traditional or even docker base fail2ban setup is currently not possible due the way kubernetes network stack works. I think few attempts have been made to work around this by various people over the years but this proposal is to gather interest and look at using the Kubernetes Network Policy API to effectively native support kubernetes from fail2ban.
Any additional information
https://kubernetes.io/docs/concepts/services-networking/network-policies/
https://network-policy-api.sigs.k8s.io/reference/spec/
The Concept
fail2ban would be given a service account with limited access to create/edit a named Network Policy.
When a jail is triggered the api would be invoked and entries would be added or removed from the policy. Eg in the below yaml example
traffic is allowed from anywhere appart from
172.17.1.0/24
123.123.123.123/32
Eg:
On the surface concept wise it sound like it should be fairly easy and then a container based instance of fail2ban could run as a side car and ban as needed.
Am raising this Issue in first instance in hope someone more experienced in the technologies will see it and run with it as not sure how to achieve the above myself.
The text was updated successfully, but these errors were encountered: