How to restrict pod forwarding to tiller using rego #43
-
Hello, I am trying to restrict port forwarding to the tiller. I am not able to match subresource. for some reason, it is not working. tried in 2 ways.. any pointers would be helpful.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
Hi @subravi92 👋 The second deny rule is almost there. However, it doesn't look like the metadata from the pod is carried into the name := input.request.object.metadata.name The name of the pod seems to be reflected in enforce[reason] {
input.request.kind.kind == "PodPortForwardOptions"
input.request.resource.resource == "pods"
input.request.subResource == "portforward"
name := input.request.name
startswith(name, "tiller")
reason := sprintf("You are not allowed to port-forward to tiller from %v namespace", [input.request.namespace])
} I can recommend enabling the decision logging capabilities of OPA when you debug things like this, as it will allow you to see the full admission review object sent from the kubernetes API server. |
Beta Was this translation helpful? Give feedback.
Hi @subravi92 👋
The second deny rule is almost there. However, it doesn't look like the metadata from the pod is carried into the
PodPortForwardOptions
admission review, so your rule fails at this line:name := input.request.object.metadata.name
The name of the pod seems to be reflected in
input.request.name
though, so you could use that instead:I …