Add healtcheck + some fixes

- better docs
- add healtcheck based on docker-compoe commands or labels
- fix some problems on secret names
- better dependency check
This commit is contained in:
2022-02-14 14:37:09 +01:00
parent 8164603b47
commit 5a4d9e396d
7 changed files with 395 additions and 209 deletions

View File

@@ -1,11 +1,13 @@
package helm
import (
"bytes"
"crypto/sha1"
"fmt"
"io/ioutil"
"os"
"strings"
"text/template"
)
const K = "katenary.io"
@@ -16,8 +18,35 @@ const (
LABEL_INGRESS = K + "/ingress"
LABEL_ENV_SERVICE = K + "/env-to-service"
LABEL_VOL_CM = K + "/configmap-volumes"
LABEL_HEALTHCHECK = K + "/healthcheck"
)
func GetLabelsDocumentation() string {
t, _ := template.New("labels").Parse(`
# Labels
{{.LABEL_ENV_SECRET | printf "%-33s"}}: set the given file names as a secret instead of configmap
{{.LABEL_PORT | printf "%-33s"}}: set the port to expose as a service
{{.LABEL_INGRESS | printf "%-33s"}}: set the port to expose in an ingress
{{.LABEL_ENV_SERVICE | printf "%-33s"}}: specifies that the environment variable points on a service name
{{.LABEL_VOL_CM | printf "%-33s"}}: specifies that the volume points on a configmap
{{.LABEL_HEALTHCHECK | printf "%-33s"}}: specifies that the container should be monitored by a healthcheck, **it overrides the docker-compose healthcheck**.
{{ printf "%-34s" ""}} You can use these form of label values:
{{ printf "%-35s" ""}}- "http://[not used address][:port][/path]" to specify an http healthcheck
{{ printf "%-35s" ""}}- "tcp://[not used address]:port" to specify a tcp healthcheck
{{ printf "%-35s" ""}}- other string is condidered as a "command" healthcheck
`)
buff := bytes.NewBuffer(nil)
t.Execute(buff, map[string]string{
"LABEL_ENV_SECRET": LABEL_ENV_SECRET,
"LABEL_ENV_SERVICE": LABEL_ENV_SERVICE,
"LABEL_PORT": LABEL_PORT,
"LABEL_INGRESS": LABEL_INGRESS,
"LABEL_VOL_CM": LABEL_VOL_CM,
"LABEL_HEALTHCHECK": LABEL_HEALTHCHECK,
})
return buff.String()
}
var (
Appname = ""
Version = "1.0" // should be set from main.Version