kove
by cmacrae
Watch your in cluster Kubernetes manifests for OPA policy violations and export them as Prometheus metrics
About this chart
Watch your in cluster Kubernetes manifests for OPA policy violations and export them as Prometheus metrics
About
Open Policy Agent provide the fearsome-but-trustworthy gatekeeper, which allows for admission control of Kubernetes manifests being submitted to the API. This is really nice and allows administrators to control the manifests coming in as fine-grained as they please.
However, administrators may not always want to take direct action (such as denial) on manifests arriving at the API. This is where kove comes in.
It allows administrators of Kubernetes clusters to define Rego policies that they want to flag violations for by exposing a Prometheus metric.
Some example use cases include monitoring the use of deprecated APIs, unwanted docker images, or container vars containing strings like API_KEY, etc.
Administrators can craft dashboards or alerts when such conditions are observed to better expose this information to users.
kove is built on an informer model, rather than admission control - so, it works on any existing objects in your cluster, instead of evaluating them when they arrive at the API (upon create/update). This means it'll expose policy violators that may otherwise go unnoticed if they're not updated often.
Values
| Key | Type | Default | Description |
|---|---|---|---|
| clusterRole | string | "" | ClusterRole to bind the ServiceAccount to use for the Deployment. If none is set, 'view' will be used |
| config | string | see values.yaml | Application configuration. See the project README for more info |
| deployment.affinity | object | {} | Affinity configuration for the Deployment |
| deployment.annotations | object | {"prometheus.io/path":"/metrics","prometheus.io/port":"3000","prometheus.io/scrape":"true"} | Annotations for the Deployment |
| deployment.livenessProbe | object | {"enabled": true, "path": "/healthz", "failureThreshold": 3, "initialDelaySeconds": 0, "periodSeconds": 10, "successThreshold": 1, "timeoutSeconds": 1} | Liveness probe configuration for the Deployment |
| deployment.readinessProbe | object | {"enabled": false} | Readiness probe configuration for the Deployment |
| fullnameOverride | string | "" | Overrides the full name for resources created by this chart |
| image.pullPolicy | string | "IfNotPresent" | Container image pull policy |
| image.repository | string | "ghcr.io/cmacrae/kove" | Container image to use for the deployment |
| image.tag | string | "" | Container image tag. If empty, defaults to .Chart.AppVersion |
| imagePullSecrets | list | [] | If authentication is required for pulling the image from the registry, it can be provided here |
| ingress.annotations | object | {} | Annotations for the Ingress |
| ingress.enabled | bool | false | Whether to create an Ingress object |
| ingress.hosts | list | [] | Host entries for the Ingress |
| ingress.tls | list | [] | TLS configuration for the Ingress |
| nameOverride | string | "" | Overrides the short name for resources created by this chart |
| namespace | string | "default" | Namespace to deploy to |
| nodeSelector | object | {} | NodeSelector configuration for the Deployment |
| policy | string | "" | Rego policy to evaluate objects against. See the project README for more info |
| policyConfigMap | string | "" | Override the ConfigMap containing the Rego policies |
| prometheusOperator | object | see values.yaml | Configures a Prometheus Operator ServiceMonitor object |
| replicaCount | int | 1 | Number of replicas for the deployment |
| resources | object | {} | Configuration for the Deployment resources |
| service.port | int | 3000 | Configures the Service port |
| service.type | string | "ClusterIP" | Configures the Service type |
| serviceAccount | string | "" | ServiceAccount to use for the Deployment. If none is set, one will be created |
| tolerations | list | [] | Toleration configuration for the Deployment |
Metrics
| Metric | Description |
|---|---|
opa_policy_violation | Represents a Kubernetes object that violates the provided Rego expression. Includes the labels name, namespace, kind, api_version, and ruleset |
opa_policy_violations_total | Total number of policy violations observed |
opa_policy_violations_resolved_total | Total number of policy violation resolutions observed |
opa_object_evaluations_total | Total number object evaluations conducted |
Usage
ConfigMap objects containing the Rego policy/policies and the application configuration can be mounted to configure what you want to evaluate and how you want to evaluate it.
Options
| Option | Default | Description |
|---|---|---|
config | "" | Path to the config file. If not set, this will look for the file config.yaml in the current directory |
config
A YAML manifest can be provided in the following format to describe how and what you want to watch for evaluation:
namespace: default
ignoreChildren: true
regoQuery: data.pkgname.blah
policies:
- example/policies
objects:
- group: apps
version: v1
resource: deployments
- group: apps
version: v1
resource: daemonsets
- group: apps
version: v1
resource: replicasets
| Option | Default | Description |
|---|---|---|
namespace | "" | Kubernetes namespace to watch objects in. If empty or omitted, all namespaces will be observed |
ignoreChildren | false | Boolean that decides if |
Deploy kove with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has kove 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 chartkove is pinned at v0.2.0 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