Skip to main content

K2I CLI Command Reference

This document provides a complete reference for all K2I CLI commands.

Global Options​

These options are available for all commands:

OptionShortDescription
--config <PATH>-cPath to configuration file (default: config.toml)
--verbose-vIncrease logging verbosity (-v debug, -vv trace)
--help-hPrint help information
--versionPrint version information

Local E2E Verification Scripts​

These repository scripts are not k2i subcommands, but they are the canonical local verification entry points used before release:

ScriptDescription
scripts/e2e-docker.shCorrectness flow with Kafka, Schema Registry, K2I, read-state RPC, Protobuf schema evolution, and DuckDB Parquet validation
K2I_E2E_LOAD_MESSAGES=100000 scripts/e2e-docker-load.shHigh-volume local load profile with full read-state visibility and zero-error metrics assertions
scripts/e2e-docker-iceberg.shReal Iceberg REST metadata validation with DuckDB iceberg_scan
K2I_E2E_LOAD_MESSAGES=100000 scripts/e2e-docker-iceberg-load.shProduction-oriented local Iceberg load profile: 100,000 rows by default, cold flush required, Parquet validation, Iceberg metadata validation, snapshot growth, DuckDB iceberg_scan, and zero-error metrics

The load scripts also support K2I_E2E_LOAD_CONCURRENCY, K2I_E2E_LOAD_PARTITIONS, and K2I_E2E_LOAD_TIMEOUT_SECONDS. scripts/e2e-docker-iceberg-load.sh additionally supports K2I_E2E_ICEBERG_LOAD_MIN_DATA_FILES and K2I_E2E_ICEBERG_LOAD_MIN_SNAPSHOTS when intentionally changing the load shape.

Commands​

k2i ingest​

Run the ingestion engine to consume from Kafka and write to Iceberg.

k2i ingest [OPTIONS]

Options​

OptionDescription
--bootstrap-servers <SERVERS>Override Kafka bootstrap servers
--topic <TOPIC>Override Kafka topic
--consumer-group <GROUP>Override consumer group

Examples​

# Start with default config
k2i ingest

# Start with custom config
k2i ingest --config /etc/k2i/production.toml

# Override Kafka settings
k2i ingest --bootstrap-servers kafka1:9092,kafka2:9092 --topic events

# Enable debug logging
k2i ingest -v

# Enable trace logging
k2i ingest -vv

Behavior​

  • Starts the main ingestion loop
  • Spawns HTTP servers for health (8080) and metrics (9090)
  • Handles graceful shutdown on SIGINT (Ctrl+C) or SIGTERM
  • Flushes buffer on shutdown to prevent data loss
  • Returns exit code 0 on successful shutdown

Signal Handling​

SignalAction
SIGINT (Ctrl+C)Graceful shutdown
SIGTERMGraceful shutdown
SIGKILLImmediate termination (no flush)

k2i status​

Check the health and metrics of a running K2I instance.

k2i status [OPTIONS]

Options​

OptionDefaultDescription
--url <URL>http://localhost:8080Health endpoint URL

Examples​

# Check local instance
k2i status

# Check remote instance
k2i status --url http://k2i-prod.internal:8080

Output​

Health Status: Healthy

Components:
kafka: Healthy
buffer: Healthy
iceberg: Healthy
catalog: Healthy
txlog: Healthy
schema: Healthy

Metrics:
messages_consumed: 1234567
rows_flushed: 1200000
buffer_flushes: 240
errors: 0
backpressure_events: 3

Exit Codes​

CodeMeaning
0Instance is healthy or degraded (operational)
6Instance is unhealthy or unreachable

k2i maintenance​

Run maintenance tasks manually. Subcommands for specific operations.

k2i maintenance <COMMAND> [OPTIONS]

Subcommands​

CommandDescription
compactMerge small Parquet files
expire-snapshotsRemove old snapshots
clean-orphansDelete orphan files

