展示HN:Kappal – CLI工具,用于在本地开发时在Kubernetes上运行Docker Compose YML
Show HN: Kappal – CLI to Run Docker Compose YML on Kubernetes for Local Dev

原始链接: https://github.com/sandys/kappal

## Kappal:Docker Compose 到 Kubernetes – 无需 Kubernetes 知识 Kappal(在泰米尔语中意为“船”)简化了将 Docker Compose 应用程序部署到 Kubernetes 的过程。它允许用户利用现有的 `docker-compose.yaml` 文件和熟悉的 `docker-compose` 命令(如 `up`、`down`、`ps`、`logs`、`exec`),*而无需*学习 Kubernetes 概念或使用 `kubectl`。 Kappal 通过在 Docker 内部自动运行轻量级的 Kubernetes 发行版 (K3s) 来实现这一点。它支持 Compose 的关键特性,如服务、端口、卷、环境变量、密钥、扩展,甚至 UDP 端口。持久卷默认受支持,可在重启后保留。 **入门很简单:**安装 Docker,拉取 Kappal 镜像,并创建一个别名。然后,导航到您的项目并运行 `kappal --setup`,然后运行 `kappal up -d` 进行部署。 Kappal 还具有 AI 代理集成,允许像 Claude Code 这样的工具自主部署 Compose 项目。它被设计为自包含的,隐藏 Kubernetes 的复杂性,并为已经熟悉 Docker Compose 的开发者提供无缝体验。

## Kappal:在 Kubernetes 上运行 Docker Compose 以进行本地开发 sandGorgon 创建并开源在 GitHub 上的新 CLI 工具 Kappal,旨在弥合本地 Docker Compose 开发与 Kubernetes 生产环境之间的差距。 Kappal 接收标准的 Docker Compose YAML 文件,并在本地 Kubernetes(特别是 k3s)上直接运行它们。 这消除了开发者在将应用程序从 Compose 设置迁移到 Kubernetes 集群时经常经历的“认知失调”。 本质上,它为本地开发提供了一个 Docker Compose 的替代方案,同时使工作流程更接近最终的生产部署。 一位评论员指出,他们已经成功地*从* Docker Compose 迁移到使用 Podman 和 `kube play` 的类似 Kubernetes 方法,这凸显了朝着生产环境一致性的本地开发趋势。
相关文章

原文

Docker Compose CLI for Kubernetes - Run your docker-compose.yaml on Kubernetes without learning Kubernetes.

Conformance Tests

Kappal (கப்பல்) means "ship" in Tamil. The name honors V.O. Chidambaram Pillai, known as Kappalottiya Tamizhan ("The Tamil Helmsman") - a freedom fighter who founded India's first indigenous shipping company.

The nautical theme connects to Kubernetes itself: Kubernetes (κυβερνήτης) is Greek for "helmsman" or "pilot" - the person who steers a ship. Kappal steers your containers on the Kubernetes seas, so you don't have to learn navigation.

Kappal lets you use familiar Docker Compose commands while running your services on Kubernetes (K3s). Users never see kubectl, YAML manifests, or Kubernetes concepts - just the same up, down, ps, logs, and exec commands they already know.

kappal up -d                    # Start services
kappal ps                       # List services
kappal logs api                 # View logs
kappal exec web sh              # Shell into service
kappal down                     # Stop services
  • Zero Kubernetes Knowledge Required - Use Docker Compose syntax, get Kubernetes benefits
  • Persistent Volumes - Named volumes survive restarts (kappal down + kappal up)
  • Service Discovery - Services find each other by name (just like Docker Compose)
  • Secrets & Configs - Mount secrets and config files the Compose way
  • Scaling - Use deploy.replicas to scale services
  • Network Isolation - Define networks to isolate service groups
  • UDP Support - Full protocol support including UDP ports

Only Docker is required. Kappal handles everything else automatically.

Requirement Notes
Docker Only prerequisite - Install Docker
Kubernetes Not needed - Kappal runs K3s automatically
kubectl Not needed - included in Kappal image
K3s Not needed - runs as a container
# 1. Install Docker (if not already installed)
curl -fsSL https://get.docker.com | sh

# 2. Pull kappal image
docker pull ghcr.io/sandys/kappal:latest

# 3. Add alias (for current session)
alias kappal='docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v "$(pwd):/project" -w /project --network host ghcr.io/sandys/kappal:latest'

# Or save permanently to ~/.bashrc or ~/.zshrc
echo "alias kappal='docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v \"\$(pwd):/project\" -w /project --network host ghcr.io/sandys/kappal:latest'" >> ~/.bashrc
source ~/.bashrc

That's it. You're ready to use Kappal.

# Navigate to your project with docker-compose.yaml
cd /path/to/your/project

# First-time setup (required once per project)
kappal --setup

# Start services in detached mode
kappal up -d

# Check status
kappal ps

# View logs
kappal logs

# View logs for specific service
kappal logs api

# Shell into a service
kappal exec web sh

# Stop everything
kappal down

# Stop and remove volumes
kappal down -v
Command Description
kappal --setup Set up kappal for this project (required first time)
kappal up [-d] Create and start services
kappal up --build Build images and start services
kappal down [-v] Stop and remove services (-v removes volumes)
kappal ps List running services
kappal logs [service] View service logs
kappal exec <service> <cmd> Execute command in service
kappal build Build images from Dockerfiles
kappal clean Remove kappal workspace and K3s
kappal eject Export as standalone Tanka workspace

Compose Features Supported

Feature Status Example
Services services.web.image: nginx
Ports ports: ["8080:80"]
Volumes (named) volumes: [data:/var/lib/data]
Environment environment: [KEY=value]
Secrets secrets: [my_secret]
Configs configs: [app_config]
Networks networks: [frontend, backend]
Scaling deploy.replicas: 3
Build build: ./app
Custom Dockerfile build.dockerfile: Dockerfile.prod
Command command: ["npm", "start"]
Entrypoint entrypoint: ["/docker-entrypoint.sh"]
UDP ports ports: ["53:53/udp"]
Depends On ⚠️ Partial (ordering only)
Healthchecks 🚧 Planned

Compose File in Subdirectory

If your docker-compose.yml is in a subdirectory (e.g., deploy/docker-compose/), use the -f flag:

# Project structure:
# myproject/
# ├── apps/
# ├── packages/
# └── deploy/
#     └── docker-compose/
#         └── docker-compose.yml

# Option 1: Use -f flag with relative path
kappal -f deploy/docker-compose/docker-compose.yml up

# Option 2: cd into the directory
cd deploy/docker-compose
kappal -f docker-compose.yml up

Monorepo / Custom Build Contexts

If your docker-compose.yml references parent directories (e.g., build: context: ../..), you need to mount from the project root and set the working directory:

# For monorepos, create a project-specific alias
alias kappal-myproject='docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v "/path/to/project/root:/project" -w /project/path/to/compose/dir --network host ghcr.io/sandys/kappal:latest'

# Then use normally
kappal-myproject up --build

AI Agent / Claude Code Integration

Kappal includes a skill file (skills/kappal/SKILL.md) that lets Claude Code and other AI coding agents deploy docker-compose projects to Kubernetes autonomously.

How it works: Claude reads the skill file and handles the full lifecycle — setup, build, deploy, logs, teardown — without the user needing to know kappal internals.

What the user says: Just tell Claude "deploy this with kappal" or "run this docker-compose in kappal" and it handles the rest.

Self-updating: The skill auto-fetches the latest version from GitHub at the start of each conversation, so it stays current with breaking changes and new features.

No other container orchestration tool offers native AI agent integration — docker compose, podman, and others require the user to know the CLI. Kappal works with AI agents out of the box.

docker-compose.yaml
        │
        ▼
┌───────────────────┐
│   compose-go     │  Parse compose file
└───────────────────┘
        │
        ▼
┌───────────────────┐
│   Transformer    │  Convert to K8s manifests
└───────────────────┘
        │
        ▼
┌───────────────────┐
│   K3s (Docker)   │  Lightweight Kubernetes
└───────────────────┘
        │
        ▼
    Your services running on Kubernetes!

Key Design Principles:

  1. Users never see Kubernetes - All K8s concepts are hidden behind Compose semantics
  2. Self-contained - K3s runs in Docker, no system installation needed
  3. Persistent by default - Volumes survive down/up cycles (use -v to remove)
  4. Standard tools - Uses compose-go (official parser), K3s, client-go
# Clone the repo
git clone https://github.com/kappal-app/kappal.git
cd kappal

# Build Docker image
make docker-build

# Run unit tests
make test

# Run conformance tests (all 8 must pass)
make conformance

# Run all lints
make lint-all

Kappal passes all 8 conformance tests based on the compose-spec:

  • SimpleLifecycle - Basic up/down
  • SimpleNetwork - Service-to-service DNS
  • VolumeFile - Persistent volume data
  • SecretFile - Secret mounting
  • ConfigFile - Config file mounting
  • UdpPort - UDP protocol support
  • Scaling - Replica scaling
  • DifferentNetworks - Network isolation

Q: Why not just use Kompose? A: Kompose converts Compose files to K8s manifests, but you still need to manage Kubernetes. Kappal hides K8s completely - same CLI experience as Docker Compose.

Q: Why K3s instead of kind/minikube? A: K3s is lightweight, fast to start, and includes essentials like ServiceLB and local-path-provisioner out of the box.

Q: Can I see the generated Kubernetes manifests? A: Yes, they're in .kappal/manifests/all.yaml (but you shouldn't need to).

Q: How do I debug issues? A: Use kappal logs <service> and kappal exec <service> sh. If you need deeper debugging, the kubeconfig is at .kappal/runtime/kubeconfig.yaml.

MIT

联系我们 contact @ memedata.com