Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Prepare helm chart for 0.3.0 #73

Merged
merged 12 commits into from
Jan 19, 2024
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 }}
58 changes: 32 additions & 26 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,21 @@ 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: the-sparrow.com
# api:
# address:
Expand All @@ -122,28 +130,26 @@ 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:
# 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/

# -- 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