Skip to content

Commit

Permalink
Merge pull request #257 from blockchaintp/feature/chronicle-liveness-…
Browse files Browse the repository at this point in the history
…probe

Merge in liveness probe functionality from chronicle chart
  • Loading branch information
ryan-s-roberts committed Apr 22, 2024
2 parents e8e3656 + b655cd8 commit be1bc3d
Show file tree
Hide file tree
Showing 10 changed files with 316 additions and 20 deletions.
2 changes: 1 addition & 1 deletion charts/chronicle-on-sawtooth/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 17 additions & 1 deletion charts/chronicle-on-sawtooth/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Chronicle
# Chronicle on Hyperledger Sawtooth

| field | description | default |
|-|-|-|
Expand Down Expand Up @@ -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" |
4 changes: 2 additions & 2 deletions charts/chronicle-on-sawtooth/app-readme.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# BTP Chronicle
# 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 <https://examples.btp.works>

## *Important*

Expand Down
112 changes: 106 additions & 6 deletions charts/chronicle-on-sawtooth/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 }}
Expand All @@ -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 </dev/urandom | head -c 13)" &&
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ") &&
echo '[
{
"@id": "_:n1",
"@type": [
"http://btp.works/chronicleoperations/ns#ActivityExists"
],
"http://btp.works/chronicleoperations/ns#activityName": [
{
"@value": "'"$PROBE_ID"'"
}
],
"http://btp.works/chronicleoperations/ns#namespaceName": [
{
"@value": "{{ .Values.livenessProbe.namespaceName }}"
}
],
"http://btp.works/chronicleoperations/ns#namespaceUuid": [
{
"@value": "{{ .Values.livenessProbe.namespaceUuid }}"
}
]
}
]' > /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 </dev/urandom | head -c 13)" &&
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ") &&
echo '[
{
"@id": "_:n1",
"@type": [
"http://btp.works/chronicleoperations/ns#ActivityExists"
],
"http://btp.works/chronicleoperations/ns#activityName": [
{
"@value": "'"$PROBE_ID"'"
}
],
"http://btp.works/chronicleoperations/ns#namespaceName": [
{
"@value": "{{ .Values.startUpProbe.namespaceName }}"
}
],
"http://btp.works/chronicleoperations/ns#namespaceUuid": [
{
"@value": "{{ .Values.startUpProbe.namespaceUuid }}"
}
]
}
]' > /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:
Expand All @@ -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
Expand All @@ -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 }}
Expand All @@ -186,4 +286,4 @@ spec:
resources:
requests:
storage: {{ .Values.postgres.persistence.size | quote }}
{{- end }}
{{- end }}
32 changes: 31 additions & 1 deletion charts/chronicle-on-sawtooth/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 |
Expand Down
4 changes: 2 additions & 2 deletions charts/chronicle/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
Expand Down
20 changes: 19 additions & 1 deletion charts/chronicle/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Chronicle
# Chronicle on Hyperledger Sawtooth

| field | description | default |
|-|-|-|
Expand Down Expand Up @@ -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 |
Expand Down Expand Up @@ -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" |
4 changes: 3 additions & 1 deletion charts/chronicle/app-readme.md
Original file line number Diff line number Diff line change
@@ -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 <https://examples.chronicle.works>

## *Important*

Expand Down
Loading

0 comments on commit be1bc3d

Please sign in to comment.