Merge pull request #82 from metal3d/develop
Some fixes on "same-pod" and volumes + add some tests
This commit is contained in:
@@ -16,7 +16,8 @@ effortlessly, saving you time and energy.
|
|||||||
🛠️ Simple automated CLI: Katenary handles the grunt work, generating everything needed for seamless service binding
|
🛠️ Simple automated CLI: Katenary handles the grunt work, generating everything needed for seamless service binding
|
||||||
and Helm Chart creation.
|
and Helm Chart creation.
|
||||||
|
|
||||||
💡 Effortless Efficiency: You only need to add labels when it's necessary to precise things. Then call `katenary convert` and let the magic happen.
|
💡 Effortless Efficiency: You only need to add labels when it's necessary to precise things.
|
||||||
|
Then call `katenary convert` and let the magic happen.
|
||||||
|
|
||||||
# What ?
|
# What ?
|
||||||
|
|
||||||
@@ -160,7 +161,7 @@ services:
|
|||||||
katenary.v3/ingress: |-
|
katenary.v3/ingress: |-
|
||||||
hostname: myapp.example.com
|
hostname: myapp.example.com
|
||||||
port: 80
|
port: 80
|
||||||
katenary.v3/mapenv: |-
|
katenary.v3/map-env: |-
|
||||||
# make adaptations, DB_HOST environment is actually the service name
|
# make adaptations, DB_HOST environment is actually the service name
|
||||||
DB_HOST: '{{ .Release.Name }}-database'
|
DB_HOST: '{{ .Release.Name }}-database'
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@ Since version v3, Katenary uses, in addition to `go-compose`, the `k8s` library
|
|||||||
to work before transformation. Katenary adds Helm syntax entries to add loops, transformations, and conditions.
|
to work before transformation. Katenary adds Helm syntax entries to add loops, transformations, and conditions.
|
||||||
|
|
||||||
We really try to follow best practices and code principles. But, Katenary needs a lot of workarounds and string
|
We really try to follow best practices and code principles. But, Katenary needs a lot of workarounds and string
|
||||||
manipulation during the process. There are, also, some drawbacks using standard k8s packages that makes a lot of type
|
manipulation during the process. There are, also, some drawbacks using standard k8s packages that make a lot of type
|
||||||
checks when generating the objects. We need to finalize the values after object generation.
|
checks when generating the objects. We need to finalize the values after object generation.
|
||||||
|
|
||||||
**This makes the coding a bit harder than simply converting from YAML to YAML.**
|
**This makes the coding a bit harder than simply converting from YAML to YAML.**
|
||||||
@@ -59,9 +59,9 @@ its associated service are still created. They are deleted last, once the merge
|
|||||||
|
|
||||||
## Conversion in "`generator`" package
|
## Conversion in "`generator`" package
|
||||||
|
|
||||||
The `generator` package is where object struct are defined, and where the `Generate()` function is written.
|
The `generator` package is where object struct are defined, and where you can find the `Generate()` function.
|
||||||
|
|
||||||
The generation is made by using a `HelmChart` object:
|
The generation fills `HelmChart` object using a loop:
|
||||||
|
|
||||||
```golang
|
```golang
|
||||||
for _, service := range project.Services {
|
for _, service := range project.Services {
|
||||||
@@ -75,7 +75,7 @@ for _, service := range project.Services {
|
|||||||
```
|
```
|
||||||
|
|
||||||
**A lot** of string manipulations are made by each `Yaml()` methods. This is where you find the complex and impacting
|
**A lot** of string manipulations are made by each `Yaml()` methods. This is where you find the complex and impacting
|
||||||
operations. The `Yaml` methods **don't return a valid YAML content**. This is a Helm Chart Yaml content with template
|
operations. The `Yaml` methods **don't return a valid YAML content**. This is a Helm Chart YAML content with template
|
||||||
conditions, values and calls to helper templates.
|
conditions, values and calls to helper templates.
|
||||||
|
|
||||||
> The `Yaml()` methods, in each object, need contribution, help, fixes, enhancements... They work, but there is a lot of
|
> The `Yaml()` methods, in each object, need contribution, help, fixes, enhancements... They work, but there is a lot of
|
||||||
@@ -92,11 +92,11 @@ For each source container linked to the destination:
|
|||||||
- we then copy the service port to the destination service
|
- we then copy the service port to the destination service
|
||||||
- we finally remove the source service and deployment
|
- we finally remove the source service and deployment
|
||||||
|
|
||||||
> The configmap, secrets, variables... are kept.
|
> The `Configmap`, secrets, variables... are kept.
|
||||||
|
|
||||||
It finaly computes the `helper` file.
|
It finally computes the `helper` file.
|
||||||
|
|
||||||
## Convertion command
|
## Conversion command
|
||||||
|
|
||||||
The `generator` works the same as described above. But the "convert" command makes some final steps:
|
The `generator` works the same as described above. But the "convert" command makes some final steps:
|
||||||
|
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
# Why those dependencies?
|
# Why those dependencies?
|
||||||
|
|
||||||
Katenary uses `compose-go` and several kubernetes official packages.
|
Katenary uses `compose-go` and several Kubernetes official packages.
|
||||||
|
|
||||||
- `github.com/compose-spec/compose-go`: to parse compose files. It ensures :
|
- `github.com/compose-spec/compose-go`: to parse compose files. It ensures :
|
||||||
- that the project respects the "compose" specification
|
- that the project respects the "compose" specification
|
||||||
- that Katenary uses the "compose" struct exactly the same way `podman compose` or `docker copose` does
|
- that Katenary uses the "compose" struct exactly the same way `podman compose` or `docker copose` does
|
||||||
- `github.com/spf13/cobra`: to parse command line arguments, subcommands and flags. It also generates completion for
|
- `github.com/spf13/cobra`: to parse command line arguments, sub-commands and flags. It also generates completion for
|
||||||
bash, zsh, fish and PowerShell.
|
bash, zsh, fish and PowerShell.
|
||||||
- `github.com/thediveo/netdb`: to get the standard names of a service from its port number
|
- `github.com/thediveo/netdb`: to get the standard names of a service from its port number
|
||||||
- `gopkg.in/yaml.v3`:
|
- `gopkg.in/yaml.v3`:
|
||||||
|
@@ -23,7 +23,7 @@ Kompose is able to generate Helm charts, but [it could be not the case in future
|
|||||||
task, and we can confirm. Katenary takes a lot of time to be developed and maintained. This issue mentions Katenary as
|
task, and we can confirm. Katenary takes a lot of time to be developed and maintained. This issue mentions Katenary as
|
||||||
an alternative to Helm chart generation :smile:
|
an alternative to Helm chart generation :smile:
|
||||||
|
|
||||||
The project is focused on Kubernetes manifests and proposes to use "kusomize" to adapt the manifests. Helm seems to be
|
The project is focused on Kubernetes manifests and proposes to use "Kustomize" to adapt the manifests. Helm seems to be
|
||||||
not the priority.
|
not the priority.
|
||||||
|
|
||||||
Anyway, before this decision, the Helm chart generation was not what we expected. We wanted to have a more complete
|
Anyway, before this decision, the Helm chart generation was not what we expected. We wanted to have a more complete
|
||||||
@@ -41,7 +41,7 @@ your `docker-compose` files to Kubernetes manifests, but if you want to use Helm
|
|||||||
|
|
||||||
## Why not using "one label" for all the configuration?
|
## Why not using "one label" for all the configuration?
|
||||||
|
|
||||||
That was a dicsussion I had with my colleagues. The idea was to use a single label to store all the configuration.
|
That was a discussion I had with my colleagues. The idea was to use a single label to store all the configuration.
|
||||||
But, it's not a good idea.
|
But, it's not a good idea.
|
||||||
|
|
||||||
Sometimes, you will have a long list of things to configure, like ports, ingress, dependencies, etc. It's better to have
|
Sometimes, you will have a long list of things to configure, like ports, ingress, dependencies, etc. It's better to have
|
||||||
@@ -78,7 +78,8 @@ There is no reason to use Rust for this project.
|
|||||||
Yes, it's a possibility. But, it's not a priority. We have a lot of things to do before. We need to stabilize the
|
Yes, it's a possibility. But, it's not a priority. We have a lot of things to do before. We need to stabilize the
|
||||||
project, to have a good documentation, to have a good test coverage, and to have a good community.
|
project, to have a good documentation, to have a good test coverage, and to have a good community.
|
||||||
|
|
||||||
But, in a not so far future, we could have a GUI. The choice of [Fyne.io](https://fyne.io) is already made and we tested some concepts.
|
But, in a not so far future, we could have a GUI. The choice of [Fyne.io](https://fyne.io) is already made, and we
|
||||||
|
tested some concepts.
|
||||||
|
|
||||||
## I'm rich (or not), I want to help you. How can I do?
|
## I'm rich (or not), I want to help you. How can I do?
|
||||||
|
|
||||||
@@ -86,13 +87,13 @@ You can help us in many ways.
|
|||||||
|
|
||||||
- The first things we really need, more than money, more than anything else, is to have feedback. If you use Katenary,
|
- The first things we really need, more than money, more than anything else, is to have feedback. If you use Katenary,
|
||||||
if you have some issues, if you have some ideas, please open an issue on the [GitHub repository](https://github.com/metal3d/katenary).
|
if you have some issues, if you have some ideas, please open an issue on the [GitHub repository](https://github.com/metal3d/katenary).
|
||||||
- The second things is to help us to fix issues. If you're a Go developper, or if you want to fix the documentation,
|
- The second thing is to help us to fix issues. If you're a Go developer, or if you want to fix the documentation,
|
||||||
your help is greatly appreciated.
|
your help is greatly appreciated.
|
||||||
- And then, of course, we need money, or sponsors.
|
- And then, of course, we need money, or sponsors.
|
||||||
|
|
||||||
### If you're a company
|
### If you're a company
|
||||||
|
|
||||||
We will be happy to communicate your help by putting your logo on the website and in the documentaiton. You can sponsor
|
We will be happy to communicate your help by putting your logo on the website and in the documentation. You can sponsor
|
||||||
us by giving us some money, or by giving us some time of your developers, or leaving us some time to work on the project.
|
us by giving us some money, or by giving us some time of your developers, or leaving us some time to work on the project.
|
||||||
|
|
||||||
### If you're an individual
|
### If you're an individual
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
Tired of manual conversions? Katenary harnesses the labels from your "compose" file to craft complete Helm Charts
|
Tired of manual conversions? Katenary harnesses the labels from your "compose" file to craft complete Helm Charts
|
||||||
effortlessly, saving you time and energy.
|
effortlessly, saving you time and energy.
|
||||||
|
|
||||||
🛠️ Simple autmated CLI: Katenary handles the grunt work, generating everything needed for seamless service binding
|
🛠️ Simple automated CLI: Katenary handles the grunt work, generating everything needed for seamless service binding
|
||||||
and Helm Chart creation.
|
and Helm Chart creation.
|
||||||
|
|
||||||
💡 Effortless Efficiency: You only need to add labels when it's necessary to precise things. Then call `katenary convert`
|
💡 Effortless Efficiency: You only need to add labels when it's necessary to precise things. Then call `katenary convert`
|
||||||
@@ -21,18 +21,18 @@ and let the magic happen.
|
|||||||
|
|
||||||
# What is it?
|
# What is it?
|
||||||
|
|
||||||
Katenary is a tool made to help you to transform "compose" files (`compose.yaml`, `docker-compose.yml`, `podman-compose.yml`...) to
|
Katenary is a tool made to help you to transform "compose" files (`compose.yaml`, `docker-compose.yml`,
|
||||||
complete and production ready [Helm Chart](https://helm.sh).
|
`podman-compose.yml`...) to complete and production ready [Helm Chart](https://helm.sh).
|
||||||
|
|
||||||
You'll be able to deploy your project in [:material-kubernetes: Kubernetes](https://kubernetes.io) in a few seconds
|
You'll be able to deploy your project in [:material-kubernetes: Kubernetes](https://kubernetes.io) in a few seconds
|
||||||
(of course, more if you need to tweak with labels).
|
(of course, more if you need to tweak with labels).
|
||||||
|
|
||||||
It uses your current file and optionnaly labels to configure the result.
|
It uses your current file and optionally labels to configure the result.
|
||||||
|
|
||||||
It's an opensource project, under MIT licence, originally partially developped at [Smile](https://www.smile.eu).
|
It's an open source project, under MIT license, originally partially developed at [Smile](https://www.smile.eu).
|
||||||
|
|
||||||
Today, it's partially developped in collaboration with [Klee Group](https://www.kleegroup.com). Note that Katenary is
|
Today, it's partially developed in collaboration with [Klee Group](https://www.kleegroup.com). Note that Katenary is
|
||||||
and **will stay an opensource and free (as freedom) project**. We are convinced that the best way to make it better is to
|
and **will stay an open source and free (as freedom) project**. We are convinced that the best way to make it better is to
|
||||||
share it with the community.
|
share it with the community.
|
||||||
|
|
||||||
<div id="klee">
|
<div id="klee">
|
||||||
@@ -46,9 +46,9 @@ code is hosted on the [:fontawesome-brands-github: Katenary GitHub Repository](h
|
|||||||
|
|
||||||
## Install Katenary
|
## Install Katenary
|
||||||
|
|
||||||
Katenary is developped using the :fontawesome-brands-golang:{ .gopher } [Go](https://go.dev) language.
|
Katenary is developed using the :fontawesome-brands-golang:{ .gopher } [Go](https://go.dev) language.
|
||||||
The binary is statically linked, so you can simply download it from the [release
|
The binary is statically linked, so you can simply download it from the [release
|
||||||
page](https://github.com/metal3d/katenary/releases) of the project in GutHub.
|
page](https://github.com/metal3d/katenary/releases) of the project in GitHub.
|
||||||
|
|
||||||
You need to select the right binary for your operating system and architecture, and copy the binary in a directory
|
You need to select the right binary for your operating system and architecture, and copy the binary in a directory
|
||||||
that is in your `PATH`.
|
that is in your `PATH`.
|
||||||
@@ -61,7 +61,7 @@ sh <(curl -sSL https://raw.githubusercontent.com/metal3d/katenary/master/install
|
|||||||
```
|
```
|
||||||
|
|
||||||
!!! Info "Upgrading is integrated to the `katenary` command"
|
!!! Info "Upgrading is integrated to the `katenary` command"
|
||||||
Katenary propose a `upgrade` subcommand to update the current binary to the latest stable release.
|
Katenary propose a `upgrade` sub-command to update the current binary to the latest stable release.
|
||||||
|
|
||||||
Of course, you need to install Katenary once :smile:
|
Of course, you need to install Katenary once :smile:
|
||||||
|
|
||||||
@@ -122,18 +122,18 @@ Anyway, it's too late to change the name now :smile:
|
|||||||
## Special thanks to
|
## Special thanks to
|
||||||
|
|
||||||
I really want to thank all the contributors, testers, and of course, the authors of the packages and tools that are used
|
I really want to thank all the contributors, testers, and of course, the authors of the packages and tools that are used
|
||||||
in this project. There is too many to list here. Katenary can works because of all these people. Open source is a great
|
in this project. There is too many to list here. Katenary can work because of all these people. Open source is a great
|
||||||
thing! :heart:
|
thing! :heart:
|
||||||
|
|
||||||
!!! Edit "Special thanks"
|
!!! Edit "Special thanks"
|
||||||
|
|
||||||
**Katenary is built with:** <br />
|
**Katenary is built with:** <br />
|
||||||
|
|
||||||
<a href="https://go.dev" target="_blank">:fontawesome-brands-golang:{ .go-logo }</a>
|
<a href="https://go.dev" target="_blank">:fontawesome-brands-golang:{ .go-logo }</a>
|
||||||
|
|
||||||
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software. Because Docker, Podman,
|
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
|
||||||
Kubernetes, and Helm are written in Go, Katenary is also written in Go and borrows packages from these projects to
|
Because Docker, Podman, Kubernetes, and Helm are written in Go, Katenary is also written in Go and borrows packages
|
||||||
make it as efficient as possible.
|
from these projects to make it as efficient as possible.
|
||||||
|
|
||||||
Thanks to Kubernetes to provide [Kind](https://kind.sigs.k8s.io) that is used to test Katenary locally.
|
Thanks to Kubernetes to provide [Kind](https://kind.sigs.k8s.io) that is used to test Katenary locally.
|
||||||
|
|
||||||
@@ -142,17 +142,17 @@ thing! :heart:
|
|||||||
Katenary can progress because of all these people. All contributions, as comments, issues, pull requests and
|
Katenary can progress because of all these people. All contributions, as comments, issues, pull requests and
|
||||||
feedbacks are welcome.
|
feedbacks are welcome.
|
||||||
|
|
||||||
**Everything was also possible because of:** <br />
|
**Everything was also possible because of:** <br />
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="https://helm.sh" target="_blank"><img src="https://helm.sh/img/helm.svg" style="height: 1rem"/>
|
<li><a href="https://helm.sh" target="_blank"><img src="https://helm.sh/img/helm.svg" style="height: 1rem"/>
|
||||||
Helm</a> that is the main toppic of Katenary, Kubernetes is easier to use with it.</li>
|
Helm</a> that is the main toppic of Katenary, Kubernetes is easier to use with it.</li>
|
||||||
<li><a href="https://cobra.dev/"><img src="https://cobra.dev/home/logo.png" style="height: 1rem"/> Cobra</a> that
|
<li><a href="https://cobra.dev/"><img src="https://cobra.dev/home/logo.png" style="height: 1rem"/> Cobra</a> that
|
||||||
makes command, subcommand and completion possible for Katenary with ease.</li>
|
makes command, subcommand and completion possible for Katenary with ease.</li>
|
||||||
<li>Podman, Docker, Kubernetes that are the main tools that Katenary is made for.</li>
|
<li>Podman, Docker, Kubernetes that are the main tools that Katenary is made for.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
**Documentation is built with:** <br />
|
**Documentation is built with:** <br />
|
||||||
|
|
||||||
<a href="https://www.mkdocs.org/" target="_blank">MkDocs</a> using <a
|
<a href="https://www.mkdocs.org/" target="_blank">MkDocs</a> using <a
|
||||||
href="https://squidfunk.github.io/mkdocs-material/" target="_blank">Material for MkDocs</a> theme template.
|
href="https://squidfunk.github.io/mkdocs-material/" target="_blank">Material for MkDocs</a> theme template.
|
||||||
|
@@ -7,22 +7,23 @@ Katenary will try to Unmarshal these labels.
|
|||||||
## Label list and types
|
## Label list and types
|
||||||
|
|
||||||
<!-- START_LABEL_DOC : do not remove this tag !-->
|
<!-- START_LABEL_DOC : do not remove this tag !-->
|
||||||
| Label name | Description | Type |
|
| Label name | Description | Type |
|
||||||
| ---------------------------- | ------------------------------------------------------ | --------------------- |
|
| ----------------------------- | ---------------------------------------------------------------- | --------------------- |
|
||||||
| `katenary.v3/configmap-files` | Add files to the configmap. | list of strings |
|
| `katenary.v3/configmap-files` | Add files to the configmap. | list of strings |
|
||||||
| `katenary.v3/cronjob` | Create a cronjob from the service. | object |
|
| `katenary.v3/cronjob` | Create a cronjob from the service. | object |
|
||||||
| `katenary.v3/dependencies` | Add Helm dependencies to the service. | list of objects |
|
| `katenary.v3/dependencies` | Add Helm dependencies to the service. | list of objects |
|
||||||
| `katenary.v3/description` | Description of the service | string |
|
| `katenary.v3/description` | Description of the service | string |
|
||||||
| `katenary.v3/env-from` | Add environment variables from antoher service. | list of strings |
|
| `katenary.v3/env-from` | Add environment variables from antoher service. | list of strings |
|
||||||
| `katenary.v3/health-check` | Health check to be added to the deployment. | object |
|
| `katenary.v3/exchange-volumes` | Add exchange volumes (empty directory on the node) to share data | list of objects |
|
||||||
| `katenary.v3/ignore` | Ignore the service | bool |
|
| `katenary.v3/health-check` | Health check to be added to the deployment. | object |
|
||||||
| `katenary.v3/ingress` | Ingress rules to be added to the service. | object |
|
| `katenary.v3/ignore` | Ignore the service | bool |
|
||||||
| `katenary.v3/main-app` | Mark the service as the main app. | bool |
|
| `katenary.v3/ingress` | Ingress rules to be added to the service. | object |
|
||||||
| `katenary.v3/map-env` | Map env vars from the service to the deployment. | object |
|
| `katenary.v3/main-app` | Mark the service as the main app. | bool |
|
||||||
| `katenary.v3/ports` | Ports to be added to the service. | list of uint32 |
|
| `katenary.v3/map-env` | Map env vars from the service to the deployment. | object |
|
||||||
| `katenary.v3/same-pod` | Move the same-pod deployment to the target deployment. | string |
|
| `katenary.v3/ports` | Ports to be added to the service. | list of uint32 |
|
||||||
| `katenary.v3/secrets` | Env vars to be set as secrets. | list of string |
|
| `katenary.v3/same-pod` | Move the same-pod deployment to the target deployment. | string |
|
||||||
| `katenary.v3/values` | Environment variables to be added to the values.yaml | list of string or map |
|
| `katenary.v3/secrets` | Env vars to be set as secrets. | list of string |
|
||||||
|
| `katenary.v3/values` | Environment variables to be added to the values.yaml | list of string or map |
|
||||||
|
|
||||||
<!-- STOP_LABEL_DOC : do not remove this tag !-->
|
<!-- STOP_LABEL_DOC : do not remove this tag !-->
|
||||||
|
|
||||||
@@ -33,7 +34,7 @@ Katenary will try to Unmarshal these labels.
|
|||||||
|
|
||||||
Add files to the configmap.
|
Add files to the configmap.
|
||||||
|
|
||||||
**Type**: `list of strings`
|
**Type**: `list of strings`
|
||||||
|
|
||||||
It makes a file or directory to be converted to one or more ConfigMaps
|
It makes a file or directory to be converted to one or more ConfigMaps
|
||||||
and mounted in the pod. The file or directory is relative to the
|
and mounted in the pod. The file or directory is relative to the
|
||||||
@@ -59,11 +60,12 @@ labels:
|
|||||||
- ./conf.d
|
- ./conf.d
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### katenary.v3/cronjob
|
### katenary.v3/cronjob
|
||||||
|
|
||||||
Create a cronjob from the service.
|
Create a cronjob from the service.
|
||||||
|
|
||||||
**Type**: `object`
|
**Type**: `object`
|
||||||
|
|
||||||
This adds a cronjob to the chart.
|
This adds a cronjob to the chart.
|
||||||
|
|
||||||
@@ -83,11 +85,12 @@ labels:
|
|||||||
schedule: "* */1 * * *" # or @hourly for example
|
schedule: "* */1 * * *" # or @hourly for example
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### katenary.v3/dependencies
|
### katenary.v3/dependencies
|
||||||
|
|
||||||
Add Helm dependencies to the service.
|
Add Helm dependencies to the service.
|
||||||
|
|
||||||
**Type**: `list of objects`
|
**Type**: `list of objects`
|
||||||
|
|
||||||
Set the service to be, actually, a Helm dependency. This means that the
|
Set the service to be, actually, a Helm dependency. This means that the
|
||||||
service will not be exported as template. The dependencies are added to
|
service will not be exported as template. The dependencies are added to
|
||||||
@@ -129,11 +132,12 @@ labels:
|
|||||||
password: the secret password
|
password: the secret password
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### katenary.v3/description
|
### katenary.v3/description
|
||||||
|
|
||||||
Description of the service
|
Description of the service
|
||||||
|
|
||||||
**Type**: `string`
|
**Type**: `string`
|
||||||
|
|
||||||
This replaces the default comment in values.yaml file to the given description.
|
This replaces the default comment in values.yaml file to the given description.
|
||||||
It is useful to document the service and configuration.
|
It is useful to document the service and configuration.
|
||||||
@@ -149,11 +153,12 @@ labels:
|
|||||||
It can be multiline.
|
It can be multiline.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### katenary.v3/env-from
|
### katenary.v3/env-from
|
||||||
|
|
||||||
Add environment variables from antoher service.
|
Add environment variables from antoher service.
|
||||||
|
|
||||||
**Type**: `list of strings`
|
**Type**: `list of strings`
|
||||||
|
|
||||||
It adds environment variables from another service to the current service.
|
It adds environment variables from another service to the current service.
|
||||||
|
|
||||||
@@ -174,11 +179,55 @@ service2:
|
|||||||
- myservice1
|
- myservice1
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### katenary.v3/exchange-volumes
|
||||||
|
|
||||||
|
Add exchange volumes (empty directory on the node) to share data
|
||||||
|
|
||||||
|
**Type**: `list of objects`
|
||||||
|
|
||||||
|
This label allows sharing data between containres. The volume is created in
|
||||||
|
the node and mounted in the pod. It is useful to share data between containers
|
||||||
|
in a "same pod" logic. For example to let PHP-FPM and Nginx share the same direcotory.
|
||||||
|
|
||||||
|
This will create:
|
||||||
|
|
||||||
|
- an `emptyDir` volume in the deployment
|
||||||
|
- a `voumeMount` in the pod for **each container**
|
||||||
|
- a `initContainer` for each definition
|
||||||
|
|
||||||
|
Fields:
|
||||||
|
- name: the name of the volume (manadatory)
|
||||||
|
- mountPath: the path where the volume is mounted in the pod (optional, default is `/opt`)
|
||||||
|
- init: a command to run to initialize the volume with data (optional)
|
||||||
|
|
||||||
|
!!! Warning
|
||||||
|
This is highly experimental. This is mainly useful when using the "same-pod" label.
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
nginx:
|
||||||
|
# ...
|
||||||
|
labels;
|
||||||
|
katenary.v3/exchange-volumes: |-
|
||||||
|
- name: php-fpm
|
||||||
|
mountPath: /var/www/html
|
||||||
|
php:
|
||||||
|
# ...
|
||||||
|
labels:
|
||||||
|
katenary.v3/exchange-volumes: |-
|
||||||
|
- name: php-fpm
|
||||||
|
mountPath: /opt
|
||||||
|
init: cp -ra /var/www/html/* /opt
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### katenary.v3/health-check
|
### katenary.v3/health-check
|
||||||
|
|
||||||
Health check to be added to the deployment.
|
Health check to be added to the deployment.
|
||||||
|
|
||||||
**Type**: `object`
|
**Type**: `object`
|
||||||
|
|
||||||
Health check to be added to the deployment.
|
Health check to be added to the deployment.
|
||||||
|
|
||||||
@@ -193,11 +242,12 @@ labels:
|
|||||||
port: 8080
|
port: 8080
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### katenary.v3/ignore
|
### katenary.v3/ignore
|
||||||
|
|
||||||
Ignore the service
|
Ignore the service
|
||||||
|
|
||||||
**Type**: `bool`
|
**Type**: `bool`
|
||||||
|
|
||||||
Ingoring a service to not be exported in helm chart.
|
Ingoring a service to not be exported in helm chart.
|
||||||
|
|
||||||
@@ -208,11 +258,12 @@ labels:
|
|||||||
katenary.v3/ignore: "true"
|
katenary.v3/ignore: "true"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### katenary.v3/ingress
|
### katenary.v3/ingress
|
||||||
|
|
||||||
Ingress rules to be added to the service.
|
Ingress rules to be added to the service.
|
||||||
|
|
||||||
**Type**: `object`
|
**Type**: `object`
|
||||||
|
|
||||||
Declare an ingress rule for the service. The port should be exposed or
|
Declare an ingress rule for the service. The port should be exposed or
|
||||||
declared with `katenary.v3/ports`.
|
declared with `katenary.v3/ports`.
|
||||||
@@ -226,17 +277,16 @@ labels:
|
|||||||
hostname: mywebsite.com (optional)
|
hostname: mywebsite.com (optional)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### katenary.v3/main-app
|
### katenary.v3/main-app
|
||||||
|
|
||||||
Mark the service as the main app.
|
Mark the service as the main app.
|
||||||
|
|
||||||
**Type**: `bool`
|
**Type**: `bool`
|
||||||
|
|
||||||
This makes the service to be the main application. Its image tag is
|
This makes the service to be the main application. Its image tag is
|
||||||
considered to be the
|
considered to be the Chart appVersion and to be the defaultvalue in Pod
|
||||||
|
container image attribute.
|
||||||
Chart appVersion and to be the defaultvalue in Pod container
|
|
||||||
image attribute.
|
|
||||||
|
|
||||||
!!! Warning
|
!!! Warning
|
||||||
This label cannot be repeated in others services. If this label is
|
This label cannot be repeated in others services. If this label is
|
||||||
@@ -254,11 +304,12 @@ ghost:
|
|||||||
katenary.v3/main-app: true
|
katenary.v3/main-app: true
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### katenary.v3/map-env
|
### katenary.v3/map-env
|
||||||
|
|
||||||
Map env vars from the service to the deployment.
|
Map env vars from the service to the deployment.
|
||||||
|
|
||||||
**Type**: `object`
|
**Type**: `object`
|
||||||
|
|
||||||
Because you may need to change the variable for Kubernetes, this label
|
Because you may need to change the variable for Kubernetes, this label
|
||||||
forces the value to another. It is also particullary helpful to use a template
|
forces the value to another. It is also particullary helpful to use a template
|
||||||
@@ -281,11 +332,12 @@ labels:
|
|||||||
DB_HOST: '{{ include "__APP__.fullname" . }}-database'
|
DB_HOST: '{{ include "__APP__.fullname" . }}-database'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### katenary.v3/ports
|
### katenary.v3/ports
|
||||||
|
|
||||||
Ports to be added to the service.
|
Ports to be added to the service.
|
||||||
|
|
||||||
**Type**: `list of uint32`
|
**Type**: `list of uint32`
|
||||||
|
|
||||||
Only useful for services without exposed port. It is mandatory if the
|
Only useful for services without exposed port. It is mandatory if the
|
||||||
service is a dependency of another service.
|
service is a dependency of another service.
|
||||||
@@ -299,11 +351,12 @@ labels:
|
|||||||
- 8081
|
- 8081
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### katenary.v3/same-pod
|
### katenary.v3/same-pod
|
||||||
|
|
||||||
Move the same-pod deployment to the target deployment.
|
Move the same-pod deployment to the target deployment.
|
||||||
|
|
||||||
**Type**: `string`
|
**Type**: `string`
|
||||||
|
|
||||||
This will make the service to be included in another service pod. Some services
|
This will make the service to be included in another service pod. Some services
|
||||||
must work together in the same pod, like a sidecar or a proxy or nginx + php-fpm.
|
must work together in the same pod, like a sidecar or a proxy or nginx + php-fpm.
|
||||||
@@ -323,11 +376,12 @@ php:
|
|||||||
katenary.v3/same-pod: web
|
katenary.v3/same-pod: web
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### katenary.v3/secrets
|
### katenary.v3/secrets
|
||||||
|
|
||||||
Env vars to be set as secrets.
|
Env vars to be set as secrets.
|
||||||
|
|
||||||
**Type**: `list of string`
|
**Type**: `list of string`
|
||||||
|
|
||||||
This label allows setting the environment variables as secrets. The variable
|
This label allows setting the environment variables as secrets. The variable
|
||||||
is removed from the environment and added to a secret object.
|
is removed from the environment and added to a secret object.
|
||||||
@@ -346,11 +400,12 @@ labels:
|
|||||||
- PASSWORD
|
- PASSWORD
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### katenary.v3/values
|
### katenary.v3/values
|
||||||
|
|
||||||
Environment variables to be added to the values.yaml
|
Environment variables to be added to the values.yaml
|
||||||
|
|
||||||
**Type**: `list of string or map`
|
**Type**: `list of string or map`
|
||||||
|
|
||||||
By default, all environment variables in the "env" and environment
|
By default, all environment variables in the "env" and environment
|
||||||
files are added to configmaps with the static values set. This label
|
files are added to configmaps with the static values set. This label
|
||||||
@@ -382,4 +437,5 @@ labels:
|
|||||||
It can be, of course, a multiline text.
|
It can be, of course, a multiline text.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
<!-- STOP_DETAILED_DOC : do not remove this tag !-->
|
<!-- STOP_DETAILED_DOC : do not remove this tag !-->
|
||||||
|
@@ -23,7 +23,7 @@ var (
|
|||||||
|
|
||||||
// Standard annotationss
|
// Standard annotationss
|
||||||
Annotations = map[string]string{
|
Annotations = map[string]string{
|
||||||
labelName("version"): Version,
|
labels.LabelName("version"): Version,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
@@ -35,7 +35,7 @@ var Version = "master" // changed at compile time
|
|||||||
```
|
```
|
||||||
|
|
||||||
<a name="Convert"></a>
|
<a name="Convert"></a>
|
||||||
## func [Convert](<https://github.com/metal3d/katenary/blob/develop/generator/converter.go#L91>)
|
## func [Convert](<https://github.com/metal3d/katenary/blob/develop/generator/converter.go#L93>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func Convert(config ConvertOptions, dockerComposeFile ...string)
|
func Convert(config ConvertOptions, dockerComposeFile ...string)
|
||||||
@@ -43,35 +43,8 @@ func Convert(config ConvertOptions, dockerComposeFile ...string)
|
|||||||
|
|
||||||
Convert a compose \(docker, podman...\) project to a helm chart. It calls Generate\(\) to generate the chart and then write it to the disk.
|
Convert a compose \(docker, podman...\) project to a helm chart. It calls Generate\(\) to generate the chart and then write it to the disk.
|
||||||
|
|
||||||
<a name="GetLabelHelp"></a>
|
|
||||||
## func [GetLabelHelp](<https://github.com/metal3d/katenary/blob/develop/generator/katenaryLabels.go#L79>)
|
|
||||||
|
|
||||||
```go
|
|
||||||
func GetLabelHelp(asMarkdown bool) string
|
|
||||||
```
|
|
||||||
|
|
||||||
Generate the help for the labels.
|
|
||||||
|
|
||||||
<a name="GetLabelHelpFor"></a>
|
|
||||||
## func [GetLabelHelpFor](<https://github.com/metal3d/katenary/blob/develop/generator/katenaryLabels.go#L88>)
|
|
||||||
|
|
||||||
```go
|
|
||||||
func GetLabelHelpFor(labelname string, asMarkdown bool) string
|
|
||||||
```
|
|
||||||
|
|
||||||
GetLabelHelpFor returns the help for a specific label.
|
|
||||||
|
|
||||||
<a name="GetLabelNames"></a>
|
|
||||||
## func [GetLabelNames](<https://github.com/metal3d/katenary/blob/develop/generator/katenaryLabels.go#L63>)
|
|
||||||
|
|
||||||
```go
|
|
||||||
func GetLabelNames() []string
|
|
||||||
```
|
|
||||||
|
|
||||||
GetLabelNames returns a sorted list of all katenary label names.
|
|
||||||
|
|
||||||
<a name="GetLabels"></a>
|
<a name="GetLabels"></a>
|
||||||
## func [GetLabels](<https://github.com/metal3d/katenary/blob/develop/generator/labels.go#L11>)
|
## func [GetLabels](<https://github.com/metal3d/katenary/blob/develop/generator/labels.go#L12>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func GetLabels(serviceName, appName string) map[string]string
|
func GetLabels(serviceName, appName string) map[string]string
|
||||||
@@ -80,7 +53,7 @@ func GetLabels(serviceName, appName string) map[string]string
|
|||||||
GetLabels returns the labels for a service. It uses the appName to replace the \_\_replace\_\_ in the labels. This is used to generate the labels in the templates.
|
GetLabels returns the labels for a service. It uses the appName to replace the \_\_replace\_\_ in the labels. This is used to generate the labels in the templates.
|
||||||
|
|
||||||
<a name="GetMatchLabels"></a>
|
<a name="GetMatchLabels"></a>
|
||||||
## func [GetMatchLabels](<https://github.com/metal3d/katenary/blob/develop/generator/labels.go#L24>)
|
## func [GetMatchLabels](<https://github.com/metal3d/katenary/blob/develop/generator/labels.go#L25>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func GetMatchLabels(serviceName, appName string) map[string]string
|
func GetMatchLabels(serviceName, appName string) map[string]string
|
||||||
@@ -89,7 +62,7 @@ func GetMatchLabels(serviceName, appName string) map[string]string
|
|||||||
GetMatchLabels returns the matchLabels for a service. It uses the appName to replace the \_\_replace\_\_ in the labels. This is used to generate the matchLabels in the templates.
|
GetMatchLabels returns the matchLabels for a service. It uses the appName to replace the \_\_replace\_\_ in the labels. This is used to generate the matchLabels in the templates.
|
||||||
|
|
||||||
<a name="Helper"></a>
|
<a name="Helper"></a>
|
||||||
## func [Helper](<https://github.com/metal3d/katenary/blob/develop/generator/helper.go#L14>)
|
## func [Helper](<https://github.com/metal3d/katenary/blob/develop/generator/helper.go#L15>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func Helper(name string) string
|
func Helper(name string) string
|
||||||
@@ -106,17 +79,17 @@ func NewCronJob(service types.ServiceConfig, chart *HelmChart, appName string) (
|
|||||||
|
|
||||||
NewCronJob creates a new CronJob from a compose service. The appName is the name of the application taken from the project name.
|
NewCronJob creates a new CronJob from a compose service. The appName is the name of the application taken from the project name.
|
||||||
|
|
||||||
<a name="Prefix"></a>
|
<a name="ToK8SYaml"></a>
|
||||||
## func [Prefix](<https://github.com/metal3d/katenary/blob/develop/generator/katenaryLabels.go#L233>)
|
## func [ToK8SYaml](<https://github.com/metal3d/katenary/blob/develop/generator/utils.go#L90>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func Prefix() string
|
func ToK8SYaml(obj interface{}) ([]byte, error)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="UnWrapTPL"></a>
|
<a name="UnWrapTPL"></a>
|
||||||
## func [UnWrapTPL](<https://github.com/metal3d/katenary/blob/develop/generator/utils.go#L84>)
|
## func [UnWrapTPL](<https://github.com/metal3d/katenary/blob/develop/generator/utils.go#L86>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func UnWrapTPL(in []byte) []byte
|
func UnWrapTPL(in []byte) []byte
|
||||||
@@ -125,7 +98,7 @@ func UnWrapTPL(in []byte) []byte
|
|||||||
UnWrapTPL removes the line wrapping from a template.
|
UnWrapTPL removes the line wrapping from a template.
|
||||||
|
|
||||||
<a name="ChartTemplate"></a>
|
<a name="ChartTemplate"></a>
|
||||||
## type [ChartTemplate](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L17-L20>)
|
## type [ChartTemplate](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L18-L21>)
|
||||||
|
|
||||||
ChartTemplate is a template of a chart. It contains the content of the template and the name of the service. This is used internally to generate the templates.
|
ChartTemplate is a template of a chart. It contains the content of the template and the name of the service. This is used internally to generate the templates.
|
||||||
|
|
||||||
@@ -185,7 +158,7 @@ func (c *ConfigMap) AppendDir(path string)
|
|||||||
AddFile adds files from given path to the configmap. It is not recursive, to add all files in a directory, you need to call this function for each subdirectory.
|
AddFile adds files from given path to the configmap. It is not recursive, to add all files in a directory, you need to call this function for each subdirectory.
|
||||||
|
|
||||||
<a name="ConfigMap.AppendFile"></a>
|
<a name="ConfigMap.AppendFile"></a>
|
||||||
### func \(\*ConfigMap\) [AppendFile](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L201>)
|
### func \(\*ConfigMap\) [AppendFile](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L200>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (c *ConfigMap) AppendFile(path string)
|
func (c *ConfigMap) AppendFile(path string)
|
||||||
@@ -194,7 +167,7 @@ func (c *ConfigMap) AppendFile(path string)
|
|||||||
|
|
||||||
|
|
||||||
<a name="ConfigMap.Filename"></a>
|
<a name="ConfigMap.Filename"></a>
|
||||||
### func \(\*ConfigMap\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L219>)
|
### func \(\*ConfigMap\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L218>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (c *ConfigMap) Filename() string
|
func (c *ConfigMap) Filename() string
|
||||||
@@ -203,7 +176,7 @@ func (c *ConfigMap) Filename() string
|
|||||||
Filename returns the filename of the configmap. If the configmap is used for files, the filename contains the path.
|
Filename returns the filename of the configmap. If the configmap is used for files, the filename contains the path.
|
||||||
|
|
||||||
<a name="ConfigMap.SetData"></a>
|
<a name="ConfigMap.SetData"></a>
|
||||||
### func \(\*ConfigMap\) [SetData](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L229>)
|
### func \(\*ConfigMap\) [SetData](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L228>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (c *ConfigMap) SetData(data map[string]string)
|
func (c *ConfigMap) SetData(data map[string]string)
|
||||||
@@ -212,7 +185,7 @@ func (c *ConfigMap) SetData(data map[string]string)
|
|||||||
SetData sets the data of the configmap. It replaces the entire data.
|
SetData sets the data of the configmap. It replaces the entire data.
|
||||||
|
|
||||||
<a name="ConfigMap.Yaml"></a>
|
<a name="ConfigMap.Yaml"></a>
|
||||||
### func \(\*ConfigMap\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L234>)
|
### func \(\*ConfigMap\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L233>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (c *ConfigMap) Yaml() ([]byte, error)
|
func (c *ConfigMap) Yaml() ([]byte, error)
|
||||||
@@ -232,7 +205,7 @@ type ConfigMapMount struct {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<a name="ConvertOptions"></a>
|
<a name="ConvertOptions"></a>
|
||||||
## type [ConvertOptions](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L23-L32>)
|
## type [ConvertOptions](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L24-L33>)
|
||||||
|
|
||||||
ConvertOptions are the options to convert a compose project to a helm chart.
|
ConvertOptions are the options to convert a compose project to a helm chart.
|
||||||
|
|
||||||
@@ -284,7 +257,7 @@ Yaml returns the yaml representation of the cronjob.
|
|||||||
Implements the Yaml interface.
|
Implements the Yaml interface.
|
||||||
|
|
||||||
<a name="CronJobValue"></a>
|
<a name="CronJobValue"></a>
|
||||||
## type [CronJobValue](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L108-L113>)
|
## type [CronJobValue](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L113-L118>)
|
||||||
|
|
||||||
CronJobValue is a cronjob configuration that will be saved in values.yaml.
|
CronJobValue is a cronjob configuration that will be saved in values.yaml.
|
||||||
|
|
||||||
@@ -319,7 +292,7 @@ func NewFileMap(service types.ServiceConfig, appName, kind string) DataMap
|
|||||||
NewFileMap creates a new DataMap from a compose service. The appName is the name of the application taken from the project name.
|
NewFileMap creates a new DataMap from a compose service. The appName is the name of the application taken from the project name.
|
||||||
|
|
||||||
<a name="Deployment"></a>
|
<a name="Deployment"></a>
|
||||||
## type [Deployment](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L34-L42>)
|
## type [Deployment](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L34-L43>)
|
||||||
|
|
||||||
Deployment is a kubernetes Deployment.
|
Deployment is a kubernetes Deployment.
|
||||||
|
|
||||||
@@ -331,7 +304,7 @@ type Deployment struct {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<a name="NewDeployment"></a>
|
<a name="NewDeployment"></a>
|
||||||
### func [NewDeployment](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L46>)
|
### func [NewDeployment](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L47>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func NewDeployment(service types.ServiceConfig, chart *HelmChart) *Deployment
|
func NewDeployment(service types.ServiceConfig, chart *HelmChart) *Deployment
|
||||||
@@ -340,7 +313,7 @@ func NewDeployment(service types.ServiceConfig, chart *HelmChart) *Deployment
|
|||||||
NewDeployment creates a new Deployment from a compose service. The appName is the name of the application taken from the project name. It also creates the Values map that will be used to create the values.yaml file.
|
NewDeployment creates a new Deployment from a compose service. The appName is the name of the application taken from the project name. It also creates the Values map that will be used to create the values.yaml file.
|
||||||
|
|
||||||
<a name="Deployment.AddContainer"></a>
|
<a name="Deployment.AddContainer"></a>
|
||||||
### func \(\*Deployment\) [AddContainer](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L111>)
|
### func \(\*Deployment\) [AddContainer](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L113>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (d *Deployment) AddContainer(service types.ServiceConfig)
|
func (d *Deployment) AddContainer(service types.ServiceConfig)
|
||||||
@@ -349,7 +322,7 @@ func (d *Deployment) AddContainer(service types.ServiceConfig)
|
|||||||
AddContainer adds a container to the deployment.
|
AddContainer adds a container to the deployment.
|
||||||
|
|
||||||
<a name="Deployment.AddHealthCheck"></a>
|
<a name="Deployment.AddHealthCheck"></a>
|
||||||
### func \(\*Deployment\) [AddHealthCheck](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L156>)
|
### func \(\*Deployment\) [AddHealthCheck](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L158>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (d *Deployment) AddHealthCheck(service types.ServiceConfig, container *corev1.Container)
|
func (d *Deployment) AddHealthCheck(service types.ServiceConfig, container *corev1.Container)
|
||||||
@@ -358,7 +331,7 @@ func (d *Deployment) AddHealthCheck(service types.ServiceConfig, container *core
|
|||||||
|
|
||||||
|
|
||||||
<a name="Deployment.AddIngress"></a>
|
<a name="Deployment.AddIngress"></a>
|
||||||
### func \(\*Deployment\) [AddIngress](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L185>)
|
### func \(\*Deployment\) [AddIngress](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L187>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (d *Deployment) AddIngress(service types.ServiceConfig, appName string) *Ingress
|
func (d *Deployment) AddIngress(service types.ServiceConfig, appName string) *Ingress
|
||||||
@@ -366,8 +339,17 @@ func (d *Deployment) AddIngress(service types.ServiceConfig, appName string) *In
|
|||||||
|
|
||||||
AddIngress adds an ingress to the deployment. It creates the ingress object.
|
AddIngress adds an ingress to the deployment. It creates the ingress object.
|
||||||
|
|
||||||
|
<a name="Deployment.AddLegacyVolume"></a>
|
||||||
|
### func \(\*Deployment\) [AddLegacyVolume](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L217>)
|
||||||
|
|
||||||
|
```go
|
||||||
|
func (d *Deployment) AddLegacyVolume(name, kind string)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="Deployment.AddVolumes"></a>
|
<a name="Deployment.AddVolumes"></a>
|
||||||
### func \(\*Deployment\) [AddVolumes](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L191>)
|
### func \(\*Deployment\) [AddVolumes](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L193>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (d *Deployment) AddVolumes(service types.ServiceConfig, appName string)
|
func (d *Deployment) AddVolumes(service types.ServiceConfig, appName string)
|
||||||
@@ -376,7 +358,7 @@ func (d *Deployment) AddVolumes(service types.ServiceConfig, appName string)
|
|||||||
AddVolumes adds a volume to the deployment. It does not create the PVC, it only adds the volumes to the deployment. If the volume is a bind volume it will warn the user that it is not supported yet.
|
AddVolumes adds a volume to the deployment. It does not create the PVC, it only adds the volumes to the deployment. If the volume is a bind volume it will warn the user that it is not supported yet.
|
||||||
|
|
||||||
<a name="Deployment.BindFrom"></a>
|
<a name="Deployment.BindFrom"></a>
|
||||||
### func \(\*Deployment\) [BindFrom](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L215>)
|
### func \(\*Deployment\) [BindFrom](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L238>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (d *Deployment) BindFrom(service types.ServiceConfig, binded *Deployment)
|
func (d *Deployment) BindFrom(service types.ServiceConfig, binded *Deployment)
|
||||||
@@ -384,8 +366,17 @@ func (d *Deployment) BindFrom(service types.ServiceConfig, binded *Deployment)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="Deployment.BindMapFilesToContainer"></a>
|
||||||
|
### func \(\*Deployment\) [BindMapFilesToContainer](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L375>)
|
||||||
|
|
||||||
|
```go
|
||||||
|
func (d *Deployment) BindMapFilesToContainer(service types.ServiceConfig, secrets []string, appName string) (*corev1.Container, int)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="Deployment.DependsOn"></a>
|
<a name="Deployment.DependsOn"></a>
|
||||||
### func \(\*Deployment\) [DependsOn](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L243>)
|
### func \(\*Deployment\) [DependsOn](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L266>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (d *Deployment) DependsOn(to *Deployment, servicename string) error
|
func (d *Deployment) DependsOn(to *Deployment, servicename string) error
|
||||||
@@ -394,7 +385,7 @@ func (d *Deployment) DependsOn(to *Deployment, servicename string) error
|
|||||||
DependsOn adds a initContainer to the deployment that will wait for the service to be up.
|
DependsOn adds a initContainer to the deployment that will wait for the service to be up.
|
||||||
|
|
||||||
<a name="Deployment.Filename"></a>
|
<a name="Deployment.Filename"></a>
|
||||||
### func \(\*Deployment\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L269>)
|
### func \(\*Deployment\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L297>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (d *Deployment) Filename() string
|
func (d *Deployment) Filename() string
|
||||||
@@ -402,17 +393,26 @@ func (d *Deployment) Filename() string
|
|||||||
|
|
||||||
Filename returns the filename of the deployment.
|
Filename returns the filename of the deployment.
|
||||||
|
|
||||||
<a name="Deployment.SetEnvFrom"></a>
|
<a name="Deployment.MountExchangeVolumes"></a>
|
||||||
### func \(\*Deployment\) [SetEnvFrom](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L274>)
|
### func \(\*Deployment\) [MountExchangeVolumes](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L426>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string)
|
func (d *Deployment) MountExchangeVolumes()
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="Deployment.SetEnvFrom"></a>
|
||||||
|
### func \(\*Deployment\) [SetEnvFrom](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L302>)
|
||||||
|
|
||||||
|
```go
|
||||||
|
func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string, samePod ...bool)
|
||||||
```
|
```
|
||||||
|
|
||||||
SetEnvFrom sets the environment variables to a configmap. The configmap is created.
|
SetEnvFrom sets the environment variables to a configmap. The configmap is created.
|
||||||
|
|
||||||
<a name="Deployment.Yaml"></a>
|
<a name="Deployment.Yaml"></a>
|
||||||
### func \(\*Deployment\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L367>)
|
### func \(\*Deployment\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L450>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (d *Deployment) Yaml() ([]byte, error)
|
func (d *Deployment) Yaml() ([]byte, error)
|
||||||
@@ -439,7 +439,7 @@ const (
|
|||||||
```
|
```
|
||||||
|
|
||||||
<a name="HelmChart"></a>
|
<a name="HelmChart"></a>
|
||||||
## type [HelmChart](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L36-L49>)
|
## type [HelmChart](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L37-L50>)
|
||||||
|
|
||||||
HelmChart is a Helm Chart representation. It contains all the tempaltes, values, versions, helpers...
|
HelmChart is a Helm Chart representation. It contains all the tempaltes, values, versions, helpers...
|
||||||
|
|
||||||
@@ -462,7 +462,7 @@ type HelmChart struct {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<a name="Generate"></a>
|
<a name="Generate"></a>
|
||||||
### func [Generate](<https://github.com/metal3d/katenary/blob/develop/generator/generator.go#L28>)
|
### func [Generate](<https://github.com/metal3d/katenary/blob/develop/generator/generator.go#L29>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func Generate(project *types.Project) (*HelmChart, error)
|
func Generate(project *types.Project) (*HelmChart, error)
|
||||||
@@ -482,7 +482,7 @@ The Generate function will create the HelmChart object this way:
|
|||||||
- Merge the same\-pod services.
|
- Merge the same\-pod services.
|
||||||
|
|
||||||
<a name="NewChart"></a>
|
<a name="NewChart"></a>
|
||||||
### func [NewChart](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L52>)
|
### func [NewChart](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L53>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func NewChart(name string) *HelmChart
|
func NewChart(name string) *HelmChart
|
||||||
@@ -491,7 +491,7 @@ func NewChart(name string) *HelmChart
|
|||||||
NewChart creates a new empty chart with the given name.
|
NewChart creates a new empty chart with the given name.
|
||||||
|
|
||||||
<a name="HelmChart.SaveTemplates"></a>
|
<a name="HelmChart.SaveTemplates"></a>
|
||||||
### func \(\*HelmChart\) [SaveTemplates](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L67>)
|
### func \(\*HelmChart\) [SaveTemplates](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L68>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (chart *HelmChart) SaveTemplates(templateDir string)
|
func (chart *HelmChart) SaveTemplates(templateDir string)
|
||||||
@@ -499,20 +499,6 @@ func (chart *HelmChart) SaveTemplates(templateDir string)
|
|||||||
|
|
||||||
SaveTemplates the templates of the chart to the given directory.
|
SaveTemplates the templates of the chart to the given directory.
|
||||||
|
|
||||||
<a name="Help"></a>
|
|
||||||
## type [Help](<https://github.com/metal3d/katenary/blob/develop/generator/katenaryLabels.go#L55-L60>)
|
|
||||||
|
|
||||||
Help is the documentation of a label.
|
|
||||||
|
|
||||||
```go
|
|
||||||
type Help struct {
|
|
||||||
Short string `yaml:"short"`
|
|
||||||
Long string `yaml:"long"`
|
|
||||||
Example string `yaml:"example"`
|
|
||||||
Type string `yaml:"type"`
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
<a name="Ingress"></a>
|
<a name="Ingress"></a>
|
||||||
## type [Ingress](<https://github.com/metal3d/katenary/blob/develop/generator/ingress.go#L17-L20>)
|
## type [Ingress](<https://github.com/metal3d/katenary/blob/develop/generator/ingress.go#L17-L20>)
|
||||||
|
|
||||||
@@ -535,7 +521,7 @@ func NewIngress(service types.ServiceConfig, Chart *HelmChart) *Ingress
|
|||||||
NewIngress creates a new Ingress from a compose service.
|
NewIngress creates a new Ingress from a compose service.
|
||||||
|
|
||||||
<a name="Ingress.Filename"></a>
|
<a name="Ingress.Filename"></a>
|
||||||
### func \(\*Ingress\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/ingress.go#L121>)
|
### func \(\*Ingress\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/ingress.go#L122>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (ingress *Ingress) Filename() string
|
func (ingress *Ingress) Filename() string
|
||||||
@@ -544,7 +530,7 @@ func (ingress *Ingress) Filename() string
|
|||||||
|
|
||||||
|
|
||||||
<a name="Ingress.Yaml"></a>
|
<a name="Ingress.Yaml"></a>
|
||||||
### func \(\*Ingress\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/ingress.go#L125>)
|
### func \(\*Ingress\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/ingress.go#L126>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (ingress *Ingress) Yaml() ([]byte, error)
|
func (ingress *Ingress) Yaml() ([]byte, error)
|
||||||
@@ -553,7 +539,7 @@ func (ingress *Ingress) Yaml() ([]byte, error)
|
|||||||
|
|
||||||
|
|
||||||
<a name="IngressValue"></a>
|
<a name="IngressValue"></a>
|
||||||
## type [IngressValue](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L24-L30>)
|
## type [IngressValue](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L28-L35>)
|
||||||
|
|
||||||
IngressValue is a ingress configuration that will be saved in values.yaml.
|
IngressValue is a ingress configuration that will be saved in values.yaml.
|
||||||
|
|
||||||
@@ -564,39 +550,10 @@ type IngressValue struct {
|
|||||||
Path string `yaml:"path"`
|
Path string `yaml:"path"`
|
||||||
Class string `yaml:"class"`
|
Class string `yaml:"class"`
|
||||||
Enabled bool `yaml:"enabled"`
|
Enabled bool `yaml:"enabled"`
|
||||||
|
TLS TLS `yaml:"tls"`
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
<a name="Label"></a>
|
|
||||||
## type [Label](<https://github.com/metal3d/katenary/blob/develop/generator/katenaryLabels.go#L48>)
|
|
||||||
|
|
||||||
Label is a katenary label to find in compose files.
|
|
||||||
|
|
||||||
```go
|
|
||||||
type Label = string
|
|
||||||
```
|
|
||||||
|
|
||||||
<a name="LabelMainApp"></a>Known labels.
|
|
||||||
|
|
||||||
```go
|
|
||||||
const (
|
|
||||||
LabelMainApp Label = katenaryLabelPrefix + "/main-app"
|
|
||||||
LabelValues Label = katenaryLabelPrefix + "/values"
|
|
||||||
LabelSecrets Label = katenaryLabelPrefix + "/secrets"
|
|
||||||
LabelPorts Label = katenaryLabelPrefix + "/ports"
|
|
||||||
LabelIngress Label = katenaryLabelPrefix + "/ingress"
|
|
||||||
LabelMapEnv Label = katenaryLabelPrefix + "/map-env"
|
|
||||||
LabelHealthCheck Label = katenaryLabelPrefix + "/health-check"
|
|
||||||
LabelSamePod Label = katenaryLabelPrefix + "/same-pod"
|
|
||||||
LabelDescription Label = katenaryLabelPrefix + "/description"
|
|
||||||
LabelIgnore Label = katenaryLabelPrefix + "/ignore"
|
|
||||||
LabelDependencies Label = katenaryLabelPrefix + "/dependencies"
|
|
||||||
LabelConfigMapFiles Label = katenaryLabelPrefix + "/configmap-files"
|
|
||||||
LabelCronJob Label = katenaryLabelPrefix + "/cronjob"
|
|
||||||
LabelEnvFrom Label = katenaryLabelPrefix + "/env-from"
|
|
||||||
)
|
|
||||||
```
|
|
||||||
|
|
||||||
<a name="PersistenceValue"></a>
|
<a name="PersistenceValue"></a>
|
||||||
## type [PersistenceValue](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L16-L21>)
|
## type [PersistenceValue](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L16-L21>)
|
||||||
|
|
||||||
@@ -706,7 +663,7 @@ func (r *RoleBinding) Yaml() ([]byte, error)
|
|||||||
|
|
||||||
|
|
||||||
<a name="Secret"></a>
|
<a name="Secret"></a>
|
||||||
## type [Secret](<https://github.com/metal3d/katenary/blob/develop/generator/secret.go#L23-L26>)
|
## type [Secret](<https://github.com/metal3d/katenary/blob/develop/generator/secret.go#L22-L25>)
|
||||||
|
|
||||||
Secret is a kubernetes Secret.
|
Secret is a kubernetes Secret.
|
||||||
|
|
||||||
@@ -720,7 +677,7 @@ type Secret struct {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<a name="NewSecret"></a>
|
<a name="NewSecret"></a>
|
||||||
### func [NewSecret](<https://github.com/metal3d/katenary/blob/develop/generator/secret.go#L29>)
|
### func [NewSecret](<https://github.com/metal3d/katenary/blob/develop/generator/secret.go#L28>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func NewSecret(service types.ServiceConfig, appName string) *Secret
|
func NewSecret(service types.ServiceConfig, appName string) *Secret
|
||||||
@@ -729,7 +686,7 @@ func NewSecret(service types.ServiceConfig, appName string) *Secret
|
|||||||
NewSecret creates a new Secret from a compose service
|
NewSecret creates a new Secret from a compose service
|
||||||
|
|
||||||
<a name="Secret.AddData"></a>
|
<a name="Secret.AddData"></a>
|
||||||
### func \(\*Secret\) [AddData](<https://github.com/metal3d/katenary/blob/develop/generator/secret.go#L79>)
|
### func \(\*Secret\) [AddData](<https://github.com/metal3d/katenary/blob/develop/generator/secret.go#L70>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (s *Secret) AddData(key, value string)
|
func (s *Secret) AddData(key, value string)
|
||||||
@@ -738,7 +695,7 @@ func (s *Secret) AddData(key, value string)
|
|||||||
AddData adds a key value pair to the secret.
|
AddData adds a key value pair to the secret.
|
||||||
|
|
||||||
<a name="Secret.Filename"></a>
|
<a name="Secret.Filename"></a>
|
||||||
### func \(\*Secret\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/secret.go#L87>)
|
### func \(\*Secret\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/secret.go#L86>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (s *Secret) Filename() string
|
func (s *Secret) Filename() string
|
||||||
@@ -747,7 +704,7 @@ func (s *Secret) Filename() string
|
|||||||
Filename returns the filename of the secret.
|
Filename returns the filename of the secret.
|
||||||
|
|
||||||
<a name="Secret.SetData"></a>
|
<a name="Secret.SetData"></a>
|
||||||
### func \(\*Secret\) [SetData](<https://github.com/metal3d/katenary/blob/develop/generator/secret.go#L92>)
|
### func \(\*Secret\) [SetData](<https://github.com/metal3d/katenary/blob/develop/generator/secret.go#L91>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (s *Secret) SetData(data map[string]string)
|
func (s *Secret) SetData(data map[string]string)
|
||||||
@@ -756,7 +713,7 @@ func (s *Secret) SetData(data map[string]string)
|
|||||||
SetData sets the data of the secret.
|
SetData sets the data of the secret.
|
||||||
|
|
||||||
<a name="Secret.Yaml"></a>
|
<a name="Secret.Yaml"></a>
|
||||||
### func \(\*Secret\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/secret.go#L99>)
|
### func \(\*Secret\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/secret.go#L98>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (s *Secret) Yaml() ([]byte, error)
|
func (s *Secret) Yaml() ([]byte, error)
|
||||||
@@ -765,7 +722,7 @@ func (s *Secret) Yaml() ([]byte, error)
|
|||||||
Yaml returns the yaml representation of the secret.
|
Yaml returns the yaml representation of the secret.
|
||||||
|
|
||||||
<a name="Service"></a>
|
<a name="Service"></a>
|
||||||
## type [Service](<https://github.com/metal3d/katenary/blob/develop/generator/service.go#L18-L21>)
|
## type [Service](<https://github.com/metal3d/katenary/blob/develop/generator/service.go#L17-L20>)
|
||||||
|
|
||||||
Service is a kubernetes Service.
|
Service is a kubernetes Service.
|
||||||
|
|
||||||
@@ -777,7 +734,7 @@ type Service struct {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<a name="NewService"></a>
|
<a name="NewService"></a>
|
||||||
### func [NewService](<https://github.com/metal3d/katenary/blob/develop/generator/service.go#L24>)
|
### func [NewService](<https://github.com/metal3d/katenary/blob/develop/generator/service.go#L23>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func NewService(service types.ServiceConfig, appName string) *Service
|
func NewService(service types.ServiceConfig, appName string) *Service
|
||||||
@@ -786,7 +743,7 @@ func NewService(service types.ServiceConfig, appName string) *Service
|
|||||||
NewService creates a new Service from a compose service.
|
NewService creates a new Service from a compose service.
|
||||||
|
|
||||||
<a name="Service.AddPort"></a>
|
<a name="Service.AddPort"></a>
|
||||||
### func \(\*Service\) [AddPort](<https://github.com/metal3d/katenary/blob/develop/generator/service.go#L53>)
|
### func \(\*Service\) [AddPort](<https://github.com/metal3d/katenary/blob/develop/generator/service.go#L52>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (s *Service) AddPort(port types.ServicePortConfig, serviceName ...string)
|
func (s *Service) AddPort(port types.ServicePortConfig, serviceName ...string)
|
||||||
@@ -795,7 +752,7 @@ func (s *Service) AddPort(port types.ServicePortConfig, serviceName ...string)
|
|||||||
AddPort adds a port to the service.
|
AddPort adds a port to the service.
|
||||||
|
|
||||||
<a name="Service.Filename"></a>
|
<a name="Service.Filename"></a>
|
||||||
### func \(\*Service\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/service.go#L77>)
|
### func \(\*Service\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/service.go#L76>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (s *Service) Filename() string
|
func (s *Service) Filename() string
|
||||||
@@ -804,7 +761,7 @@ func (s *Service) Filename() string
|
|||||||
Filename returns the filename of the service.
|
Filename returns the filename of the service.
|
||||||
|
|
||||||
<a name="Service.Yaml"></a>
|
<a name="Service.Yaml"></a>
|
||||||
### func \(\*Service\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/service.go#L82>)
|
### func \(\*Service\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/service.go#L81>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (s *Service) Yaml() ([]byte, error)
|
func (s *Service) Yaml() ([]byte, error)
|
||||||
@@ -842,8 +799,19 @@ func (r *ServiceAccount) Yaml() ([]byte, error)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="TLS"></a>
|
||||||
|
## type [TLS](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L23-L25>)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```go
|
||||||
|
type TLS struct {
|
||||||
|
Enabled bool `yaml:"enabled"`
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
<a name="Value"></a>
|
<a name="Value"></a>
|
||||||
## type [Value](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L33-L44>)
|
## type [Value](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L38-L49>)
|
||||||
|
|
||||||
Value will be saved in values.yaml. It contains configuraiton for all deployment and services.
|
Value will be saved in values.yaml. It contains configuraiton for all deployment and services.
|
||||||
|
|
||||||
@@ -863,7 +831,7 @@ type Value struct {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<a name="NewValue"></a>
|
<a name="NewValue"></a>
|
||||||
### func [NewValue](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L51>)
|
### func [NewValue](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L56>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func NewValue(service types.ServiceConfig, main ...bool) *Value
|
func NewValue(service types.ServiceConfig, main ...bool) *Value
|
||||||
@@ -874,7 +842,7 @@ NewValue creates a new Value from a compose service. The value contains the nece
|
|||||||
If \`main\` is true, the tag will be empty because it will be set in the helm chart appVersion.
|
If \`main\` is true, the tag will be empty because it will be set in the helm chart appVersion.
|
||||||
|
|
||||||
<a name="Value.AddIngress"></a>
|
<a name="Value.AddIngress"></a>
|
||||||
### func \(\*Value\) [AddIngress](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L84>)
|
### func \(\*Value\) [AddIngress](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L89>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (v *Value) AddIngress(host, path string)
|
func (v *Value) AddIngress(host, path string)
|
||||||
@@ -883,7 +851,7 @@ func (v *Value) AddIngress(host, path string)
|
|||||||
|
|
||||||
|
|
||||||
<a name="Value.AddPersistence"></a>
|
<a name="Value.AddPersistence"></a>
|
||||||
### func \(\*Value\) [AddPersistence](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L94>)
|
### func \(\*Value\) [AddPersistence](<https://github.com/metal3d/katenary/blob/develop/generator/values.go#L99>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (v *Value) AddPersistence(volumeName string)
|
func (v *Value) AddPersistence(volumeName string)
|
||||||
@@ -892,7 +860,7 @@ func (v *Value) AddPersistence(volumeName string)
|
|||||||
AddPersistence adds persistence configuration to the Value.
|
AddPersistence adds persistence configuration to the Value.
|
||||||
|
|
||||||
<a name="VolumeClaim"></a>
|
<a name="VolumeClaim"></a>
|
||||||
## type [VolumeClaim](<https://github.com/metal3d/katenary/blob/develop/generator/volume.go#L19-L24>)
|
## type [VolumeClaim](<https://github.com/metal3d/katenary/blob/develop/generator/volume.go#L18-L23>)
|
||||||
|
|
||||||
VolumeClaim is a kubernetes VolumeClaim. This is a PersistentVolumeClaim.
|
VolumeClaim is a kubernetes VolumeClaim. This is a PersistentVolumeClaim.
|
||||||
|
|
||||||
@@ -904,7 +872,7 @@ type VolumeClaim struct {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<a name="NewVolumeClaim"></a>
|
<a name="NewVolumeClaim"></a>
|
||||||
### func [NewVolumeClaim](<https://github.com/metal3d/katenary/blob/develop/generator/volume.go#L27>)
|
### func [NewVolumeClaim](<https://github.com/metal3d/katenary/blob/develop/generator/volume.go#L26>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func NewVolumeClaim(service types.ServiceConfig, volumeName, appName string) *VolumeClaim
|
func NewVolumeClaim(service types.ServiceConfig, volumeName, appName string) *VolumeClaim
|
||||||
@@ -913,7 +881,7 @@ func NewVolumeClaim(service types.ServiceConfig, volumeName, appName string) *Vo
|
|||||||
NewVolumeClaim creates a new VolumeClaim from a compose service.
|
NewVolumeClaim creates a new VolumeClaim from a compose service.
|
||||||
|
|
||||||
<a name="VolumeClaim.Filename"></a>
|
<a name="VolumeClaim.Filename"></a>
|
||||||
### func \(\*VolumeClaim\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/volume.go#L63>)
|
### func \(\*VolumeClaim\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/volume.go#L62>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (v *VolumeClaim) Filename() string
|
func (v *VolumeClaim) Filename() string
|
||||||
@@ -922,7 +890,7 @@ func (v *VolumeClaim) Filename() string
|
|||||||
Filename returns the suggested filename for a VolumeClaim.
|
Filename returns the suggested filename for a VolumeClaim.
|
||||||
|
|
||||||
<a name="VolumeClaim.Yaml"></a>
|
<a name="VolumeClaim.Yaml"></a>
|
||||||
### func \(\*VolumeClaim\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/volume.go#L68>)
|
### func \(\*VolumeClaim\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/volume.go#L67>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (v *VolumeClaim) Yaml() ([]byte, error)
|
func (v *VolumeClaim) Yaml() ([]byte, error)
|
||||||
|
66
doc/docs/packages/generator/katenaryfile.md
Normal file
66
doc/docs/packages/generator/katenaryfile.md
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
|
||||||
|
|
||||||
|
# katenaryfile
|
||||||
|
|
||||||
|
```go
|
||||||
|
import "katenary/generator/katenaryfile"
|
||||||
|
```
|
||||||
|
|
||||||
|
Package katenaryfile is a package for reading and writing katenary files.
|
||||||
|
|
||||||
|
A katenary file, named "katenary.yml" or "katenary.yaml", is a file where you can define the configuration of the conversion avoiding the use of labels in the compose file.
|
||||||
|
|
||||||
|
Formely, the file describe the same structure as in labels, and so that can be validated and completed by LSP. It also ease the use of katenary.
|
||||||
|
|
||||||
|
## func [GenerateSchema](<https://github.com/metal3d/katenary/blob/develop/generator/katenaryfile/main.go#L116>)
|
||||||
|
|
||||||
|
```go
|
||||||
|
func GenerateSchema() string
|
||||||
|
```
|
||||||
|
|
||||||
|
GenerateSchema generates the schema for the katenary.yaml file.
|
||||||
|
|
||||||
|
<a name="OverrideWithConfig"></a>
|
||||||
|
## func [OverrideWithConfig](<https://github.com/metal3d/katenary/blob/develop/generator/katenaryfile/main.go#L48>)
|
||||||
|
|
||||||
|
```go
|
||||||
|
func OverrideWithConfig(project *types.Project)
|
||||||
|
```
|
||||||
|
|
||||||
|
OverrideWithConfig overrides the project with the katenary.yaml file. It will set the labels of the services with the values from the katenary.yaml file. It work in memory, so it will not modify the original project.
|
||||||
|
|
||||||
|
<a name="Service"></a>
|
||||||
|
## type [Service](<https://github.com/metal3d/katenary/blob/develop/generator/katenaryfile/main.go#L27-L43>)
|
||||||
|
|
||||||
|
Service is a struct that contains the service configuration for katenary
|
||||||
|
|
||||||
|
```go
|
||||||
|
type Service struct {
|
||||||
|
MainApp *bool `json:"main-app,omitempty" jsonschema:"title=Is this service the main application"`
|
||||||
|
Values []StringOrMap `json:"values,omitempty" jsonschema:"description=Environment variables to be set in values.yaml with or without a description"`
|
||||||
|
Secrets *labelStructs.Secrets `json:"secrets,omitempty" jsonschema:"title=Secrets,description=Environment variables to be set as secrets"`
|
||||||
|
Ports *labelStructs.Ports `json:"ports,omitempty" jsonschema:"title=Ports,description=Ports to be exposed in services"`
|
||||||
|
Ingress *labelStructs.Ingress `json:"ingress,omitempty" jsonschema:"title=Ingress,description=Ingress configuration"`
|
||||||
|
HealthCheck *labelStructs.HealthCheck `json:"health-check,omitempty" jsonschema:"title=Health Check,description=Health check configuration that respects the kubernetes api"`
|
||||||
|
SamePod *string `json:"same-pod,omitempty" jsonschema:"title=Same Pod,description=Service that should be in the same pod"`
|
||||||
|
Description *string `json:"description,omitempty" jsonschema:"title=Description,description=Description of the service that will be injected in the values.yaml file"`
|
||||||
|
Ignore *bool `json:"ignore,omitempty" jsonschema:"title=Ignore,description=Ignore the service in the conversion"`
|
||||||
|
Dependencies []labelStructs.Dependency `json:"dependencies,omitempty" jsonschema:"title=Dependencies,description=Services that should be injected in the Chart.yaml file"`
|
||||||
|
ConfigMapFile *labelStructs.ConfigMapFile `json:"configmap-files,omitempty" jsonschema:"title=ConfigMap Files,description=Files that should be injected as ConfigMap"`
|
||||||
|
MapEnv *labelStructs.MapEnv `json:"map-env,omitempty" jsonschema:"title=Map Env,description=Map environment variables to another value"`
|
||||||
|
CronJob *labelStructs.CronJob `json:"cron-job,omitempty" jsonschema:"title=Cron Job,description=Cron Job configuration"`
|
||||||
|
EnvFrom *labelStructs.EnvFrom `json:"env-from,omitempty" jsonschema:"title=Env From,description=Inject environment variables from another service"`
|
||||||
|
ExchangeVolumes []*labelStructs.ExchangeVolume `json:"exchange-volumes,omitempty" jsonschema:"title=Exchange Volumes,description=Exchange volumes between services"`
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
<a name="StringOrMap"></a>
|
||||||
|
## type [StringOrMap](<https://github.com/metal3d/katenary/blob/develop/generator/katenaryfile/main.go#L24>)
|
||||||
|
|
||||||
|
StringOrMap is a struct that can be either a string or a map of strings. It's a helper struct to unmarshal the katenary.yaml file and produce the schema
|
||||||
|
|
||||||
|
```go
|
||||||
|
type StringOrMap any
|
||||||
|
```
|
||||||
|
|
||||||
|
Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)
|
@@ -1,193 +0,0 @@
|
|||||||
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
|
|
||||||
|
|
||||||
# labelStructs
|
|
||||||
|
|
||||||
```go
|
|
||||||
import "katenary/generator/labelStructs"
|
|
||||||
```
|
|
||||||
|
|
||||||
labelStructs is a package that contains the structs used to represent the labels in the yaml files.
|
|
||||||
|
|
||||||
## type [ConfigMapFile](<https://github.com/metal3d/katenary/blob/develop/generator/labelStructs/configMap.go#L5>)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```go
|
|
||||||
type ConfigMapFile []string
|
|
||||||
```
|
|
||||||
|
|
||||||
<a name="ConfigMapFileFrom"></a>
|
|
||||||
### func [ConfigMapFileFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labelStructs/configMap.go#L7>)
|
|
||||||
|
|
||||||
```go
|
|
||||||
func ConfigMapFileFrom(data string) (ConfigMapFile, error)
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="CronJob"></a>
|
|
||||||
## type [CronJob](<https://github.com/metal3d/katenary/blob/develop/generator/labelStructs/cronJob.go#L5-L10>)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```go
|
|
||||||
type CronJob struct {
|
|
||||||
Image string `yaml:"image,omitempty"`
|
|
||||||
Command string `yaml:"command"`
|
|
||||||
Schedule string `yaml:"schedule"`
|
|
||||||
Rbac bool `yaml:"rbac"`
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
<a name="CronJobFrom"></a>
|
|
||||||
### func [CronJobFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labelStructs/cronJob.go#L12>)
|
|
||||||
|
|
||||||
```go
|
|
||||||
func CronJobFrom(data string) (*CronJob, error)
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="Dependency"></a>
|
|
||||||
## type [Dependency](<https://github.com/metal3d/katenary/blob/develop/generator/labelStructs/dependencies.go#L6-L12>)
|
|
||||||
|
|
||||||
Dependency is a dependency of a chart to other charts.
|
|
||||||
|
|
||||||
```go
|
|
||||||
type Dependency struct {
|
|
||||||
Values map[string]any `yaml:"-"`
|
|
||||||
Name string `yaml:"name"`
|
|
||||||
Version string `yaml:"version"`
|
|
||||||
Repository string `yaml:"repository"`
|
|
||||||
Alias string `yaml:"alias,omitempty"`
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
<a name="DependenciesFrom"></a>
|
|
||||||
### func [DependenciesFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labelStructs/dependencies.go#L15>)
|
|
||||||
|
|
||||||
```go
|
|
||||||
func DependenciesFrom(data string) ([]Dependency, error)
|
|
||||||
```
|
|
||||||
|
|
||||||
DependenciesFrom returns a slice of dependencies from the given string.
|
|
||||||
|
|
||||||
<a name="EnvFrom"></a>
|
|
||||||
## type [EnvFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labelStructs/envFrom.go#L5>)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```go
|
|
||||||
type EnvFrom []string
|
|
||||||
```
|
|
||||||
|
|
||||||
<a name="EnvFromFrom"></a>
|
|
||||||
### func [EnvFromFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labelStructs/envFrom.go#L8>)
|
|
||||||
|
|
||||||
```go
|
|
||||||
func EnvFromFrom(data string) (EnvFrom, error)
|
|
||||||
```
|
|
||||||
|
|
||||||
EnvFromFrom returns a EnvFrom from the given string.
|
|
||||||
|
|
||||||
<a name="Ingress"></a>
|
|
||||||
## type [Ingress](<https://github.com/metal3d/katenary/blob/develop/generator/labelStructs/ingress.go#L5-L12>)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```go
|
|
||||||
type Ingress struct {
|
|
||||||
Port *int32 `yaml:"port,omitempty"`
|
|
||||||
Annotations map[string]string `yaml:"annotations,omitempty"`
|
|
||||||
Hostname string `yaml:"hostname"`
|
|
||||||
Path string `yaml:"path"`
|
|
||||||
Class string `yaml:"class"`
|
|
||||||
Enabled bool `yaml:"enabled"`
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
<a name="IngressFrom"></a>
|
|
||||||
### func [IngressFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labelStructs/ingress.go#L15>)
|
|
||||||
|
|
||||||
```go
|
|
||||||
func IngressFrom(data string) (*Ingress, error)
|
|
||||||
```
|
|
||||||
|
|
||||||
IngressFrom creates a new Ingress from a compose service.
|
|
||||||
|
|
||||||
<a name="MapEnv"></a>
|
|
||||||
## type [MapEnv](<https://github.com/metal3d/katenary/blob/develop/generator/labelStructs/mapenv.go#L5>)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```go
|
|
||||||
type MapEnv map[string]string
|
|
||||||
```
|
|
||||||
|
|
||||||
<a name="MapEnvFrom"></a>
|
|
||||||
### func [MapEnvFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labelStructs/mapenv.go#L8>)
|
|
||||||
|
|
||||||
```go
|
|
||||||
func MapEnvFrom(data string) (MapEnv, error)
|
|
||||||
```
|
|
||||||
|
|
||||||
MapEnvFrom returns a MapEnv from the given string.
|
|
||||||
|
|
||||||
<a name="Ports"></a>
|
|
||||||
## type [Ports](<https://github.com/metal3d/katenary/blob/develop/generator/labelStructs/ports.go#L5>)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```go
|
|
||||||
type Ports []uint32
|
|
||||||
```
|
|
||||||
|
|
||||||
<a name="PortsFrom"></a>
|
|
||||||
### func [PortsFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labelStructs/ports.go#L8>)
|
|
||||||
|
|
||||||
```go
|
|
||||||
func PortsFrom(data string) (Ports, error)
|
|
||||||
```
|
|
||||||
|
|
||||||
PortsFrom returns a Ports from the given string.
|
|
||||||
|
|
||||||
<a name="Probe"></a>
|
|
||||||
## type [Probe](<https://github.com/metal3d/katenary/blob/develop/generator/labelStructs/probes.go#L11-L14>)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```go
|
|
||||||
type Probe struct {
|
|
||||||
LivenessProbe *corev1.Probe `yaml:"livenessProbe,omitempty"`
|
|
||||||
ReadinessProbe *corev1.Probe `yaml:"readinessProbe,omitempty"`
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
<a name="ProbeFrom"></a>
|
|
||||||
### func [ProbeFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labelStructs/probes.go#L16>)
|
|
||||||
|
|
||||||
```go
|
|
||||||
func ProbeFrom(data string) (*Probe, error)
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="Secrets"></a>
|
|
||||||
## type [Secrets](<https://github.com/metal3d/katenary/blob/develop/generator/labelStructs/secrets.go#L5>)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```go
|
|
||||||
type Secrets []string
|
|
||||||
```
|
|
||||||
|
|
||||||
<a name="SecretsFrom"></a>
|
|
||||||
### func [SecretsFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labelStructs/secrets.go#L7>)
|
|
||||||
|
|
||||||
```go
|
|
||||||
func SecretsFrom(data string) (Secrets, error)
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)
|
|
107
doc/docs/packages/generator/labels.md
Normal file
107
doc/docs/packages/generator/labels.md
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
|
||||||
|
|
||||||
|
# labels
|
||||||
|
|
||||||
|
```go
|
||||||
|
import "katenary/generator/labels"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Constants
|
||||||
|
|
||||||
|
<a name="KatenaryLabelPrefix"></a>
|
||||||
|
|
||||||
|
```go
|
||||||
|
const KatenaryLabelPrefix = "katenary.v3"
|
||||||
|
```
|
||||||
|
|
||||||
|
<a name="GetLabelHelp"></a>
|
||||||
|
## func [GetLabelHelp](<https://github.com/metal3d/katenary/blob/develop/generator/labels/katenaryLabels.go#L86>)
|
||||||
|
|
||||||
|
```go
|
||||||
|
func GetLabelHelp(asMarkdown bool) string
|
||||||
|
```
|
||||||
|
|
||||||
|
Generate the help for the labels.
|
||||||
|
|
||||||
|
<a name="GetLabelHelpFor"></a>
|
||||||
|
## func [GetLabelHelpFor](<https://github.com/metal3d/katenary/blob/develop/generator/labels/katenaryLabels.go#L95>)
|
||||||
|
|
||||||
|
```go
|
||||||
|
func GetLabelHelpFor(labelname string, asMarkdown bool) string
|
||||||
|
```
|
||||||
|
|
||||||
|
GetLabelHelpFor returns the help for a specific label.
|
||||||
|
|
||||||
|
<a name="GetLabelNames"></a>
|
||||||
|
## func [GetLabelNames](<https://github.com/metal3d/katenary/blob/develop/generator/labels/katenaryLabels.go#L70>)
|
||||||
|
|
||||||
|
```go
|
||||||
|
func GetLabelNames() []string
|
||||||
|
```
|
||||||
|
|
||||||
|
GetLabelNames returns a sorted list of all katenary label names.
|
||||||
|
|
||||||
|
<a name="Prefix"></a>
|
||||||
|
## func [Prefix](<https://github.com/metal3d/katenary/blob/develop/generator/labels/katenaryLabels.go#L223>)
|
||||||
|
|
||||||
|
```go
|
||||||
|
func Prefix() string
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="Help"></a>
|
||||||
|
## type [Help](<https://github.com/metal3d/katenary/blob/develop/generator/labels/katenaryLabels.go#L62-L67>)
|
||||||
|
|
||||||
|
Help is the documentation of a label.
|
||||||
|
|
||||||
|
```go
|
||||||
|
type Help struct {
|
||||||
|
Short string `yaml:"short"`
|
||||||
|
Long string `yaml:"long"`
|
||||||
|
Example string `yaml:"example"`
|
||||||
|
Type string `yaml:"type"`
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
<a name="Label"></a>
|
||||||
|
## type [Label](<https://github.com/metal3d/katenary/blob/develop/generator/labels/katenaryLabels.go#L55>)
|
||||||
|
|
||||||
|
Label is a katenary label to find in compose files.
|
||||||
|
|
||||||
|
```go
|
||||||
|
type Label = string
|
||||||
|
```
|
||||||
|
|
||||||
|
<a name="LabelMainApp"></a>Known labels.
|
||||||
|
|
||||||
|
```go
|
||||||
|
const (
|
||||||
|
LabelMainApp Label = KatenaryLabelPrefix + "/main-app"
|
||||||
|
LabelValues Label = KatenaryLabelPrefix + "/values"
|
||||||
|
LabelSecrets Label = KatenaryLabelPrefix + "/secrets"
|
||||||
|
LabelPorts Label = KatenaryLabelPrefix + "/ports"
|
||||||
|
LabelIngress Label = KatenaryLabelPrefix + "/ingress"
|
||||||
|
LabelMapEnv Label = KatenaryLabelPrefix + "/map-env"
|
||||||
|
LabelHealthCheck Label = KatenaryLabelPrefix + "/health-check"
|
||||||
|
LabelSamePod Label = KatenaryLabelPrefix + "/same-pod"
|
||||||
|
LabelDescription Label = KatenaryLabelPrefix + "/description"
|
||||||
|
LabelIgnore Label = KatenaryLabelPrefix + "/ignore"
|
||||||
|
LabelDependencies Label = KatenaryLabelPrefix + "/dependencies"
|
||||||
|
LabelConfigMapFiles Label = KatenaryLabelPrefix + "/configmap-files"
|
||||||
|
LabelCronJob Label = KatenaryLabelPrefix + "/cronjob"
|
||||||
|
LabelEnvFrom Label = KatenaryLabelPrefix + "/env-from"
|
||||||
|
LabelExchangeVolume Label = KatenaryLabelPrefix + "/exchange-volumes"
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
<a name="LabelName"></a>
|
||||||
|
### func [LabelName](<https://github.com/metal3d/katenary/blob/develop/generator/labels/katenaryLabels.go#L57>)
|
||||||
|
|
||||||
|
```go
|
||||||
|
func LabelName(name string) Label
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)
|
228
doc/docs/packages/generator/labels/labelStructs.md
Normal file
228
doc/docs/packages/generator/labels/labelStructs.md
Normal file
@@ -0,0 +1,228 @@
|
|||||||
|
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
|
||||||
|
|
||||||
|
# labelStructs
|
||||||
|
|
||||||
|
```go
|
||||||
|
import "katenary/generator/labels/labelStructs"
|
||||||
|
```
|
||||||
|
|
||||||
|
labelStructs is a package that contains the structs used to represent the labels in the yaml files.
|
||||||
|
|
||||||
|
## type [ConfigMapFile](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/configMap.go#L5>)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```go
|
||||||
|
type ConfigMapFile []string
|
||||||
|
```
|
||||||
|
|
||||||
|
<a name="ConfigMapFileFrom"></a>
|
||||||
|
### func [ConfigMapFileFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/configMap.go#L7>)
|
||||||
|
|
||||||
|
```go
|
||||||
|
func ConfigMapFileFrom(data string) (ConfigMapFile, error)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="CronJob"></a>
|
||||||
|
## type [CronJob](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/cronJob.go#L5-L10>)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```go
|
||||||
|
type CronJob struct {
|
||||||
|
Image string `yaml:"image,omitempty" json:"image,omitempty"`
|
||||||
|
Command string `yaml:"command" json:"command,omitempty"`
|
||||||
|
Schedule string `yaml:"schedule" json:"schedule,omitempty"`
|
||||||
|
Rbac bool `yaml:"rbac" json:"rbac,omitempty"`
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
<a name="CronJobFrom"></a>
|
||||||
|
### func [CronJobFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/cronJob.go#L12>)
|
||||||
|
|
||||||
|
```go
|
||||||
|
func CronJobFrom(data string) (*CronJob, error)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="Dependency"></a>
|
||||||
|
## type [Dependency](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/dependencies.go#L6-L12>)
|
||||||
|
|
||||||
|
Dependency is a dependency of a chart to other charts.
|
||||||
|
|
||||||
|
```go
|
||||||
|
type Dependency struct {
|
||||||
|
Values map[string]any `yaml:"-" json:"values,omitempty"`
|
||||||
|
Name string `yaml:"name" json:"name"`
|
||||||
|
Version string `yaml:"version" json:"version"`
|
||||||
|
Repository string `yaml:"repository" json:"repository"`
|
||||||
|
Alias string `yaml:"alias,omitempty" json:"alias,omitempty"`
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
<a name="DependenciesFrom"></a>
|
||||||
|
### func [DependenciesFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/dependencies.go#L15>)
|
||||||
|
|
||||||
|
```go
|
||||||
|
func DependenciesFrom(data string) ([]Dependency, error)
|
||||||
|
```
|
||||||
|
|
||||||
|
DependenciesFrom returns a slice of dependencies from the given string.
|
||||||
|
|
||||||
|
<a name="EnvFrom"></a>
|
||||||
|
## type [EnvFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/envFrom.go#L5>)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```go
|
||||||
|
type EnvFrom []string
|
||||||
|
```
|
||||||
|
|
||||||
|
<a name="EnvFromFrom"></a>
|
||||||
|
### func [EnvFromFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/envFrom.go#L8>)
|
||||||
|
|
||||||
|
```go
|
||||||
|
func EnvFromFrom(data string) (EnvFrom, error)
|
||||||
|
```
|
||||||
|
|
||||||
|
EnvFromFrom returns a EnvFrom from the given string.
|
||||||
|
|
||||||
|
<a name="ExchangeVolume"></a>
|
||||||
|
## type [ExchangeVolume](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/exchangeVolume.go#L5-L10>)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```go
|
||||||
|
type ExchangeVolume struct {
|
||||||
|
Name string `yaml:"name" json:"name"`
|
||||||
|
MountPath string `yaml:"mountPath" json:"mountPath"`
|
||||||
|
Type string `yaml:"type,omitempty" json:"type,omitempty"`
|
||||||
|
Init string `yaml:"init,omitempty" json:"init,omitempty"`
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
<a name="NewExchangeVolumes"></a>
|
||||||
|
### func [NewExchangeVolumes](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/exchangeVolume.go#L12>)
|
||||||
|
|
||||||
|
```go
|
||||||
|
func NewExchangeVolumes(data string) ([]*ExchangeVolume, error)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="HealthCheck"></a>
|
||||||
|
## type [HealthCheck](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/probes.go#L11-L14>)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```go
|
||||||
|
type HealthCheck struct {
|
||||||
|
LivenessProbe *corev1.Probe `yaml:"livenessProbe,omitempty" json:"livenessProbe,omitempty"`
|
||||||
|
ReadinessProbe *corev1.Probe `yaml:"readinessProbe,omitempty" json:"readinessProbe,omitempty"`
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
<a name="ProbeFrom"></a>
|
||||||
|
### func [ProbeFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/probes.go#L16>)
|
||||||
|
|
||||||
|
```go
|
||||||
|
func ProbeFrom(data string) (*HealthCheck, error)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="Ingress"></a>
|
||||||
|
## type [Ingress](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/ingress.go#L9-L17>)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```go
|
||||||
|
type Ingress struct {
|
||||||
|
Port *int32 `yaml:"port,omitempty" jsonschema:"nullable" json:"port,omitempty"`
|
||||||
|
Annotations map[string]string `yaml:"annotations,omitempty" jsonschema:"nullable" json:"annotations,omitempty"`
|
||||||
|
Hostname string `yaml:"hostname" json:"hostname,omitempty"`
|
||||||
|
Path string `yaml:"path" json:"path,omitempty"`
|
||||||
|
Class string `yaml:"class" json:"class,omitempty" jsonschema:"default:-"`
|
||||||
|
Enabled bool `yaml:"enabled" json:"enabled,omitempty"`
|
||||||
|
TLS *TLS `yaml:"tls,omitempty" json:"tls,omitempty"`
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
<a name="IngressFrom"></a>
|
||||||
|
### func [IngressFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/ingress.go#L20>)
|
||||||
|
|
||||||
|
```go
|
||||||
|
func IngressFrom(data string) (*Ingress, error)
|
||||||
|
```
|
||||||
|
|
||||||
|
IngressFrom creates a new Ingress from a compose service.
|
||||||
|
|
||||||
|
<a name="MapEnv"></a>
|
||||||
|
## type [MapEnv](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/mapenv.go#L5>)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```go
|
||||||
|
type MapEnv map[string]string
|
||||||
|
```
|
||||||
|
|
||||||
|
<a name="MapEnvFrom"></a>
|
||||||
|
### func [MapEnvFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/mapenv.go#L8>)
|
||||||
|
|
||||||
|
```go
|
||||||
|
func MapEnvFrom(data string) (MapEnv, error)
|
||||||
|
```
|
||||||
|
|
||||||
|
MapEnvFrom returns a MapEnv from the given string.
|
||||||
|
|
||||||
|
<a name="Ports"></a>
|
||||||
|
## type [Ports](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/ports.go#L5>)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```go
|
||||||
|
type Ports []uint32
|
||||||
|
```
|
||||||
|
|
||||||
|
<a name="PortsFrom"></a>
|
||||||
|
### func [PortsFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/ports.go#L8>)
|
||||||
|
|
||||||
|
```go
|
||||||
|
func PortsFrom(data string) (Ports, error)
|
||||||
|
```
|
||||||
|
|
||||||
|
PortsFrom returns a Ports from the given string.
|
||||||
|
|
||||||
|
<a name="Secrets"></a>
|
||||||
|
## type [Secrets](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/secrets.go#L5>)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```go
|
||||||
|
type Secrets []string
|
||||||
|
```
|
||||||
|
|
||||||
|
<a name="SecretsFrom"></a>
|
||||||
|
### func [SecretsFrom](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/secrets.go#L7>)
|
||||||
|
|
||||||
|
```go
|
||||||
|
func SecretsFrom(data string) (Secrets, error)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="TLS"></a>
|
||||||
|
## type [TLS](<https://github.com/metal3d/katenary/blob/develop/generator/labels/labelStructs/ingress.go#L5-L7>)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```go
|
||||||
|
type TLS struct {
|
||||||
|
Enabled bool `yaml:"enabled" json:"enabled,omitempty"`
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)
|
@@ -8,6 +8,15 @@ import "katenary/utils"
|
|||||||
|
|
||||||
Utils package provides some utility functions used in katenary. It defines some constants and functions used in the whole project.
|
Utils package provides some utility functions used in katenary. It defines some constants and functions used in the whole project.
|
||||||
|
|
||||||
|
## func [AsResourceName](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L204>)
|
||||||
|
|
||||||
|
```go
|
||||||
|
func AsResourceName(name string) string
|
||||||
|
```
|
||||||
|
|
||||||
|
AsResourceName returns a resource name with underscores to respect the kubernetes naming convention. It's the opposite of FixedResourceName.
|
||||||
|
|
||||||
|
<a name="Confirm"></a>
|
||||||
## func [Confirm](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L174>)
|
## func [Confirm](<https://github.com/metal3d/katenary/blob/develop/utils/utils.go#L174>)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
|
@@ -106,3 +106,12 @@ h3[id*="katenaryio"] {
|
|||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#klee {
|
||||||
|
filter: drop-shadow(0 0 16px var(--md-default-fg-color));
|
||||||
|
text-align: center;
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
#klee svg {
|
||||||
|
zoom: 2;
|
||||||
|
}
|
||||||
|
@@ -4,10 +4,77 @@ Basically, you can use `katenary` to transpose a docker-compose file (or any com
|
|||||||
`podman-compose` and `docker-compose`) to a configurable Helm Chart. This resulting helm chart can be installed with
|
`podman-compose` and `docker-compose`) to a configurable Helm Chart. This resulting helm chart can be installed with
|
||||||
`helm` command to your Kubernetes cluster.
|
`helm` command to your Kubernetes cluster.
|
||||||
|
|
||||||
|
For very basic compose files, without any specific configuration, Katenary will create a working helm chart using the
|
||||||
|
simple command line:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
katenary convert
|
||||||
|
```
|
||||||
|
|
||||||
|
This will create a `chart` directory with the helm chart inside.
|
||||||
|
|
||||||
|
But, in general, you will need to add a few configuration to help Katenary to transpose the compose file to a working
|
||||||
|
helm chart.
|
||||||
|
|
||||||
|
There are two ways to configure Katenary:
|
||||||
|
|
||||||
|
- Using the compose files, adding labels to the services
|
||||||
|
- Using a specific file named `katenary.yaml`
|
||||||
|
|
||||||
|
The Katenary file `katenary.yaml` has benefits over the labels in the compose file:
|
||||||
|
|
||||||
|
- you can validate the configuration with a schema, and use completion in your editor
|
||||||
|
- you separate the configuration and leave the compose file "intact"
|
||||||
|
- the syntax is a bit simpler, instead of using `katenary.v3/xxx: |-" you can use`xxx: ...`
|
||||||
|
|
||||||
|
But: **this implies that you have to maintain two files if the compose file changes.**
|
||||||
|
|
||||||
|
For example. With "labels", you should do:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# in compose file
|
||||||
|
services:
|
||||||
|
webapp:
|
||||||
|
image: php:7-apache
|
||||||
|
ports:
|
||||||
|
- 8080:80
|
||||||
|
environment:
|
||||||
|
DB_HOST: database
|
||||||
|
labels:
|
||||||
|
katenary.v3/ingress: |-
|
||||||
|
hostname: myapp.example.com
|
||||||
|
port: 8080
|
||||||
|
katenary.v3/map-env: |-
|
||||||
|
DB_HOST: "{{ .Release.Name }}-database"
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Using a Katenary file, you can do:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# in compose file, no need to add labels
|
||||||
|
services:
|
||||||
|
webapp:
|
||||||
|
image: php:7-apache
|
||||||
|
ports:
|
||||||
|
- 8080:80
|
||||||
|
environment:
|
||||||
|
DB_HOST: database
|
||||||
|
|
||||||
|
# in katenary.yaml
|
||||||
|
webapp:
|
||||||
|
ingress:
|
||||||
|
hostname: myapp.example.com
|
||||||
|
port: 8080
|
||||||
|
|
||||||
|
map-env:
|
||||||
|
DB_HOST: "{{ .Release.Name }}-database"
|
||||||
|
```
|
||||||
|
|
||||||
!!! Warning "YAML in multiline label"
|
!!! Warning "YAML in multiline label"
|
||||||
|
|
||||||
Compose only accept text label. So, to put a complete YAML content in the target label, you need to use a pipe char (`|` or `|-`)
|
Compose only accept text label. So, to put a complete YAML content in the target label,
|
||||||
and to **indent** your content.
|
you need to use a pipe char (`|` or `|-`) and to **indent** your content.
|
||||||
|
|
||||||
For example :
|
For example :
|
||||||
|
|
||||||
@@ -26,14 +93,15 @@ Basically, you can use `katenary` to transpose a docker-compose file (or any com
|
|||||||
Katenary transforms compose services this way:
|
Katenary transforms compose services this way:
|
||||||
|
|
||||||
- Takes the service and create a "Deployment" file
|
- Takes the service and create a "Deployment" file
|
||||||
- if a port is declared, Katenary creates a service (ClusterIP)
|
- if a port is declared, Katenary creates a service (`ClusterIP`)
|
||||||
- if a port is exposed, Katenary creates a service (NodePort)
|
- if a port is exposed, Katenary creates a service (`NodePort`)
|
||||||
- environment variables will be stored inside a configMap
|
- environment variables will be stored inside a `ConfigMap`
|
||||||
- image, tags, and ingresses configuration are also stored in `values.yaml` file
|
- image, tags, and ingresses configuration are also stored in `values.yaml` file
|
||||||
- if named volumes are declared, Katenary create PersistentVolumeClaims - not enabled in values file
|
- if named volumes are declared, Katenary create `PersistentVolumeClaims` - not enabled in values file
|
||||||
- `depends_on` needs that the pointed service declared a port. If not, you can use labels to inform Katenary
|
- `depends_on` needs that the pointed service declared a port. If not, you can use labels to inform Katenary
|
||||||
|
|
||||||
For any other specific configuration, like binding local files as configMap, bind variables, add values with documentation, etc. You'll need to use labels.
|
For any other specific configuration, like binding local files as `ConfigMap`, bind variables, add values with
|
||||||
|
documentation, etc. You'll need to use labels.
|
||||||
|
|
||||||
Katenary can also configure containers grouping in pods, declare dependencies, ignore some services, force variables as
|
Katenary can also configure containers grouping in pods, declare dependencies, ignore some services, force variables as
|
||||||
secrets, mount files as `configMap`, and many others things. To adapt the helm chart generation, you will need to use
|
secrets, mount files as `configMap`, and many others things. To adapt the helm chart generation, you will need to use
|
||||||
@@ -100,7 +168,7 @@ services:
|
|||||||
|
|
||||||
In this case, `webapp` needs to know the `database` port because the `depends_on` points on it and Kubernetes has not
|
In this case, `webapp` needs to know the `database` port because the `depends_on` points on it and Kubernetes has not
|
||||||
(yet) solution to check the database startup. Katenary wants to create a `initContainer` to hit on the related service.
|
(yet) solution to check the database startup. Katenary wants to create a `initContainer` to hit on the related service.
|
||||||
So, instead of exposing the port in the compose definition, let's declare this to katenary with labels:
|
So, instead of exposing the port in the compose definition, let's declare this to Katenary with labels:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
version: "3"
|
version: "3"
|
||||||
|
@@ -59,4 +59,8 @@ nav:
|
|||||||
- Generator:
|
- Generator:
|
||||||
- Index: packages/generator.md
|
- Index: packages/generator.md
|
||||||
- ExtraFiles: packages/generator/extrafiles.md
|
- ExtraFiles: packages/generator/extrafiles.md
|
||||||
- LabelStructs: packages/generator/labelStructs.md
|
- labels:
|
||||||
|
- packages/generator/labels.md
|
||||||
|
- LabelStructs: packages/generator/labels/labelStructs.md
|
||||||
|
- KatenaryFile: packages/generator/katenaryfile.md
|
||||||
|
|
||||||
|
@@ -33,7 +33,7 @@ type ConvertOptions struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HelmChart is a Helm Chart representation. It contains all the
|
// HelmChart is a Helm Chart representation. It contains all the
|
||||||
// tempaltes, values, versions, helpers...
|
// templates, values, versions, helpers...
|
||||||
type HelmChart struct {
|
type HelmChart struct {
|
||||||
Templates map[string]*ChartTemplate `yaml:"-"`
|
Templates map[string]*ChartTemplate `yaml:"-"`
|
||||||
Values map[string]any `yaml:"-"`
|
Values map[string]any `yaml:"-"`
|
||||||
@@ -209,10 +209,21 @@ func (chart *HelmChart) generateDeployment(service types.ServiceConfig, deployme
|
|||||||
// generate the cronjob if needed
|
// generate the cronjob if needed
|
||||||
chart.setCronJob(service, appName)
|
chart.setCronJob(service, appName)
|
||||||
|
|
||||||
|
if exchange, ok := service.Labels[labels.LabelExchangeVolume]; ok {
|
||||||
|
// we need to add a volume and a mount point
|
||||||
|
ex, err := labelStructs.NewExchangeVolumes(exchange)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, exchangeVolume := range ex {
|
||||||
|
d.AddLegacyVolume("exchange-"+exchangeVolume.Name, exchangeVolume.Type)
|
||||||
|
d.exchangesVolumes[service.Name] = exchangeVolume
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// get the same-pod label if exists, add it to the list.
|
// get the same-pod label if exists, add it to the list.
|
||||||
// We later will copy some parts to the target deployment and remove this one.
|
// We later will copy some parts to the target deployment and remove this one.
|
||||||
if samePod, ok := service.Labels[labels.LabelSamePod]; ok && samePod != "" {
|
if samePod, ok := service.Labels[labels.LabelSamePod]; ok && samePod != "" {
|
||||||
log.Printf("Found same-pod label for %s", service.Name)
|
|
||||||
podToMerge[samePod] = &service
|
podToMerge[samePod] = &service
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,17 +24,6 @@ const (
|
|||||||
FileMapUsageFiles // files in a configmap.
|
FileMapUsageFiles // files in a configmap.
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewFileMap creates a new DataMap from a compose service. The appName is the name of the application taken from the project name.
|
|
||||||
func NewFileMap(service types.ServiceConfig, appName, kind string) DataMap {
|
|
||||||
switch kind {
|
|
||||||
case "configmap":
|
|
||||||
return NewConfigMap(service, appName, true)
|
|
||||||
default:
|
|
||||||
log.Fatalf("Unknown filemap kind: %s", kind)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// only used to check interface implementation
|
// only used to check interface implementation
|
||||||
var (
|
var (
|
||||||
_ DataMap = (*ConfigMap)(nil)
|
_ DataMap = (*ConfigMap)(nil)
|
||||||
@@ -109,14 +98,14 @@ func NewConfigMap(service types.ServiceConfig, appName string, forFile bool) *Co
|
|||||||
done[key] = true
|
done[key] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
for key, env := range service.Environment {
|
||||||
for key, env := range service.Environment {
|
_, isDropped := drop[key]
|
||||||
_, isDropped := drop[key]
|
_, isDone := done[key]
|
||||||
_, isDone := done[key]
|
if isDropped || isDone {
|
||||||
if isDropped || isDone {
|
continue
|
||||||
continue
|
}
|
||||||
|
cm.AddData(key, *env)
|
||||||
}
|
}
|
||||||
cm.AddData(key, *env)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cm
|
return cm
|
||||||
@@ -168,7 +157,6 @@ func (c *ConfigMap) AppendDir(path string) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Path %s does not exist\n", path)
|
log.Fatalf("Path %s does not exist\n", path)
|
||||||
}
|
}
|
||||||
log.Printf("Appending files from %s to configmap\n", path)
|
|
||||||
// recursively read all files in the path and add them to the configmap
|
// recursively read all files in the path and add them to the configmap
|
||||||
if stat.IsDir() {
|
if stat.IsDir() {
|
||||||
files, err := os.ReadDir(path)
|
files, err := os.ReadDir(path)
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
package generator
|
package generator
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"katenary/generator/labels"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -40,3 +42,34 @@ services:
|
|||||||
t.Errorf("Expected BAR to be baz, got %s", data["BAR"])
|
t.Errorf("Expected BAR to be baz, got %s", data["BAR"])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMapEnv(t *testing.T) {
|
||||||
|
composeFile := `
|
||||||
|
services:
|
||||||
|
web:
|
||||||
|
image: nginx:1.29
|
||||||
|
environment:
|
||||||
|
FOO: bar
|
||||||
|
labels:
|
||||||
|
%[1]s/map-env: |-
|
||||||
|
FOO: 'baz'
|
||||||
|
`
|
||||||
|
|
||||||
|
composeFile = fmt.Sprintf(composeFile, labels.KatenaryLabelPrefix)
|
||||||
|
tmpDir := setup(composeFile)
|
||||||
|
defer teardown(tmpDir)
|
||||||
|
|
||||||
|
currentDir, _ := os.Getwd()
|
||||||
|
os.Chdir(tmpDir)
|
||||||
|
defer os.Chdir(currentDir)
|
||||||
|
|
||||||
|
output := internalCompileTest(t, "-s", "templates/web/configmap.yaml")
|
||||||
|
configMap := v1.ConfigMap{}
|
||||||
|
if err := yaml.Unmarshal([]byte(output), &configMap); err != nil {
|
||||||
|
t.Errorf(unmarshalError, err)
|
||||||
|
}
|
||||||
|
data := configMap.Data
|
||||||
|
if v, ok := data["FOO"]; !ok || v != "baz" {
|
||||||
|
t.Errorf("Expected FOO to be baz, got %s", v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -53,7 +53,7 @@ const imagePullSecretHelp = `
|
|||||||
# e.g.
|
# e.g.
|
||||||
# pullSecrets:
|
# pullSecrets:
|
||||||
# - name: regcred
|
# - name: regcred
|
||||||
# You are, for now, repsonsible for creating the secret.
|
# You are, for now, responsible for creating the secret.
|
||||||
`
|
`
|
||||||
|
|
||||||
const imagePullPolicyHelp = `# imagePullPolicy allows you to specify a policy to cache or always pull an image.
|
const imagePullPolicyHelp = `# imagePullPolicy allows you to specify a policy to cache or always pull an image.
|
||||||
@@ -397,23 +397,6 @@ func addMainTagAppDoc(values []byte, project *types.Project) []byte {
|
|||||||
return []byte(strings.Join(lines, "\n"))
|
return []byte(strings.Join(lines, "\n"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// addModeline adds a modeline to the values.yaml file to make sure that vim
|
|
||||||
// will use the correct syntax highlighting.
|
|
||||||
func addModeline(values []byte) []byte {
|
|
||||||
modeline := "# vi" + "m: ft=helm.gotmpl.yaml"
|
|
||||||
|
|
||||||
// if the values ends by `{{- end }}` we need to add the modeline before
|
|
||||||
lines := strings.Split(string(values), "\n")
|
|
||||||
|
|
||||||
if lines[len(lines)-1] == "{{- end }}" || lines[len(lines)-1] == "{{- end -}}" {
|
|
||||||
lines = lines[:len(lines)-1]
|
|
||||||
lines = append(lines, modeline, "{{- end }}")
|
|
||||||
return []byte(strings.Join(lines, "\n"))
|
|
||||||
}
|
|
||||||
|
|
||||||
return append(values, []byte(modeline)...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func addResourceHelp(values []byte) []byte {
|
func addResourceHelp(values []byte) []byte {
|
||||||
lines := strings.Split(string(values), "\n")
|
lines := strings.Split(string(values), "\n")
|
||||||
for i, line := range lines {
|
for i, line := range lines {
|
||||||
|
@@ -33,12 +33,13 @@ type ConfigMapMount struct {
|
|||||||
// Deployment is a kubernetes Deployment.
|
// Deployment is a kubernetes Deployment.
|
||||||
type Deployment struct {
|
type Deployment struct {
|
||||||
*appsv1.Deployment `yaml:",inline"`
|
*appsv1.Deployment `yaml:",inline"`
|
||||||
chart *HelmChart `yaml:"-"`
|
chart *HelmChart `yaml:"-"`
|
||||||
configMaps map[string]*ConfigMapMount `yaml:"-"`
|
configMaps map[string]*ConfigMapMount `yaml:"-"`
|
||||||
volumeMap map[string]string `yaml:"-"` // keep map of fixed named to original volume name
|
volumeMap map[string]string `yaml:"-"` // keep map of fixed named to original volume name
|
||||||
service *types.ServiceConfig `yaml:"-"`
|
service *types.ServiceConfig `yaml:"-"`
|
||||||
defaultTag string `yaml:"-"`
|
defaultTag string `yaml:"-"`
|
||||||
isMainApp bool `yaml:"-"`
|
isMainApp bool `yaml:"-"`
|
||||||
|
exchangesVolumes map[string]*labelStructs.ExchangeVolume `yaml:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDeployment creates a new Deployment from a compose service. The appName is the name of the application taken from the project name.
|
// NewDeployment creates a new Deployment from a compose service. The appName is the name of the application taken from the project name.
|
||||||
@@ -90,8 +91,9 @@ func NewDeployment(service types.ServiceConfig, chart *HelmChart) *Deployment {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
configMaps: make(map[string]*ConfigMapMount),
|
configMaps: make(map[string]*ConfigMapMount),
|
||||||
volumeMap: make(map[string]string),
|
volumeMap: make(map[string]string),
|
||||||
|
exchangesVolumes: map[string]*labelStructs.ExchangeVolume{},
|
||||||
}
|
}
|
||||||
|
|
||||||
// add containers
|
// add containers
|
||||||
@@ -212,6 +214,27 @@ func (d *Deployment) AddVolumes(service types.ServiceConfig, appName string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *Deployment) AddLegacyVolume(name, kind string) {
|
||||||
|
// ensure the volume is not present
|
||||||
|
for _, v := range d.Spec.Template.Spec.Volumes {
|
||||||
|
if v.Name == name {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// init
|
||||||
|
if d.Spec.Template.Spec.Volumes == nil {
|
||||||
|
d.Spec.Template.Spec.Volumes = []corev1.Volume{}
|
||||||
|
}
|
||||||
|
|
||||||
|
d.Spec.Template.Spec.Volumes = append(d.Spec.Template.Spec.Volumes, corev1.Volume{
|
||||||
|
Name: name,
|
||||||
|
VolumeSource: corev1.VolumeSource{
|
||||||
|
EmptyDir: &corev1.EmptyDirVolumeSource{},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (d *Deployment) BindFrom(service types.ServiceConfig, binded *Deployment) {
|
func (d *Deployment) BindFrom(service types.ServiceConfig, binded *Deployment) {
|
||||||
// find the volume in the binded deployment
|
// find the volume in the binded deployment
|
||||||
for _, bindedVolume := range binded.Spec.Template.Spec.Volumes {
|
for _, bindedVolume := range binded.Spec.Template.Spec.Volumes {
|
||||||
@@ -276,14 +299,27 @@ func (d *Deployment) Filename() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetEnvFrom sets the environment variables to a configmap. The configmap is created.
|
// SetEnvFrom sets the environment variables to a configmap. The configmap is created.
|
||||||
func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string) {
|
func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string, samePod ...bool) {
|
||||||
if len(service.Environment) == 0 {
|
if len(service.Environment) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
inSamePod := false
|
||||||
|
if len(samePod) > 0 && samePod[0] {
|
||||||
|
inSamePod = true
|
||||||
|
}
|
||||||
|
|
||||||
drop := []string{}
|
drop := []string{}
|
||||||
secrets := []string{}
|
secrets := []string{}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
c, index := d.BindMapFilesToContainer(service, secrets, appName)
|
||||||
|
if c == nil || index == -1 {
|
||||||
|
log.Println("Container not found for service ", service.Name)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
d.Spec.Template.Spec.Containers[index] = *c
|
||||||
|
}()
|
||||||
|
|
||||||
// secrets from label
|
// secrets from label
|
||||||
labelSecrets, err := labelStructs.SecretsFrom(service.Labels[labels.LabelSecrets])
|
labelSecrets, err := labelStructs.SecretsFrom(service.Labels[labels.LabelSecrets])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -308,6 +344,10 @@ func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string) {
|
|||||||
secrets = append(secrets, secret)
|
secrets = append(secrets, secret)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if inSamePod {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// for each values from label "values", add it to Values map and change the envFrom
|
// for each values from label "values", add it to Values map and change the envFrom
|
||||||
// value to {{ .Values.<service>.<value> }}
|
// value to {{ .Values.<service>.<value> }}
|
||||||
for _, value := range labelValues {
|
for _, value := range labelValues {
|
||||||
@@ -330,10 +370,26 @@ func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string) {
|
|||||||
for _, value := range drop {
|
for _, value := range drop {
|
||||||
delete(service.Environment, value)
|
delete(service.Environment, value)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Deployment) BindMapFilesToContainer(service types.ServiceConfig, secrets []string, appName string) (*corev1.Container, int) {
|
||||||
fromSources := []corev1.EnvFromSource{}
|
fromSources := []corev1.EnvFromSource{}
|
||||||
|
|
||||||
if len(service.Environment) > 0 {
|
envSize := len(service.Environment)
|
||||||
|
|
||||||
|
for _, secret := range secrets {
|
||||||
|
for k := range service.Environment {
|
||||||
|
if k == secret {
|
||||||
|
envSize--
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if envSize > 0 {
|
||||||
|
if service.Name == "db" {
|
||||||
|
log.Println("Service ", service.Name, " has environment variables")
|
||||||
|
log.Println(service.Environment)
|
||||||
|
}
|
||||||
fromSources = append(fromSources, corev1.EnvFromSource{
|
fromSources = append(fromSources, corev1.EnvFromSource{
|
||||||
ConfigMapRef: &corev1.ConfigMapEnvSource{
|
ConfigMapRef: &corev1.ConfigMapEnvSource{
|
||||||
LocalObjectReference: corev1.LocalObjectReference{
|
LocalObjectReference: corev1.LocalObjectReference{
|
||||||
@@ -356,7 +412,7 @@ func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string) {
|
|||||||
container, index := utils.GetContainerByName(service.Name, d.Spec.Template.Spec.Containers)
|
container, index := utils.GetContainerByName(service.Name, d.Spec.Template.Spec.Containers)
|
||||||
if container == nil {
|
if container == nil {
|
||||||
utils.Warn("Container not found for service " + service.Name)
|
utils.Warn("Container not found for service " + service.Name)
|
||||||
return
|
return nil, -1
|
||||||
}
|
}
|
||||||
|
|
||||||
container.EnvFrom = append(container.EnvFrom, fromSources...)
|
container.EnvFrom = append(container.EnvFrom, fromSources...)
|
||||||
@@ -364,8 +420,30 @@ func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string) {
|
|||||||
if container.Env == nil {
|
if container.Env == nil {
|
||||||
container.Env = []corev1.EnvVar{}
|
container.Env = []corev1.EnvVar{}
|
||||||
}
|
}
|
||||||
|
return container, index
|
||||||
|
}
|
||||||
|
|
||||||
d.Spec.Template.Spec.Containers[index] = *container
|
func (d *Deployment) MountExchangeVolumes() {
|
||||||
|
for name, ex := range d.exchangesVolumes {
|
||||||
|
for i, c := range d.Spec.Template.Spec.Containers {
|
||||||
|
c.VolumeMounts = append(c.VolumeMounts, corev1.VolumeMount{
|
||||||
|
Name: "exchange-" + ex.Name,
|
||||||
|
MountPath: ex.MountPath,
|
||||||
|
})
|
||||||
|
if len(ex.Init) > 0 && name == c.Name {
|
||||||
|
d.Spec.Template.Spec.InitContainers = append(d.Spec.Template.Spec.InitContainers, corev1.Container{
|
||||||
|
Command: []string{"/bin/sh", "-c", ex.Init},
|
||||||
|
Image: c.Image,
|
||||||
|
Name: "exhange-init-" + name,
|
||||||
|
VolumeMounts: []corev1.VolumeMount{{
|
||||||
|
Name: "exchange-" + ex.Name,
|
||||||
|
MountPath: ex.MountPath,
|
||||||
|
}},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
d.Spec.Template.Spec.Containers[i] = c
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Yaml returns the yaml representation of the deployment.
|
// Yaml returns the yaml representation of the deployment.
|
||||||
@@ -405,7 +483,11 @@ func (d *Deployment) Yaml() ([]byte, error) {
|
|||||||
|
|
||||||
if strings.Contains(volume, "mountPath: ") {
|
if strings.Contains(volume, "mountPath: ") {
|
||||||
spaces = strings.Repeat(" ", utils.CountStartingSpaces(volume))
|
spaces = strings.Repeat(" ", utils.CountStartingSpaces(volume))
|
||||||
varName := d.volumeMap[volumeName]
|
varName, ok := d.volumeMap[volumeName]
|
||||||
|
if !ok {
|
||||||
|
// this case happens when the volume is a "bind" volume comming from a "same-pod" service.
|
||||||
|
continue
|
||||||
|
}
|
||||||
varName = strings.ReplaceAll(varName, "-", "_")
|
varName = strings.ReplaceAll(varName, "-", "_")
|
||||||
content[line] = spaces + `{{- if .Values.` + serviceName + `.persistence.` + varName + `.enabled }}` + "\n" + volume
|
content[line] = spaces + `{{- if .Values.` + serviceName + `.persistence.` + varName + `.enabled }}` + "\n" + volume
|
||||||
changing = true
|
changing = true
|
||||||
@@ -581,10 +663,12 @@ func (d *Deployment) appendFileToConfigMap(service types.ServiceConfig, appName
|
|||||||
|
|
||||||
func (d *Deployment) bindVolumes(volume types.ServiceVolumeConfig, isSamePod bool, tobind map[string]bool, service types.ServiceConfig, appName string) {
|
func (d *Deployment) bindVolumes(volume types.ServiceVolumeConfig, isSamePod bool, tobind map[string]bool, service types.ServiceConfig, appName string) {
|
||||||
container, index := utils.GetContainerByName(service.Name, d.Spec.Template.Spec.Containers)
|
container, index := utils.GetContainerByName(service.Name, d.Spec.Template.Spec.Containers)
|
||||||
|
|
||||||
defer func(d *Deployment, container *corev1.Container, index int) {
|
defer func(d *Deployment, container *corev1.Container, index int) {
|
||||||
d.Spec.Template.Spec.Containers[index] = *container
|
d.Spec.Template.Spec.Containers[index] = *container
|
||||||
}(d, container, index)
|
}(d, container, index)
|
||||||
if _, ok := tobind[volume.Source]; !isSamePod && volume.Type == "bind" && !ok {
|
|
||||||
|
if _, found := tobind[volume.Source]; !isSamePod && volume.Type == "bind" && !found {
|
||||||
utils.Warn(
|
utils.Warn(
|
||||||
"Bind volumes are not supported yet, " +
|
"Bind volumes are not supported yet, " +
|
||||||
"excepting for those declared as " +
|
"excepting for those declared as " +
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
The generator package generates kubernetes objects from a "compose" file and transforms them into a helm chart.
|
The generator package generates kubernetes objects from a "compose" file and transforms them into a helm chart.
|
||||||
|
|
||||||
The generator package is the core of katenary. It is responsible for generating kubernetes objects from a compose file and transforming them into a helm chart.
|
The generator package is the core of katenary. It is responsible for generating kubernetes objects from a compose file and transforming them into a helm chart.
|
||||||
Convertion manipulates Yaml representation of kubernetes object to add conditions, labels, annotations, etc. to the objects. It also create the values to be set to
|
Conversion manipulates Yaml representation of kubernetes object to add conditions, labels, annotations, etc. to the objects. It also create the values to be set to
|
||||||
the values.yaml file.
|
the values.yaml file.
|
||||||
|
|
||||||
The generate.Convert() create an HelmChart object and call "Generate()" method to convert from a compose file to a helm chart.
|
The generate.Convert() create an HelmChart object and call "Generate()" method to convert from a compose file to a helm chart.
|
||||||
|
@@ -79,6 +79,11 @@ func Generate(project *types.Project) (*HelmChart, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if we have built exchange volumes, we need to moint them in each deployment
|
||||||
|
for _, d := range deployments {
|
||||||
|
d.MountExchangeVolumes()
|
||||||
|
}
|
||||||
|
|
||||||
// drop all "same-pod" deployments because the containers and volumes are already
|
// drop all "same-pod" deployments because the containers and volumes are already
|
||||||
// in the target deployment
|
// in the target deployment
|
||||||
for _, service := range podToMerge {
|
for _, service := range podToMerge {
|
||||||
@@ -87,6 +92,10 @@ func Generate(project *types.Project) (*HelmChart, error) {
|
|||||||
if target, ok := deployments[samepod]; ok {
|
if target, ok := deployments[samepod]; ok {
|
||||||
target.AddContainer(*service)
|
target.AddContainer(*service)
|
||||||
target.BindFrom(*service, deployments[service.Name])
|
target.BindFrom(*service, deployments[service.Name])
|
||||||
|
target.SetEnvFrom(*service, appName, true)
|
||||||
|
// copy all init containers
|
||||||
|
initContainers := deployments[service.Name].Spec.Template.Spec.InitContainers
|
||||||
|
target.Spec.Template.Spec.InitContainers = append(target.Spec.Template.Spec.InitContainers, initContainers...)
|
||||||
delete(deployments, service.Name)
|
delete(deployments, service.Name)
|
||||||
} else {
|
} else {
|
||||||
log.Printf("service %[1]s is declared as %[2]s, but %[2]s is not defined", service.Name, labels.LabelSamePod)
|
log.Printf("service %[1]s is declared as %[2]s, but %[2]s is not defined", service.Name, labels.LabelSamePod)
|
||||||
@@ -146,7 +155,9 @@ func Generate(project *types.Project) (*HelmChart, error) {
|
|||||||
for _, s := range podToMerge {
|
for _, s := range podToMerge {
|
||||||
// get the target service
|
// get the target service
|
||||||
target := services[s.Name]
|
target := services[s.Name]
|
||||||
delete(chart.Templates, target.Filename())
|
if target != nil {
|
||||||
|
delete(chart.Templates, target.Filename())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// compute all needed resplacements in YAML templates
|
// compute all needed resplacements in YAML templates
|
||||||
@@ -272,7 +283,7 @@ func buildVolumes(service types.ServiceConfig, chart *HelmChart, deployments map
|
|||||||
}
|
}
|
||||||
switch v.Type {
|
switch v.Type {
|
||||||
case "volume":
|
case "volume":
|
||||||
v.Source = strings.ReplaceAll(v.Source, "-", "_")
|
v.Source = utils.AsResourceName(v.Source)
|
||||||
pvc := NewVolumeClaim(service, v.Source, appName)
|
pvc := NewVolumeClaim(service, v.Source, appName)
|
||||||
|
|
||||||
// if the service is integrated in another deployment, we need to add the volume
|
// if the service is integrated in another deployment, we need to add the volume
|
||||||
|
@@ -51,9 +51,9 @@ func NewIngress(service types.ServiceConfig, Chart *HelmChart) *Ingress {
|
|||||||
|
|
||||||
Chart.Values[service.Name].(*Value).Ingress = &IngressValue{
|
Chart.Values[service.Name].(*Value).Ingress = &IngressValue{
|
||||||
Enabled: mapping.Enabled,
|
Enabled: mapping.Enabled,
|
||||||
Path: mapping.Path,
|
Path: *mapping.Path,
|
||||||
Host: mapping.Hostname,
|
Host: mapping.Hostname,
|
||||||
Class: mapping.Class,
|
Class: *mapping.Class,
|
||||||
Annotations: mapping.Annotations,
|
Annotations: mapping.Annotations,
|
||||||
TLS: TLS{Enabled: mapping.TLS.Enabled},
|
TLS: TLS{Enabled: mapping.TLS.Enabled},
|
||||||
}
|
}
|
||||||
|
@@ -25,20 +25,21 @@ type StringOrMap any
|
|||||||
|
|
||||||
// Service is a struct that contains the service configuration for katenary
|
// Service is a struct that contains the service configuration for katenary
|
||||||
type Service struct {
|
type Service struct {
|
||||||
MainApp *bool `json:"main-app,omitempty" jsonschema:"title=Is this service the main application"`
|
MainApp *bool `json:"main-app,omitempty" jsonschema:"title=Is this service the main application"`
|
||||||
Values []StringOrMap `json:"values,omitempty" jsonschema:"description=Environment variables to be set in values.yaml with or without a description"`
|
Values []StringOrMap `json:"values,omitempty" jsonschema:"description=Environment variables to be set in values.yaml with or without a description"`
|
||||||
Secrets *labelStructs.Secrets `json:"secrets,omitempty" jsonschema:"title=Secrets,description=Environment variables to be set as secrets"`
|
Secrets *labelStructs.Secrets `json:"secrets,omitempty" jsonschema:"title=Secrets,description=Environment variables to be set as secrets"`
|
||||||
Ports *labelStructs.Ports `json:"ports,omitempty" jsonschema:"title=Ports,description=Ports to be exposed in services"`
|
Ports *labelStructs.Ports `json:"ports,omitempty" jsonschema:"title=Ports,description=Ports to be exposed in services"`
|
||||||
Ingress *labelStructs.Ingress `json:"ingress,omitempty" jsonschema:"title=Ingress,description=Ingress configuration"`
|
Ingress *labelStructs.Ingress `json:"ingress,omitempty" jsonschema:"title=Ingress,description=Ingress configuration"`
|
||||||
HealthCheck *labelStructs.HealthCheck `json:"health-check,omitempty" jsonschema:"title=Health Check,description=Health check configuration that respects the kubernetes api"`
|
HealthCheck *labelStructs.HealthCheck `json:"health-check,omitempty" jsonschema:"title=Health Check,description=Health check configuration that respects the kubernetes api"`
|
||||||
SamePod *string `json:"same-pod,omitempty" jsonschema:"title=Same Pod,description=Service that should be in the same pod"`
|
SamePod *string `json:"same-pod,omitempty" jsonschema:"title=Same Pod,description=Service that should be in the same pod"`
|
||||||
Description *string `json:"description,omitempty" jsonschema:"title=Description,description=Description of the service that will be injected in the values.yaml file"`
|
Description *string `json:"description,omitempty" jsonschema:"title=Description,description=Description of the service that will be injected in the values.yaml file"`
|
||||||
Ignore *bool `json:"ignore,omitempty" jsonschema:"title=Ignore,description=Ignore the service in the conversion"`
|
Ignore *bool `json:"ignore,omitempty" jsonschema:"title=Ignore,description=Ignore the service in the conversion"`
|
||||||
Dependencies []labelStructs.Dependency `json:"dependencies,omitempty" jsonschema:"title=Dependencies,description=Services that should be injected in the Chart.yaml file"`
|
Dependencies []labelStructs.Dependency `json:"dependencies,omitempty" jsonschema:"title=Dependencies,description=Services that should be injected in the Chart.yaml file"`
|
||||||
ConfigMapFile *labelStructs.ConfigMapFile `json:"configmap-files,omitempty" jsonschema:"title=ConfigMap Files,description=Files that should be injected as ConfigMap"`
|
ConfigMapFile *labelStructs.ConfigMapFile `json:"configmap-files,omitempty" jsonschema:"title=ConfigMap Files,description=Files that should be injected as ConfigMap"`
|
||||||
MapEnv *labelStructs.MapEnv `json:"map-env,omitempty" jsonschema:"title=Map Env,description=Map environment variables to another value"`
|
MapEnv *labelStructs.MapEnv `json:"map-env,omitempty" jsonschema:"title=Map Env,description=Map environment variables to another value"`
|
||||||
CronJob *labelStructs.CronJob `json:"cron-job,omitempty" jsonschema:"title=Cron Job,description=Cron Job configuration"`
|
CronJob *labelStructs.CronJob `json:"cron-job,omitempty" jsonschema:"title=Cron Job,description=Cron Job configuration"`
|
||||||
EnvFrom *labelStructs.EnvFrom `json:"env-from,omitempty" jsonschema:"title=Env From,description=Inject environment variables from another service"`
|
EnvFrom *labelStructs.EnvFrom `json:"env-from,omitempty" jsonschema:"title=Env From,description=Inject environment variables from another service"`
|
||||||
|
ExchangeVolumes []*labelStructs.ExchangeVolume `json:"exchange-volumes,omitempty" jsonschema:"title=Exchange Volumes,description=Exchange volumes between services"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// OverrideWithConfig overrides the project with the katenary.yaml file. It
|
// OverrideWithConfig overrides the project with the katenary.yaml file. It
|
||||||
@@ -89,6 +90,7 @@ func OverrideWithConfig(project *types.Project) {
|
|||||||
getLabelContent(s.MapEnv, &project.Services[i], labels.LabelMapEnv)
|
getLabelContent(s.MapEnv, &project.Services[i], labels.LabelMapEnv)
|
||||||
getLabelContent(s.CronJob, &project.Services[i], labels.LabelCronJob)
|
getLabelContent(s.CronJob, &project.Services[i], labels.LabelCronJob)
|
||||||
getLabelContent(s.EnvFrom, &project.Services[i], labels.LabelEnvFrom)
|
getLabelContent(s.EnvFrom, &project.Services[i], labels.LabelEnvFrom)
|
||||||
|
getLabelContent(s.ExchangeVolumes, &project.Services[i], labels.LabelExchangeVolume)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Println(utils.IconInfo, "Katenary file loaded successfully, the services are now configured.")
|
fmt.Println(utils.IconInfo, "Katenary file loaded successfully, the services are now configured.")
|
||||||
@@ -105,6 +107,19 @@ func getLabelContent(o any, service *types.ServiceConfig, labelName string) erro
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
val := strings.TrimSpace(string(c))
|
val := strings.TrimSpace(string(c))
|
||||||
|
if labelName == labels.LabelIngress {
|
||||||
|
// special case, values must be set from some defaults
|
||||||
|
ing, err := labelStructs.IngressFrom(val)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
c, err := yaml.Marshal(ing)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
val = strings.TrimSpace(string(c))
|
||||||
|
}
|
||||||
|
|
||||||
service.Labels[labelName] = val
|
service.Labels[labelName] = val
|
||||||
return nil
|
return nil
|
||||||
|
119
generator/katenaryfile/main_test.go
Normal file
119
generator/katenaryfile/main_test.go
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
package katenaryfile
|
||||||
|
|
||||||
|
import (
|
||||||
|
"katenary/generator/labels"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/compose-spec/compose-go/cli"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestBuildSchema(t *testing.T) {
|
||||||
|
sh := GenerateSchema()
|
||||||
|
if len(sh) == 0 {
|
||||||
|
t.Errorf("Expected schema to be defined")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOverrideProjectWithKatenaryFile(t *testing.T) {
|
||||||
|
composeContent := `
|
||||||
|
services:
|
||||||
|
webapp:
|
||||||
|
image: nginx:latest
|
||||||
|
`
|
||||||
|
|
||||||
|
katenaryfileContent := `
|
||||||
|
webapp:
|
||||||
|
ports:
|
||||||
|
- 80
|
||||||
|
`
|
||||||
|
|
||||||
|
// create /tmp/katenary-test-override directory, save the compose.yaml file
|
||||||
|
tmpDir, err := os.MkdirTemp("", "katenary-test-override")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf(err.Error())
|
||||||
|
}
|
||||||
|
composeFile := filepath.Join(tmpDir, "compose.yaml")
|
||||||
|
katenaryFile := filepath.Join(tmpDir, "katenary.yaml")
|
||||||
|
|
||||||
|
os.MkdirAll(tmpDir, 0755)
|
||||||
|
if err := os.WriteFile(composeFile, []byte(composeContent), 0644); err != nil {
|
||||||
|
t.Log(err)
|
||||||
|
}
|
||||||
|
if err := os.WriteFile(katenaryFile, []byte(katenaryfileContent), 0644); err != nil {
|
||||||
|
t.Log(err)
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
|
c, _ := os.ReadFile(composeFile)
|
||||||
|
log.Println(string(c))
|
||||||
|
|
||||||
|
// chand dir to this directory
|
||||||
|
os.Chdir(tmpDir)
|
||||||
|
options, _ := cli.NewProjectOptions(nil,
|
||||||
|
cli.WithWorkingDirectory(tmpDir),
|
||||||
|
cli.WithDefaultConfigPath,
|
||||||
|
)
|
||||||
|
project, err := cli.ProjectFromOptions(options)
|
||||||
|
|
||||||
|
OverrideWithConfig(project)
|
||||||
|
w := project.Services[0].Labels
|
||||||
|
if v, ok := w[labels.LabelPorts]; !ok {
|
||||||
|
t.Fatal("Expected ports to be defined", v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOverrideProjectWithIngress(t *testing.T) {
|
||||||
|
composeContent := `
|
||||||
|
services:
|
||||||
|
webapp:
|
||||||
|
image: nginx:latest
|
||||||
|
`
|
||||||
|
|
||||||
|
katenaryfileContent := `
|
||||||
|
webapp:
|
||||||
|
ports:
|
||||||
|
- 80
|
||||||
|
ingress:
|
||||||
|
port: 80
|
||||||
|
`
|
||||||
|
|
||||||
|
// create /tmp/katenary-test-override directory, save the compose.yaml file
|
||||||
|
tmpDir, err := os.MkdirTemp("", "katenary-test-override")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf(err.Error())
|
||||||
|
}
|
||||||
|
composeFile := filepath.Join(tmpDir, "compose.yaml")
|
||||||
|
katenaryFile := filepath.Join(tmpDir, "katenary.yaml")
|
||||||
|
|
||||||
|
os.MkdirAll(tmpDir, 0755)
|
||||||
|
if err := os.WriteFile(composeFile, []byte(composeContent), 0644); err != nil {
|
||||||
|
t.Log(err)
|
||||||
|
}
|
||||||
|
if err := os.WriteFile(katenaryFile, []byte(katenaryfileContent), 0644); err != nil {
|
||||||
|
t.Log(err)
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
|
c, _ := os.ReadFile(composeFile)
|
||||||
|
log.Println(string(c))
|
||||||
|
|
||||||
|
// chand dir to this directory
|
||||||
|
os.Chdir(tmpDir)
|
||||||
|
options, _ := cli.NewProjectOptions(nil,
|
||||||
|
cli.WithWorkingDirectory(tmpDir),
|
||||||
|
cli.WithDefaultConfigPath,
|
||||||
|
)
|
||||||
|
project, err := cli.ProjectFromOptions(options)
|
||||||
|
|
||||||
|
OverrideWithConfig(project)
|
||||||
|
w := project.Services[0].Labels
|
||||||
|
if v, ok := w[labels.LabelPorts]; !ok {
|
||||||
|
t.Fatal("Expected ports to be defined", v)
|
||||||
|
}
|
||||||
|
if v, ok := w[labels.LabelIngress]; !ok {
|
||||||
|
t.Fatal("Expected ingress to be defined", v)
|
||||||
|
}
|
||||||
|
}
|
14
generator/labels/help-template.md.tpl
Normal file
14
generator/labels/help-template.md.tpl
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
## {{ .KatenaryPrefix }}/{{ .Name }}
|
||||||
|
|
||||||
|
{{ .Help.Short }}
|
||||||
|
|
||||||
|
**Type**: `{{ .Help.Type }}`
|
||||||
|
|
||||||
|
{{ .Help.Long }}
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
{{ .Help.Example }}
|
||||||
|
```
|
||||||
|
|
9
generator/labels/help-template.tpl
Normal file
9
generator/labels/help-template.tpl
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{{ .KatenaryPrefix }}/{{ .Name }}: {{ .Help.Short }}
|
||||||
|
Type: {{ .Help.Type }}
|
||||||
|
|
||||||
|
{{ .Help.Long }}
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
{{ .Help.Example }}
|
||||||
|
|
@@ -32,6 +32,7 @@ const (
|
|||||||
LabelConfigMapFiles Label = KatenaryLabelPrefix + "/configmap-files"
|
LabelConfigMapFiles Label = KatenaryLabelPrefix + "/configmap-files"
|
||||||
LabelCronJob Label = KatenaryLabelPrefix + "/cronjob"
|
LabelCronJob Label = KatenaryLabelPrefix + "/cronjob"
|
||||||
LabelEnvFrom Label = KatenaryLabelPrefix + "/env-from"
|
LabelEnvFrom Label = KatenaryLabelPrefix + "/env-from"
|
||||||
|
LabelExchangeVolume Label = KatenaryLabelPrefix + "/exchange-volumes"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -42,6 +43,12 @@ var (
|
|||||||
|
|
||||||
// parsed yaml
|
// parsed yaml
|
||||||
labelFullHelp map[string]Help
|
labelFullHelp map[string]Help
|
||||||
|
|
||||||
|
//go:embed help-template.tpl
|
||||||
|
helpTemplatePlain string
|
||||||
|
|
||||||
|
//go:embed help-template.md.tpl
|
||||||
|
helpTemplateMarkdown string
|
||||||
)
|
)
|
||||||
|
|
||||||
// Label is a katenary label to find in compose files.
|
// Label is a katenary label to find in compose files.
|
||||||
@@ -95,9 +102,6 @@ func GetLabelHelpFor(labelname string, asMarkdown bool) string {
|
|||||||
help.Example = strings.TrimPrefix(help.Example, "\n")
|
help.Example = strings.TrimPrefix(help.Example, "\n")
|
||||||
help.Short = strings.TrimPrefix(help.Short, "\n")
|
help.Short = strings.TrimPrefix(help.Short, "\n")
|
||||||
|
|
||||||
// get help template
|
|
||||||
helpTemplate := getHelpTemplate(asMarkdown)
|
|
||||||
|
|
||||||
if asMarkdown {
|
if asMarkdown {
|
||||||
// enclose templates in backticks
|
// enclose templates in backticks
|
||||||
help.Long = regexp.MustCompile(`\{\{(.*?)\}\}`).ReplaceAllString(help.Long, "`{{$1}}`")
|
help.Long = regexp.MustCompile(`\{\{(.*?)\}\}`).ReplaceAllString(help.Long, "`{{$1}}`")
|
||||||
@@ -110,6 +114,15 @@ func GetLabelHelpFor(labelname string, asMarkdown bool) string {
|
|||||||
help.Long = utils.WordWrap(help.Long, 80)
|
help.Long = utils.WordWrap(help.Long, 80)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get help template
|
||||||
|
var helpTemplate string
|
||||||
|
switch asMarkdown {
|
||||||
|
case true:
|
||||||
|
helpTemplate = helpTemplateMarkdown
|
||||||
|
case false:
|
||||||
|
helpTemplate = helpTemplatePlain
|
||||||
|
}
|
||||||
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
template.Must(template.New("shorthelp").Parse(help.Long)).Execute(&buf, struct {
|
template.Must(template.New("shorthelp").Parse(help.Long)).Execute(&buf, struct {
|
||||||
KatenaryPrefix string
|
KatenaryPrefix string
|
||||||
@@ -207,29 +220,6 @@ func generateTableHeaderSeparator(maxNameLength, maxDescriptionLength, maxTypeLe
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getHelpTemplate(asMarkdown bool) string {
|
|
||||||
if asMarkdown {
|
|
||||||
return `## {{ .KatenaryPrefix }}/{{ .Name }}
|
|
||||||
|
|
||||||
{{ .Help.Short }}
|
|
||||||
|
|
||||||
**Type**: ` + "`" + `{{ .Help.Type }}` + "`" + `
|
|
||||||
|
|
||||||
{{ .Help.Long }}
|
|
||||||
|
|
||||||
**Example:**` + "\n\n```yaml\n" + `{{ .Help.Example }}` + "\n```\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
return `{{ .KatenaryPrefix }}/{{ .Name }}: {{ .Help.Short }}
|
|
||||||
Type: {{ .Help.Type }}
|
|
||||||
|
|
||||||
{{ .Help.Long }}
|
|
||||||
|
|
||||||
Example:
|
|
||||||
{{ .Help.Example }}
|
|
||||||
`
|
|
||||||
}
|
|
||||||
|
|
||||||
func Prefix() string {
|
func Prefix() string {
|
||||||
return KatenaryLabelPrefix
|
return KatenaryLabelPrefix
|
||||||
}
|
}
|
||||||
|
@@ -284,4 +284,41 @@
|
|||||||
{{ .KatenaryPrefix }}/env-from: |-
|
{{ .KatenaryPrefix }}/env-from: |-
|
||||||
- myservice1
|
- myservice1
|
||||||
|
|
||||||
|
"exchange-volumes":
|
||||||
|
short: Add exchange volumes (empty directory on the node) to share data
|
||||||
|
type: "list of objects"
|
||||||
|
long: |-
|
||||||
|
This label allows sharing data between containres. The volume is created in
|
||||||
|
the node and mounted in the pod. It is useful to share data between containers
|
||||||
|
in a "same pod" logic. For example to let PHP-FPM and Nginx share the same direcotory.
|
||||||
|
|
||||||
|
This will create:
|
||||||
|
|
||||||
|
- an `emptyDir` volume in the deployment
|
||||||
|
- a `voumeMount` in the pod for **each container**
|
||||||
|
- a `initContainer` for each definition
|
||||||
|
|
||||||
|
Fields:
|
||||||
|
- name: the name of the volume (manadatory)
|
||||||
|
- mountPath: the path where the volume is mounted in the pod (optional, default is `/opt`)
|
||||||
|
- init: a command to run to initialize the volume with data (optional)
|
||||||
|
|
||||||
|
!!! Warning
|
||||||
|
This is highly experimental. This is mainly useful when using the "same-pod" label.
|
||||||
|
|
||||||
|
example: |-
|
||||||
|
nginx:
|
||||||
|
# ...
|
||||||
|
labels;
|
||||||
|
{{ .KatenaryPrefix }}/exchange-volumes: |-
|
||||||
|
- name: php-fpm
|
||||||
|
mountPath: /var/www/html
|
||||||
|
php:
|
||||||
|
# ...
|
||||||
|
labels:
|
||||||
|
{{ .KatenaryPrefix }}/exchange-volumes: |-
|
||||||
|
- name: php-fpm
|
||||||
|
mountPath: /opt
|
||||||
|
init: cp -ra /var/www/html/* /opt
|
||||||
|
|
||||||
# vim: ft=gotmpl.yaml
|
# vim: ft=gotmpl.yaml
|
||||||
|
20
generator/labels/labelStructs/exchangeVolume.go
Normal file
20
generator/labels/labelStructs/exchangeVolume.go
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package labelStructs
|
||||||
|
|
||||||
|
import "gopkg.in/yaml.v3"
|
||||||
|
|
||||||
|
type ExchangeVolume struct {
|
||||||
|
Name string `yaml:"name" json:"name"`
|
||||||
|
MountPath string `yaml:"mountPath" json:"mountPath"`
|
||||||
|
Type string `yaml:"type,omitempty" json:"type,omitempty"`
|
||||||
|
Init string `yaml:"init,omitempty" json:"init,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewExchangeVolumes(data string) ([]*ExchangeVolume, error) {
|
||||||
|
mapping := []*ExchangeVolume{}
|
||||||
|
|
||||||
|
if err := yaml.Unmarshal([]byte(data), &mapping); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return mapping, nil
|
||||||
|
}
|
@@ -1,17 +1,22 @@
|
|||||||
package labelStructs
|
package labelStructs
|
||||||
|
|
||||||
import "gopkg.in/yaml.v3"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"katenary/utils"
|
||||||
|
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
|
)
|
||||||
|
|
||||||
type TLS struct {
|
type TLS struct {
|
||||||
Enabled bool `yaml:"enabled" json:"enabled,omitempty"`
|
Enabled bool `yaml:"enabled" json:"enabled,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Ingress struct {
|
type Ingress struct {
|
||||||
Port *int32 `yaml:"port,omitempty" jsonschema:"nullable" json:"port,omitempty"`
|
Port *int32 `yaml:"port,omitempty" json:"port,omitempty"`
|
||||||
Annotations map[string]string `yaml:"annotations,omitempty" jsonschema:"nullable" json:"annotations,omitempty"`
|
Annotations map[string]string `yaml:"annotations,omitempty" jsonschema:"nullable" json:"annotations,omitempty"`
|
||||||
Hostname string `yaml:"hostname" json:"hostname,omitempty"`
|
Hostname string `yaml:"hostname" json:"hostname,omitempty"`
|
||||||
Path string `yaml:"path" json:"path,omitempty"`
|
Path *string `yaml:"path,omitempty" json:"path,omitempty"`
|
||||||
Class string `yaml:"class" json:"class,omitempty" jsonschema:"default:-"`
|
Class *string `yaml:"class,omitempty" json:"class,omitempty" jsonschema:"default:-"`
|
||||||
Enabled bool `yaml:"enabled" json:"enabled,omitempty"`
|
Enabled bool `yaml:"enabled" json:"enabled,omitempty"`
|
||||||
TLS *TLS `yaml:"tls,omitempty" json:"tls,omitempty"`
|
TLS *TLS `yaml:"tls,omitempty" json:"tls,omitempty"`
|
||||||
}
|
}
|
||||||
@@ -20,14 +25,17 @@ type Ingress struct {
|
|||||||
func IngressFrom(data string) (*Ingress, error) {
|
func IngressFrom(data string) (*Ingress, error) {
|
||||||
mapping := Ingress{
|
mapping := Ingress{
|
||||||
Hostname: "",
|
Hostname: "",
|
||||||
Path: "/",
|
Path: utils.StrPtr("/"),
|
||||||
Enabled: false,
|
Enabled: false,
|
||||||
Class: "-",
|
Class: utils.StrPtr("-"),
|
||||||
Port: nil,
|
Port: nil,
|
||||||
TLS: &TLS{Enabled: true},
|
TLS: &TLS{Enabled: true},
|
||||||
}
|
}
|
||||||
if err := yaml.Unmarshal([]byte(data), &mapping); err != nil {
|
if err := yaml.Unmarshal([]byte(data), &mapping); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if mapping.Port == nil {
|
||||||
|
return nil, fmt.Errorf("port is required in ingress definition")
|
||||||
|
}
|
||||||
return &mapping, nil
|
return &mapping, nil
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
package generator
|
package generator
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"katenary/generator/labels"
|
"katenary/generator/labels"
|
||||||
"os"
|
"os"
|
||||||
@@ -44,3 +45,49 @@ services:
|
|||||||
t.Errorf("Expected BAR to be baz, got %s", data["BAR"])
|
t.Errorf("Expected BAR to be baz, got %s", data["BAR"])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCreateSecretFromEnvironmentWithValue(t *testing.T) {
|
||||||
|
composeFile := `
|
||||||
|
services:
|
||||||
|
web:
|
||||||
|
image: nginx:1.29
|
||||||
|
environment:
|
||||||
|
- FOO=bar
|
||||||
|
- BAR=baz
|
||||||
|
labels:
|
||||||
|
%[1]s/secrets: |-
|
||||||
|
- BAR
|
||||||
|
%[1]s/values: |-
|
||||||
|
- BAR
|
||||||
|
`
|
||||||
|
composeFile = fmt.Sprintf(composeFile, labels.KatenaryLabelPrefix)
|
||||||
|
tmpDir := setup(composeFile)
|
||||||
|
defer teardown(tmpDir)
|
||||||
|
|
||||||
|
currentDir, _ := os.Getwd()
|
||||||
|
os.Chdir(tmpDir)
|
||||||
|
defer os.Chdir(currentDir)
|
||||||
|
|
||||||
|
force := false
|
||||||
|
outputDir := "./chart"
|
||||||
|
profiles := make([]string, 0)
|
||||||
|
helmdepUpdate := true
|
||||||
|
var appVersion *string
|
||||||
|
chartVersion := "0.1.0"
|
||||||
|
convertOptions := ConvertOptions{
|
||||||
|
Force: force,
|
||||||
|
OutputDir: outputDir,
|
||||||
|
Profiles: profiles,
|
||||||
|
HelmUpdate: helmdepUpdate,
|
||||||
|
AppVersion: appVersion,
|
||||||
|
ChartVersion: chartVersion,
|
||||||
|
}
|
||||||
|
Convert(convertOptions, "compose.yml")
|
||||||
|
c, err := os.ReadFile("chart/values.yaml")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if !bytes.Contains(c, []byte("BAR: baz")) {
|
||||||
|
t.Errorf("Expected BAR to be baz, got %s", c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -34,7 +34,7 @@ type IngressValue struct {
|
|||||||
TLS TLS `yaml:"tls"`
|
TLS TLS `yaml:"tls"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Value will be saved in values.yaml. It contains configuraiton for all deployment and services.
|
// Value will be saved in values.yaml. It contains configuration for all deployment and services.
|
||||||
type Value struct {
|
type Value struct {
|
||||||
Repository *RepositoryValue `yaml:"repository,omitempty"`
|
Repository *RepositoryValue `yaml:"repository,omitempty"`
|
||||||
Persistence map[string]*PersistenceValue `yaml:"persistence,omitempty"`
|
Persistence map[string]*PersistenceValue `yaml:"persistence,omitempty"`
|
||||||
|
@@ -191,3 +191,60 @@ volumes:
|
|||||||
t.Errorf("Expected volume name to be data: %v", dt)
|
t.Errorf("Expected volume name to be data: %v", dt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestExchangeVolume(t *testing.T) {
|
||||||
|
composeFile := `
|
||||||
|
services:
|
||||||
|
app1:
|
||||||
|
image: nginx:1.29
|
||||||
|
labels:
|
||||||
|
%[1]s/exchange-volumes: |-
|
||||||
|
- name: data
|
||||||
|
mountPath: /var/www
|
||||||
|
app2:
|
||||||
|
image: foo:bar
|
||||||
|
labels:
|
||||||
|
%[1]s/same-pod: app1
|
||||||
|
%[1]s/exchange-volumes: |-
|
||||||
|
- name: data
|
||||||
|
mountPath: /opt
|
||||||
|
init: cp -r /var/www /opt
|
||||||
|
`
|
||||||
|
composeFile = fmt.Sprintf(composeFile, labels.KatenaryLabelPrefix)
|
||||||
|
tmpDir := setup(composeFile)
|
||||||
|
defer teardown(tmpDir)
|
||||||
|
|
||||||
|
currentDir, _ := os.Getwd()
|
||||||
|
os.Chdir(tmpDir)
|
||||||
|
defer os.Chdir(currentDir)
|
||||||
|
output := internalCompileTest(t, "-s", "templates/app1/deployment.yaml")
|
||||||
|
dt := v1.Deployment{}
|
||||||
|
if err := yaml.Unmarshal([]byte(output), &dt); err != nil {
|
||||||
|
t.Errorf(unmarshalError, err)
|
||||||
|
}
|
||||||
|
// the deployment should have a volume named "data"
|
||||||
|
volumes := dt.Spec.Template.Spec.Volumes
|
||||||
|
found := false
|
||||||
|
for v := range volumes {
|
||||||
|
if volumes[v].Name == "exchange-data" {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
t.Errorf("Expected volume name to be data: %v", volumes)
|
||||||
|
}
|
||||||
|
mounted := 0
|
||||||
|
// we should have a volume mount for both containers
|
||||||
|
containers := dt.Spec.Template.Spec.Containers
|
||||||
|
for c := range containers {
|
||||||
|
for _, vm := range containers[c].VolumeMounts {
|
||||||
|
if vm.Name == "exchange-data" {
|
||||||
|
mounted++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if mounted != 2 {
|
||||||
|
t.Errorf("Expected 2 mounted volumes, got %d", mounted)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -6,7 +6,7 @@ sonar.go.tests.reportPaths=gotest.json
|
|||||||
sonar.go.coverage.reportPaths=coverprofile.out
|
sonar.go.coverage.reportPaths=coverprofile.out
|
||||||
|
|
||||||
# excludde
|
# excludde
|
||||||
sonar.exclusions=doc/**
|
sonar.exclusions=doc/**,**/*_test.go
|
||||||
sonar.coverage.exclusions=doc/**,**/*_test.go
|
sonar.coverage.exclusions=doc/**,**/*_test.go
|
||||||
|
|
||||||
# This is the name and version displayed in the SonarCloud UI.
|
# This is the name and version displayed in the SonarCloud UI.
|
||||||
|
@@ -70,11 +70,6 @@ func Wrap(src, above, below string) string {
|
|||||||
return spaces + above + "\n" + src + "\n" + spaces + below
|
return spaces + above + "\n" + src + "\n" + spaces + below
|
||||||
}
|
}
|
||||||
|
|
||||||
// WrapBytes wraps a byte array with a byte array above and below. It will respect the indentation of the src string.
|
|
||||||
func WrapBytes(src, above, below []byte) []byte {
|
|
||||||
return []byte(Wrap(string(src), string(above), string(below)))
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetServiceNameByPort returns the service name for a port. It the service name is not found, it returns an empty string.
|
// GetServiceNameByPort returns the service name for a port. It the service name is not found, it returns an empty string.
|
||||||
func GetServiceNameByPort(port int) string {
|
func GetServiceNameByPort(port int) string {
|
||||||
name := ""
|
name := ""
|
||||||
@@ -162,14 +157,6 @@ func WordWrap(text string, lineWidth int) string {
|
|||||||
return wordwrap.WrapString(text, uint(lineWidth))
|
return wordwrap.WrapString(text, uint(lineWidth))
|
||||||
}
|
}
|
||||||
|
|
||||||
func MapKeys(m map[string]interface{}) []string {
|
|
||||||
keys := make([]string, 0, len(m))
|
|
||||||
for k := range m {
|
|
||||||
keys = append(keys, k)
|
|
||||||
}
|
|
||||||
return keys
|
|
||||||
}
|
|
||||||
|
|
||||||
// Confirm asks a question and returns true if the answer is y.
|
// Confirm asks a question and returns true if the answer is y.
|
||||||
func Confirm(question string, icon ...Icon) bool {
|
func Confirm(question string, icon ...Icon) bool {
|
||||||
if len(icon) > 0 {
|
if len(icon) > 0 {
|
||||||
@@ -198,3 +185,9 @@ func EncodeBasicYaml(data any) ([]byte, error) {
|
|||||||
func FixedResourceName(name string) string {
|
func FixedResourceName(name string) string {
|
||||||
return strings.ReplaceAll(name, "_", "-")
|
return strings.ReplaceAll(name, "_", "-")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AsResourceName returns a resource name with underscores to respect the kubernetes naming convention.
|
||||||
|
// It's the opposite of FixedResourceName.
|
||||||
|
func AsResourceName(name string) string {
|
||||||
|
return strings.ReplaceAll(name, "-", "_")
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user