-
Notifications
You must be signed in to change notification settings - Fork 1.5k
WAFv2 support #1211
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
WAFv2 support #1211
Conversation
Hi @Vlaaaaaaad. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
Failed due to a timeout last time, so let's try again! /test pull-aws-alb-ingress-controller-e2e-test |
/test pull-aws-alb-ingress-controller-e2e-test :D |
i think the tests fails due to lack of IAM permissions. the tests uses IAM permission from https://github.com/kubernetes-sigs/aws-alb-ingress-controller/blob/master/docs/examples/iam-policy.json. Also, the UX is better to be like:
|
🤦♂ Yup, that's a very likely reason why tests fail. In regards to having
On the other hand, using the ARN directly would eliminate the need for me to call the AWS API to get the ARN from the I'll try to fix the above issues by early next week! |
thanks :D wafv2-acl-arn make sence. And i think it could be an UI change for waf team to disclose the arn information in UI. |
I just wanted to mention that the wafv2 ACL ARN is available in the management console if you click the gear icon in the top right corner of the table and enable the ARN column. Definitely not ideal nor intuitive but its at least possible. |
Fixed it based on the AWS Shield implementation( #1126). I was a bit concerned about braking expectations: if I delete an SSL annotation, the SSL cert will be detached. If I delete a WAFv2 annotation nothing will happen. Still left to do: tests. I have a couple of ideas about what I would like to test, but unclear when I'll have the time to write them. By next Monday for sure. |
I just want to mention that in general I think requiring an annotation be set to an empty string in order for that feature to be disabled on the ALB is very unintuitive. One would expect removing the annotation altogether to do the same thing. I would expect that if someone didn't add the WAFv2 permissions when upgrading to a version of the controller that includes this functionality that the rest of the controller would still function as expected, and only WAFv2 calls would fail, causing noisy logs but be otherwise functional. I could also see an argument that if the controller's IAM policy isn't setup correctly then it should fail early (exit?) in order to be more visible to the cluster administrator. I understand that some administrators don't want to enable something like WAFv2 (which could currently be accomplished by not including it in the controller's IAM policy), so perhaps flags on the controller that selectively disable certain functionality would be appropriate. Thoughts @M00nF1sh ? |
I'll implement this however y'all want 😆 I'll just give my opinion, but since @M00nF1sh maintains this and has to carry that burden, they have the final say.
Besides performance issues( for every reconcile loop and every ALB, run
It seems that Feature Gates can be sent as command-line arguments, but I never saw that used: https://github.com/kubernetes-sigs/aws-alb-ingress-controller/blob/95ee2ac800f6b7c1904d5d7fd69acb8867131983/internal/ingress/controller/config/features.go#L66 We could set WAFv2 support as Anyway, this was also brought up in #1126 (comment):
|
Sure thing, this was mostly directed at @M00nF1sh :) I think this PR looks great so far I would argue that noisy PermissionDenied errors in the logs would be best because it would most clearly alert the administrator that something isn't configured correctly. I think I would rather have these errors in my logs continuously rather than waiting until I need to add my first wafv2 annotation to an ingress, though I could see see a debate for either side on this. I guess it comes down to "should the controller run out-of-the-box without any errors when using an incomplete/up-to-date IAM policy?" I think the answer should be no. The controller will still work to the best of its ability, but a stream of PermissionDenied errors should be expected. When upgrading the controller the administrator should be expected to update the IAM policy to match the documented policy for the controller version. If an administrator chooses to deviate from the policy, they can use the FeatureGates to disable the associated functionality in the controller. Personally I like the idea of using a feature gate for this and having it enabled by default. |
this looks good to me. So there are three semantic:
I favor semantic #1 since it's more flexible. (i have see use cases like a company wide policy that automatically attach waf to all ALBs, which is out of k8s's control). |
I think semantic #3 should be considered along with feature flags. If either the user (someone managing an ingress resource) or the cluster administrator (someone managing the ingress controller) desire the behavior "don't manage WAFv2 for me" either because they don't want to allow WAFv2 permissions or they have an external service managing that feature for the ALB, that is a conscious decision they need to make therefor it should be "opt in". The user could achieve that by setting the annotation value to Regarding behavior for setting an annotation's value to an empty string, I feel like this would be a problem not unique to AWS ALB Ingress Controller. Do other ingress controllers have this problem? Do they solve it with empty annotation values?
I disagree. Consistency does not imply intuitiveness. Especially if this is the only ingress controller with this behavior. If someone with experience with other ingress controllers starts using this one, the behavior wont be intuitive to them. I think as someone glancing at an ingress definition, seeing
more clearly helps me understand how the WAFv2 ACL attachment is being managed, rather than an empty string or no annotation at all. |
|
I am a tad confused. Let me try to clarify. So, what you are proposing is this:
Did I get it correctly? |
Yes, but we don't need to support "alb.ingress.kubernetes.io/wafv2-acl-arn: external = do nothing" for now. :D sorry for the back and forth |
No need to apologize @M00nF1sh. This is important 🙂 I'll code it up and test it manually this week. I hope that by Monday, I'll have tests added to the PR and have everything ready for review! |
Ok, changed it to the above flow and manually tested all combinations. Lack of WAFv2 permissions will result in the following error:
The error is quite clear and signals to any cluster admin that there is a lack of IAM permissions. Still left to do: add tests. We're getting closer and closer! |
Added tests for the WAFv2 🎉 Aaaaand with the tests added I am also marking this PR as ready for review! Don't be afraid to be merciless in your reviews, I can take it! |
Thanks for contributing this 🤣 |
[APPROVALNOTIFIER] This PR is APPROVED Approval requirements bypassed by manually added approval. This pull-request has been approved by: Vlaaaaaaad The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Has this been added to the documentation :( |
@M00nF1sh do I have to do anything for the docs to be updated? The docs were added with this PR and they are present in |
+1 for updating documentation :) |
Missing docs are tracked as part of #1324 |
This PR adds support for attaching WAFv2 WebACLs to ALBs managed by the ALB Ingress Controller.
To do this, a new annotation is added:
alb.ingress.kubernetes.io/wafv2-acl-arn
Closes #1089
Now, this is a draft PR because I want to at least know I am on the right path. Early feedback and communication is good!
The code is not fully ready to be merged yet.
I saw that the AWS Console did allow me to attach both WAFv1 and WAFv2 WebACLs to the same ALB. That directly led to me creating a new controller for WAFv2, instead of extending the pre-existing WAF controller.
The WAFv2 implementation is heavily based on the existing WAF code and patterns.
Still to do, after I get a hint I am on the good path: