ksoc-plugins

by RAD Security

Helm chartv1.9.10Verified publisher

A Helm chart to run the KSOC plugins

About this chart

RAD Security Plugins

Introduction

This chart deploys the following plugins required for the RAD Security platform(former KSOC):

  • ksoc-sync
  • ksoc-watch
  • ksoc-sbom
  • ksoc-guard
  • ksoc-node-agent

These plugins perform several different tasks, which will be explained below.

ksoc-sync plugin

ksoc-sync is the plugin component synchronising Kubernetes resources to the customer cluster. Currently, only the GuardPolicy CRD is supported, but the mechanism is extensible and allows RAD Security to sync different resource types in the future. The plugin fetches resources from the RAD Security API. After executing them on the customer's cluster, the execution statuses are reported to the RAD Security API via HTTP calls. By default, the interval between the fetches is 60 seconds.

ksoc-watch plugin

ksoc-watch is the plugin component responsible for syncing cluster state back to RAD Security. On startup, a controller is created that follows the Kubernetes Informer pattern via the SharedIndexInformer to target the resource types that we are interested in individually. The first action of the service is to upload the entire inventory of the cluster. Once this inventory is up-to-date, the plugin tracks events only generated when we detect a change in the object (or resource) state. In this way, we can avoid the degradation of the API server, which would occur if we were to poll for resources. Automatic reconciliation is run every 24h by default in case any delete events are lost and prevent RAD Security from keeping track of stale objects.

ksoc-sbom plugin

ksoc-sbom is the plugin responsible for calculating SBOMs directly on the customer cluster. The plugin is run as an admission/mutating webhook, adding an image digest next to its tag if it's missing. This mutation is performed so TOCTOU does not impact the user. The image deployed is the image that RAD Security scanned. It sees all new workloads and calculates SBOMs for them. It continuously checks the RAD Security API to save time and resources to see if the SBOM is already known for any particular image digest. If not, it is being calculated and uploaded to RAD Security for further processing. By default we use cyclonedx-json format for SBOMs, but it can be changed to spdx-json or syft-json by setting the SBOM_FORMAT environment variable in the values.yaml file. To prevent the plugin from mutating the Pod resource, set the MUTATE_IMAGE and MUTATE_ANNOTATIONS environment variables to false. If observe a performance degradation while deploying new workloads, you can improve it significantly by disabling the mutation of the image tag and annotations.

ksocSbom:
  env:
    SBOM_FORMAT: cyclonedx-json
    MUTATE_IMAGE: true
    MUTATE_ANNOTATIONS: false

ksoc-guard plugin

ksoc-guard is the plugin responsible for executing GuardPolicy (in the form of Rego) against a specific set of Kubernetes resources during their admission to the cluster, either allowing the admission or denying it. The configuration for the blocking logic can be found in the ksocGuard section of the helm chart values file; see below.

ksocGuard:
  config:
    BLOCK_ON_POLICY_VIOLATION: true

If admission is blocked, it can be seen in the RAD Security application under the Events tab for the specific cluster. Finally, the plugin also acts as a mutating webhook that simply takes the AdmissionReview.UID and adds it as an annotation (ksoc-guard/admission: xxx). In the case of a blocked object, this gives RAD Security an identifier to track what would otherwise be an ephemeral event.

ksoc-node-agent plugin

ksoc-node-agent is the plugin responsible for gathering runtime information from the nodes in the cluster. The plugin is not enabled by default. To enable the plugin, set the enabled value to true in your values file.

ksocNodeAgent:
  enabled: true

When ksoc-node-agent is enabled an additional daemonset can be seen in the cluster. The daemonset is responsible for collecting runtime information from the nodes in the cluster. The information collected includes the following:

  • Process information
  • Network information
  • Filesystem information
  • Container information

By default the plugin uses containerd as a container runtime. If you are using docker or crio-o as your container runtime, you can enable it by configuring collectors in the values.yaml file.

ksocNodeAgent:
  enabled: true
  agent:
    collectors:
      containerd:
        enabled: true
        socket: /run/containerd/containerd.sock
      crio:
        enabled: false
        socket: /run/crio/crio.sock
      docker:
        enabled: false
        socket: /run/docker.sock

