k8s-metacollector

by Helm

Helm chartv0.3.3App 0.1.5

Install k8s-metacollector to fetch and distribute Kubernetes metadata to Falco instances.

About this chart

k8s-metacollector

k8s-metacollector is a self-contained module that can be deployed within a Kubernetes cluster to perform the task of gathering metadata from various Kubernetes resources and subsequently transmitting this collected metadata to designated subscribers.

Introduction

This chart installs the k8s-metacollector in a kubernetes cluster. The main application will be deployed as Kubernetes deployment with replica count equal to 1. In order for the application to work correctly the following resources will be created:

  • ServiceAccount;
  • ClusterRole;
  • ClusterRoleBinding;
  • Service;
  • ServiceMonitor (optional);

Note: Incrementing the number of replicas is not recommended. The k8s-metacollector does not implement memory sharding techniques. Furthermore, events are distributed over gRPC using streams which does not work well with load balancing mechanisms implemented by Kubernetes.

Adding falcosecurity repository

Before installing the chart, add the falcosecurity charts repository:

helm repo add falcosecurity https://falcosecurity.github.io/charts
helm repo update

Installing the Chart

To install the chart with default values and release name k8s-metacollector run:

helm install k8s-metacollector falcosecurity/k8s-metacollector --namespace metacollector --create-namespace

After a few seconds, k8s-metacollector should be running in the metacollector namespace.

Enabling ServiceMonitor

Assuming that Prometheus scrapes only the ServiceMonitors that present a release label the following command will install and label the ServiceMonitor:

helm install k8s-metacollector falcosecurity/k8s-metacollector \
    --create-namespace \
    --namespace metacollector \
    --set serviceMonitor.create=true \
    --set serviceMonitor.labels.release="kube-prometheus-stack"

Deploying the Grafana Dashboard

By setting grafana.dashboards.enabled=true the k8s-metacollector's grafana dashboard is deployed in the cluster using a configmap. Based in Grafana's configuration, the configmap could be scraped by Grafana dashboard sidecar. The following command will deploy the k8s-metacollector + serviceMonitor + grafana dashboard:

helm install k8s-metacollector falcosecurity/k8s-metacollector \
    --create-namespace \
    --namespace metacollector \
    --set serviceMonitor.create=true \
    --set serviceMonitor.labels.release="kube-prometheus-stack" \
    --set grafana.dashboards.enabled=true

Uninstalling the Chart

To uninstall the k8s-metacollector release in namespace metacollector:

helm uninstall k8s-metacollector --namespace metacollector

The command removes all the Kubernetes resources associated with the chart and deletes the release.

Configuration

The following table lists the main configurable parameters of the k8s-metacollector chart v0.3.3 and their default values. See values.yaml for full list.

Values

KeyTypeDefaultDescription
affinityobject{}affinity allows pod placement based on node characteristics, or any other custom labels assigned to nodes.
containerSecurityContextobject{"capabilities":{"drop":["ALL"]}}containerSecurityContext holds the security settings for the container.
containerSecurityContext.capabilitiesobject{"drop":["ALL"]}capabilities fine-grained privileges that can be assigned to processes.
containerSecurityContext.capabilities.droplist["ALL"]drop drops the given set of privileges.
fullnameOverridestring""fullNameOverride same as nameOverride but for the full name.
grafanaobject{"dashboards":{"configMaps":{"collector":{"folder":"","folderAnnotation":"grafana_dashboard_folder","name":"k8s-metacollector-grafana-dashboard","namespace":""}},"enabled":false}}grafana contains the configuration related to grafana.
grafana.dashboardsobject{"configMaps":{"collector":{"folder":"","folderAnnotation":"grafana_dashboard_folder","name":"k8s-metacollector-grafana-dashboard","namespace":""}},"enabled":false}dashboards contains configuration for grafana dashboards.
grafana.dashboards.configMapsobject{"collector":{"folder":"","folderAnnotation":"grafana_dashboard_folder","name":"k8s-metacollector-grafana-dashboard","namespace":""}}configmaps to be deployed that contain a grafana dashboard.
grafana.dashboards.configMaps.collectorobject{"folder":"","folderAnnotation":"grafana_dashboard_folder","name":"k8s-metacollector-grafana-dashboard","namespace":""}collector contains the configuration for collector's dashboard.
grafana.dashboards.configMaps.collector.folderstring""folder where the dashboard is stored by grafana.
grafana.dashboards.configMaps.collector.folderAnnotationstring"grafana_dashboard_folder"annotation used by grafana
grafana.dashboards.configMaps.collector.namestring"k8s-metacollector-grafana-dashboard"name specifies the name for the configmap.
grafana.dashboards.configMaps.collector.namespacestring""namespace specifies the namespace for the configmap.
grafana.dashboards.enabledboolfalseenabled specifies whether the dashboards should be deployed.
healthChecksobject{"livenessProbe":{"httpGet":{"path":"/healthz","port":8081},"initialDelaySeconds":45,"periodSeconds":15,"timeoutSeconds":5},"readinessProbe":{"httpGet":{"path":"/readyz","port":8081},"initialDelaySeconds":30,"periodSeconds":15,"timeoutSeconds":5}}healthChecks contains the configuration for liveness and readiness probes.
healthChecks.livenessProbeobject{"httpGet":{"path":"/healthz","port":8081},"initialDelaySeconds":45,"periodSeconds":15,"timeoutSeconds":5}livenessProbe is a diagnostic mechanism used to determine wether a container within a Pod is still running and healthy.
healthChecks.livenessProbe.httpGetobject{"path":"/healthz","port":8081}httpGet specifies that the liveness probe will make an HTTP GET request to check the health of the container.
healthChecks.livenessProbe.httpGet.pathstring"/healthz"path is the specific endpoint on which the HTTP GET request will be made.
healthChecks.livenessProbe.httpGet.portint8081port is the port on which the container exposes the "/healthz" endpoint.
healthChecks.livenessProbe.initialDelaySecondsint45initialDelaySeconds tells the kubelet that it should wait X seconds before performing the first probe.
healthChecks.livenessProbe.periodSecondsint15periodSeconds specifies the interval at which the liveness probe will be repeated.
healthChecks.livenessProbe.timeoutSecondsint5timeoutSeconds is the number of seconds after which the probe times out.
healthChecks.readinessProbeobject{"httpGet":{"path":"/readyz","port":8081},"initialDelaySeconds":30,"periodSeconds":15,"timeoutSeconds":5}readinessProbe is a mechanism used to determine whether a container within a Pod is ready to serve traffic.
healthChecks.readinessProbe.httpGetobject{"path":"/readyz","port":8081}httpGet specifies that the readiness probe will make an HTTP GET request to check whether the container is ready.
healthChecks.readinessProbe.httpGet.pathstring"/readyz"path is the specific endpoint on which the HTTP GET request will be made.
healthChecks.readinessProbe.httpGet.portint8081port is the port on which the container exposes the "/readyz" endpoint.
healthChecks.readinessProbe.initialDelaySecondsint30initialDelaySeconds tells the kubelet that it should wait X seconds before performing the first probe.
healthChecks.readinessProbe.periodSecondsint15periodSeconds specifies the interval at which the readiness probe will be repeated.
healthChecks.readinessProbe.timeoutSecondsint5timeoutSeconds is the number of seconds after which the probe times out.
imageobject{"pullPolicy":"IfNotPresent","pullSecrets":[],"registry":"docker.io","repository":"falcosecurity/k8s-metacollector","tag":""}image is the configuration for the k8s-metacollector image.
image.pullPolicystring"IfNotPresent"pullPolicy is the policy used to determine when a node should attempt to pull the container image.
image.pullSecretslist[]pullSecects a list of secrets containing credentials used when pulling from private/secure registries.
image.registrystring"docker.io"registry is the image registry to pull from.
image.repositorystring"falcosecurity/k8s-metacollector"repository is the image repository to pull from
image.tagstring""tag is image tag to pull. Overrides the image tag whose default is the chart appVersion.
nameOverridestring""nameOverride is the new name used to override the release name used for k8s-metacollector components.
namespaceOverridestring""namespaceOverride overrides the deployment namespace. It's useful for multi-namespace deployments in combined charts.
nodeSelectorobject{}nodeSelector specifies a set of key-value pairs that must match labels assigned to nodes for the Pod to be eligible for scheduling on that node.
podAnnotationsobject{}podAnnotations are custom annotations to be added to the pod.
podLabelsobject{}podLabels are labels to be added to the pod.
podSecurityContextobject{"fsGroup":1000,"runAsGroup":1000,"runAsNonRoot":true,"runAsUser":1000}These settings are override by the ones specified for the container when there is overlap.
podSecurityContext.fsGroupint1000fsGroup specifies the group ID (GID) that should be used for the volume mounted within a Pod.
podSecurityContext.runAsGroupint1000runAsGroup specifies the group ID (GID) that the containers inside the pod should run as.
podSecurityContext.runAsNonRootbooltruerunAsNonRoot when set to true enforces that the specified container runs as a non-root user.
podSecurityContext.runAsUserint1000runAsUser specifies the user ID (UID) that the containers inside the pod should run as.
replicaCountint1replicaCount is the number of identical copies of the k8s-metacollector.
resourcesobject{}resources defines the computing resources (CPU and memory) that are allocated to the containers running within the Pod.
serviceobject{"create":true,"ports":{"broker-grpc":{"port":45000,"protocol":"TCP","targetPort":"broker-grpc"},"health-probe":{"port":8081,"protocol":"TCP","targetPort":"health-probe"},"metrics":{"port":8080,"protocol":"TCP","targetPort":"metrics"}},"type":"ClusterIP"}service exposes the k8s-metacollector services to be accessed from within the cluster. ref: https://kubernetes.io/docs/concepts/services-networking/service/
service.createbooltrueenabled specifies whether a service should be created.
service.portsobject{"broker-grpc":{"port":45000,"protocol":"TCP","targetPort":"broker-grpc"},"health-probe":{"port":8081,"protocol":"TCP","targetPort":"health-probe"},"metrics":{"port":8080,"protocol":"TCP","targetPort":"metrics"}}ports denotes all the ports on which the Service will listen.
service.ports.broker-grpcobject{"port":45000,"protocol":"TCP","targetPort":"broker-grpc"}broker-grpc denotes a listening service named "grpc-broker"
service.ports.broker-grpc.portint45000port is the port on which the Service will listen.
service.ports.broker-grpc.protocolstring"TCP"protocol specifies the network protocol that the Service should use for the associated port.
service.ports.broker-grpc.targetPortstring"broker-grpc"targetPort is the port on which the Pod is listening.
service.ports.health-probeobject{"port":8081,"protocol":"TCP","targetPort":"health-probe"}health-probe denotes a listening service named "health-probe"
service.ports.health-probe.portint8081port is the port on which the Service will listen.
service.ports.health-probe.protocolstring"TCP"protocol specifies the network protocol that the Service should use for the associated port.
service.ports.health-probe.targetPortstring"health-probe"targetPort is the port on which the Pod is listening.
service.ports.metricsobject{"port":8080,"protocol":"TCP","targetPort":"metrics"}metrics denotes a listening service named "metrics".
service.ports.metrics.portint8080port is the port on which the Service will listen.
service.ports.metrics.protocolstring"TCP"protocol specifies the network protocol that the Service should use for the associated port.
service.ports.metrics.targetPortstring"metrics"targetPort is the port on which the Pod is listening.
service.typestring"ClusterIP"type denotes the service type. Setting it to "ClusterIP" we ensure that are accessible from within the cluster.
serviceAccountobject{"annotations":{},"create":true,"name":""}serviceAccount is the configuration for the service account.
serviceAccount.annotationsobject{}annotations to add to the service account.
serviceAccount.createbooltruecreate specifies whether a service account should be created.
serviceAccount.namestring""If not set and create is true, a name is generated using the full name template.
serviceMonitorobject{"create":false,"interval":"15s","labels":{},"path":"/metrics","relabelings":[],"scheme":"http","scrapeTimeout":"10s","targetLabels":[],"tlsConfig":{}}serviceMonitor holds th

Deploy k8s-metacollector with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has k8s-metacollector 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 chartk8s-metacollector is pinned at v0.3.3 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