Skip to content

Commit

Permalink
feat: Prepare helm chart for 0.3.0 (#73)
Browse files Browse the repository at this point in the history
* chore: updated helm chart version to 0.0.4

* chore: bump appVersion to v0.3.0

* fix: incorrect formatting on empty labels

* fix: newline indent

* fix: remove default runtime config in helm chart

* feat: simplify helm chart (#75)

* feat: simplify helm chart

* fix: remove -n

* fix: register healthcheck for e2e test

* feat: separate checks and sparrow config

* fix: e2e tests

* fix: bug where env variables would not be read correctly

* feat: allow mounting extra secrets as env variables

* docs: envfromSecrets

* chore: bump viper version to fix issue with env variables

* chore: remove old secret

* chore: increase check value examples for slow networks

* feat: default config

* fix: configmap file not created

---------

Co-authored-by: lvlcn-t <75443136+lvlcn-t@users.noreply.github.com>
  • Loading branch information
niklastreml and lvlcn-t authored Jan 19, 2024
1 parent 9dc3eed commit c4a6b54
Show file tree
Hide file tree
Showing 13 changed files with 158 additions and 605 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/end2end.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ jobs:
helm upgrade -i sparrow \
--atomic \
--timeout 300s \
--set extraArgs.loaderType=file \
--set extraArgs.loaderFilePath=/runconfig/checks.yaml \
--set image.tag=${{ steps.version.outputs.value }} \
--set startupConfig.name=the-sparrow.com \
chart
--set image.tag=${{ steps.version.outputs.value }} \
--set sparrowConfig.name=the-sparrow.com \
--set sparrowConfig.loader.type=file \
--set sparrowConfig.loader.file.path=/config/.sparrow.yaml \
--set checksConfig.checks.health.interval=1s \
./chart
- name: Check Pods
run: |
kubectl get pods
Expand Down
4 changes: 2 additions & 2 deletions chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ description: A Helm chart to install Sparrow
type: application
keywords:
- monitoring
version: 0.0.3
appVersion: "v0.2.0"
version: 0.0.4
appVersion: "v0.3.0"
icon: https://github.com/caas-team/sparrow/blob/main/docs/img/sparrow.png
sources:
- https://github.com/caas-team/sparrow
Expand Down
101 changes: 51 additions & 50 deletions chart/README.md

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,11 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{- define "sparrow.checksConfigName"}}
{{- include "sparrow.fullname" . }}-checks
{{- end }}

{{- define "sparrow.sparrowConfigName"}}
{{- include "sparrow.fullname" . }}-config
{{- end }}
37 changes: 0 additions & 37 deletions chart/templates/configmap.yaml

This file was deleted.

46 changes: 19 additions & 27 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spec:
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
checksum/config: {{ include (print $.Template.BasePath "/sparrowConfig.yaml") . | sha256sum }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
Expand All @@ -30,25 +30,34 @@ spec:
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
{{- if or .Values.extraArgs .Values.startupConfig }}
- args:
{{- end }}
{{- if .Values.startupConfig}}
- --config
- /startupconfig/.sparrow.yaml
- /config/.sparrow.yaml
{{- if .Values.checksConfig }}
- --loaderFilePath
- /config/checks.yaml
{{- end }}
{{- if .Values.extraArgs }}
{{- range $key, $value := .Values.extraArgs }}
- --{{ $key }}
- {{ $value }}
{{- end }}
{{- end }}
{{- if .Values.env }}
{{- if or .Values.env .Values.envFromSecrets }}
env:
{{- range $key, $val := .Values.env }}
- name: {{ $key }}
value: {{ $val | quote }}
{{- end }}
{{- if .Values.envFromSecrets }}
{{- range $i,$s := .Values.envFromSecrets }}
- name: {{ $s.name }}
valueFrom:
secretKeyRef:
name: {{ $s.valueFrom.secretName }}
key: {{ $s.valueFrom.key }}
{{ end -}}
{{ end -}}
{{- end }}
name: {{ .Chart.Name }}
securityContext:
Expand All @@ -63,30 +72,13 @@ spec:
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- end }}
{{- if or .Values.runtimeConfig .Values.startupConfig}}
volumeMounts:
{{- end }}
{{- if .Values.startupConfig}}
- name: startup
mountPath: /startupconfig
{{- end }}
{{- if .Values.runtimeConfig}}
- name: runtime
mountPath: /runconfig
{{- end }}
{{- if or .Values.runtimeConfig .Values.startupConfig}}
- name: sparrow-config
mountPath: /config/
volumes:
{{- end }}
{{- if .Values.startupConfig}}
- name: startup
secret:
secretName: {{ include "sparrow.fullname" . }}
{{- end }}
{{- if .Values.runtimeConfig}}
- name: runtime
- name: sparrow-config
configMap:
name: {{ include "sparrow.fullname" . }}
{{- end }}
name: {{ include "sparrow.sparrowConfigName" . }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
13 changes: 0 additions & 13 deletions chart/templates/secret.yaml

This file was deleted.

4 changes: 3 additions & 1 deletion chart/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ metadata:
name: {{ .Release.Name }}-service-monitor
labels:
app.kubernetes.io/name: {{ include "sparrow.fullname" . }}-service-monitor
{{ .Values.serviceMonitor.labels | toYaml | nindent 4 }}
{{- with .Values.serviceMonitor.labels }}
{{ toYaml . | nindent 4 }}
{{- end }}
namespace: {{ .Release.Namespace }}
spec:
selector:
Expand Down
13 changes: 13 additions & 0 deletions chart/templates/sparrowConfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "sparrow.sparrowConfigName" . }}
labels:
{{- include "sparrow.labels" . | nindent 4 }}
data:
.sparrow.yaml: |
{{- .Values.sparrowConfig | toYaml | nindent 4 }}
{{- if .Values.checksConfig }}
checks.yaml: |
{{- .Values.checksConfig | toYaml | nindent 4 }}
{{- end }}
63 changes: 37 additions & 26 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,25 @@ affinity: {}