Each plugin pod contains agent and exporter containers. The agent container is responsible for collecting runtime information from the nodes in the cluster. The exporter container is responsible for exporting the collected information to the RAD Security platform.

The information collected is sent to the RAD Security platform for further processing. For more information on the ksoc-node-agent plugin, please see the RAD Security Runtime documentation

k9 plugin

k9 is a plugin that responds in-cluster to commands from the Rad Security platform. The plugin will poll the Rad Security backend, and does not require any ingress to the cluster. The plugin is not enabled by default. Individual capabilities must be opted-into by the user, and the plugin will only respond to commands that are explicitly enabled. To enable a capability, please enable the plugin with enabled: true and set the capabilities you wish to enable to true in your values file.

k9:
  enabled: true
  capabilities:
    enableTerminatePod: true
    enableTerminateNamespace: true
    enableQuarantine: true
    enableGetLogs: true
    enableLabelPod: true

Terminate Pod: Allows the plugin to terminate a pod in the cluster. Terminate Namespace: Allows the plugin to terminate a namespace in the cluster. Quarantine: Allows the plugin to quarantine a pod in the cluster via a NetworkPolicy to prevent it from communicating over the network. Get Logs: Allows the plugin to retrieve logs from a pod in the cluster. Label Pod: Allows the plugin to label a pod in the cluster.

Prerequisites

The remainder of this page assumes the following:

  • An Account in RAD Security already exists
  • The user has obtained the base64AccessKey and base64SecretKey values required for the installation via the UI or the API
  • The user has kubectl installed
  • The user has Helm v3 installed
  • The user has kubectl admin access to the cluster
  • The KSOC pods have outbound port 443 access to https://api.ksoc.com

Installing the Chart

1. Install cert-manager

cert-manager must be installed, as RAD Security deploys Admission Controllers that create certificates to secure their communication with the Kubernetes API. At present RAD Security only supports cert-manager as the means of creating these certificates.

You can check if cert-manager is installed using the command below:

kubectl get pods -A | grep cert-manager

If the command above returns no results, you must install cert-manager into your cluster using the following commands:

NOTE: It may take up to 2 minutes for the helm installcommand below to complete.

helm repo add jetstack https://charts.jetstack.io
helm repo update

helm install \
  cert-manager jetstack/cert-manager \
  --namespace cert-manager \
  --create-namespace \
  --version v1.14.0 \
  --set installCRDs=true

A full list of available Helm values is oncert-manager's ArtifactHub page.

2. Verify cert-manager installation

Now we have installed cert-manager, we need to validate that it is running successfully. This can be achieved using the command below:

kubectl get pods -n cert-manager

You should see the following pods (with slightly different generated IDs at the end) with a status of Running:

NAME                                     	 READY   STATUS	RESTARTS   AGE
cert-manager-7dc9d6599-5fj6g             	 1/1 	   Running   0      	1m
cert-manager-cainjector-757dd96b8b-hlqgp 	 1/1 	   Running   0      	1m
cert-manager-webhook-854656c6ff-b4zqp    	 1/1 	   Running   0      	1m

3. Configure RAD Security helm repository

To install the RAD Security plugins Helm chart, we need to configure access to the KSOC helm repository using the commands below:

helm repo add ksoc https://charts.ksoc.com/stable
helm repo update

If you already had RAD Security's Helm chart installed, it is recommended to update it.

helm repo update ksoc

Verify the RAD Security plugins Helm chart has been installed:

helm search repo ksoc

Example output (chart version may differ):

helm search repo ksoc
NAME                     	CHART VERSION	APP VERSION	DESCRIPTION
ksoc/ksoc-plugins        	1.6.3        	           	A Helm chart to run the KSOC plugins

4. Create cluster-specific values file

Next, we need to create a values file called values.yaml with the following content that includes the base64AccessKeyId and base64SecretKey:

ksoc:
  base64AccessKeyId: "YOURACCESSKEYID"
  base64SecretKey: "YOURSECRETKEY"
  clusterName: "please add a name here"

