Skip to content

Commit

Permalink
Improve Helm chart to be rendered locally and on machines where is no…
Browse files Browse the repository at this point in the history
…t the application target (#2706)

* fix(helm): add issuer group to create the certificate without wait for the previous created issuer

Signed-off-by: Fabiano Arruda Ferreira das Graças <[email protected]>

* fix(helm): remove condition that can prevent the helm chart be rendered on machines where monitoring.coreos.com is not installed or is not the end target of the helm template command

Signed-off-by: fafg <[email protected]>

* fix(helm): lint - remove blank line

Signed-off-by: fafg <[email protected]>

* add(helm): missing service monitor test files

Signed-off-by: fafg <[email protected]>

* add(helm): add missing cert-manager test files

Signed-off-by: fafg <[email protected]>

* fix(helm): lint - add missing blank lines

Signed-off-by: fafg <[email protected]>

* fix(helm): rebase

Signed-off-by: fafg <[email protected]>

* Revert "fix(helm): rebase"

This reverts commit c4ce16b.

* fix(helm): fix service monitor namespace rendering

Signed-off-by: fafg <[email protected]>

* fix(helm): add missing up to date golden file

Signed-off-by: fafg <[email protected]>

* fix(helm): merge upstream

Signed-off-by: fafg <[email protected]>

* update golden files

* also install prom operator dependencies

* also install cert-manager

* skip cert-manager chart

* skip cert-manager value

* remove CI TLS files

* fix formatting

* fix formatting

* fix actions

---------

Signed-off-by: Fabiano Arruda Ferreira das Graças <[email protected]>
Signed-off-by: fafg <[email protected]>
Co-authored-by: Tarun Pothulapati <[email protected]>
Co-authored-by: Tarun Pothulapati <[email protected]>
  • Loading branch information
3 people authored Mar 25, 2024
1 parent b830a71 commit 30ec81c
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .github/actions/lint-test-chart/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ runs:
- name: Create kind cluster
uses: helm/kind-action@v1

- name: Install Dependencies
shell: bash
run: |
LATEST=$(curl -s https://api.github.com/repos/prometheus-operator/prometheus-operator/releases/latest | jq -cr .tag_name)
curl -sL https://github.com/prometheus-operator/prometheus-operator/releases/download/${LATEST}/bundle.yaml | kubectl create -f -
- name: Getting cluster ready
shell: bash
run: |
Expand Down
146 changes: 146 additions & 0 deletions contrib/charts/dragonfly/ci/service-monitor-values.golden.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
---
# Source: dragonfly/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: test-dragonfly
namespace: default
labels:
app.kubernetes.io/name: dragonfly
app.kubernetes.io/instance: test
app.kubernetes.io/version: "v1.15.1"
app.kubernetes.io/managed-by: Helm
---
# Source: dragonfly/templates/metrics-service.yaml
apiVersion: v1
kind: Service
metadata:
name: test-dragonfly-metrics
namespace: default
labels:
app.kubernetes.io/name: dragonfly
app.kubernetes.io/instance: test
app.kubernetes.io/version: "v1.15.1"
app.kubernetes.io/managed-by: Helm
type: metrics
spec:
type: ClusterIP
ports:
- name: metrics
port: 6379
targetPort: 6379
protocol: TCP
selector:
app.kubernetes.io/name: dragonfly
app.kubernetes.io/instance: test
---
# Source: dragonfly/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
name: test-dragonfly
namespace: default
labels:
app.kubernetes.io/name: dragonfly
app.kubernetes.io/instance: test
app.kubernetes.io/version: "v1.15.1"
app.kubernetes.io/managed-by: Helm
spec:
type: ClusterIP
ports:
- port: 6379
targetPort: dragonfly
protocol: TCP
name: dragonfly
selector:
app.kubernetes.io/name: dragonfly
app.kubernetes.io/instance: test
---
# Source: dragonfly/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-dragonfly
namespace: default
labels:
app.kubernetes.io/name: dragonfly
app.kubernetes.io/instance: test
app.kubernetes.io/version: "v1.15.1"
app.kubernetes.io/managed-by: Helm
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: dragonfly
app.kubernetes.io/instance: test
template:
metadata:
annotations:
labels:
app.kubernetes.io/name: dragonfly
app.kubernetes.io/instance: test
spec:
serviceAccountName: test-dragonfly
containers:
- name: dragonfly
image: "docker.dragonflydb.io/dragonflydb/dragonfly:v1.15.1"
imagePullPolicy: IfNotPresent
ports:
- name: dragonfly
containerPort: 6379
protocol: TCP
livenessProbe:
exec:
command:
- /bin/sh
- /usr/local/bin/healthcheck.sh
failureThreshold: 3
initialDelaySeconds: 10
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
readinessProbe:
exec:
command:
- /bin/sh
- /usr/local/bin/healthcheck.sh
failureThreshold: 3
initialDelaySeconds: 10
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
args:
- "--alsologtostderr"
resources:
limits: {}
requests: {}
---
# Source: dragonfly/templates/servicemonitor.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: test-dragonfly-metrics
namespace: default
labels:
release: prometheus-stack
app.kubernetes.io/name: dragonfly
app.kubernetes.io/instance: test
app.kubernetes.io/version: "v1.15.1"
app.kubernetes.io/managed-by: Helm
spec:
endpoints:
- interval: 10s
scrapeTimeout: 10s
honorLabels: true
port: metrics
path: /metrics
scheme: http
jobLabel: "test"
selector:
matchLabels:
app.kubernetes.io/name: dragonfly
app.kubernetes.io/instance: test
type: metrics
namespaceSelector:
matchNames:
- default
8 changes: 8 additions & 0 deletions contrib/charts/dragonfly/ci/service-monitor-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
serviceMonitor:
enabled: true
namespace: ""
labels:
release: prometheus-stack
annotations: {}
interval: 10s
scrapeTimeout: 10s
6 changes: 2 additions & 4 deletions contrib/charts/dragonfly/golden_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package golden
import (
"flag"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -40,13 +39,13 @@ func TestHelmRender(t *testing.T) {
output = fmt.Sprintf("%s\n", string(bytes))

if *update {
err := ioutil.WriteFile(goldenFile, []byte(output), 0644)
err := os.WriteFile(goldenFile, []byte(output), 0644)
if err != nil {
t.Fatal(err)
}
}

expected, err := ioutil.ReadFile(goldenFile)
expected, err := os.ReadFile(goldenFile)
if err != nil {
t.Fatal(err)
}
Expand All @@ -55,6 +54,5 @@ func TestHelmRender(t *testing.T) {
t.Fatalf("Expected %s, but got %s\n. Update golden files by running `go test -v ./... -update`", string(expected), output)
}
}

}
}
1 change: 1 addition & 0 deletions contrib/charts/dragonfly/templates/certificate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ spec:
issuerRef:
kind: {{ required "tls.issuer.kind is required, if createCerts is enabled" .Values.tls.issuer.kind }}
name: {{ required "tls.issuer.name is required, if createCerts is enabled" .Values.tls.issuer.name }}
group: {{ .Values.tls.issuer.group }}
secretName: '{{ include "dragonfly.fullname" . }}-server-tls'
usages:
- client auth
Expand Down
8 changes: 5 additions & 3 deletions contrib/charts/dragonfly/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{{- if and ( .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" ) .Values.serviceMonitor.enabled }}
{{- if .Values.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "dragonfly.fullname" . }}-metrics
{{- with .Values.serviceMonitor.namespace }}
namespace: {{ . }}
{{- if .Values.serviceMonitor.namespace }}
namespace: {{ .Values.serviceMonitor.namespace }}
{{- else }}
namespace: {{ .Release.Namespace }}
{{- end }}
{{- with .Values.serviceMonitor.annotations }}
annotations:
Expand Down
3 changes: 3 additions & 0 deletions contrib/charts/dragonfly/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ tls:
kind: ClusterIssuer
# -- name of the referenced issuer
name: selfsigned
# -- group of the referenced issuer
# if you are using an external issuer, change this to that issuer group.
group: cert-manager.io
# -- use TLS certificates from existing secret
existing_secret: ""
# -- TLS certificate
Expand Down

0 comments on commit 30ec81c

Please sign in to comment.