From 6cf1fdd145ac72cb74431bf635d760ccd6cb5aed Mon Sep 17 00:00:00 2001 From: "javier.juarez" Date: Sat, 14 Oct 2023 09:14:28 +0200 Subject: [PATCH 1/4] chore: Better approach for the runtime image --- Dockerfile | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8b30071..e2e913a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,10 +12,9 @@ RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -v -ldflags="-X 'github.com/j FROM alpine:3.18.4 AS runtime -WORKDIR /app -RUN mkdir -p config -USER 1001 -COPY --from=builder --chown=1001:1001 /build/dist/simple-prober ./simple-prober -VOLUME /app/config -ENTRYPOINT [ "/app/simple-prober" ] -CMD [ "check", "--config", "/app/config/endpoints.yaml", "--timeout", "5", "--loglevel", "debug" ] +ARG UID=1001 + +COPY --from=builder --chown=1001:1001 /build/dist/simple-prober /usr/local/bin/simple-prober +USER ${UID} +VOLUME /endpoints.yaml +CMD [ "simple-prober", "check", "--config", "/endpoints.yaml", "--timeout", "5", "--loglevel", "debug" ] From 92bc25273132a113498347a0934da02128d81c95 Mon Sep 17 00:00:00 2001 From: "javier.juarez" Date: Sat, 14 Oct 2023 09:17:44 +0200 Subject: [PATCH 2/4] feat: More flexible configuration --- .../k8s/chart/simple-prober/templates/cronjob.yaml | 2 +- .../k8s/chart/simple-prober/values-production.yaml | 7 ------- ci/deployment/k8s/chart/simple-prober/values.yaml | 3 +++ ci/deployment/k8s/chart/values-production.yaml | 14 ++++++++++++++ 4 files changed, 18 insertions(+), 8 deletions(-) delete mode 100644 ci/deployment/k8s/chart/simple-prober/values-production.yaml create mode 100644 ci/deployment/k8s/chart/values-production.yaml diff --git a/ci/deployment/k8s/chart/simple-prober/templates/cronjob.yaml b/ci/deployment/k8s/chart/simple-prober/templates/cronjob.yaml index 083cbeb..15949e6 100644 --- a/ci/deployment/k8s/chart/simple-prober/templates/cronjob.yaml +++ b/ci/deployment/k8s/chart/simple-prober/templates/cronjob.yaml @@ -33,7 +33,7 @@ spec: volumes: - name: config-volume configMap: - name: simple-prober-icd-endpoints + name: {{ .Values.config.configMapName | default "simple-prober-endpoints" }} optional: true items: - key: endpoints diff --git a/ci/deployment/k8s/chart/simple-prober/values-production.yaml b/ci/deployment/k8s/chart/simple-prober/values-production.yaml deleted file mode 100644 index 35fe6a0..0000000 --- a/ci/deployment/k8s/chart/simple-prober/values-production.yaml +++ /dev/null @@ -1,7 +0,0 @@ ---- -name: simple-prober -cron: - scheduledExpression: "0 * * * *" - -image: - tag: latest diff --git a/ci/deployment/k8s/chart/simple-prober/values.yaml b/ci/deployment/k8s/chart/simple-prober/values.yaml index 821fb85..1c874d8 100644 --- a/ci/deployment/k8s/chart/simple-prober/values.yaml +++ b/ci/deployment/k8s/chart/simple-prober/values.yaml @@ -1,6 +1,9 @@ --- name: simple-prober istio: false +config: + configMapName: simple-prober-endpoints + cron: scheduledExpression: "* * * * *" failedJobsHistoryLimit: 3 diff --git a/ci/deployment/k8s/chart/values-production.yaml b/ci/deployment/k8s/chart/values-production.yaml new file mode 100644 index 0000000..36fb0d3 --- /dev/null +++ b/ci/deployment/k8s/chart/values-production.yaml @@ -0,0 +1,14 @@ +--- +name: simple-prober +cron: + scheduledExpression: "0 * * * *" + +image: + repository: us.icr.io + namespace: qc-production-ext-images + name: simple-prober + pullPolicy: Always + tag: 0.3.0 + +imagePullSecrets: + - name: all-icr-io From 3db249481896c6decb071d9e3be7fc430cd25fea Mon Sep 17 00:00:00 2001 From: "javier.juarez" Date: Sat, 14 Oct 2023 09:21:29 +0200 Subject: [PATCH 3/4] chore: New pattern to ignore the CM manifests --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 506e9c7..8fa2c97 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,6 @@ dist/* go.work # Real endpoints configurations -*-endpoints.yaml +**/endpoints.yaml # End of https://www.toptal.com/developers/gitignore/api/go From a1ccb5c3805195a483838036aee7c7ad21013170 Mon Sep 17 00:00:00 2001 From: "javier.juarez" Date: Sun, 15 Oct 2023 08:53:39 +0200 Subject: [PATCH 4/4] chore: Default loglevel to debug --- cmd/check.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/check.go b/cmd/check.go index f8b752d..797ca7f 100644 --- a/cmd/check.go +++ b/cmd/check.go @@ -16,9 +16,9 @@ import ( ) const ( - defaultConfigFileName string = "./config/endpoints.yaml" + defaultConfigFileName string = "endpoints.yaml" defaultTimeout int = 5 - defaultLogLevel string = "info" + defaultLogLevel string = "debug" ) var ( @@ -83,7 +83,7 @@ func init() { // The log level rootCmd.PersistentFlags().StringVar(&logLevel, "loglevel", defaultLogLevel, "The log level") // The confiuration file name - rootCmd.PersistentFlags().StringVar(&configFileName, "config", defaultConfigFileName, "Config file (default is: config/endpoints.yaml)") + rootCmd.PersistentFlags().StringVar(&configFileName, "config", defaultConfigFileName, "Config file (default is: endpoints.yaml)") // The connection timeout rootCmd.PersistentFlags().IntVar(¶meterTimeout, "timeout", defaultTimeout, "Connection timeout") timeout = time.Duration(parameterTimeout) * time.Second