2024-04-23 14:37:19 +02:00
|
|
|
|
2024-04-04 09:50:17 +02:00
|
|
|
<div style="text-align:center; margin: auto 0 4em 0" align="center">
|
2024-04-22 15:17:28 +02:00
|
|
|
<img src="./doc/docs/statics/logo-vertical.svg" alt="Katenary Logo" style="max-width: 90%" align="center"/>
|
2024-10-29 17:42:17 +01:00
|
|
|
|
2022-03-31 14:12:20 +02:00
|
|
|
</div>
|
2022-02-17 12:22:52 +01:00
|
|
|
|
2024-04-22 15:17:28 +02:00
|
|
|
[](https://katenary.readthedocs.io/en/latest/?badge=latest)
|
|
|
|
[](https://goreportcard.com/report/github.com/metal3d/katenary)
|
|
|
|
[](https://github.com/metal3d/katenary/releases)
|
2024-04-04 09:50:17 +02:00
|
|
|
|
|
|
|
🚀 Unleash Productivity with Katenary! 🚀
|
|
|
|
|
2024-10-17 17:08:42 +02:00
|
|
|
Tired of manual conversions? Katenary harnesses the labels from your "`compose`" file to craft complete Helm Charts
|
2024-04-04 09:50:17 +02:00
|
|
|
effortlessly, saving you time and energy.
|
|
|
|
|
2024-10-17 17:08:42 +02:00
|
|
|
🛠️ Simple automated CLI: Katenary handles the grunt work, generating everything needed for seamless service binding
|
2024-04-04 09:50:17 +02:00
|
|
|
and Helm Chart creation.
|
|
|
|
|
2024-11-25 12:02:04 +01:00
|
|
|
💡 Effortless Efficiency: You only need to add labels when it's necessary to precise things.
|
|
|
|
Then call `katenary convert` and let the magic happen.
|
2024-04-04 09:50:17 +02:00
|
|
|
|
2024-11-26 17:10:54 +01:00
|
|
|
## What ?
|
2024-04-04 09:50:17 +02:00
|
|
|
|
2024-11-26 23:43:57 +01:00
|
|
|
Katenary is a tool to help to transform `compose` (`docker compose`, `podman compose`, `nerdctl compose`, ...) files
|
|
|
|
to a working Helm Chart for Kubernetes.
|
2021-12-01 13:34:01 +01:00
|
|
|
|
2024-10-17 17:08:42 +02:00
|
|
|
Today, it's partially developed in collaboration with [Klee Group](https://www.kleegroup.com). Note that Katenary is
|
|
|
|
and **will stay an open source and free (as freedom) project**. We are convinced that the best way to make it better is to
|
2024-04-22 15:17:28 +02:00
|
|
|
share it with the community.
|
|
|
|
|
|
|
|
The main developer is [Patrice FERLET](https://github.com/metal3d).
|
|
|
|
|
2024-11-26 17:10:54 +01:00
|
|
|
## Install
|
2021-12-01 09:09:50 +01:00
|
|
|
|
2024-04-03 23:30:24 +02:00
|
|
|
You can download the binaries from the [Release](https://github.com/metal3d/katenary/releases) section. Copy the binary
|
|
|
|
and rename it to `katenary`. Place the binary inside your `PATH`. You should now be able to call the `katenary` command.
|
2022-02-17 10:06:50 +01:00
|
|
|
|
2024-04-03 23:30:24 +02:00
|
|
|
You can of course get the binary with `go install -u github.com/metal3d/katenary/cmd/katenary/...` but the `main` branch
|
|
|
|
is continuously updated. It's preferable to use releases.
|
2022-03-31 14:12:20 +02:00
|
|
|
|
|
|
|
You can use this commands on Linux:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
sh <(curl -sSL https://raw.githubusercontent.com/metal3d/katenary/master/install.sh)
|
|
|
|
```
|
|
|
|
|
2024-11-26 17:10:54 +01:00
|
|
|
## Or, build yourself
|
2022-03-31 14:12:20 +02:00
|
|
|
|
2021-12-01 09:09:50 +01:00
|
|
|
If you've got `podman` or `docker`, you can build `katenary` by using:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
make build
|
|
|
|
```
|
|
|
|
|
|
|
|
You can then install it with:
|
2024-10-17 17:08:42 +02:00
|
|
|
|
2021-12-01 09:09:50 +01:00
|
|
|
```bash
|
|
|
|
make install
|
|
|
|
```
|
|
|
|
|
2024-04-03 23:30:24 +02:00
|
|
|
It will use the default PREFIX (`~/.local/`) to install the binary in the `bin` subdirectory. You can force the PREFIX
|
|
|
|
value at install time, but maybe you need to use "sudo":
|
2021-12-01 09:09:50 +01:00
|
|
|
|
|
|
|
```bash
|
|
|
|
sudo make install PREFIX=/usr/local
|
|
|
|
```
|
|
|
|
|
2022-03-31 14:12:20 +02:00
|
|
|
If that goes wrong, you can use your local Go compiler:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
make build GO=local
|
|
|
|
|
|
|
|
# To force OS or architecture
|
|
|
|
make build GO=local GOOS=linux GOARCH=arm64
|
|
|
|
```
|
|
|
|
|
|
|
|
Then place the `katenary` binary file inside your PATH.
|
|
|
|
|
2024-11-26 17:10:54 +01:00
|
|
|
## Tips
|
2022-02-16 17:57:14 +01:00
|
|
|
|
2024-10-17 17:08:42 +02:00
|
|
|
We strongly recommend adding the completion call to you SHELL using the common `bashrc`, or whatever the profile file
|
2024-04-03 23:30:24 +02:00
|
|
|
you use.
|
2022-02-16 17:57:14 +01:00
|
|
|
|
2024-10-17 17:08:42 +02:00
|
|
|
E.g.,
|
2022-02-16 17:57:14 +01:00
|
|
|
|
2022-02-16 18:32:51 +01:00
|
|
|
```bash
|
2022-02-16 17:57:14 +01:00
|
|
|
# bash in ~/.bashrc file
|
|
|
|
source <(katenary completion bash)
|
|
|
|
# if the documentation breaks a bit your completion:
|
|
|
|
source <(katenary completion bash --no-description)
|
|
|
|
|
|
|
|
# zsh in ~/.zshrc
|
2022-10-25 21:55:58 +08:00
|
|
|
source <(katenary completion zsh)
|
2022-02-16 17:57:14 +01:00
|
|
|
|
|
|
|
# fish in ~/.config/fish/config.fish
|
2024-04-22 15:43:02 +02:00
|
|
|
katenary completion fish | source
|
2022-02-16 17:57:14 +01:00
|
|
|
|
2024-04-22 15:43:02 +02:00
|
|
|
# experimental
|
2022-02-16 17:57:14 +01:00
|
|
|
# powershell (as we don't provide any support on Windows yet, please avoid this...)
|
2024-04-22 15:43:02 +02:00
|
|
|
```
|
2022-02-16 17:57:14 +01:00
|
|
|
|
2024-11-26 17:10:54 +01:00
|
|
|
## Usage
|
2021-12-01 09:09:50 +01:00
|
|
|
|
2024-10-17 17:08:42 +02:00
|
|
|
```text
|
2024-04-22 15:36:49 +02:00
|
|
|
Katenary is a tool to convert compose files to Helm Charts.
|
2022-02-16 17:48:57 +01:00
|
|
|
|
2024-04-22 15:36:49 +02:00
|
|
|
Each [command] and subcommand has got an "help" and "--help" flag to show more information.
|
2022-02-16 17:48:57 +01:00
|
|
|
|
2024-04-22 15:36:49 +02:00
|
|
|
Usage:
|
2024-11-26 16:47:05 +01:00
|
|
|
katenary [command]
|
2022-02-16 17:48:57 +01:00
|
|
|
|
2024-04-22 15:36:49 +02:00
|
|
|
Examples:
|
2024-11-26 16:47:05 +01:00
|
|
|
katenary convert -c docker-compose.yml -o ./charts
|
2024-04-03 22:38:23 +02:00
|
|
|
|
2024-04-22 15:36:49 +02:00
|
|
|
Available Commands:
|
2024-11-26 16:47:05 +01:00
|
|
|
completion Generates completion scripts
|
|
|
|
convert Converts a docker-compose file to a Helm Chart
|
|
|
|
hash-composefiles Print the hash of the composefiles
|
|
|
|
help Help about any command
|
|
|
|
help-labels Print the labels help for all or a specific label
|
|
|
|
schema Print the schema of the katenary file
|
|
|
|
version Print the version number of Katenary
|
2022-02-16 17:48:57 +01:00
|
|
|
|
2024-04-22 15:36:49 +02:00
|
|
|
Flags:
|
2024-11-26 16:47:05 +01:00
|
|
|
-h, --help help for katenary
|
|
|
|
-v, --version version for katenary
|
2022-02-16 17:48:57 +01:00
|
|
|
|
2024-04-22 15:36:49 +02:00
|
|
|
Use "katenary [command] --help" for more information about a command.
|
|
|
|
```
|
2021-12-01 09:09:50 +01:00
|
|
|
|
2024-04-22 15:17:28 +02:00
|
|
|
Katenary will try to find a `docker-compose.yaml` or `docker-compose.yml` file inside the current directory. It will
|
|
|
|
check *the existence of the `chart` directory to create a new Helm Chart inside a named subdirectory. Katenary will ask
|
|
|
|
you if you want to delete it before recreating.
|
2021-12-01 09:09:50 +01:00
|
|
|
|
|
|
|
It creates a subdirectory inside `chart` that is named with the `appname` option (default is `MyApp`)
|
|
|
|
|
2024-10-17 17:08:42 +02:00
|
|
|
> To respect the ability to install the same application in the same namespace, Katenary will create variable names
|
2024-04-22 15:17:28 +02:00
|
|
|
> like `{{ .Release.Name }}-servicename`. So, you will need to use some labels inside your docker-compose file to help
|
2024-10-17 17:08:42 +02:00
|
|
|
> Katenary to build a correct helm chart.
|
2021-12-01 09:15:40 +01:00
|
|
|
|
2024-10-17 17:08:42 +02:00
|
|
|
Example of a possible `docker-compose.yaml` file:
|
2024-04-22 15:17:28 +02:00
|
|
|
|
2024-04-22 15:36:49 +02:00
|
|
|
```yaml
|
|
|
|
services:
|
|
|
|
webapp:
|
|
|
|
image: php:7-apache
|
|
|
|
environment:
|
|
|
|
# note that "database" is a "compose" service name
|
|
|
|
# so we need to adapt it with the map-env label
|
|
|
|
DB_HOST: database
|
2024-11-26 23:43:57 +01:00
|
|
|
# a pitty to repeat this values, isn't it?
|
|
|
|
# so, let's change them with "values-from" label
|
|
|
|
DB_USER: foo
|
|
|
|
DB_PASSWORD: bar
|
2024-04-22 15:36:49 +02:00
|
|
|
expose:
|
2024-04-22 15:43:02 +02:00
|
|
|
- 80
|
2024-04-22 15:36:49 +02:00
|
|
|
depends_on:
|
|
|
|
# this will create a init container waiting for 3306 port
|
|
|
|
# because it's the "exposed" port
|
|
|
|
- database
|
|
|
|
labels:
|
|
|
|
# expose the port 80 as an ingress
|
|
|
|
katenary.v3/ingress: |-
|
|
|
|
hostname: myapp.example.com
|
|
|
|
port: 80
|
2024-11-25 12:02:04 +01:00
|
|
|
katenary.v3/map-env: |-
|
2024-04-22 15:36:49 +02:00
|
|
|
# make adaptations, DB_HOST environment is actually the service name
|
|
|
|
DB_HOST: '{{ .Release.Name }}-database'
|
2024-11-26 23:43:57 +01:00
|
|
|
katenary.v3/values-from: |-
|
|
|
|
# get the values from the "database" service
|
|
|
|
# this will use the databas secret, see below
|
|
|
|
DB_USER: databse.MARIADB_USER
|
|
|
|
DB_PASSWORD: database.MARIADB_PASSWORD
|
2024-04-22 15:36:49 +02:00
|
|
|
|
|
|
|
database:
|
|
|
|
image: mariadb:10
|
|
|
|
env_file:
|
2024-11-26 23:43:57 +01:00
|
|
|
# this valuse will be added in a configMap
|
2024-04-22 15:36:49 +02:00
|
|
|
- my_env.env
|
|
|
|
environment:
|
|
|
|
MARIADB_USER: foo
|
|
|
|
MARIADB_ROOT_PASSWORD: foobar
|
|
|
|
MARIADB_PASSWORD: bar
|
|
|
|
labels:
|
|
|
|
# no need to declare this port in docker-compose
|
|
|
|
# but katenary will need it
|
|
|
|
katenary.v3/ports: |-
|
|
|
|
- 3306
|
|
|
|
# these variables are secrets
|
|
|
|
katenary.v3/secrets: |-
|
|
|
|
- MARIADB_ROOT_PASSWORD
|
|
|
|
- MARIADB_PASSWORD
|
2021-12-01 09:09:50 +01:00
|
|
|
```
|
|
|
|
|
2024-11-26 17:10:54 +01:00
|
|
|
## Labels
|
2021-12-01 09:15:40 +01:00
|
|
|
|
2024-10-17 17:08:42 +02:00
|
|
|
These labels could be found by `katenary help-labels`, and can be placed as labels inside your docker-compose file:
|
2022-02-16 17:48:57 +01:00
|
|
|
|
2024-10-17 17:08:42 +02:00
|
|
|
```text
|
2024-04-03 22:38:23 +02:00
|
|
|
To get more information about a label, use `katenary help-label <name_without_prefix>
|
|
|
|
e.g. katenary help-label dependencies
|
|
|
|
|
|
|
|
katenary.v3/configmap-files: list of strings Add files to the configmap.
|
|
|
|
katenary.v3/cronjob: object Create a cronjob from the service.
|
|
|
|
katenary.v3/dependencies: list of objects Add Helm dependencies to the service.
|
|
|
|
katenary.v3/description: string Description of the service
|
|
|
|
katenary.v3/env-from: list of strings Add environment variables from antoher service.
|
2024-11-26 17:10:54 +01:00
|
|
|
katenary.v3/exchange-volumes: list of objects Add exchange volumes (empty directory on the node) to share data
|
2024-04-03 22:38:23 +02:00
|
|
|
katenary.v3/health-check: object Health check to be added to the deployment.
|
|
|
|
katenary.v3/ignore: bool Ignore the service
|
|
|
|
katenary.v3/ingress: object Ingress rules to be added to the service.
|
|
|
|
katenary.v3/main-app: bool Mark the service as the main app.
|
|
|
|
katenary.v3/map-env: object Map env vars from the service to the deployment.
|
|
|
|
katenary.v3/ports: list of uint32 Ports to be added to the service.
|
|
|
|
katenary.v3/same-pod: string Move the same-pod deployment to the target deployment.
|
|
|
|
katenary.v3/secrets: list of string Env vars to be set as secrets.
|
|
|
|
katenary.v3/values: list of string or map Environment variables to be added to the values.yaml
|
2024-11-26 17:10:54 +01:00
|
|
|
katenary.v3/values-from: map[string]string Add values from another service.
|
2022-02-16 17:48:57 +01:00
|
|
|
```
|
|
|
|
|
2024-11-26 17:10:54 +01:00
|
|
|
## Katenary.yaml file and schema validation
|
|
|
|
|
|
|
|
Instead of using labels inside the docker-compose file, you can use a `katenary.yaml` file to define the labels. This
|
|
|
|
file is simpler to read and maintain, but you need to keep it up-to-date with the docker-compose file.
|
|
|
|
|
|
|
|
For example, instead of using this:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
services:
|
|
|
|
web:
|
|
|
|
image: nginx:latest
|
|
|
|
katenary.v3/ingress: |-
|
|
|
|
hostname: myapp.example.com
|
|
|
|
port: 80
|
|
|
|
```
|
|
|
|
|
|
|
|
You can remove the labels, and use a kanetary.yaml file:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
web:
|
|
|
|
ingress:
|
|
|
|
hostname: myapp.example.com
|
|
|
|
port: 80
|
|
|
|
```
|
|
|
|
|
|
|
|
To validate the `katenary.yaml` file, you can use the JSON schema using the "master" raw content:
|
|
|
|
|
|
|
|
`https://raw.githubusercontent.com/metal3d/katenary/refs/heads/master/katenary.json`
|
|
|
|
|
2024-11-26 23:43:57 +01:00
|
|
|
It's easy to configure in [LazyVim](https://www.lazyvim.org/), using `nvim-lspconfig`,
|
|
|
|
create a Lua file in your `plugins` directory, or apply the settings as the example below:
|
2024-11-26 17:10:54 +01:00
|
|
|
|
|
|
|
```lua
|
|
|
|
-- yaml.lua
|
|
|
|
|
|
|
|
return {
|
|
|
|
{
|
|
|
|
"neovim/nvim-lspconfig",
|
|
|
|
opts = {
|
|
|
|
servers = {
|
|
|
|
yamlls = {
|
|
|
|
settings = {
|
|
|
|
yaml = {
|
|
|
|
schemas = {
|
|
|
|
["https://raw.githubusercontent.com/metal3d/katenary/refs/heads/master/katenary.json"] = "katenary.yaml",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Use this address to validate the `katenary.yaml` file in VSCode:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"yaml.schemas": {
|
|
|
|
"https://raw.githubusercontent.com/metal3d/katenary/refs/heads/master/katenary.json": "katenary.yaml"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2024-11-26 23:43:57 +01:00
|
|
|
> You can, of course, replace the `refs/heads/master` with a specific tag or branch.
|
2024-11-26 17:10:54 +01:00
|
|
|
|
|
|
|
## What a name…
|
2022-02-17 15:12:15 +01:00
|
|
|
|
|
|
|
Katenary is the stylized name of the project that comes from the "catenary" word.
|
|
|
|
|
2024-04-03 23:30:24 +02:00
|
|
|
A catenary is a curve formed by a wire, rope, or chain hanging freely from two points that are not in the same vertical
|
|
|
|
line. For example, the anchor chain between a boat and the anchor.
|
2022-02-17 15:12:15 +01:00
|
|
|
|
2024-10-17 17:08:42 +02:00
|
|
|
This curved link represents what we try to do, the project is a stretched link from docker-compose to helm chart.
|