diff --git a/.changeset/pretty-ants-arrive.md b/.changeset/pretty-ants-arrive.md new file mode 100644 index 0000000..378aeed --- /dev/null +++ b/.changeset/pretty-ants-arrive.md @@ -0,0 +1,5 @@ +--- +"helm-charts": patch +--- + +feat: add livenessProbe and readinessProbe for services diff --git a/charts/hdx-oss-v2/templates/clickhouse-deployment.yaml b/charts/hdx-oss-v2/templates/clickhouse-deployment.yaml index cd99ccf..8799a3b 100644 --- a/charts/hdx-oss-v2/templates/clickhouse-deployment.yaml +++ b/charts/hdx-oss-v2/templates/clickhouse-deployment.yaml @@ -35,6 +35,26 @@ spec: env: - name: CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT value: "1" + {{- if .Values.clickhouse.livenessProbe.enabled }} + livenessProbe: + httpGet: + path: /ping + port: {{ .Values.clickhouse.port }} + initialDelaySeconds: {{ .Values.clickhouse.livenessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.clickhouse.livenessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.clickhouse.livenessProbe.timeoutSeconds }} + failureThreshold: {{ .Values.clickhouse.livenessProbe.failureThreshold }} + {{- end }} + {{- if .Values.clickhouse.readinessProbe.enabled }} + readinessProbe: + httpGet: + path: /ping + port: {{ .Values.clickhouse.port }} + initialDelaySeconds: {{ .Values.clickhouse.readinessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.clickhouse.readinessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.clickhouse.readinessProbe.timeoutSeconds }} + failureThreshold: {{ .Values.clickhouse.readinessProbe.failureThreshold }} + {{- end }} volumeMounts: - name: config mountPath: /etc/clickhouse-server/config.xml @@ -153,4 +173,4 @@ spec: requests: storage: {{ .Values.clickhouse.persistence.logSize }} {{- end }} -{{- end }} \ No newline at end of file +{{- end }} diff --git a/charts/hdx-oss-v2/templates/hyperdx-deployment.yaml b/charts/hdx-oss-v2/templates/hyperdx-deployment.yaml index a0fd03e..cdab8f6 100644 --- a/charts/hdx-oss-v2/templates/hyperdx-deployment.yaml +++ b/charts/hdx-oss-v2/templates/hyperdx-deployment.yaml @@ -64,6 +64,26 @@ spec: resources: {{- toYaml .Values.hyperdx.resources | nindent 12 }} {{- end }} + {{- if .Values.hyperdx.livenessProbe.enabled }} + livenessProbe: + httpGet: + path: /health + port: {{ .Values.hyperdx.apiPort }} + initialDelaySeconds: {{ .Values.hyperdx.livenessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.hyperdx.livenessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.hyperdx.livenessProbe.timeoutSeconds }} + failureThreshold: {{ .Values.hyperdx.livenessProbe.failureThreshold }} + {{- end }} + {{- if .Values.hyperdx.readinessProbe.enabled }} + readinessProbe: + httpGet: + path: /health + port: {{ .Values.hyperdx.apiPort }} + initialDelaySeconds: {{ .Values.hyperdx.readinessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.hyperdx.readinessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.hyperdx.readinessProbe.timeoutSeconds }} + failureThreshold: {{ .Values.hyperdx.readinessProbe.failureThreshold }} + {{- end }} envFrom: - configMapRef: name: {{ include "hdx-oss.fullname" . }}-app-config diff --git a/charts/hdx-oss-v2/templates/mongodb-deployment.yaml b/charts/hdx-oss-v2/templates/mongodb-deployment.yaml index 51efd12..5d23559 100644 --- a/charts/hdx-oss-v2/templates/mongodb-deployment.yaml +++ b/charts/hdx-oss-v2/templates/mongodb-deployment.yaml @@ -31,6 +31,24 @@ spec: image: "{{ .Values.mongodb.image }}" ports: - containerPort: {{ .Values.mongodb.port }} + {{- if .Values.mongodb.livenessProbe.enabled }} + livenessProbe: + tcpSocket: + port: {{ .Values.mongodb.port }} + initialDelaySeconds: {{ .Values.mongodb.livenessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.mongodb.livenessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.mongodb.livenessProbe.timeoutSeconds }} + failureThreshold: {{ .Values.mongodb.livenessProbe.failureThreshold }} + {{- end }} + {{- if .Values.mongodb.readinessProbe.enabled }} + readinessProbe: + tcpSocket: + port: {{ .Values.mongodb.port }} + initialDelaySeconds: {{ .Values.mongodb.readinessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.mongodb.readinessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.mongodb.readinessProbe.timeoutSeconds }} + failureThreshold: {{ .Values.mongodb.readinessProbe.failureThreshold }} + {{- end }} volumeMounts: - name: mongodb-data mountPath: /data/db diff --git a/charts/hdx-oss-v2/templates/otel-collector-deployment.yaml b/charts/hdx-oss-v2/templates/otel-collector-deployment.yaml index 1fd743a..f390867 100644 --- a/charts/hdx-oss-v2/templates/otel-collector-deployment.yaml +++ b/charts/hdx-oss-v2/templates/otel-collector-deployment.yaml @@ -46,6 +46,26 @@ spec: resources: {{- toYaml .Values.otel.resources | nindent 12 }} {{- end }} + {{- if .Values.otel.livenessProbe.enabled }} + livenessProbe: + httpGet: + path: / + port: {{ .Values.otel.port }} + initialDelaySeconds: {{ .Values.otel.livenessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.otel.livenessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.otel.livenessProbe.timeoutSeconds }} + failureThreshold: {{ .Values.otel.livenessProbe.failureThreshold }} + {{- end }} + {{- if .Values.otel.readinessProbe.enabled }} + readinessProbe: + httpGet: + path: / + port: {{ .Values.otel.port }} + initialDelaySeconds: {{ .Values.otel.readinessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.otel.readinessProbe.periodSeconds}} + timeoutSeconds: {{ .Values.otel.readinessProbe.timeoutSeconds}} + failureThreshold: {{ .Values.otel.readinessProbe.failureThreshold }} + {{- end }} env: - name: CLICKHOUSE_ENDPOINT value: "{{ .Values.otel.clickhouseEndpoint | default (printf "tcp://%s-clickhouse:%v?dial_timeout=10s" (include "hdx-oss.fullname" .) .Values.clickhouse.nativePort) }}" diff --git a/charts/hdx-oss-v2/tests/clickhouse-deployment_test.yaml b/charts/hdx-oss-v2/tests/clickhouse-deployment_test.yaml index b445381..05f4135 100644 --- a/charts/hdx-oss-v2/tests/clickhouse-deployment_test.yaml +++ b/charts/hdx-oss-v2/tests/clickhouse-deployment_test.yaml @@ -145,4 +145,125 @@ tests: path: spec.template.spec.volumes[3].emptyDir - documentIndex: 0 isNull: - path: spec.template.spec.volumes[3].persistentVolumeClaim \ No newline at end of file + path: spec.template.spec.volumes[3].persistentVolumeClaim + + - it: should include livenessProbe with default values when enabled + set: + clickhouse: + enabled: true + port: 8123 + asserts: + - documentIndex: 0 + isSubset: + path: spec.template.spec.containers[0].livenessProbe + content: + httpGet: + path: /ping + port: 8123 + initialDelaySeconds: 10 + periodSeconds: 30 + timeoutSeconds: 5 + failureThreshold: 3 + + - it: should include readinessProbe with default values when enabled + set: + clickhouse: + enabled: true + port: 8123 + asserts: + - documentIndex: 0 + isSubset: + path: spec.template.spec.containers[0].readinessProbe + content: + httpGet: + path: /ping + port: 8123 + initialDelaySeconds: 1 + periodSeconds: 10 + timeoutSeconds: 5 + failureThreshold: 3 + + - it: should not include livenessProbe when disabled + set: + clickhouse: + enabled: true + livenessProbe: + enabled: false + asserts: + - documentIndex: 0 + isNull: + path: spec.template.spec.containers[0].livenessProbe + + - it: should not include readinessProbe when disabled + set: + clickhouse: + enabled: true + readinessProbe: + enabled: false + asserts: + - documentIndex: 0 + isNull: + path: spec.template.spec.containers[0].readinessProbe + + - it: should use custom livenessProbe values when provided + set: + clickhouse: + enabled: true + port: 8123 + livenessProbe: + enabled: true + initialDelaySeconds: 20 + periodSeconds: 60 + timeoutSeconds: 10 + failureThreshold: 5 + asserts: + - documentIndex: 0 + isSubset: + path: spec.template.spec.containers[0].livenessProbe + content: + httpGet: + path: /ping + port: 8123 + initialDelaySeconds: 20 + periodSeconds: 60 + timeoutSeconds: 10 + failureThreshold: 5 + + - it: should use custom readinessProbe values when provided + set: + clickhouse: + enabled: true + port: 8123 + readinessProbe: + enabled: true + initialDelaySeconds: 5 + periodSeconds: 20 + timeoutSeconds: 3 + failureThreshold: 2 + asserts: + - documentIndex: 0 + isSubset: + path: spec.template.spec.containers[0].readinessProbe + content: + httpGet: + path: /ping + port: 8123 + initialDelaySeconds: 5 + periodSeconds: 20 + timeoutSeconds: 3 + failureThreshold: 2 + + - it: should use custom port in probes when provided + set: + clickhouse: + enabled: true + port: 8124 + asserts: + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].livenessProbe.httpGet.port + value: 8124 + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].readinessProbe.httpGet.port + value: 8124 \ No newline at end of file diff --git a/charts/hdx-oss-v2/tests/hyperdx-deployment_test.yaml b/charts/hdx-oss-v2/tests/hyperdx-deployment_test.yaml index a8389c7..1d07d04 100644 --- a/charts/hdx-oss-v2/tests/hyperdx-deployment_test.yaml +++ b/charts/hdx-oss-v2/tests/hyperdx-deployment_test.yaml @@ -128,4 +128,102 @@ tests: content: -c - matchRegex: path: spec.template.spec.initContainers[0].command[2] - pattern: "until nc -z .+-mongodb [0-9]+; do echo waiting for mongodb; sleep 2; done;" \ No newline at end of file + pattern: "until nc -z .+-mongodb [0-9]+; do echo waiting for mongodb; sleep 2; done;" + + - it: should include livenessProbe with default values when enabled + asserts: + - isSubset: + path: spec.template.spec.containers[0].livenessProbe + content: + httpGet: + path: /health + port: 8000 + initialDelaySeconds: 10 + periodSeconds: 30 + timeoutSeconds: 5 + failureThreshold: 3 + + - it: should include readinessProbe with default values when enabled + asserts: + - isSubset: + path: spec.template.spec.containers[0].readinessProbe + content: + httpGet: + path: /health + port: 8000 + initialDelaySeconds: 1 + periodSeconds: 10 + timeoutSeconds: 5 + failureThreshold: 3 + + - it: should not include livenessProbe when disabled + set: + hyperdx: + livenessProbe: + enabled: false + asserts: + - isNull: + path: spec.template.spec.containers[0].livenessProbe + + - it: should not include readinessProbe when disabled + set: + hyperdx: + readinessProbe: + enabled: false + asserts: + - isNull: + path: spec.template.spec.containers[0].readinessProbe + + - it: should use custom livenessProbe values when provided + set: + hyperdx: + livenessProbe: + enabled: true + initialDelaySeconds: 20 + periodSeconds: 60 + timeoutSeconds: 10 + failureThreshold: 5 + asserts: + - isSubset: + path: spec.template.spec.containers[0].livenessProbe + content: + httpGet: + path: /health + port: 8000 + initialDelaySeconds: 20 + periodSeconds: 60 + timeoutSeconds: 10 + failureThreshold: 5 + + - it: should use custom readinessProbe values when provided + set: + hyperdx: + readinessProbe: + enabled: true + initialDelaySeconds: 5 + periodSeconds: 20 + timeoutSeconds: 3 + failureThreshold: 2 + asserts: + - isSubset: + path: spec.template.spec.containers[0].readinessProbe + content: + httpGet: + path: /health + port: 8000 + initialDelaySeconds: 5 + periodSeconds: 20 + timeoutSeconds: 3 + failureThreshold: 2 + + - it: should use custom apiPort in probes when provided + set: + hyperdx: + apiPort: 9000 + asserts: + - equal: + path: spec.template.spec.containers[0].livenessProbe.httpGet.port + value: 9000 + - equal: + path: spec.template.spec.containers[0].readinessProbe.httpGet.port + value: 9000 \ No newline at end of file diff --git a/charts/hdx-oss-v2/tests/mongodb-deployment_test.yaml b/charts/hdx-oss-v2/tests/mongodb-deployment_test.yaml index 2c2c8a0..e970eae 100644 --- a/charts/hdx-oss-v2/tests/mongodb-deployment_test.yaml +++ b/charts/hdx-oss-v2/tests/mongodb-deployment_test.yaml @@ -70,4 +70,102 @@ tests: path: spec.template.spec.volumes[0].emptyDir - documentIndex: 0 isNull: - path: spec.template.spec.volumes[0].persistentVolumeClaim \ No newline at end of file + path: spec.template.spec.volumes[0].persistentVolumeClaim + + - it: should include livenessProbe with tcpSocket when enabled + set: + mongodb: + enabled: true + asserts: + - documentIndex: 0 + isSubset: + path: spec.template.spec.containers[0].livenessProbe + content: + tcpSocket: + port: 27017 + initialDelaySeconds: 10 + periodSeconds: 30 + timeoutSeconds: 5 + failureThreshold: 3 + + - it: should include readinessProbe with tcpSocket when enabled + set: + mongodb: + enabled: true + asserts: + - documentIndex: 0 + isSubset: + path: spec.template.spec.containers[0].readinessProbe + content: + tcpSocket: + port: 27017 + initialDelaySeconds: 1 + periodSeconds: 10 + timeoutSeconds: 5 + failureThreshold: 3 + + - it: should not include livenessProbe when disabled + set: + mongodb: + enabled: true + livenessProbe: + enabled: false + asserts: + - documentIndex: 0 + isNull: + path: spec.template.spec.containers[0].livenessProbe + + - it: should not include readinessProbe when disabled + set: + mongodb: + enabled: true + readinessProbe: + enabled: false + asserts: + - documentIndex: 0 + isNull: + path: spec.template.spec.containers[0].readinessProbe + + - it: should use custom livenessProbe values when provided + set: + mongodb: + enabled: true + livenessProbe: + enabled: true + initialDelaySeconds: 20 + periodSeconds: 60 + timeoutSeconds: 10 + failureThreshold: 5 + asserts: + - documentIndex: 0 + isSubset: + path: spec.template.spec.containers[0].livenessProbe + content: + tcpSocket: + port: 27017 + initialDelaySeconds: 20 + periodSeconds: 60 + timeoutSeconds: 10 + failureThreshold: 5 + + - it: should use custom readinessProbe values when provided + set: + mongodb: + enabled: true + readinessProbe: + enabled: true + initialDelaySeconds: 5 + periodSeconds: 20 + timeoutSeconds: 3 + failureThreshold: 2 + asserts: + - documentIndex: 0 + isSubset: + path: spec.template.spec.containers[0].readinessProbe + content: + tcpSocket: + port: 27017 + initialDelaySeconds: 5 + periodSeconds: 20 + timeoutSeconds: 3 + failureThreshold: 2 diff --git a/charts/hdx-oss-v2/tests/otel-collector_test.yaml b/charts/hdx-oss-v2/tests/otel-collector_test.yaml index a85febf..39ce113 100644 --- a/charts/hdx-oss-v2/tests/otel-collector_test.yaml +++ b/charts/hdx-oss-v2/tests/otel-collector_test.yaml @@ -686,3 +686,124 @@ tests: checksum/config: "abcdef1234567890" deployment.kubernetes.io/revision: "1" sidecar.istio.io/inject: "false" + + - it: should include livenessProbe with default values when enabled + set: + otel: + enabled: true + port: 13133 + asserts: + - documentIndex: 0 + isSubset: + path: spec.template.spec.containers[0].livenessProbe + content: + httpGet: + path: / + port: 13133 + initialDelaySeconds: 10 + periodSeconds: 30 + timeoutSeconds: 5 + failureThreshold: 3 + + - it: should include readinessProbe with default values when enabled + set: + otel: + enabled: true + port: 13133 + asserts: + - documentIndex: 0 + isSubset: + path: spec.template.spec.containers[0].readinessProbe + content: + httpGet: + path: / + port: 13133 + initialDelaySeconds: 5 + periodSeconds: 10 + timeoutSeconds: 5 + failureThreshold: 3 + + - it: should not include livenessProbe when disabled + set: + otel: + enabled: true + livenessProbe: + enabled: false + asserts: + - documentIndex: 0 + isNull: + path: spec.template.spec.containers[0].livenessProbe + + - it: should not include readinessProbe when disabled + set: + otel: + enabled: true + readinessProbe: + enabled: false + asserts: + - documentIndex: 0 + isNull: + path: spec.template.spec.containers[0].readinessProbe + + - it: should use custom livenessProbe values when provided + set: + otel: + enabled: true + port: 13133 + livenessProbe: + enabled: true + initialDelaySeconds: 20 + periodSeconds: 60 + timeoutSeconds: 10 + failureThreshold: 5 + asserts: + - documentIndex: 0 + isSubset: + path: spec.template.spec.containers[0].livenessProbe + content: + httpGet: + path: / + port: 13133 + initialDelaySeconds: 20 + periodSeconds: 60 + timeoutSeconds: 10 + failureThreshold: 5 + + - it: should use custom readinessProbe values when provided + set: + otel: + enabled: true + port: 13133 + readinessProbe: + enabled: true + initialDelaySeconds: 15 + periodSeconds: 20 + timeoutSeconds: 3 + failureThreshold: 2 + asserts: + - documentIndex: 0 + isSubset: + path: spec.template.spec.containers[0].readinessProbe + content: + httpGet: + path: / + port: 13133 + initialDelaySeconds: 15 + periodSeconds: 20 + timeoutSeconds: 3 + failureThreshold: 2 + + - it: should use custom port in probes when provided + set: + otel: + enabled: true + port: 13134 + asserts: + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].livenessProbe.httpGet.port + value: 13134 + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].readinessProbe.httpGet.port + value: 13134 diff --git a/charts/hdx-oss-v2/values.yaml b/charts/hdx-oss-v2/values.yaml index f09e51d..1c48dbf 100644 --- a/charts/hdx-oss-v2/values.yaml +++ b/charts/hdx-oss-v2/values.yaml @@ -8,6 +8,18 @@ hyperdx: repository: docker.hyperdx.io/hyperdx/hyperdx tag: pullPolicy: IfNotPresent + livenessProbe: + enabled: true + initialDelaySeconds: 10 + periodSeconds: 30 + timeoutSeconds: 5 + failureThreshold: 3 + readinessProbe: + enabled: true + initialDelaySeconds: 1 + periodSeconds: 10 + timeoutSeconds: 5 + failureThreshold: 3 # Add nodeSelector and tolerations for hyperdx service nodeSelector: {} # Example: @@ -221,11 +233,35 @@ mongodb: persistence: enabled: true dataSize: 10Gi + livenessProbe: + enabled: true + initialDelaySeconds: 10 + periodSeconds: 30 + timeoutSeconds: 5 + failureThreshold: 3 + readinessProbe: + enabled: true + initialDelaySeconds: 1 + periodSeconds: 10 + timeoutSeconds: 5 + failureThreshold: 3 clickhouse: image: "clickhouse/clickhouse-server:24-alpine" port: 8123 nativePort: 9000 + livenessProbe: + enabled: true + initialDelaySeconds: 10 + periodSeconds: 30 + timeoutSeconds: 5 + failureThreshold: 3 + readinessProbe: + enabled: true + initialDelaySeconds: 1 + periodSeconds: 10 + timeoutSeconds: 5 + failureThreshold: 3 enabled: true # Add nodeSelector and tolerations for clickhouse service nodeSelector: {} @@ -330,6 +366,18 @@ otel: clickhousePrometheusEndpoint: # Clickhouse database to send logs/traces/metrics to. Defaults to "default" clickhouseDatabase: "default" + livenessProbe: + enabled: true + initialDelaySeconds: 10 + periodSeconds: 30 + timeoutSeconds: 5 + failureThreshold: 3 + readinessProbe: + enabled: true + initialDelaySeconds: 5 + periodSeconds: 10 + timeoutSeconds: 5 + failureThreshold: 3 tasks: enabled: false