k2i maintenance compact​

Run file compaction to merge small Parquet files into larger ones.

k2i maintenance compact [OPTIONS]

Examples​

# Run compaction with default config
k2i maintenance compact

# Run compaction with custom config
k2i maintenance compact --config production.toml

Behavior​

  • Scans Iceberg table for files smaller than compaction_threshold_mb
  • Merges files until reaching compaction_target_mb
  • Creates new manifest with merged files
  • Atomically commits to catalog
  • Does not delete old files immediately (handled by orphan cleanup)

Output​

Starting compaction...
Found 45 files eligible for compaction
Merging files into 3 new files...
Created: data_00001.parquet (512 MB, 1,234,567 rows)
Created: data_00002.parquet (512 MB, 1,234,568 rows)
Created: data_00003.parquet (256 MB, 617,284 rows)
Committed snapshot: 12345678901234
Compaction complete: merged 45 files into 3

k2i maintenance expire-snapshots​

Remove old Iceberg snapshots beyond the retention period.

k2i maintenance expire-snapshots [OPTIONS]

Examples​

# Expire snapshots with default retention
k2i maintenance expire-snapshots

# With custom config (retention set in config)
k2i maintenance expire-snapshots --config production.toml

Behavior​

  • Lists all snapshots in the table
  • Identifies snapshots older than snapshot_retention_days
  • Removes snapshot metadata entries
  • Does not delete data files still referenced by other snapshots

Output​

Starting snapshot expiration...
Retention period: 7 days
Found 25 snapshots total
Expiring 18 snapshots older than 2024-01-01T00:00:00Z
Expired: snapshot 12345678901230 (2023-12-25T10:30:00Z)
Expired: snapshot 12345678901231 (2023-12-26T11:00:00Z)
...
Snapshot expiration complete: removed 18 snapshots

k2i maintenance clean-orphans​

Delete orphan files not referenced by any snapshot.

k2i maintenance clean-orphans [OPTIONS]

Examples​

# Clean orphan files
k2i maintenance clean-orphans

# With custom config
k2i maintenance clean-orphans --config production.toml

Behavior​

  • Lists all data files in the warehouse path
  • Lists all files referenced by any snapshot
  • Identifies orphan files (present but not referenced)
  • Applies safety buffer (orphan_retention_days)
  • Deletes orphan files older than retention period

Output​

Starting orphan cleanup...
Safety buffer: 3 days
Scanning warehouse path: s3://bucket/warehouse/
Found 150 data files
Found 142 referenced files
Identified 8 orphan files
Deleting 5 orphan files older than 2024-01-05T00:00:00Z
Deleted: data_abc123.parquet (512 MB)
Deleted: data_def456.parquet (128 MB)
...
Orphan cleanup complete: deleted 5 files (640 MB recovered)

k2i validate​

Validate the configuration file without starting the engine.

k2i validate [OPTIONS]

Examples​

# Validate default config
k2i validate

# Validate specific config
k2i validate --config /etc/k2i/production.toml

Behavior​

Validates:

  • TOML syntax
  • Required fields present
  • Kafka bootstrap servers non-empty
  • Valid catalog type
  • Valid compression codec
  • Memory alignment is power of 2
  • Port numbers in valid range

Output​

Success:

Configuration is valid

Failure:

Configuration error: missing required field 'kafka.topic'

Exit Codes​

CodeMeaning
0Configuration is valid
1Configuration error

k2i table​

Register or reset existing Parquet data for a K2I-readable table.

k2i table <COMMAND> [OPTIONS]

Subcommands​

CommandDescription
registerRegister existing Parquet files without copying them
resetReset a registered table

k2i table register​

Register one or more existing Parquet files as an Iceberg table and read-state source.

k2i table register --database <DATABASE> --table <TABLE> --source <SOURCE> [OPTIONS]

Options​

