Deploy the Kubernetes node scanner

The Rapid7 Kubernetes node scanner can be deployed as a daemonset and provides extra data and context for node-based file systems in your Kubernetes cluster. Having access to node-level information is especially important for manually-managed Kubernetes deployments that might be exposed to deployment mistakes more than a cloud provider-managed Kubernetes cluster. Deploying the node scanner is not required to enable Kubernetes Security Guardrails, but this lightweight deployment can assist with CIS benchmark compliance.

Prerequisites

Cluster deployment limitations

This scanner is relevant for standard Kubernetes clusters and has been tested on AWS’ Elastic Kubernetes Service (EKS), GCP’s Google Kubernetes Engine (GKE), and Azure Kubernetes Service (AKS). It is not, however, for clusters with fully-managed infrastructure, such as AWS’ EKS Fargate and GKE Autopilot.

Node scanner file

Install the node scanner

Cluster Administrator Required

Due to its required permissions, the installation needs to be performed locally on each cluster by the cluster administrator.
  1. Verify your cluster meets the prerequisites.

  2. If your cluster uses the local scanner, add this setting to your helm command:

--set Config.HasNodeFsAccess=true
  1. Create a namespace of your choice for the node scanner. For this guide, we used r7-node-scan as an example:
kubectl create namespace r7-node-scan
  1. Create a secret to encrypt the scanner data. This secret will be used by the cluster’s configured scanner (local or remote) to decrypt and consume the scan results. Anyone with access to this secret will be able to read the scan results. Use the following command to create the secret and ensure that the openssl command is installed:
kubectl -n r7-node-scan create secret generic r7-node-scanner-key --from-literal=encKey=$(openssl rand -hex 32)
  1. After ensuring the node scanner file is available to the cluster, deploy it by applying the file using the following command:
kubectl -n r7-node-scan apply -f r7-node-scan.yaml
  1. Verify that the DaemonSet is running using the following command:
kubectl -n r7-node-scan get daemonset r7-node-scanner
Isolated Environment

The Node Scanner runs on alpine/openssl image. This image is available from Docker Hub. In isolated environments, you can replace the image with your own custom Alpine image that has pre-installed openssl.

Verify compliance with node scanner details

After the node scanner is successfully deployed, there are several Insights you can use to assess cluster compliance. Use the Ensure that r7-node-scanner is deployed Insight to see which clusters have (or do not have) the Node Scanner deployed. The CIS - Kubernetes Compliance Pack features the following Insights:

  • Ensure that the kubelet service file permissions are set to 600 or more restrictive

  • Ensure that the kubelet service file ownership is set to root:root

  • If proxy kubeconfig file exists ensure permissions are set to 600 or more restrictive

  • If proxy kubeconfig file exists ensure ownership is set to root:root

  • Ensure that the --kubeconfig kubelet.conf file permissions are set to 600 or more restrictive

  • Ensure that the --kubeconfig kubelet.conf file ownership is set to root:root

  • Ensure that the certificate authorities file permissions are set to 644 or more restrictive

  • Ensure that the client certificate authorities file ownership is set to root:root

  • Ensure that the kubelet --config configuration file has permissions set to 600 or more restrictive

  • Ensure that the kubelet --config configuration file ownership is set to root:root