From b655cd85cb439c20ec1bd9f8805a145315ad3705 Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 22 Apr 2024 17:08:29 +0100 Subject: [PATCH] Merge in liveness probe functionality from chronicle chart Signed-off-by: Ryan --- charts/chronicle-on-sawtooth/Chart.yaml | 2 +- charts/chronicle-on-sawtooth/README.md | 18 ++- charts/chronicle-on-sawtooth/app-readme.md | 4 +- .../templates/statefulset.yaml | 112 +++++++++++++++++- charts/chronicle-on-sawtooth/values.yaml | 32 ++++- charts/chronicle/Chart.yaml | 4 +- charts/chronicle/README.md | 20 +++- charts/chronicle/app-readme.md | 4 +- charts/chronicle/templates/statefulset.yaml | 108 ++++++++++++++++- charts/chronicle/values.yaml | 32 ++++- 10 files changed, 316 insertions(+), 20 deletions(-) diff --git a/charts/chronicle-on-sawtooth/Chart.yaml b/charts/chronicle-on-sawtooth/Chart.yaml index f2262d64..5580d287 100644 --- a/charts/chronicle-on-sawtooth/Chart.yaml +++ b/charts/chronicle-on-sawtooth/Chart.yaml @@ -17,7 +17,7 @@ keywords: # This is the chart version. This version number should be incremented each # time you make changes to the chart and its templates, including the app # version. -version: 0.1.23 +version: 0.1.24 # This is the version number of Chronicle being deployed. This version # number should be incremented each time you make changes to Chronicle. diff --git a/charts/chronicle-on-sawtooth/README.md b/charts/chronicle-on-sawtooth/README.md index e72e2f98..6bc73c0b 100644 --- a/charts/chronicle-on-sawtooth/README.md +++ b/charts/chronicle-on-sawtooth/README.md @@ -1,4 +1,4 @@ -# Chronicle +# Chronicle on Hyperledger Sawtooth | field | description | default | |-|-|-| @@ -87,3 +87,19 @@ | `tp.maxUnavailable` | maximum unavailable nodes during a rolling upgrade | | `tp.minReadySeconds` | minimum time before node becomes available | | `sawtooth` | sawtooth options may be configured | see [Sawtooth](../sawtooth/README.md) | +| `livenessProbe.enabled` | if true, enables the liveness probe | false | +| `livenessProbe.initialDelaySeconds` | delay before liveness probe is initiated | 30 | +| `livenessProbe.periodSeconds` | how often to perform the probe | 10 | +| `livenessProbe.timeoutSeconds` | when the probe times out | 1 | +| `livenessProbe.failureThreshold` | how many times to retry the probe before giving up | 3 | +| `livenessProbe.successThreshold` | how many times the probe must report success to be considered successful after having failed | 1 | +| `livenessProbe.namespaceName` | the namespace name for the liveness probe | "default" | +| `livenessProbe.namespaceUuid` | the namespace UUID for the liveness probe | "fd717fd6-70f1-44c1-81de-287d5e101089" | +| `startupProbe.enabled` | if true, enables the startup probe | false | +| `startupProbe.initialDelaySeconds` | delay before startup probe is initiated | 10 | +| `startupProbe.periodSeconds` | how often to perform the probe | 10 | +| `startupProbe.timeoutSeconds` | when the probe times out | 1 | +| `startupProbe.failureThreshold` | how many times to retry the probe before giving up | 3 | +| `startupProbe.successThreshold` | how many times the probe must report success to be considered successful after having failed | 1 | +| `startupProbe.namespaceName` | the namespace name for the startup probe | "default" | +| `startupProbe.namespaceUuid` | the namespace UUID for the startup probe | "fd717fd6-70f1-44c1-81de-287d5e101089" | diff --git a/charts/chronicle-on-sawtooth/app-readme.md b/charts/chronicle-on-sawtooth/app-readme.md index 97817390..4f131e6a 100644 --- a/charts/chronicle-on-sawtooth/app-readme.md +++ b/charts/chronicle-on-sawtooth/app-readme.md @@ -1,4 +1,4 @@ -# BTP Chronicle +# Chronicle on Hyperledger Sawtooth Chronicle records provenance information of any physical or digital asset on a distributed ledger. @@ -6,7 +6,7 @@ Chronicle records provenance information of any physical or digital asset on a d - Chronicle is built on the established W3C PROV Ontology standard; it uses the lightweight JSON-LD linked data format, and the data query language GraphQL. - Chronicle is easily adaptable to enable users to model, capture, and query provenance information pertinent to their industry, application and use case. -You can find example domains and further instructions at https://examples.btp.works +You can find example domains and further instructions at ## *Important* diff --git a/charts/chronicle-on-sawtooth/templates/statefulset.yaml b/charts/chronicle-on-sawtooth/templates/statefulset.yaml index 96ac24fb..d7989872 100644 --- a/charts/chronicle-on-sawtooth/templates/statefulset.yaml +++ b/charts/chronicle-on-sawtooth/templates/statefulset.yaml @@ -87,7 +87,7 @@ spec: name: {{ .Values.postgres.existingPasswordSecret }} key: {{ .Values.postgres.existingPasswordSecretKey }} {{- else }} - value: {{ .Values.postgres.password | quote }} + value: {{ .Values.postgres.password }} {{- end }} {{- include "lib.safeToYaml" .Values.postgres.env | nindent 12 }} volumeMounts: @@ -140,7 +140,7 @@ spec: name: {{ .Values.postgres.existingPasswordSecret }} key: {{ .Values.postgres.existingPasswordSecretKey }} {{- else }} - value: {{ .Values.postgres.password | quote }} + value: {{ .Values.postgres.password }} {{- end }} {{- include "lib.safeToYaml" .Values.postgres.env | nindent 12 }} resources: {{- include "lib.safeToYaml" .Values.resources | nindent 12 }} @@ -153,6 +153,106 @@ spec: - name: chronicle-data mountPath: /var/lib/chronicle/store/ {{- include "lib.volumeMounts" .Values.extraVolumeMounts | nindent 12 }} + {{- if .Values.livenessProbe.enabled }} + livenessProbe: + exec: + command: + - bash + - -c + - | + PROBE_ID="startup_$(LC_ALL=C tr -dc A-Za-z0-9 /tmp/import.json && + echo "Probe ID: $PROBE_ID" && + chronicle \ + -c /etc/chronicle/config/config.toml \ + --console-logging json \ + --sawtooth tcp://{{ include "chronicle.sawtooth.service" . }}:{{ include "chronicle.sawtooth.sawcomp" . }} \ + --remote-database \ + --database-name {{ .Values.postgres.database }} \ + --database-username {{ .Values.postgres.user }} \ + --database-host {{ .Values.postgres.host }} \ + {{- if not .Values.opa.enabled }} + --embedded-opa-policy \ + {{- end }} + import {{ .Values.livenessProbe.namespaceName }} {{ .Values.livenessProbe.namespaceUuid }} < /tmp/import.json + initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.livenessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }} + failureThreshold: {{ .Values.livenessProbe.failureThreshold }} + {{- end }} + {{- if .Values.startUpProbe.enabled }} + startupProbe: + exec: + command: + - bash + - -c + - | + PROBE_ID="startup_$(LC_ALL=C tr -dc A-Za-z0-9 /tmp/import.json && + echo "Probe ID: $PROBE_ID" && + chronicle \ + -c /etc/chronicle/config/config.toml \ + --console-logging json \ + --sawtooth tcp://{{ include "chronicle.sawtooth.service" . }}:{{ include "chronicle.sawtooth.sawcomp" . }} \ + --remote-database \ + --database-name {{ .Values.postgres.database }} \ + --database-username {{ .Values.postgres.user }} \ + --database-host {{ .Values.postgres.host }} \ + {{- if not .Values.opa.enabled }} + --embedded-opa-policy \ + {{- end }} + import {{ .Values.startUpProbe.namespaceName }} {{ .Values.startUpProbe.namespaceUuid }} < /tmp/import.json + initialDelaySeconds: {{ .Values.startUpProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.startUpProbe.periodSeconds }} + timeoutSeconds: {{ .Values.startUpProbe.timeoutSeconds }} + failureThreshold: {{ .Values.startUpProbe.failureThreshold }} + {{- end }} volumes: - name: chronicle-secrets persistentVolumeClaim: @@ -163,10 +263,10 @@ spec: - name: chronicle-config configMap: name: {{ .Release.Name }}-chronicle-config -{{- if not .Values.postgres.persistence.enabled }} + {{- if not .Values.postgres.persistence.enabled }} - name: "pgdata" emptyDir: {} -{{- end }} + {{- end }} volumeClaimTemplates: - metadata: name: chronicle-data @@ -176,7 +276,7 @@ spec: resources: requests: storage: 6Gi -{{- if .Values.postgres.persistence.enabled }} + {{- if .Values.postgres.persistence.enabled }} - metadata: name: "pgdata" annotations: {{- include "lib.safeToYaml" .Values.postgres.persistence.annotations | nindent 10 }} @@ -186,4 +286,4 @@ spec: resources: requests: storage: {{ .Values.postgres.persistence.size | quote }} -{{- end }} + {{- end }} diff --git a/charts/chronicle-on-sawtooth/values.yaml b/charts/chronicle-on-sawtooth/values.yaml index ca63ad91..0159d7d8 100644 --- a/charts/chronicle-on-sawtooth/values.yaml +++ b/charts/chronicle-on-sawtooth/values.yaml @@ -22,6 +22,36 @@ auth: userinfo: url: +## @md | `livenessProbe.enabled` | if true, enables the liveness probe | false | +livenessProbe: + enabled: false + ## @md | `livenessProbe.timeoutSeconds` | number of seconds after which the probe times out | 10 | + timeoutSeconds: 20 + ## @md | `livenessProbe.periodSeconds` | how often (in seconds) to perform the probe | 60 | + periodSeconds: 60 + ## @md | `livenessProbe.failureThreshold` | when a probe fails, Kubernetes will try failureThreshold times before giving up | 1 | + failureThreshold: 1 + ## @md | `livenessProbe.namespaceName` | the Chronicle namespace in which the probe operates | default | + namespaceName: default + ## @md | `livenessProbe.namespaceUuid` | the UUID of the Chronicle namespace in which the probe operates | fd717fd6-70f1-44c1-81de-287d5e101089 | + namespaceUuid: fd717fd6-70f1-44c1-81de-287d5e101089 + +## @md | `startUpProbe.enabled` | if true, enables the startup probe | true | +startUpProbe: + enabled: false + ## @md | `startUpProbe.initialDelaySeconds` | number of seconds after which the probe starts | 5 | + initialDelaySeconds: 5 + ## @md | `startUpProbe.failureThreshold` | when a probe fails, Kubernetes will try failureThreshold times before giving up | 30 | + failureThreshold: 30 + ## @md | `startUpProbe.periodSeconds` | how often (in seconds) to perform the probe | 10 | + periodSeconds: 10 + ## @md | `startUpProbe.timeoutSeconds` | number of seconds after which the probe times out | 3 | + timeoutSeconds: 3 + ## @md | `startUpProbe.namespaceName` | the Chronicle namespace in which the probe operates | default | + namespaceName: default + ## @md | `startUpProbe.namespaceUuid` | the UUID of the Chronicle namespace in which the probe operates | fd717fd6-70f1-44c1-81de-287d5e101089 | + namespaceUuid: fd717fd6-70f1-44c1-81de-287d5e101089 + ## @md | `backtraceLevel` | backtrace level for Chronicle | nil | backtraceLevel: full @@ -134,7 +164,7 @@ test: ## @md | `test.api` | test the chronicle GraphQL server API | api: ## @md | `test.api.enabled` | true to enable api-test Jobs and Services | true | - enabled: true + enabled: false ## @md | `test.api.image` | the image to use for the api-test container | blockchaintp/chronicle-helm-api-test | image: ## @md | `test.api.image.pullPolicy` | the image pull policy | IfNotPresent | diff --git a/charts/chronicle/Chart.yaml b/charts/chronicle/Chart.yaml index 154b42cd..5580d287 100644 --- a/charts/chronicle/Chart.yaml +++ b/charts/chronicle/Chart.yaml @@ -1,6 +1,6 @@ --- apiVersion: v2 -name: chronicle +name: chronicle-on-sawtooth description: | Chronicle is an open-source, blockchain-backed, domain-agnostic provenance product. Chronicle makes it easy for users to record and query immutable @@ -17,7 +17,7 @@ keywords: # This is the chart version. This version number should be incremented each # time you make changes to the chart and its templates, including the app # version. -version: 0.1.23 +version: 0.1.24 # This is the version number of Chronicle being deployed. This version # number should be incremented each time you make changes to Chronicle. diff --git a/charts/chronicle/README.md b/charts/chronicle/README.md index 684cb403..6bc73c0b 100644 --- a/charts/chronicle/README.md +++ b/charts/chronicle/README.md @@ -1,4 +1,4 @@ -# Chronicle +# Chronicle on Hyperledger Sawtooth | field | description | default | |-|-|-| @@ -51,6 +51,8 @@ | `test.api.image.pullPolicy` | the image pull policy | IfNotPresent | | `test.api.image.repository` | the image repository | blockchaintp/chronicle-helm-api-test | | `test.api.image.tag` | the image tag | latest | +| `test.auth` | test the chronicle auth server API | +| `test.auth.enabled` | true to enable auth-related testing | true | | `test.auth.token` | provide a token for auth-related testing | nil | | `postgres.enabled` | if true create an internal postgres instance | boolean | true | | `postgres.env` | postgres environment variables | map | N/A | @@ -85,3 +87,19 @@ | `tp.maxUnavailable` | maximum unavailable nodes during a rolling upgrade | | `tp.minReadySeconds` | minimum time before node becomes available | | `sawtooth` | sawtooth options may be configured | see [Sawtooth](../sawtooth/README.md) | +| `livenessProbe.enabled` | if true, enables the liveness probe | false | +| `livenessProbe.initialDelaySeconds` | delay before liveness probe is initiated | 30 | +| `livenessProbe.periodSeconds` | how often to perform the probe | 10 | +| `livenessProbe.timeoutSeconds` | when the probe times out | 1 | +| `livenessProbe.failureThreshold` | how many times to retry the probe before giving up | 3 | +| `livenessProbe.successThreshold` | how many times the probe must report success to be considered successful after having failed | 1 | +| `livenessProbe.namespaceName` | the namespace name for the liveness probe | "default" | +| `livenessProbe.namespaceUuid` | the namespace UUID for the liveness probe | "fd717fd6-70f1-44c1-81de-287d5e101089" | +| `startupProbe.enabled` | if true, enables the startup probe | false | +| `startupProbe.initialDelaySeconds` | delay before startup probe is initiated | 10 | +| `startupProbe.periodSeconds` | how often to perform the probe | 10 | +| `startupProbe.timeoutSeconds` | when the probe times out | 1 | +| `startupProbe.failureThreshold` | how many times to retry the probe before giving up | 3 | +| `startupProbe.successThreshold` | how many times the probe must report success to be considered successful after having failed | 1 | +| `startupProbe.namespaceName` | the namespace name for the startup probe | "default" | +| `startupProbe.namespaceUuid` | the namespace UUID for the startup probe | "fd717fd6-70f1-44c1-81de-287d5e101089" | diff --git a/charts/chronicle/app-readme.md b/charts/chronicle/app-readme.md index eb862a2f..02201a72 100644 --- a/charts/chronicle/app-readme.md +++ b/charts/chronicle/app-readme.md @@ -1,10 +1,12 @@ +# Chronicle on Hyperledger Sawtooth + Chronicle records provenance information of any physical or digital asset on a distributed ledger. - Chronicle is available with Hyperledger Sawtooth as its default backing ledger. - Chronicle is built on the established W3C PROV Ontology standard; it uses the lightweight JSON-LD linked data format, and the data query language GraphQL. - Chronicle is easily adaptable to enable users to model, capture, and query provenance information pertinent to their industry, application and use case. -You can find example domains and further instructions at https://examples.btp.works +You can find example domains and further instructions at ## *Important* diff --git a/charts/chronicle/templates/statefulset.yaml b/charts/chronicle/templates/statefulset.yaml index 96ac24fb..fa7d4cbd 100644 --- a/charts/chronicle/templates/statefulset.yaml +++ b/charts/chronicle/templates/statefulset.yaml @@ -153,6 +153,106 @@ spec: - name: chronicle-data mountPath: /var/lib/chronicle/store/ {{- include "lib.volumeMounts" .Values.extraVolumeMounts | nindent 12 }} + {{- if .Values.livenessProbe.enabled }} + livenessProbe: + exec: + command: + - bash + - -c + - | + PROBE_ID="startup_$(LC_ALL=C tr -dc A-Za-z0-9 /tmp/import.json && + echo "Probe ID: $PROBE_ID" && + chronicle \ + -c /etc/chronicle/config/config.toml \ + --console-logging json \ + --sawtooth tcp://{{ include "chronicle.sawtooth.service" . }}:{{ include "chronicle.sawtooth.sawcomp" . }} \ + --remote-database \ + --database-name {{ .Values.postgres.database }} \ + --database-username {{ .Values.postgres.user }} \ + --database-host {{ .Values.postgres.host }} \ + {{- if not .Values.opa.enabled }} + --embedded-opa-policy \ + {{- end }} + import {{ .Values.livenessProbe.namespaceName }} {{ .Values.livenessProbe.namespaceUuid }} < /tmp/import.json + initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.livenessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }} + failureThreshold: {{ .Values.livenessProbe.failureThreshold }} + {{- end }} + {{- if .Values.startUpProbe.enabled }} + startupProbe: + exec: + command: + - bash + - -c + - | + PROBE_ID="startup_$(LC_ALL=C tr -dc A-Za-z0-9 /tmp/import.json && + echo "Probe ID: $PROBE_ID" && + chronicle \ + -c /etc/chronicle/config/config.toml \ + --console-logging json \ + --sawtooth tcp://{{ include "chronicle.sawtooth.service" . }}:{{ include "chronicle.sawtooth.sawcomp" . }} \ + --remote-database \ + --database-name {{ .Values.postgres.database }} \ + --database-username {{ .Values.postgres.user }} \ + --database-host {{ .Values.postgres.host }} \ + {{- if not .Values.opa.enabled }} + --embedded-opa-policy \ + {{- end }} + import {{ .Values.startUpProbe.namespaceName }} {{ .Values.startUpProbe.namespaceUuid }} < /tmp/import.json + initialDelaySeconds: {{ .Values.startUpProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.startUpProbe.periodSeconds }} + timeoutSeconds: {{ .Values.startUpProbe.timeoutSeconds }} + failureThreshold: {{ .Values.startUpProbe.failureThreshold }} + {{- end }} volumes: - name: chronicle-secrets persistentVolumeClaim: @@ -163,10 +263,10 @@ spec: - name: chronicle-config configMap: name: {{ .Release.Name }}-chronicle-config -{{- if not .Values.postgres.persistence.enabled }} + {{- if not .Values.postgres.persistence.enabled }} - name: "pgdata" emptyDir: {} -{{- end }} + {{- end }} volumeClaimTemplates: - metadata: name: chronicle-data @@ -176,7 +276,7 @@ spec: resources: requests: storage: 6Gi -{{- if .Values.postgres.persistence.enabled }} + {{- if .Values.postgres.persistence.enabled }} - metadata: name: "pgdata" annotations: {{- include "lib.safeToYaml" .Values.postgres.persistence.annotations | nindent 10 }} @@ -186,4 +286,4 @@ spec: resources: requests: storage: {{ .Values.postgres.persistence.size | quote }} -{{- end }} + {{- end }} diff --git a/charts/chronicle/values.yaml b/charts/chronicle/values.yaml index ca63ad91..0159d7d8 100644 --- a/charts/chronicle/values.yaml +++ b/charts/chronicle/values.yaml @@ -22,6 +22,36 @@ auth: userinfo: url: +## @md | `livenessProbe.enabled` | if true, enables the liveness probe | false | +livenessProbe: + enabled: false + ## @md | `livenessProbe.timeoutSeconds` | number of seconds after which the probe times out | 10 | + timeoutSeconds: 20 + ## @md | `livenessProbe.periodSeconds` | how often (in seconds) to perform the probe | 60 | + periodSeconds: 60 + ## @md | `livenessProbe.failureThreshold` | when a probe fails, Kubernetes will try failureThreshold times before giving up | 1 | + failureThreshold: 1 + ## @md | `livenessProbe.namespaceName` | the Chronicle namespace in which the probe operates | default | + namespaceName: default + ## @md | `livenessProbe.namespaceUuid` | the UUID of the Chronicle namespace in which the probe operates | fd717fd6-70f1-44c1-81de-287d5e101089 | + namespaceUuid: fd717fd6-70f1-44c1-81de-287d5e101089 + +## @md | `startUpProbe.enabled` | if true, enables the startup probe | true | +startUpProbe: + enabled: false + ## @md | `startUpProbe.initialDelaySeconds` | number of seconds after which the probe starts | 5 | + initialDelaySeconds: 5 + ## @md | `startUpProbe.failureThreshold` | when a probe fails, Kubernetes will try failureThreshold times before giving up | 30 | + failureThreshold: 30 + ## @md | `startUpProbe.periodSeconds` | how often (in seconds) to perform the probe | 10 | + periodSeconds: 10 + ## @md | `startUpProbe.timeoutSeconds` | number of seconds after which the probe times out | 3 | + timeoutSeconds: 3 + ## @md | `startUpProbe.namespaceName` | the Chronicle namespace in which the probe operates | default | + namespaceName: default + ## @md | `startUpProbe.namespaceUuid` | the UUID of the Chronicle namespace in which the probe operates | fd717fd6-70f1-44c1-81de-287d5e101089 | + namespaceUuid: fd717fd6-70f1-44c1-81de-287d5e101089 + ## @md | `backtraceLevel` | backtrace level for Chronicle | nil | backtraceLevel: full @@ -134,7 +164,7 @@ test: ## @md | `test.api` | test the chronicle GraphQL server API | api: ## @md | `test.api.enabled` | true to enable api-test Jobs and Services | true | - enabled: true + enabled: false ## @md | `test.api.image` | the image to use for the api-test container | blockchaintp/chronicle-helm-api-test | image: ## @md | `test.api.image.pullPolicy` | the image pull policy | IfNotPresent |