# -- extra command line start parameters
# see: https://github.com/caas-team/sparrow/blob/main/docs/sparrow_run.md
extraArgs:
loaderFilePath: /runconfig/checks.yaml
loaderType: file
extraArgs: {}

# -- extra environment variables
# Allows you to set environment variables through secrets you defined outside of the helm chart
# Useful for sensitive information like the http loader token
envFromSecrets:
[]
# - name: SPARROW_LOADER_HTTP_TOKEN
# valueFrom:
# secretName: sparrow-auth
# key: SPARROW_LOADER_HTTP_TOKEN

# -- startup configuration of the Sparrow
# see: https://github.com/caas-team/sparrow/blob/main/docs/sparrow_run.md
startupConfig: {}
sparrowConfig:
name: sparrow.com
loader:
type: file
path: /config/checksConfig.yaml
# name: the-sparrow.com
# api:
# address:
Expand All @@ -122,28 +134,27 @@ startupConfig: {}
# token: ""
# baseUrl: https://gitlab.com
# projectId: ""

# -- runtime configuration of the Sparrow
# see: https://github.com/caas-team/sparrow#runtime
runtimeConfig:
health:
interval: 20s
timeout: 10s
retry:
count: 3
delay: 1s
targets:
- "https://www.example.com/"
- "https://www.google.com/"
latency:
interval: 1s
timeout: 3s
retry:
count: 3
delay: 1s
targets:
- https://example.com/
- https://google.com/
checksConfig:
checks: {}
# checks:
# health:
# interval: 15s
# timeout: 10s
# retry:
# count: 3
# delay: 1s
# targets:
# - "https://www.example.com/"
# - "https://www.google.com/"
# latency:
# interval: 15s
# timeout: 30s
# retry:
# count: 3
# delay: 2s
# targets:
# - https://example.com/
# - https://google.com/

# -- Configure a service monitor for prometheus-operator
serviceMonitor:
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func initConfig(cfgFile string) {

viper.SetEnvPrefix("sparrow")
dotreplacer := strings.NewReplacer(".", "_")
viper.EnvKeyReplacer(dotreplacer)
viper.SetEnvKeyReplacer(dotreplacer)
viper.AutomaticEnv()

if err := viper.ReadInConfig(); err == nil {
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/jarcoal/httpmock v1.3.1
github.com/mitchellh/mapstructure v1.5.0
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.17.0
github.com/spf13/viper v1.18.0
github.com/stretchr/testify v1.8.4
gopkg.in/yaml.v3 v3.0.1
)
Expand Down Expand Up @@ -38,16 +38,16 @@ require (
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sagikazarmark/locafero v0.3.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.10.0 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
Loading

0 comments on commit c4a6b54

Please sign in to comment.