1
0
Fork 0
mirror of https://github.com/dragonflydb/dragonfly.git synced 2024-12-14 11:58:02 +00:00

Improve Helm chart to be rendered locally and on machines where is not 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 <fafg@fafg-mbm1.fritz.box>

* 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 <fabiano.arruda@hotmail.com>

* fix(helm): lint - remove blank line

Signed-off-by: fafg <fabiano.arruda@hotmail.com>

* add(helm): missing service monitor test files

Signed-off-by: fafg <fabiano.arruda@hotmail.com>

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

Signed-off-by: fafg <fabiano.arruda@hotmail.com>

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

Signed-off-by: fafg <fabiano.arruda@hotmail.com>

* fix(helm): rebase

Signed-off-by: fafg <fabiano.arruda@hotmail.com>

* Revert "fix(helm): rebase"

This reverts commit c4ce16b76e.

* fix(helm): fix service monitor namespace rendering

Signed-off-by: fafg <fabiano.arruda@hotmail.com>

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

Signed-off-by: fafg <fabiano.arruda@hotmail.com>

* fix(helm): merge upstream

Signed-off-by: fafg <fabiano.arruda@hotmail.com>

* 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 <fafg@fafg-mbm1.fritz.box>
Signed-off-by: fafg <fabiano.arruda@hotmail.com>
Co-authored-by: Tarun Pothulapati <tarun@dragonflydb.io>
Co-authored-by: Tarun Pothulapati <tarunpothulapati@outlook.com>
This commit is contained in:
Fabiano Arruda 2024-03-25 07:59:42 +01:00 committed by GitHub
parent b830a71e66
commit 30ec81c456
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 171 additions and 7 deletions

View file

@ -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: |

View file

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

View file

@ -0,0 +1,8 @@
serviceMonitor:
enabled: true
namespace: ""
labels:
release: prometheus-stack
annotations: {}
interval: 10s
scrapeTimeout: 10s

View file

@ -3,7 +3,6 @@ package golden
import (
"flag"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"
@ -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)
}
@ -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)
}
}
}
}

View file

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

View file

@ -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:

View file

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