OptionDefaultDescription
--database <DATABASE>RequiredDatabase/namespace name
--table <TABLE>RequiredTable name
--source <SOURCE>RequiredParquet file, directory, or glob. Can be repeated
--schema-source <SOURCE>first-fileUse the first Parquet file schema or a .proto file path
--message-type <TYPE>Fully-qualified Protobuf message type when --schema-source is a .proto file
--kafka-topic <TOPIC>Optional topic label for read-state provenance

Examples​

# Register a directory of historical Parquet files
k2i table register \
--config config.toml \
--database f1 \
--table derived_state \
--source '/data/historical/*.parquet'

# Register with an explicit Protobuf schema
k2i table register \
--config config.toml \
--database f1 \
--table derived_state \
--source /data/historical \
--schema-source schemas/derived_state.proto \
--message-type f1.timing.v1.DerivedState

Behavior​

  • Expands files, directories, and glob sources.
  • Infers schema from the first Parquet file unless a .proto schema source is supplied.
  • Registers metadata through the configured catalog path.
  • Adds transaction-log records so the read-state path can recover the registered table.
  • Does not copy source files.

k2i table reset​

Reset a registered table.

k2i table reset --database <DATABASE> --table <TABLE> [OPTIONS]

Options​

OptionDescription
--database <DATABASE>Database/namespace name
--table <TABLE>Table name
--keep-dataRetain source data files

Example​

k2i table reset --config config.toml --database f1 --table derived_state --keep-data

k2i dev​

Run a zero-cloud local development instance. This command builds an in-process configuration that uses Kafka plus a local filesystem warehouse, a SQLite-backed catalog, local transaction logs, and an enabled read-state Unix socket.

k2i dev --topic <TOPIC> --warehouse <PATH> [OPTIONS]

Options​

OptionDefaultDescription
--topic <TOPIC>RequiredKafka topic to consume
--warehouse <PATH>RequiredLocal warehouse directory
--bootstrap-servers <SERVERS>localhost:9092Kafka bootstrap servers
--database <DATABASE>defaultDatabase/namespace name
--table <TABLE>eventsTable name
--consumer-group <GROUP>k2i-devKafka consumer group
--schema-registry-url <URL>Optional Confluent Schema Registry URL for Protobuf values
--message-type <TYPE>Optional fully-qualified Protobuf message type

Examples​

# Raw Kafka values into a local warehouse
k2i dev --topic events --warehouse ./warehouse

# Confluent-framed Protobuf values
k2i dev \
--topic f1.timing.derived_state \
--warehouse ./warehouse \
--schema-registry-url http://localhost:8081 \
--message-type f1.timing.v1.DerivedState

Behavior​

  • Creates the warehouse, transaction-log, and runtime socket directories.
  • Uses a local SQLite catalog at <warehouse>/catalog.db.
  • Uses the filesystem object store rooted at the warehouse path.
  • Enables read-state RPC at <warehouse>/run/k2i.sock.

k2i completions​

Generate shell completions or recursive man pages from the live clap command definitions.

k2i completions <COMMAND>

Subcommands​

CommandDescription
bashPrint bash completions to stdout
zshPrint zsh completions to stdout
fishPrint fish completions to stdout
power-shellPrint PowerShell completions to stdout
manGenerate recursive .1 man page files

Examples​

# Shell completions
k2i completions bash > ~/.local/share/bash-completion/completions/k2i
k2i completions zsh > ~/.zfunc/_k2i
k2i completions fish > ~/.config/fish/completions/k2i.fish
k2i completions power-shell > k2i.ps1

# Man pages
k2i completions man --output-dir docs/man/man1
man ./docs/man/man1/k2i.1
man ./docs/man/man1/k2i-table-register.1

The checked-in man pages under docs/man/man1/ are generated with this command and should be regenerated after any CLI help, flag, subcommand, or version change.


Environment Variables​

K2I respects these environment variables:

VariableDescription
RUST_LOGOverride log level (e.g., k2i=debug,rdkafka=warn)
AWS_ACCESS_KEY_IDAWS access key for S3/Glue
AWS_SECRET_ACCESS_KEYAWS secret key
AWS_REGIONAWS region
AWS_PROFILEAWS profile name

Configuration values can reference environment variables:

[kafka.security]
sasl_password = "${KAFKA_PASSWORD}"

Exit Codes​

CodeMeaningCause
0SuccessNormal completion
1Config ErrorInvalid configuration file
2Kafka ErrorKafka connection or consumer failure
3Iceberg ErrorCatalog or commit failure
4Storage ErrorObject storage failure
5Transaction Log ErrorLog corruption or write failure
6Health Check ErrorInstance unreachable or unhealthy
10Runtime ErrorUnclassified runtime failure
130Signal InterruptSIGINT or SIGTERM received

HTTP Endpoints​

When running k2i ingest, HTTP endpoints are available:

Health Endpoints (port 8080)​

EndpointMethodDescription
/healthGETFull health status (JSON)
/healthzGETKubernetes liveness probe
/readyzGETKubernetes readiness probe

/health Response​

{
"status": "healthy",
"components": {
"kafka": { "status": "healthy" },
"buffer": { "status": "healthy" },
"iceberg": { "status": "healthy" },
"catalog": { "status": "healthy" },
"txlog": { "status": "healthy" },
"schema": { "status": "healthy" }
}
}

/healthz and /readyz​

  • /healthz is the liveness probe. It returns 200 OK when the process is operational (healthy or degraded) and 503 Service Unavailable when overall health is unhealthy.
  • /readyz is the readiness probe. It returns 200 OK only when the process is operational and there are no readiness blockers. Schema pauses from manual evolution or breaking Protobuf changes return 503 Service Unavailable even when /healthz still returns 200 OK.

Metrics Endpoint (port 9090)​

EndpointMethodDescription
/metricsGETPrometheus metrics

Sample Metrics​

# HELP k2i_messages_consumed_total Total messages consumed from Kafka
# TYPE k2i_messages_consumed_total counter
k2i_messages_consumed_total 1234567

# HELP k2i_buffer_size_bytes Current buffer memory usage
# TYPE k2i_buffer_size_bytes gauge
k2i_buffer_size_bytes 52428800

# HELP k2i_buffer_record_count Current records in buffer
# TYPE k2i_buffer_record_count gauge
k2i_buffer_record_count 5000

# HELP k2i_flush_duration_seconds Flush operation duration
# TYPE k2i_flush_duration_seconds histogram
k2i_flush_duration_seconds_bucket{le="0.1"} 10
k2i_flush_duration_seconds_bucket{le="0.25"} 45
k2i_flush_duration_seconds_bucket{le="0.5"} 180
k2i_flush_duration_seconds_bucket{le="1.0"} 235
k2i_flush_duration_seconds_bucket{le="+Inf"} 240
k2i_flush_duration_seconds_sum 89.5
k2i_flush_duration_seconds_count 240

Quick Reference​

# Start ingestion
k2i ingest --config config.toml

# Check health
k2i status --url http://localhost:8080

# Validate config
k2i validate --config config.toml

# Register existing Parquet files
k2i table register --config config.toml --database f1 --table derived_state --source '/data/*.parquet'

# Run a zero-cloud local dev instance
k2i dev --topic events --warehouse ./warehouse

# Manual maintenance
k2i maintenance compact --config config.toml
k2i maintenance expire-snapshots --config config.toml
k2i maintenance clean-orphans --config config.toml

# Debug logging
k2i ingest -v

# Trace logging
k2i ingest -vv

# Help
k2i --help
k2i ingest --help
k2i maintenance --help

# Full local Docker validation
scripts/e2e-docker.sh
scripts/e2e-docker-iceberg.sh
K2I_E2E_LOAD_MESSAGES=100000 scripts/e2e-docker-iceberg-load.sh