You can manually create the file or use values.yaml file downloaded from the RAD Security UI.

NOTE: Be sure to set the clusterName value with a descriptive name of the cluster where you will be installing RAD Security.

4.1 Recommended installation

By default, a secret is created as part of our Helm chart, which we use to securely connect to RAD Security. However, it is highly recommended that this secret is created outside of the helm installation and is just referenced in the Helm values.

The structure of the secret is as follows:

apiVersion: v1
kind: Secret
metadata:
  name: ksoc-access-key
  namespace: ksoc
data:
  access-key-id: "YOURACCESSKEYID"
  secret-key: "YOURSECRETKEY"

The secret can now be referenced in the Helm chart using the following values.yaml configuration:

ksoc:
  clusterName: "please add a name here"
  accessKeySecretNameOverride: "ksoc-access-key"

RAD Security ksoc-guard plugin integrates with the Kubernetes admission controller. All admission controller communications require TLS. RAD Security Helm chart installs and ksoc-guard utilizes Let’s Encrypt to automate the issuance and renewal of certificates using the cert-manager add-on.

4.2 AWS Secret Manager

If you are using AWS Secret Manager to store your access key, you can use the awsSecretId parameter to specify the secret ID. Secret ID could be the name of the secret or the full ARN. The service accounts need to have access to the secret in AWS, via IRSA or EKS Pod Identity. There is no need to provide base64AccessKeyId and base64SecretKey in this case.

ksoc:
  awsSecretId: "arn:aws:secretsmanager:us-west-2:123456789012:secret:my-secret

Format of the secret in AWS Secret Manager:

{
  "access-key-id": "value copied from the RAD Security UI, decoded from base64",
  "secret-key": "value copied from the RAD Security UI, decoded from base64"
}

If IRSA is used, following serviceAccountAnnotations should be added to the values.yaml file:

ksocGuard:
  serviceAccountAnnotations:
    eks.amazonaws.com/role-arn: arn:aws:iam::123456789012:role/role-name-which-can-read-secrets
ksocSbom:
  serviceAccountAnnotations:
    eks.amazonaws.com/role-arn: arn:aws:iam::123456789012:role/role-name-which-can-read-secrets
ksocSync:
  serviceAccountAnnotations:
    eks.amazonaws.com/role-arn: arn:aws:iam::123456789012:role/role-name-which-can-read-secrets
ksocWatch:
  serviceAccountAnnotations:
    eks.amazonaws.com/role-arn: arn:aws:iam::123456789012:role/role-name-which-can-read-secrets
k9:
  enabled: true
  serviceAccountAnnotations:
    eks.amazonaws.com/role-arn: arn:aws:iam::123456789012:role/role-name-which-can-read-secrets
ksocNodeAgent:
  enabled: true
  serviceAccountAnnotations:
    eks.amazonaws.com/role-arn: arn:aws:iam::123456789012:role/role-name-which-can-read-secrets

5. Installing the KSOC plugins

Finally, you can install ksoc-plugins using the following command:

NOTE: It may take up to 2 minutes for the helm installcommand below to complete.

helm install \
  ksoc ksoc/ksoc-plugins \
  --namespace ksoc \
  --create-namespace \
  -f values.yaml

6. Verify KSOC plugins

Now we have installed the KSOC plugins, we need to validate that it is running successfully. This can be achieved using the command below:

kubectl get pods -n ksoc

You should expect to see the following pods in a state of Running:

NAME                            READY   STATUS    RESTARTS   AGE
ksoc-guard-86959f7544-96hbl     1/1     Running   0          1m
ksoc-sbom-664bf566dc-bxm5c      1/1     Running   0          1m
ksoc-sync-769cd7c6fc-cxczq      1/1     Running   0          1m
ksoc-watch-7bf4d7b6b9-kqblh     1/1     Running   0          1m

If you have enabled the ksoc-node-agent plugin you should also see the following pods in a state of Running:

NAME                   

Deploy ksoc-plugins with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has ksoc-plugins on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartksoc-plugins is pinned at v1.9.10 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply