Kubesense

ECS EC2 Deployment

Deploy KubeSense sensors alongside your application containers in an ECS EC2 task definition.

Prerequisites

  • AWS account with permissions for ECS, EC2, IAM, and S3
  • An existing ECS cluster with EC2 instances (with public IP allocated)
  • Your application containerized and pushed to a container registry

Setup

  1. Navigate to your existing EC2 task definition in the ECS console.
  2. Create a new revision of the task definition.
  3. Download configuration files:

Download: Download the configuration files tarball from https://docker.kubesense.ai/configs.tar. Extract and transfer the files to your EC2 instance.

  1. Add the following containers to the task definition:

KubeSensor

SettingValue
Image365639915496.dkr.ecr.us-east-1.amazonaws.com/kubesensor:1.1.0
Network ModeHost
PID ModeHost
PrivilegedYes (required for eBPF)
Health Check Port22143

Required Linux capabilities: SYS_ADMIN, SYS_RESOURCE, SYS_PTRACE, NET_ADMIN, NET_RAW, IPC_LOCK, SYSLOG

Volume mounts:

Source PathMount PathPurpose
{hostpath}/kubesensor.yaml/etc/kubesensor/kubesensor.yamlSensor configuration
/var/run/docker.sock/var/run/docker.sockContainer stats and info
/sys/kernel/debug/sys/kernel/debugeBPF instrumentation

LogSensor

SettingValue
Image365639915496.dkr.ecr.us-east-1.amazonaws.com/vector:0.43.X-debian

Volume mounts:

Source PathMount PathPurpose
{hostpath}/logsensor.yaml/etc/vector/LogSensor configuration
/var/run/docker.sock/var/run/docker.sockLog capture

Metrics Scraper

SettingValue
Image365639915496.dkr.ecr.us-east-1.amazonaws.com/vmagent:v1.101.0

Start command arguments:

-promscrape.config=/config/scrape.yml
-remoteWrite.tmpDataPath=/tmpData
-remoteWrite.maxDiskUsagePerURL=1GB
-envflag.enable=true
-envflag.prefix=VM_
-loggerFormat=json
-promscrape.dropOriginalLabels=true
-promscrape.streamParse=true
-remoteWrite.showURL=true
-remoteWrite.tlsInsecureSkipVerify=true
-remoteWrite.url=http://<METRICS_STORE_HOST>:<METRICS_STORE_PORT>/api/v1/write

info: Replace METRICS_STORE_HOST and METRICS_STORE_PORT with your server's metrics endpoint.

Volume mounts:

Source PathMount PathPurpose
{hostpath}/scrape.yaml/config/scrape.ymlScrape configuration

cAdvisor

SettingValue
Image365639915496.dkr.ecr.us-east-1.amazonaws.com/cadvisor:latest
PID ModeHost
PrivilegedYes

Volume mounts:

Source PathMount Path
//rootfs
/var/run/var/run
/sys/sys
/var/lib/docker//var/lib/docker/
/dev/disk//dev/disk/

Node Exporter

SettingValue
Image365639915496.dkr.ecr.us-east-1.amazonaws.com/node-exporter:v1.8.1
PID ModeHost
PrivilegedYes

Volume mounts:

Source PathMount PathPurpose
{hostpath}/scrape.yaml/config/scrape.ymlScrape configuration

  1. Save the new task definition revision and update the ECS service.