LinuxCommandLibrary

kompose

Convert Docker Compose to Kubernetes resources

TLDR

Deploy a dockerized application to Kubernetes

$ kompose up [[-f|--file]] [docker-compose.yml]
copy

Delete instantiated services/deployments from Kubernetes
$ kompose down [[-f|--file]] [docker-compose.yml]
copy

Convert a docker-compose file into Kubernetes resources file
$ kompose convert [[-f|--file]] [docker-compose.yml]
copy

SYNOPSIS

kompose command [options]
kompose convert [options]
kompose up [options]
kompose down [options]
kompose logs [options]
kompose version

PARAMETERS

--file, -f path
    Specify the path to the Docker Compose file to be processed. Defaults to docker-compose.yaml.

--output, -o directory
    Specify a directory where the generated Kubernetes artifact files (YAML) will be written. If not specified, files are written to the current directory.

--stdout
    Print the generated Kubernetes manifests directly to standard output instead of creating files. Useful for piping output to kubectl.

--controller type
    Specify the Kubernetes controller type for services (e.g., deployment, daemonset, statefulset). Default is deployment.

--replicas count
    Set the number of replicas for generated controllers (e.g., for a Deployment). This applies to all services unless specified otherwise.

--service-type type
    Define the type of Kubernetes service to create (e.g., ClusterIP, NodePort, LoadBalancer). Default is ClusterIP.

--chart
    Generate a Helm chart instead of individual Kubernetes YAML manifest files. This creates a directory with a Chart.yaml and templates/ directory.

--push-images
    For the kompose up command, this option instructs kompose to push built Docker images to a configured registry before deployment.

--verbose
    Enable verbose output, providing more detailed information and debug messages during execution.

--version
    Display the current version of the kompose tool.

--help
    Show help message for a command or subcommand. Use kompose convert --help for specific options.

DESCRIPTION

kompose is an open-source command-line tool designed to help developers migrate Docker Compose applications to Kubernetes. It processes a Docker Compose file (e.g., docker-compose.yaml) and translates its definitions—services, networks, and volumes—into equivalent Kubernetes resources such as Deployments, Services, and Persistent Volume Claims.

This significantly streamlines the process of migrating existing containerized applications to a Kubernetes environment, allowing users to leverage their familiar Docker Compose configurations. kompose can generate various output formats, including raw Kubernetes manifest files (YAML) or even Helm charts, or it can directly deploy resources to a Kubernetes cluster. It serves as a valuable bridge, simplifying the transition from local Docker development to cloud-native Kubernetes deployments.

CAVEATS

kompose is primarily a migration aid and should not be seen as a full replacement for understanding Kubernetes concepts.

It may not perfectly translate all complex Docker Compose features, especially advanced networking, volume configurations, or specific build contexts.

The generated Kubernetes YAMLs often require manual review, optimization, and refinement for production environments to ensure best practices for security, scalability, and resilience.

The kompose up and kompose down commands are generally considered less robust than direct kubectl commands and are often discouraged for production deployments; it's recommended to use kubectl for managing Kubernetes resources after conversion.

PRIMARY USE CASE

The main purpose of kompose is to facilitate the initial migration of applications from a Docker Compose setup to Kubernetes. It generates baseline Kubernetes manifests that can then be further customized and optimized according to specific deployment needs.

TYPICAL WORKFLOW

A common workflow for using kompose involves:
1. Defining your multi-container application with a docker-compose.yaml file.
2. Running kompose convert to generate Kubernetes YAML files (e.g., deployment.yaml, service.yaml, pvc.yaml).
3. Reviewing and potentially modifying the generated YAMLs to add Kubernetes-specific features like probes, resource limits, or network policies.
4. Deploying the application to Kubernetes using kubectl apply -f generated_files.yaml.

HISTORY

kompose was initially developed and open-sourced by Google in 2016 with the goal of simplifying the adoption of Kubernetes for developers already using Docker Compose. It quickly gained traction as a valuable tool for bridging the gap between local Docker development workflows and cloud-native Kubernetes deployments. While active development has somewhat slowed down, relying more on community contributions, it remains a foundational tool for initial migration efforts, allowing users to leverage their existing Compose configurations to kickstart their Kubernetes journey.

SEE ALSO

Copied to clipboard