Skip to content

How to restrict pod forwarding to tiller using rego #43

Discussion options

You must be logged in to vote

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:

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 …

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@jsarkar
Comment options

@anderseknert
Comment options

@jsarkar
Comment options

@anderseknert
Comment options

@jsarkar
Comment options

Answer selected by anderseknert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment