kubescape-cloud-operator

by Kubescape

Helm chartv1.14.5App 1.14.5

Kubescape is an E2E Kubernetes cluster security platform

About this chart

Kubescape Operator

Docs

Installing Kubescape Operator in a Kubernetes cluster using Helm:

  1. Add the Kubescape Helm Repo
helm repo add kubescape https://kubescape.github.io/helm-charts/
  1. Update helm repo
helm repo update
  1. Install the Helm Chart, use your account ID and give your cluster a name

if you ran kubescape cli tool and submitted, you can get your Account ID from the local cache:

kubescape config view | grep -i accountID

Otherwise, get the account ID from the kubescape SaaS

Run the install command:

helm upgrade --install kubescape kubescape/kubescape-cloud-operator -n kubescape --create-namespace --set account=<my_account_ID> --set clusterName=`kubectl config current-context` 

Add --set clientID=<generated client id> --set secretKey=<generated secret key> if you have generated an auth key

Add --set kubescape.serviceMonitor.enabled=true for installing the Prometheus service monitor, read more about Prometheus integration

Removing old version of Kubescape helm chart

To avoid collisions, if are running an older versions (>=1.7.18), you should run the following command: helm uninstall armo -n armo-system

Adjusting Resource Usage for Your Cluster

By default, Kubescape is configured for small- to medium-sized clusters. If you have a larger cluster and you experience slowdowns or see Kubernetes evicting components, please revise the amount of resources allocated for the troubled component.

Taking Kubescape for example, we found that our defaults of 500 MiB of memory and 500m CPU work well for clusters up to 1250 total resources. If you have more total resources or experience resource pressure already, first check out how many resources are in your cluster by running the following command:

kubectl get all -A --no-headers | wc -l

The command should print an approximate count of resources in your cluster. Then, based on the number you see, allocate 100 MiB of memory for every 200 resources in your cluster over the count of 1250, but no less than 128 MiB total. The formula for memory is as follows:

MemoryLimit := max(128, 0.4 * YOUR_AMOUNT_OF_RESOURCES)

For example, if your cluster has 500 resources, a sensible memory limit would be:

kubescape:
  resources:
    limits:
      memory: 200Mi  # max(128, 0.4 * 500) == 200

If your cluster has 50 resources, we still recommend allocating at least 128 MiB of memory.

When it comes to CPU, the more you allocate, the faster Kubescape will scan your cluster. This is especially true for clusters that have a large amount of resources. However, we recommend that you give Kubescape no less than 500m CPU no matter the size of your cluster so it can scan a relatively large amount of resources fast ;)

Setting up Telemetry

Several or our in-cluster components implement telemetry data using OpenTelemetry (otel). You can optionally install an otel collector to your cluster to aggregate all metrics and send them to your own tracing tool.

You simply have to fill in these information before installing kubescape operator:

otelCollector:
  enabled: true
  endpoint:
    host: <ip or dns for your gRPC otel endpoint>
    port: 4317
    insecure: <whether your otel endpoint requires ssl>
    headers: <optional - map of headers required by tracing tool>

If you don't have an otel distribution, we suggest you try either Uptrace or SigNoz as they are free, opensource and can be quickly deployed using docker-compose.

Host metrics collection

The OpenTelemetry collector is configured with the hostmetrics receiver to collect CPU and memory utilization metrics.

Note that the hostmetrics receiver is disabled by default. If you wish to enable it, simply install the operator with --set otelCollector.hostmetrics.enabled=true

Example: exporting to uptrace running inside docker-compose

flowchart LR
    subgraph kubernetes
    A(kubescape) --> B(otel collector)
    D(operator) --> B
    E(host-scanner) --> B
    F(kubevuln) --> B
    end
    subgraph docker-compose
    B --> C(uptrace)
    end
  1. Download the example using Git:
git clone https://github.com/uptrace/uptrace.git
cd uptrace/example/docker
  1. Start the services using Docker:
docker-compose pull
docker-compose up -d
  1. Make sure Uptrace is running:
docker-compose logs uptrace
  1. Follow the instructions above, add the OTEL collector configuration and install the operator as follows:
--set otelCollector.enabled=true --set otelCollector.endpoint.host=<collector host> --set otelCollector.endpoint.port=14317 --set otelCollector.endpoint.insecure=false
  1. Open Uptrace UI at http://localhost:14318/overview/2

Chart support

Values

KeyTypeDefaultDescription
global.networkPolicy.enabledboolfalseCreate NetworkPolicies for all components
global.networkPolicy.createEgressRulesboolfalseCreate common Egress rules for NetworkPolicies
global.kubescapePsp.enabledboolfalseEnable all privileges in Pod Security Policies for Kubescape namespace
global.httpsProxystring""Set https egress proxy for all components. Must supply also port.
global.proxySecretFilestring""Set proxy certificate / RootCA for all components to be used for proxy configured in global.httpsProxy
kollector.affinityobject{}Assign custom affinity rules to the StatefulSet
kollector.enabledbooltrueenable/disable the kollector
kollector.env[0]object{"name":"PRINT_REPORT","value":"false"}print in verbose mode (print all reported data)
kollector.image.repositorystring"quay.io/kubescape/kollector"source code
kollector.nodeSelectorobject{}Node selector
kollector.volumesobject[]Additional volumes for the collector
kollector.volumeMountsobject[]Additional volumeMounts for the collector
kubescape.affinityobject{}Assign custom affinity rules to the deployment
kubescape.downloadArtifactsbooltruedownload policies every scan, we recommend it should remain true, you should change to 'false' when running in an air-gapped environment or when scanning with high frequency (when running with Prometheus)
kubescape.enableHostScanbooltrueenable host scanner feature
kubescape.enabledbooltrueenable/disable kubescape scanning
kubescape.image.repositorystring"quay.io/kubescape/kubescape"source code (public repo)
kubescape.nodeSelectorobject{}Node selector
kubescape.serviceMonitor.enabledboolfalseenable/disable service monitor for prometheus (operator) integration
kubescape.skipUpdateCheckboolfalseskip check for a newer version
kubescape.submitbooltruesubmit results to Kubescape SaaS: https://cloud.armosec.io/
kubescape.urls.reportstring""override the default cloud report URL
kubescape.urls.apistring""override the default cloud API URL
kubescape.urls.uistring""override the default cloud UI URL
kubescape.urls.authstring""override the default cloud authentication URL
kubescape.volumesobject[]Additional volumes for Kubescape
kubescape.volumeMountsobject[]Additional volumeMounts for Kubescape
kubescapeScheduler.enabledbooltrueenable/disable a kubescape scheduled scan using a CronJob
kubescapeScheduler.image.repositorystring"quay.io/kubescape/http_request"source code (public repo)
kubescapeScheduler.scanSchedulestring"0 0 * * *"scan schedule frequency
kubescapeScheduler.volumesobject[]Additional volumes for scan scheduler
kubescapeScheduler.volumeMountsobject[]Additional volumeMounts for scan scheduler
gateway.affinityobject{}Assign custom affinity rules to the deployment
gateway.enabledbooltrueenable/disable passing notifications from Kubescape SaaS to the Operator microservice. The notifications are the onDemand scanning and the scanning schedule settings
gateway.image.repositorystring"quay.io/kubescape/gateway"source code
gateway.nodeSelectorobject{}Node selector
gateway.volumesobject[]Additional volumes for the notification service
gateway.volumeMountsobject[]Additional volumeMounts for the notification service
kubevuln.affinityobject{}Assign custom affinity rules to the deployment
kubevuln.enabledbooltrueenable/disable image vulnerability scanning
kubevuln.image.repositorystring"quay.io/kubescape/kubevuln"source code
kubevuln.nodeSelectorobject{}Node selector
kubevuln.volumesobject[]Additional volumes for the image vulnerability scanning
kubevuln.volumeMountsobject[]Additional volumeMounts for the image vulnerability scanning
kubevulnScheduler.enabledbooltrueenable/disable a image vulnerability scheduled scan using a CronJob
kubevulnScheduler.image.repositorystring"quay.io/kubescape/http_request"source code (public repo)
kubevulnScheduler.scanSchedulestring"0 0 * * *"scan schedule frequency
kubevulnScheduler.volumesobject[]Additional volumes for scan scheduler
kubevulnScheduler.volumeMountsobject[]Additional volumeMounts for scan scheduler
operator.affinityobject{}Assign custom affinity rules to the deployment
operator.enabledbooltrueenable/disable kubescape and image vulnerability scanning
operator.image.repositorystring"quay.io/kubescape/operator"source code
operator.nodeSelectorobject{}Node selector
operator.volumesobject[]Additional volumes for the web socket
operator.volumeMountsobject[]Additional volumeMounts for the web socket
hostScanner.volumesobject[]Additional volumes for the host scanner
hostScanner.volumeMountsobject[]Additional volumeMounts for the host scanner
awsIamRoleArnstringnilAWS IAM arn role
clientIDstring""client ID, read more
addRevisionLabelbooltrueAdd revision label to the components. This will insure the components will restart when updating the helm
cloudProviderMetadata.cloudRegionstringnilcloud region
cloudProviderMetadata.gkeProjectstringnilGKE project
cloudProviderMetadata.gkeServiceAccountstringnilGKE service account
cloudProviderMetadata.aksSubscriptionIDstringnilAKS subscription ID
cloudProviderMetadata.aksResourceGroupstringnilAKS resource group
secretKeystring""secret key, read more
triggerNewImageScanboolfalseenable/disable trigger image scan for new images
volumesobject[]Additional volumes for all containers
volumeMountsobject[]Additional volumeMounts for all containers

In-cluster components overview

An overview of each in-cluster component which is part of the Kubescape platform helm chart. Follow the repository link for in-depth information on a specific component.


High-level Architecture Diagram

graph TB

  client([client]) .-> dashboard
  masterGw  .- gw

  subgraph Cluster
    gw(Gateway)
    operator(Operator)
    k8sApi(Kubernetes API);
    kubevuln(Kubevuln)
    ks(Kubescape)
    gw --- operator
    operator -->|scan cluster| ks
    operator -->|scan images| kubevuln
    operator --> k8sA

Deploy kubescape-cloud-operator with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has kubescape-cloud-operator 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 chartkubescape-cloud-operator is pinned at v1.14.5 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