Learn KOP - Deploy Test Workload - Rafay Product Documentation

Part 4: Workload

What Will You Do

In this part of the self-paced exercise, you will deploy a "test workload" to your OPA Gatekeeper cluster that will be used to test the OPA Gatekeeper policy.


Step 1: Deploy Workload

Important

An "App Developer" would like clear and obvious instructions on what they need to do to make sure their workloads are compliant with organizational policy.

In this step, you will create a namespace and deploy a workload in that namespace.

Create Namespace

Deploy the workload

apiVersion: v1
kind: Pod
metadata:
  name: opa-gs-nginx
spec:
  containers:
  - name: opa-gs-nginx
    image: nginx
    resources:
      limits:
        cpu: "800m"
      requests:
        cpu: "500m"

You should see something like the following showing the workload deployment status as "In Progress"

After a few minutes, you will see something like the following showing the workload deployment status as "Published Failed"

The error message shows that the OPA Gatekeeper constraint denied the request to create the pod as the image is not from a valid repo.

    image: docker.io/nginx

The file should look like the following once updated

After a few minutes, you will see something like the following showing the workload status as "Running"

kubectl get pods -n default

You should see a result like the following showing the nginx pod running.

NAME           READY   STATUS    RESTARTS   AGE
opa-gs-nginx   1/1     Running   0          5m37s

Step 2: Review Policy Violations

Important

A "Security Admin" would like to be able to centrally "specify and enforce" policies organization wide. In addition, they would like "centralized visibility" into policy violations across the organization.

In this step, you will review the OPA Gatekeeper policy violations.

You should see a result like the following showing "warn" enforcement actions for the container ratio constraint


Step 3: Review Audit Logs

In this step, you will review the OPA Gatekeeper audit logs.

You should see a result like the following showing both the "warn" and "deny" enforcement actions that were triggered when the workload was published both times.


Recap

Congratulations! At this point, you have successfully deployed a workload onto the OPA Gatekeeper cluster from an approved repository and reviewed the policy violations and audit logs to understand current violations and enforcement action history.