kubescape-prometheus-integrator
by Kubescape
Kubescape integration with Prometheus
About this chart
Kubescape-Prometheus Integration
Docs
Most of the end users either use kube-prometheus-stack prometheus operator else prometheus helm chart to install prometheus for monitoring. Based on your choice of prometheus, you can follow either of the below method to enable kubescape monitoring with Prometheus.
Kubescape integration with Kube-Prometheus-stack (Prometheus operator):
- Install the
kube-prometheus-stackHelm Chart
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
kubectl create namespace prometheus
helm install -n prometheus kube-prometheus-stack prometheus-community/kube-prometheus-stack --set prometheus.prometheusSpec.podMonitorSelectorNilUsesHelmValues=false,prometheus.prometheusSpec.serviceMonitorSelectorNilUsesHelmValues=false
- Install the
kubescape-prometheus-integratorHelm Chart
helm repo add kubescape https://kubescape.github.io/helm-charts/
helm repo update
helm upgrade --install kubescape-prometheus kubescape/kubescape-prometheus-integrator -n kubescape-prometheus --create-namespace
Kubescape integration with Prometheus community helm chart:
- Install the
prometheus-communityHelm Chart
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
kubectl create namespace prometheus
helm install -n prometheus prometheus prometheus-community/prometheus
- Install the
kubescape-prometheus-integratorHelm Chart with podAnnotations enabled
helm repo add kubescape https://kubescape.github.io/helm-charts/
helm repo update
helm upgrade --install kubescape-prometheus kubescape/kubescape-prometheus-integrator -n kubescape-prometheus --set kubescape.prometheusAnnotation.enabled=True --create-namespace
Kubescape
- Resource Kind:
Deployment - Communication: REST API
- Responsibility: Runs Kubescape for detecting misconfigurations in the cluster; This is microservice uses the same engine as the Kubescape CLI tool.
Component Diagram
graph TB
subgraph Cluster
pr(Prometheus)
ks(Kubescape)
k8sApi(Kubernetes API)
end
pr -->|Start Scan| ks
ks -->|Collect Cluster Info|k8sApi
ks -->|Scan results| pr
classDef k8s fill:#326ce5,stroke:#fff,stroke-width:1px,color:#fff;
classDef plain fill:#ddd,stroke:#fff,stroke-width:1px,color:#000
class k8sApi k8s
class pr plain
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 ;)
Chart support
Values
| Key | Type | Default | Description |
|---|---|---|---|
| kubescape.affinity | object | {} | Assign custom affinity rules to the deployment |
| kubescape.downloadArtifacts | bool | false | download 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.enableHostScan | bool | false | enable host scanner feature |
| kubescape.enabled | bool | true | enable/disable kubescape scanning |
| kubescape.image.repository | string | "quay.io/kubescape/kubescape" | source code (public repo) |
| kubescape.nodeSelector | object | {} | Node selector |
| kubescape.serviceMonitor.enabled | bool | true | enable/disable service monitor for prometheus (operator) integration |
| kubescape.serviceMonitor.interval | string | 20m | Scrape interval |
| kubescape.serviceMonitor.scrapeTimeout | string | 100s | Adjust to avoid timeout |
| kubescape.prometheusAnnotation.enabled | bool | false | add/remove pod annotation for prometheus (non-operator) integration |
| kubescape.volumes | object | [] | Additional volumes for Kubescape |
| kubescape.volumeMounts | object | [] | Additional volumeMounts for Kubescape |
| kubescape.includeNamespaces | object | [] | List of namespaces to include, rest of the namespaces will be ignored. |
| kubescape.excludeNamespaces | object | [] | List of namespaces to exclude |
| kubescapeHostScanner.volumes | object | [] | Additional volumes for the host scanner |
| kubescapeHostScanner.volumeMounts | object | [] | Additional volumeMounts for the host scanner |
| awsIamRoleArn | string | nil | AWS IAM arn role |
| cloudProviderMetadata.cloudRegion | string | nil | cloud region |
| cloudProviderMetadata.cloudProviderEngine | string | nil | cloud provider engine |
| cloudProviderMetadata.gkeProject | string | nil | GKE project |
| cloudProviderMetadata.gkeServiceAccount | string | nil | GKE service account |
| cloudProviderMetadata.aksSubscriptionID | string | nil | AKS subscription ID |
| cloudProviderMetadata.aksResourceGroup | string | nil | AKS resource group |
| volumes | object | [] | Additional volumes for all containers |
| volumeMounts | object | [] | Additional volumeMounts for all containers |
Deploy kubescape-prometheus-integrator with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has kubescape-prometheus-integrator 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.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartkubescape-prometheus-integrator is pinned at v0.0.13 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- 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