Skip to content

Commit

Permalink
doc(refresh): Refresh documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
metal3d committed Nov 26, 2024
1 parent 3b4dade commit 9181c38
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 85 deletions.
39 changes: 39 additions & 0 deletions doc/docs/labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Katenary will try to Unmarshal these labels.
| `katenary.v3/same-pod` | Move the same-pod deployment to the target deployment. | string |
| `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 |
| `katenary.v3/values-from` | Add values from another service. | map[string]string |

<!-- STOP_LABEL_DOC : do not remove this tag !-->

Expand Down Expand Up @@ -438,4 +439,42 @@ labels:
```


### katenary.v3/values-from

Add values from another service.

**Type**: `map[string]string`

This label allows adding values from another service to the current service.
It avoid duplicating values, environment or secrets that should be the same.

The key is the value to be added, and the value is the "key" to fetch in the
form `service_name.environment_name`.

**Example:**

```yaml
database:
image: mariadb:10.5
environment:
MARIADB_USER: myuser
MARIADB_PASSWORD: mypassword
labels:
# it can be a secret
katenary.v3/secrets: |-
- DB_PASSWORD
php:
image: php:7.4-fpm
environment:
# it's duplicated in docker / podman
DB_USER: myuser
DB_PASSWORD: mypassword
labels:
# removes the duplicated, use the configMap and secrets from "database"
katenary.v3/values-from: |-
DB_USER: database.MARIADB_USER
DB_PASSWORD: database.MARIADB_PASSWORD
```


<!-- STOP_DETAILED_DOC : do not remove this tag !-->
71 changes: 31 additions & 40 deletions doc/docs/packages/generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "katenary/generator"

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. 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 the values.yaml file.
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. 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 generate.Convert\(\) create an HelmChart object and call "Generate\(\)" method to convert from a compose file to a helm chart. It saves the helm chart in the given directory.

Expand Down Expand Up @@ -98,7 +98,7 @@ func UnWrapTPL(in []byte) []byte
UnWrapTPL removes the line wrapping from a template.

<a name="ChartTemplate"></a>
## type [ChartTemplate](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L18-L21>)
## type [ChartTemplate](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L19-L22>)

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.

Expand All @@ -110,7 +110,7 @@ type ChartTemplate struct {
```

<a name="ConfigMap"></a>
## type [ConfigMap](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L46-L51>)
## type [ConfigMap](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L35-L40>)

ConfigMap is a kubernetes ConfigMap. Implements the DataMap interface.

Expand All @@ -122,7 +122,7 @@ type ConfigMap struct {
```

<a name="NewConfigMap"></a>
### func [NewConfigMap](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L55>)
### func [NewConfigMap](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L44>)

```go
func NewConfigMap(service types.ServiceConfig, appName string, forFile bool) *ConfigMap
Expand All @@ -131,7 +131,7 @@ func NewConfigMap(service types.ServiceConfig, appName string, forFile bool) *Co
NewConfigMap creates a new ConfigMap from a compose service. The appName is the name of the application taken from the project name. The ConfigMap is filled by environment variables and labels "map\-env".

<a name="NewConfigMapFromDirectory"></a>
### func [NewConfigMapFromDirectory](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L128>)
### func [NewConfigMapFromDirectory](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L117>)

```go
func NewConfigMapFromDirectory(service types.ServiceConfig, appName, path string) *ConfigMap
Expand All @@ -140,7 +140,7 @@ func NewConfigMapFromDirectory(service types.ServiceConfig, appName, path string
NewConfigMapFromDirectory creates a new ConfigMap from a compose service. This path is the path to the file or directory. If the path is a directory, all files in the directory are added to the ConfigMap. Each subdirectory are ignored. Note that the Generate\(\) function will create the subdirectories ConfigMaps.

<a name="ConfigMap.AddData"></a>
### func \(\*ConfigMap\) [AddData](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L159>)
### func \(\*ConfigMap\) [AddData](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L148>)

```go
func (c *ConfigMap) AddData(key, value string)
Expand All @@ -149,7 +149,7 @@ func (c *ConfigMap) AddData(key, value string)
AddData adds a key value pair to the configmap. Append or overwrite the value if the key already exists.

<a name="ConfigMap.AppendDir"></a>
### func \(\*ConfigMap\) [AppendDir](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L165>)
### func \(\*ConfigMap\) [AppendDir](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L154>)

```go
func (c *ConfigMap) AppendDir(path string)
Expand All @@ -158,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.

<a name="ConfigMap.AppendFile"></a>
### func \(\*ConfigMap\) [AppendFile](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L200>)
### func \(\*ConfigMap\) [AppendFile](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L189>)

```go
func (c *ConfigMap) AppendFile(path string)
Expand All @@ -167,7 +167,7 @@ func (c *ConfigMap) AppendFile(path string)


<a name="ConfigMap.Filename"></a>
### func \(\*ConfigMap\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L218>)
### func \(\*ConfigMap\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L207>)

```go
func (c *ConfigMap) Filename() string
Expand All @@ -176,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.

<a name="ConfigMap.SetData"></a>
### func \(\*ConfigMap\) [SetData](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L228>)
### func \(\*ConfigMap\) [SetData](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L217>)

```go
func (c *ConfigMap) SetData(data map[string]string)
Expand All @@ -185,7 +185,7 @@ func (c *ConfigMap) SetData(data map[string]string)
SetData sets the data of the configmap. It replaces the entire data.

<a name="ConfigMap.Yaml"></a>
### func \(\*ConfigMap\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L233>)
### func \(\*ConfigMap\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L222>)

```go
func (c *ConfigMap) Yaml() ([]byte, error)
Expand All @@ -205,7 +205,7 @@ type ConfigMapMount struct {
```

<a name="ConvertOptions"></a>
## type [ConvertOptions](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L24-L33>)
## type [ConvertOptions](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L25-L34>)

ConvertOptions are the options to convert a compose project to a helm chart.

Expand Down Expand Up @@ -282,17 +282,8 @@ type DataMap interface {
}
```

<a name="NewFileMap"></a>
### func [NewFileMap](<https://github.com/metal3d/katenary/blob/develop/generator/configMap.go#L28>)

```go
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.

<a name="Deployment"></a>
## type [Deployment](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L34-L43>)
## type [Deployment](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L34-L44>)

Deployment is a kubernetes Deployment.

Expand All @@ -304,7 +295,7 @@ type Deployment struct {
```

<a name="NewDeployment"></a>
### func [NewDeployment](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L47>)
### func [NewDeployment](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L48>)

```go
func NewDeployment(service types.ServiceConfig, chart *HelmChart) *Deployment
Expand All @@ -313,7 +304,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.

<a name="Deployment.AddContainer"></a>
### func \(\*Deployment\) [AddContainer](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L113>)
### func \(\*Deployment\) [AddContainer](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L115>)

```go
func (d *Deployment) AddContainer(service types.ServiceConfig)
Expand All @@ -322,7 +313,7 @@ func (d *Deployment) AddContainer(service types.ServiceConfig)
AddContainer adds a container to the deployment.

<a name="Deployment.AddHealthCheck"></a>
### func \(\*Deployment\) [AddHealthCheck](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L158>)
### func \(\*Deployment\) [AddHealthCheck](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L160>)

```go
func (d *Deployment) AddHealthCheck(service types.ServiceConfig, container *corev1.Container)
Expand All @@ -331,7 +322,7 @@ func (d *Deployment) AddHealthCheck(service types.ServiceConfig, container *core


<a name="Deployment.AddIngress"></a>
### func \(\*Deployment\) [AddIngress](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L187>)
### func \(\*Deployment\) [AddIngress](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L189>)

```go
func (d *Deployment) AddIngress(service types.ServiceConfig, appName string) *Ingress
Expand All @@ -340,7 +331,7 @@ func (d *Deployment) AddIngress(service types.ServiceConfig, appName string) *In
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>)
### func \(\*Deployment\) [AddLegacyVolume](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L219>)

```go
func (d *Deployment) AddLegacyVolume(name, kind string)
Expand All @@ -349,7 +340,7 @@ func (d *Deployment) AddLegacyVolume(name, kind string)


<a name="Deployment.AddVolumes"></a>
### func \(\*Deployment\) [AddVolumes](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L193>)
### func \(\*Deployment\) [AddVolumes](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L195>)

```go
func (d *Deployment) AddVolumes(service types.ServiceConfig, appName string)
Expand All @@ -358,7 +349,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.

<a name="Deployment.BindFrom"></a>
### func \(\*Deployment\) [BindFrom](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L238>)
### func \(\*Deployment\) [BindFrom](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L240>)

```go
func (d *Deployment) BindFrom(service types.ServiceConfig, binded *Deployment)
Expand All @@ -367,7 +358,7 @@ 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>)
### func \(\*Deployment\) [BindMapFilesToContainer](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L377>)

```go
func (d *Deployment) BindMapFilesToContainer(service types.ServiceConfig, secrets []string, appName string) (*corev1.Container, int)
Expand All @@ -376,7 +367,7 @@ func (d *Deployment) BindMapFilesToContainer(service types.ServiceConfig, secret


<a name="Deployment.DependsOn"></a>
### func \(\*Deployment\) [DependsOn](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L266>)
### func \(\*Deployment\) [DependsOn](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L268>)

```go
func (d *Deployment) DependsOn(to *Deployment, servicename string) error
Expand All @@ -385,7 +376,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.

<a name="Deployment.Filename"></a>
### func \(\*Deployment\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L297>)
### func \(\*Deployment\) [Filename](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L299>)

```go
func (d *Deployment) Filename() string
Expand All @@ -394,7 +385,7 @@ func (d *Deployment) Filename() string
Filename returns the filename of the deployment.

<a name="Deployment.MountExchangeVolumes"></a>
### func \(\*Deployment\) [MountExchangeVolumes](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L426>)
### func \(\*Deployment\) [MountExchangeVolumes](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L428>)

```go
func (d *Deployment) MountExchangeVolumes()
Expand All @@ -403,7 +394,7 @@ func (d *Deployment) MountExchangeVolumes()


<a name="Deployment.SetEnvFrom"></a>
### func \(\*Deployment\) [SetEnvFrom](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L302>)
### func \(\*Deployment\) [SetEnvFrom](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L304>)

```go
func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string, samePod ...bool)
Expand All @@ -412,7 +403,7 @@ func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string, sam
SetEnvFrom sets the environment variables to a configmap. The configmap is created.

<a name="Deployment.Yaml"></a>
### func \(\*Deployment\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L450>)
### func \(\*Deployment\) [Yaml](<https://github.com/metal3d/katenary/blob/develop/generator/deployment.go#L452>)

```go
func (d *Deployment) Yaml() ([]byte, error)
Expand All @@ -439,9 +430,9 @@ const (
```

<a name="HelmChart"></a>
## type [HelmChart](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L37-L50>)
## type [HelmChart](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L38-L51>)

HelmChart is a Helm Chart representation. It contains all the tempaltes, values, versions, helpers...
HelmChart is a Helm Chart representation. It contains all the templates, values, versions, helpers...

```go
type HelmChart struct {
Expand Down Expand Up @@ -482,7 +473,7 @@ The Generate function will create the HelmChart object this way:
- Merge the same\-pod services.

<a name="NewChart"></a>
### func [NewChart](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L53>)
### func [NewChart](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L54>)

```go
func NewChart(name string) *HelmChart
Expand All @@ -491,7 +482,7 @@ func NewChart(name string) *HelmChart
NewChart creates a new empty chart with the given name.

<a name="HelmChart.SaveTemplates"></a>
### func \(\*HelmChart\) [SaveTemplates](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L68>)
### func \(\*HelmChart\) [SaveTemplates](<https://github.com/metal3d/katenary/blob/develop/generator/chart.go#L69>)

```go
func (chart *HelmChart) SaveTemplates(templateDir string)
Expand Down Expand Up @@ -813,7 +804,7 @@ type TLS struct {
<a name="Value"></a>
## 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 configuration for all deployment and services.

```go
type Value struct {
Expand Down
7 changes: 4 additions & 3 deletions doc/docs/packages/generator/katenaryfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ A katenary file, named "katenary.yml" or "katenary.yaml", is a file where you ca

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>)
## func [GenerateSchema](<https://github.com/metal3d/katenary/blob/develop/generator/katenaryfile/main.go#L131>)

```go
func GenerateSchema() string
Expand All @@ -21,7 +21,7 @@ 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>)
## func [OverrideWithConfig](<https://github.com/metal3d/katenary/blob/develop/generator/katenaryfile/main.go#L49>)

```go
func OverrideWithConfig(project *types.Project)
Expand All @@ -30,7 +30,7 @@ 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>)
## type [Service](<https://github.com/metal3d/katenary/blob/develop/generator/katenaryfile/main.go#L27-L44>)

Service is a struct that contains the service configuration for katenary

Expand All @@ -51,6 +51,7 @@ type Service struct {
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"`
ValuesFrom *labelStructs.ValueFrom `json:"values-from,omitempty" jsonschema:"title=Values From,description=Inject values from another service (secret or configmap environment variables)"`
}
```

Expand Down
Loading

0 comments on commit 9181c38

Please sign in to comment.