Files
floci/docs/services/msk.md
T
Priamo Germosen 4c510e576c feat(msk): add configuration CRUD (Create/List/Describe/Delete) (#2336)
* feat(msk): add configuration CRUD (Create/List/Describe/Delete)

MskController only served /v1/clusters and /api/v2/clusters, so every
configuration action 404s. An MSK configuration is the only supported
way to set broker-level server_properties, and aws_msk_configuration /
aws_msk_domain_policy are first-class Terraform resources - any stack
setting broker properties failed before the cluster was even attempted.

Adds a second StorageBackend on MskService (msk-configurations.json,
mirroring msk-clusters.json), a new MskConfiguration model, and four
endpoints on MskController mirroring the existing cluster handlers.
serverProperties is base64 on the wire; decoded and kept internal
(@JsonIgnore) since AWS only returns it via DescribeConfigurationRevision,
which is a separate follow-up issue - this stays plain CRUD.

Field names verified against botocore's actual kafka service model
rather than trusting the API reference docs verbatim: every field is
lowerCamelCase, including DeleteConfigurationResponse's `arn` (the
public API reference page shows "Arn" capitalized, which does not
match the real wire format).

* fix(msk): validate request field types and persist serverProperties

CreateConfiguration cast request fields directly (String)/(List<String>),
so a wrong-typed field threw ClassCastException instead of an AWS-shaped
BadRequestException, surfacing as an internal server error.

serverProperties was @JsonIgnore, which excludes it from Jackson
serialization entirely - not just REST responses, but also the
persistent/hybrid/wal StorageBackend serialization that uses the same
model. A configuration would silently lose its broker properties on
reload under any non-memory storage mode. The field now serializes
normally; the controller instead builds explicit response views for
Describe/List/Create so serverProperties still never appears on the
wire outside CreateConfiguration's own request, matching AWS (which
only returns it via the out-of-scope DescribeConfigurationRevision).

* fix(msk): default kafkaVersions to an empty array when omitted

kafkaVersions is optional on CreateConfigurationRequest, but
asStringList returns null when it's absent, and toConfigurationView
put that null straight into the response - AWS's Configuration shape
always populates it as an array. Default it the same way description
already is. No existing test created a configuration without the
field, which is why it slipped through.

* feat(msk): support maxResults/nextToken pagination on ListConfigurations

ListConfigurations previously returned every configuration in one
response, ignoring the maxResults/nextToken query parameters the
model declares. Mirrors the existing pagination pattern from
BedrockAgentCoreGatewayService (ListResult<T> + a private paginate()
helper): the cursor is the last returned item's ARN, base64
URL-encoded, resumed by scanning the ARN-sorted list past that value.
maxResults is bounded to [1, 100] and an undecodable token both throw
BadRequestException, matching CreateConfiguration's existing error
family for this service.
2026-08-15 21:50:20 -04:00

2.8 KiB

MSK (Managed Streaming for Kafka)

Protocol: REST-JSON Endpoint: http://localhost:4566/

Floci emulates Amazon MSK by orchestrating Redpanda containers. This provides high compatibility with the Kafka API while maintaining a low footprint.

Supported Actions

Action Description
CreateCluster Spawns a new Redpanda container for the cluster
CreateClusterV2 Modern serverless/provisioned creation (mapped to provisioned)
ListClusters List all emulated clusters
ListClustersV2 List all emulated clusters using V2 API
DescribeCluster Get cluster metadata and state
DescribeClusterV2 Get cluster metadata and state using V2 API
DeleteCluster Stops and removes the Redpanda container
GetBootstrapBrokers Get the connection strings for the cluster
CreateConfiguration Create a broker configuration (server.properties)
ListConfigurations List all configurations
DescribeConfiguration Get configuration metadata and latest revision
DeleteConfiguration Delete a configuration

Configuration

Variable Default Description
FLOCI_SERVICES_MSK_ENABLED true Enable or disable the service
FLOCI_SERVICES_MSK_MOCK false true = metadata-only CRUD, no Docker containers
FLOCI_SERVICES_MSK_DEFAULT_IMAGE redpandadata/redpanda:latest Docker image for Redpanda (Kafka) containers

How it works

When mock is set to false (default), Floci uses the Docker API to start a Redpanda container for each created cluster. For Docker socket setup, private registry authentication, and other Docker settings see Docker Configuration.

  • Port Mapping: The Kafka API (9092) is mapped to a dynamic host port.
  • Persistence: Each cluster gets a named Docker volume (floci-msk-{volumeId}). In memory mode the volume is removed on cluster delete; in persistent modes it is retained unless FLOCI_STORAGE_PRUNE_VOLUMES_ON_DELETE=true.
  • Readiness: The cluster state transitions to ACTIVE once the Redpanda /ready endpoint is reachable.

Examples

export AWS_ENDPOINT_URL=http://localhost:4566

# Create a cluster
aws kafka create-cluster \
  --cluster-name my-cluster \
  --kafka-version "3.6.1" \
  --numberOfBrokerNodes 1 \
  --broker-node-group-info '{"InstanceType":"kafka.m5.large","ClientSubnets":["subnet-1"]}' \
  --endpoint-url $AWS_ENDPOINT_URL

# List clusters
aws kafka list-clusters --endpoint-url $AWS_ENDPOINT_URL

# Get bootstrap brokers
CLUSTER_ARN=$(aws kafka list-clusters --query 'ClusterInfoList[0].ClusterArn' --output text --endpoint-url $AWS_ENDPOINT_URL)
aws kafka get-bootstrap-brokers --cluster-arn $CLUSTER_ARN --endpoint-url $AWS_ENDPOINT_URL

# Delete a cluster
aws kafka delete-cluster --cluster-arn $CLUSTER_ARN --endpoint-url $AWS_ENDPOINT_URL