Generate values.yaml out of config.yaml

This commit is contained in:
M. Mert Yildiran 2023-04-11 23:01:29 +03:00
parent 562dff0d6c
commit 504ecc4f83
No known key found for this signature in database
GPG Key ID: DA5D6DCBB758A461
2 changed files with 70 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import (
"path/filepath"
"sort"
"github.com/kubeshark/kubeshark/config"
"github.com/kubeshark/kubeshark/kubernetes"
"github.com/kubeshark/kubeshark/misc"
"github.com/kubeshark/kubeshark/utils"
@ -156,6 +157,7 @@ func dumpHelmChart(objects map[string]interface{}) error {
}
sort.Strings(filenames)
// Generate templates
for _, filename := range filenames {
manifest, err := utils.PrettyYamlOmitEmpty(objects[filename])
if err != nil {
@ -170,6 +172,7 @@ func dumpHelmChart(objects map[string]interface{}) error {
log.Info().Msgf("Helm chart template generated: %s", path)
}
// Copy LICENSE
licenseSrcPath := filepath.Join(".", "LICENSE")
licenseDstPath := filepath.Join(folder, "LICENSE")
err = copy.Copy(licenseSrcPath, licenseDstPath)
@ -179,6 +182,7 @@ func dumpHelmChart(objects map[string]interface{}) error {
log.Info().Msgf("Helm chart license copied: %s", licenseDstPath)
}
// Generate Chart.yaml
chartMetadata := Metadata{
APIVersion: "v2",
Name: misc.Program,
@ -222,5 +226,17 @@ func dumpHelmChart(objects map[string]interface{}) error {
}
log.Info().Msgf("Helm chart Chart.yaml generated: %s", path)
// Generate values.yaml
values, err := utils.PrettyYaml(config.Config)
if err != nil {
return err
}
path = filepath.Join(folder, "values.yaml")
err = os.WriteFile(path, []byte(values), 0644)
if err != nil {
return err
}
log.Info().Msgf("Helm chart values.yaml generated: %s", path)
return nil
}

54
helm-chart/values.yaml Normal file
View File

@ -0,0 +1,54 @@
tap:
docker:
registry: docker.io/kubeshark
tag: latest
imagepullpolicy: Always
imagepullsecrets: []
proxy:
worker:
port: 8897
srvport: 8897
hub:
port: 8898
srvport: 80
front:
port: 8899
srvport: 80
host: 127.0.0.1
regex: .*
namespaces: []
allnamespaces: true
selfnamespace: kubeshark
storagelimit: 200MB
dryrun: false
pcap: ""
resources:
worker:
cpu-limit: 750m
memory-limit: 1Gi
cpu-requests: 50m
memory-requests: 50Mi
hub:
cpu-limit: 750m
memory-limit: 1Gi
cpu-requests: 50m
memory-requests: 50Mi
servicemesh: true
tls: true
packetcapture: libpcap
ignoreTainted: false
resourceLabels: {}
nodeSelectorTerms: []
debug: false
logs:
file: ""
kube:
configpath: ""
context: ""
dumplogs: false
headless: false
license: ""
scripting:
env: {}
source: ""
watchScripts: true