From 504ecc4f83fb3ab126db21038fd7246cd8e3beea Mon Sep 17 00:00:00 2001 From: "M. Mert Yildiran" Date: Tue, 11 Apr 2023 23:01:29 +0300 Subject: [PATCH] :sparkles: Generate `values.yaml` out of `config.yaml` --- cmd/helmChart.go | 16 +++++++++++++ helm-chart/values.yaml | 54 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 helm-chart/values.yaml diff --git a/cmd/helmChart.go b/cmd/helmChart.go index 144941833..4a5695462 100644 --- a/cmd/helmChart.go +++ b/cmd/helmChart.go @@ -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 } diff --git a/helm-chart/values.yaml b/helm-chart/values.yaml new file mode 100644 index 000000000..20dd3edfd --- /dev/null +++ b/helm-chart/values.yaml @@ -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