From d87d3f6a390f085e161e2faf6398be2990184c1c Mon Sep 17 00:00:00 2001 From: Sami Alajrami Date: Wed, 6 Mar 2024 10:42:41 +0100 Subject: [PATCH] fix command syntax to work on the CLI scratch image (#141) --- charts/k8s-reporter/Chart.yaml | 2 +- charts/k8s-reporter/templates/cronjob.yaml | 18 ++++++++++++++---- charts/k8s-reporter/values.yaml | 15 ++++++++------- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/charts/k8s-reporter/Chart.yaml b/charts/k8s-reporter/Chart.yaml index 641c6c78b..185666b8c 100644 --- a/charts/k8s-reporter/Chart.yaml +++ b/charts/k8s-reporter/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 1.4.2 +version: 1.4.3 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/k8s-reporter/templates/cronjob.yaml b/charts/k8s-reporter/templates/cronjob.yaml index 0e38614b5..eaff05b4e 100644 --- a/charts/k8s-reporter/templates/cronjob.yaml +++ b/charts/k8s-reporter/templates/cronjob.yaml @@ -20,19 +20,29 @@ spec: image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} env: + - name: KOSLI_ORG + value: {{ required ".Values.reporterConfig.kosliOrg is required" .Values.reporterConfig.kosliOrg }} - name: KOSLI_API_TOKEN valueFrom: secretKeyRef: name: {{ required ".Values.kosliApiToken.secretName is required." .Values.kosliApiToken.secretName }} key: {{ .Values.kosliApiToken.secretKey | default "token" }} + {{ if .Values.reporterConfig.namespaces }} + - name: KOSLI_NAMESPACES + value: {{ .Values.reporterConfig.namespaces | quote }} + {{ end }} {{- range $key, $value := .Values.env }} - name: {{ $key }} value: {{ $value }} {{ end }} - command: - - /bin/sh - - -c - - kosli snapshot k8s {{ required ".Values.reporterConfig.kosliEnvironmentName is required" .Values.reporterConfig.kosliEnvironmentName }} {{ if .Values.reporterConfig.namespaces }} --namespaces {{ .Values.reporterConfig.namespaces | quote }} {{ end }} --org {{ required ".Values.reporterConfig.kosliOrg is required" .Values.reporterConfig.kosliOrg }} {{ if .Values.reporterConfig.dryRun }}--dry-run{{ end }} + args: + - snapshot + - k8s + - {{ required ".Values.reporterConfig.kosliEnvironmentName is required" .Values.reporterConfig.kosliEnvironmentName }} + {{ if .Values.reporterConfig.dryRun }} + - --dry-run + {{ end }} + resources: {{ toYaml .Values.resources | indent 14 }} restartPolicy: Never diff --git a/charts/k8s-reporter/values.yaml b/charts/k8s-reporter/values.yaml index b3692d80c..10689ef87 100644 --- a/charts/k8s-reporter/values.yaml +++ b/charts/k8s-reporter/values.yaml @@ -24,19 +24,19 @@ serviceAccount: # If not set and create is true, a name is generated using the fullname template name: "" -# -- the cron schedule at which the reporter is triggered to report to kosli +# -- the cron schedule at which the reporter is triggered to report to Kosli cronSchedule: "*/5 * * * *" kosliApiToken: # -- the name of the secret containing the kosli API token - secretName: "" - # -- the name of the key in the secret data which contains the kosli API token - secretKey: "" + secretName: "kosli-api-token" + # -- the name of the key in the secret data which contains the Kosli API token + secretKey: "key" reporterConfig: - # -- the name of the kosli org + # -- the name of the Kosli org kosliOrg: "" - # -- the name of kosli environment that the k8s cluster/namespace correlates to + # -- the name of Kosli environment that the k8s cluster/namespace correlates to kosliEnvironmentName: "" # -- the namespaces which represent the environment. # It is a comma separated list of namespace name regex patterns. @@ -46,8 +46,9 @@ reporterConfig: # -- whether the dry run mode is enabled or not. In dry run mode, the reporter logs the reports to stdout and does not send them to kosli. dryRun: false +# Uncomment the env variable below and replace , if you are on a single tenant Kosli instance # env: -# KOSLI_HOST: https://staging.app.kosli.com +# KOSLI_HOST: https://.kosli.com # -- any custom annotations to be added to the cronjob podAnnotations: {}