Skip to content

feat: add capabilities parameter to ServiceConfig#2889

Draft
swapnilraj wants to merge 3 commits intokurtosis-tech:mainfrom
swapnilraj:feat/add-capabilities-support
Draft

feat: add capabilities parameter to ServiceConfig#2889
swapnilraj wants to merge 3 commits intokurtosis-tech:mainfrom
swapnilraj:feat/add-capabilities-support

Conversation

@swapnilraj
Copy link

Summary

  • Add capabilities parameter to ServiceConfig in Starlark, allowing users to specify Linux container capabilities (e.g., NET_ADMIN, SYS_PTRACE)
  • Wire capabilities through both Docker backend (via WithAddedCapabilities) and Kubernetes backend (via SecurityContext.Capabilities)
  • Include unit tests for field storage, JSON marshalling, and Starlark parsing

This is a revival of the previously closed #2457, with a complete implementation that covers both Docker and Kubernetes backends, uses the setter pattern (non-breaking, no changes to CreateServiceConfig signature), and includes full test coverage.

Motivation

We are building chaoswopr, an AI-driven chaos engineering tool for Ethereum operational resilience testing. It uses Kurtosis to deploy private Ethereum testnets and inject faults at the network level using tools like tc and netem. These tools require the NET_ADMIN capability, which is not currently exposed through Kurtosis's ServiceConfig.

Usage

plan.add_service(
    name = "test-net-admin",
    config = ServiceConfig(
        image = "alpine:latest",
        capabilities = ["NET_ADMIN"],
    ),
)

After which:

kurtosis service exec <enclave> test-net-admin "tc qdisc add dev eth0 root netem loss 20%"
# Succeeds without "Operation not permitted"

Changes

File Change
service_config.go (objects/service) Add Capabilities []string field, getter, and setter
service_config.go (kurtosis_types) Add capabilities Starlark parameter, extract and set on ServiceConfig
start_user_services.go (docker) Extract capabilities, convert to ContainerCapability map, pass to builder
start_user_services.go (kubernetes) Extract capabilities, add to SecurityContext.Capabilities.Add
service_config_test.go Unit tests for field access and JSON marshalling
service_config_capabilities_test.go Starlark framework test for parsing capabilities

Is this change user facing?

YES

Test plan

  • Unit tests for ServiceConfig.GetCapabilities() / SetCapabilities()
  • JSON marshal/unmarshal round-trip test for capabilities
  • Starlark framework test parsing capabilities = ["NET_ADMIN", "SYS_PTRACE"]
  • All existing tests pass (service config, add_service, Starlark framework)
  • go build succeeds for core/server and container-engine-lib modules

Generated with Claude Code

… capabilities

Add support for specifying Linux capabilities (e.g., NET_ADMIN, SYS_PTRACE) on
user service containers via the Starlark ServiceConfig type. This enables chaos
engineering use cases that require network manipulation tools like `tc` and `netem`
inside containers, which need the NET_ADMIN capability.

Changes:
- Add Capabilities field to service.ServiceConfig with getter/setter methods
- Add 'capabilities' Starlark parameter to ServiceConfig type (optional list of strings)
- Pass capabilities through Docker backend via WithAddedCapabilities on container builder
- Pass capabilities through Kubernetes backend via SecurityContext.Capabilities
- Add unit tests for field storage, JSON marshalling, and Starlark parsing

Usage in Starlark:
  plan.add_service(
      name = "test-net-admin",
      config = ServiceConfig(
          image = "alpine:latest",
          capabilities = ["NET_ADMIN"],
      ),
  )

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@swapnilraj swapnilraj marked this pull request as draft February 16, 2026 19:10
swapnilraj and others added 2 commits February 16, 2026 19:35
Add the missing capabilities field to the ServiceInfo protobuf message to allow
capabilities to be returned when querying service information via the API. This
completes the capabilities feature implementation by ensuring that capabilities
set on a service are included in the service metadata returned to clients.

Changes:
- Add capabilities field (repeated string, field 21) to ServiceInfo message in api_container_service.proto
- Regenerate protobuf Go bindings with the new field
- Update NewServiceInfo binding constructor to accept capabilities parameter
- Pass serviceConfig.GetCapabilities() when constructing ServiceInfo in api_container_service.go

This fix ensures that the capabilities parameter works end-to-end from Starlark
parsing through Docker/K8s container creation to API responses.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…nfig

The capabilities were being lost during service creation because the
replaceMagicStrings function creates a new ServiceConfig but was not
copying the capabilities from the original config.

This fix adds the capabilities back to the rendered service config,
similar to how FilesToBeMoved is handled.

Tested end-to-end:
- Container capabilities verified with docker inspect
- tc/netem commands work successfully with NET_ADMIN

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
swapnilraj added a commit to swapnilraj/chaoswopr that referenced this pull request Feb 18, 2026
Major integration of custom Kurtosis build with NET_ADMIN capabilities support,
unifying all Phase 2 components on a single Kurtosis platform.

## What Changed

**New Components:**
- KurtosisChaosInjector: Python wrapper for chaos injection with NET_ADMIN
- chaos-injector package: Kurtosis package deploying chaos containers
- Comprehensive test suite: 17 unit + 11 integration tests
- Complete documentation: KURTOSIS_INTEGRATION.md

**Updated:**
- KurtosisClient: Now defaults to capabilities-enabled Kurtosis binary

## Integration Details

All Phase 2 tracks now run on unified Kurtosis:
- Track E (Orchestrator): Uses KurtosisClient
- Track F (Node Agents): Beacon API via Kurtosis
- Track G (Observer): Prometheus via Kurtosis
- Track H (Chaos Injection): NEW KurtosisChaosInjector with NET_ADMIN

## Test Results

✅ 17/17 unit tests passing
✅ Integration tests created and verified
✅ NET_ADMIN capability verified on real containers
✅ tc/netem commands working (packet loss, latency, etc.)

## Architecture Benefits

Before: Split deployment (Kurtosis + Docker Compose)
After: Unified Kurtosis platform with all capabilities

- Single orchestration system
- Consistent service discovery
- Scales to 500 nodes seamlessly
- Production-ready

## Upstream Contribution

Created PR #2889 to Kurtosis:
kurtosis-tech/kurtosis#2889

Fixes critical bug in add_service_shared.go where capabilities
weren't preserved during magic string replacement.

Phase 2 is now 100% complete with 426 total tests passing.
Ready for Phase 3 development!

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Entire-Checkpoint: 3639e54bc537
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments