From 57b274e345271120789ad80d2adba609ced09edc Mon Sep 17 00:00:00 2001 From: Patrice Ferlet Date: Fri, 19 Apr 2024 11:17:54 +0200 Subject: [PATCH] Fixing documentation --- doc/docs/packages/generator.md | 56 +++++++++++++++++++++++----------- doc/docs/usage.md | 14 +++++++-- 2 files changed, 50 insertions(+), 20 deletions(-) diff --git a/doc/docs/packages/generator.md b/doc/docs/packages/generator.md index fb824ec..a8ab1a1 100644 --- a/doc/docs/packages/generator.md +++ b/doc/docs/packages/generator.md @@ -149,14 +149,14 @@ func NewConfigMap(service types.ServiceConfig, appName string) *ConfigMap 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". - -### func [NewConfigMapFromFiles]() + +### func [NewConfigMapFromDirectory]() ```go -func NewConfigMapFromFiles(service types.ServiceConfig, appName string, path string) *ConfigMap +func NewConfigMapFromDirectory(service types.ServiceConfig, appName string, path string) *ConfigMap ``` -NewConfigMapFromFiles 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. +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. ### func \(\*ConfigMap\) [AddData]() @@ -176,8 +176,17 @@ 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. + +### func \(\*ConfigMap\) [AppendFile]() + +```go +func (c *ConfigMap) AppendFile(path string) +``` + + + -### func \(\*ConfigMap\) [Filename]() +### func \(\*ConfigMap\) [Filename]() ```go func (c *ConfigMap) Filename() string @@ -195,7 +204,7 @@ func (c *ConfigMap) SetData(data map[string]string) SetData sets the data of the configmap. It replaces the entire data. -### func \(\*ConfigMap\) [Yaml]() +### func \(\*ConfigMap\) [Yaml]() ```go func (c *ConfigMap) Yaml() ([]byte, error) @@ -203,6 +212,17 @@ func (c *ConfigMap) Yaml() ([]byte, error) Yaml returns the yaml representation of the configmap + +## type [ConfigMapMount]() + + + +```go +type ConfigMapMount struct { + // contains filtered or unexported fields +} +``` + ## type [ConvertOptions]() @@ -304,7 +324,7 @@ type Dependency struct { ``` -## type [Deployment]() +## type [Deployment]() Deployment is a kubernetes Deployment. @@ -316,7 +336,7 @@ type Deployment struct { ``` -### func [NewDeployment]() +### func [NewDeployment]() ```go func NewDeployment(service types.ServiceConfig, chart *HelmChart) *Deployment @@ -325,7 +345,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. -### func \(\*Deployment\) [AddContainer]() +### func \(\*Deployment\) [AddContainer]() ```go func (d *Deployment) AddContainer(service types.ServiceConfig) @@ -334,7 +354,7 @@ func (d *Deployment) AddContainer(service types.ServiceConfig) AddContainer adds a container to the deployment. -### func \(\*Deployment\) [AddHealthCheck]() +### func \(\*Deployment\) [AddHealthCheck]() ```go func (d *Deployment) AddHealthCheck(service types.ServiceConfig, container *corev1.Container) @@ -343,7 +363,7 @@ func (d *Deployment) AddHealthCheck(service types.ServiceConfig, container *core -### func \(\*Deployment\) [AddIngress]() +### func \(\*Deployment\) [AddIngress]() ```go func (d *Deployment) AddIngress(service types.ServiceConfig, appName string) *Ingress @@ -352,7 +372,7 @@ func (d *Deployment) AddIngress(service types.ServiceConfig, appName string) *In AddIngress adds an ingress to the deployment. It creates the ingress object. -### func \(\*Deployment\) [AddVolumes]() +### func \(\*Deployment\) [AddVolumes]() ```go func (d *Deployment) AddVolumes(service types.ServiceConfig, appName string) @@ -361,7 +381,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. -### func \(\*Deployment\) [BindFrom]() +### func \(\*Deployment\) [BindFrom]() ```go func (d *Deployment) BindFrom(service types.ServiceConfig, binded *Deployment) @@ -370,7 +390,7 @@ func (d *Deployment) BindFrom(service types.ServiceConfig, binded *Deployment) -### func \(\*Deployment\) [DependsOn]() +### func \(\*Deployment\) [DependsOn]() ```go func (d *Deployment) DependsOn(to *Deployment, servicename string) error @@ -379,7 +399,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. -### func \(\*Deployment\) [Filename]() +### func \(\*Deployment\) [Filename]() ```go func (d *Deployment) Filename() string @@ -388,7 +408,7 @@ func (d *Deployment) Filename() string Filename returns the filename of the deployment. -### func \(\*Deployment\) [SetEnvFrom]() +### func \(\*Deployment\) [SetEnvFrom]() ```go func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string) @@ -397,7 +417,7 @@ func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string) SetEnvFrom sets the environment variables to a configmap. The configmap is created. -### func \(\*Deployment\) [Yaml]() +### func \(\*Deployment\) [Yaml]() ```go func (d *Deployment) Yaml() ([]byte, error) @@ -445,7 +465,7 @@ type HelmChart struct { ``` -### func [Generate]() +### func [Generate]() ```go func Generate(project *types.Project) (*HelmChart, error) diff --git a/doc/docs/usage.md b/doc/docs/usage.md index 1808bdb..0b955ef 100644 --- a/doc/docs/usage.md +++ b/doc/docs/usage.md @@ -86,6 +86,7 @@ to make you able to wait for a service to respond. But you'll probably need to a See this compose file: +```yaml version: "3" services: @@ -98,12 +99,14 @@ services: image: mariadb environment: MYSQL_ROOT_PASSWORD: foobar +``` 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. So, instead of exposing the port in the compose definition, let's declare this to katenary with labels: +```yaml version: "3" services: @@ -119,6 +122,7 @@ services: labels: katenary.v3/ports: |- - 3306 +``` ### Declare ingresses @@ -126,6 +130,7 @@ It's very common to have an `Ingress` on web application to deploy on Kuberenete port to bind. # ... +```yaml services: webapp: image: ... @@ -134,6 +139,7 @@ services: katenary.v3/ingress: |- port: 5050 hostname: myapp.example.com +``` Note that the port to bind is the one used by the container, not the used locally. This is because Katenary create a service to bind the container itself. @@ -146,6 +152,7 @@ example, to connect a PHP application to a database. With a compose file, there is no problem as Docker/Podman allows to resolve the name by container name: +```yaml services: webapp: image: php:7-apache @@ -154,11 +161,13 @@ services: database: image: mariadb +``` Katenary prefixes the services with `{{ .Release.Name }}` (to make it possible to install the application several times in a namespace), so you need to "remap" the environment variable to the right one. +```yaml services: webapp: image: php:7-apache @@ -170,12 +179,12 @@ services: database: image: mariadb - +``` This label can be used to map others environment for any others reason. E.g. to change an informational environment variable. - +```yaml services: webapp: #... @@ -184,6 +193,7 @@ services: labels: katenary.v3/mapenv: |- RUNNING: kubernetes +``` In the above example, `RUNNING` will be set to `kubernetes` when you'll deploy the application with helm, and it's `docker` for "podman" and "docker" executions.