Enhanced Security Measures in Place:   To ensure a safer experience, we’ve implemented additional, temporary security measures for all users.

When running a REGO script with the open policy agent OPA how do i only specify the kubernetes cluster to run against

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements

When running a REGO script with the open policy agent OPA how do i only specify the kubernetes cluster to run against

L0 Member

I have multiple kubernetes clusters ; however when running a REGO script with the open policy agent how do i only run the policy against the cluster i want..

https://docs.paloaltonetworks.com/prisma/prisma-cloud/prisma-cloud-admin-compute/access_control/open...

q1) Is this done in the REGO script itself (see below) ..eg "if cluster == XXX" etc
q2) Would this be done in the Prisma cloud UI ( i cannot see any where to mark a OPA policy as run on particular cluster etc )

# pseudo code.. How do i only run this policy on the cluster i care about

if CLUSTER == "XXXX" 
{
  repo := "foobar"
  deny[msg] {
	some i
	input.request.kind.kind == "Pod"
	image := input.request.object.spec.containers[i].image
	not startswith(image, repo)
	msg := sprintf("Image '%s' comes from untrusted registry use '%s'",[image,repo])
}

 


The UI - shows no setting to only run this policy against a particular cluster ..

image.png

2 REPLIES 2

L4 Transporter

Greetings SCullum,

 

I hope that this note finds you well! I know that it has been a while since you had posted this question but I wanted to see if you still potentially needed any help. Thank you for your time and I hope that you have a good remainder of your day.

 

Kind Regards,

J. Avery King

J. Avery King | Prisma Cloud | Customer Success Engineer

Hello, I am not OP but I do have the same question. I want to apply the folowing policy only to one cluster:

match[{"msg": msg}] {
 input.request.operation == "CREATE"
 input.request.object.metadata.namespace == "default"
 msg := "It's not allowed to create resources in the Default Namespace"
}

How could I be able to do this?

Thank you for your help

 

  • 2596 Views
  • 2 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!