Recipes - Trivy and Rafay - Rafay Product Documentation

Trivy

The two best known Kubernetes Security Benchmarks are CIS and NSA. As part of their work, they have released a set of recommendations for configuring Kubernetes clusters and workloads.

CIS (Center for Internet Security) benchmarks consists of secure configuration guidelines developed for Kubernetes. These include not only the running workloads but also the Kubernetes infrastructure set-up. CIS benchmarks are documented here.

NSA and CISA's guidance details recommendations to harden Kubernetes systems. Primary actions include the scanning of containers and Pods for vulnerabilities or misconfigurations, running containers and Pods with the least privileges possible, and using network separation, firewalls, strong authentication, and log auditing. NSA/CISA's Kubernetes Hardening Guidance report is available here.

This recipe describes how customers can standardize the deployment of the Trivy Operator, and generate CIS and NSA compliance reports.


What Will You Do

In this exercise,


Assumptions


Step 1: Create the Trivy Operator add-on

1.1: Create Repository

1.2: Create Custom Catalog

1.3: Create Namespace

You will now create a managed namespace from the controller for the Trivy Operator.

1.4: Create custom Add-on

In this step, you will create a custom cluster add-on from the Catalog. The add-on will then be used in a custom cluster blueprint.


Step 2: Create Blueprint

In this step, you will create a custom cluster blueprint which contains the previously created add-on.


Step 3: Apply Blueprint

In this step, you will apply the previously created blueprint to the cluster. Applying the blueprint will install the Trivy operator.


Step 4: Query benchmark reports

4.1 Verify installation of Trivy Operator

kubectl get all -n trivy-system

The output should be similar to below.

4.2 Query reports

Once you have verified that everything is running correctly, you should be able to query the Kubernetes benchmark reports generated by the Trivy Operator.

kubectl get clustercompliancereport
kubectl get clustercompliancereport nsa -o yaml
kubectl get clustercompliancereport cis -o yaml

Step 5: Aggregating Results across fleet of clusters

With 10s or 100s of clusters organization wide, it is critical to have the means to centrally aggregate CIS benchmark reports to demonstrate "compliance" to the auditors. By default, the Trivy operator scans the cluster every 6 hours. Each scan results in an updated cluster compliance report that can be downloaded as described below.

You can use Rafay's Zero Trust Kubectl as the means to securely access their fleet of clusters to centrally aggregate the CIS Benchmark reports.

For example, an external pipeline can download the consolidated kubeconfig with all cluster contexts to retrieve the CIS scan results in seconds. See visual below for an illustrative example.

Cluster FleetRafay ControllerPipelineSplunkCluster FleetRafay ControllerPipelineSplunkloop[Every Cluster]loop[Every "x" Hours]Download consolidated kubeconfigRetrieve CIS scan report from each cluster using Rafay's zero trust kubectlRetrieve CIS scan reportStore CIS scan report

You can aggregate the reports in your organization's preferred CMDB such as Service Now or enterprise security platform such as Splunk. This ensures that the compliance team has visibility and access to every compliance report right from the birth of each cluster.


Recap

Congratulations! You have successfully created a custom cluster blueprint with Trivy Operator as a custom add-on. You can now use this blueprint on as many clusters as you require and query/generate and aggregate NSA and CIS compliance reports.