Skip to content

Commit

Permalink
feat(daml-on-sawtooth): fully refactor chart
Browse files Browse the repository at this point in the history
Replacing sawtooth declarations with sawtooth dependency, and
dividing up services cleanly

* fix(daml-on-sawtooth): use templates for labels and names
* fix(daml-on-sawtooth): remove items replaced by dependency
* feat(daml-on-sawtooth): fully refactor chart into individual services
* fix(daml-on-sawtooth): add authToken parameter

Signed-off-by: Kevin O'Donnell <kevin@blockchaintp.com>
  • Loading branch information
scealiontach committed Oct 13, 2021
1 parent b7a4bb2 commit 869b0af
Show file tree
Hide file tree
Showing 31 changed files with 667 additions and 1,883 deletions.
7 changes: 5 additions & 2 deletions charts/daml-on-sawtooth/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ dependencies:
- name: standard-defs
repository: https://btp-charts-stable.s3.amazonaws.com/charts/
version: 0.1.2
digest: sha256:b072a3f7726bb97088f486103c12d3c8c01d81b31e72bd972b93fbd61f4adb85
generated: "2021-10-09T05:31:32.23547771Z"
- name: sawtooth
repository: https://btp-charts-unstable.s3.amazonaws.com/charts/
version: 0.2.6
digest: sha256:144958c37f681b00c1ec3fc9b6c3e2de712b9e33d3f1b50ec24497332c0162f8
generated: "2021-10-12T15:18:18.753793876Z"
5 changes: 4 additions & 1 deletion charts/daml-on-sawtooth/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type: application
# 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.62
version: 0.2.0

# This is the version number of the application being deployed. This version
# number should be incremented each time you make changes to the application.
Expand All @@ -29,3 +29,6 @@ dependencies:
- name: standard-defs
version: ~0.1.0
repository: https://btp-charts-stable.s3.amazonaws.com/charts/
- name: sawtooth
version: ~0.2.0
repository: https://btp-charts-unstable.s3.amazonaws.com/charts/
2 changes: 1 addition & 1 deletion charts/daml-on-sawtooth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
| field | description | type | default |
|-|-|-|-|
| `affinity` | group of affinity related parameters | map | N/A |
| `affinity.enabled` | false: no efffect true: then validators will be deployed only to k8s nodes with the label `app={{.sawtooth.networkName}}-validator` | boolean | false |
| `affinity.enabled` | false: no efffect true: then validators will be deployed only to k8s nodes with the label `app={{ .sawtooth.networkName }}-validator` | boolean | false |
| `imagePullSecrets` | group of image pull secrets related parameters | map | N/A |
| `imagePullSecrets.enabled` | if true use the list of named imagePullSecrests | boolean | false |
| `imagePullSecrets.value` | a list if named secret references of the form ```- name: secretName```| list | [] |
Expand Down
2 changes: 1 addition & 1 deletion charts/daml-on-sawtooth/sextant/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const form = [
{
id: 'affinity.enabled',
title: 'Affinity',
helperText: 'If enabled - pods will only deploy to nodes that have the label: app={{.sawtooth.networkName}}-validator',
helperText: 'If enabled - pods will only deploy to nodes that have the label: app={{ .sawtooth.networkName }}-validator',
component: 'radio',
default: false,
dataType: 'boolean',
Expand Down
82 changes: 82 additions & 0 deletions charts/daml-on-sawtooth/templates/_daml.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@

{{- define "daml.labels.appLabels" -}}
app: {{ include "common.names.fullname" . }}
daml: {{ include "common.names.fullname" . }}
{{- end -}}

{{- define "daml.labels" -}}
{{ include "lib.labels" . }}
{{ include "daml.labels.appLabels" . }}
{{- end -}}

{{- define "daml.labels.matchLabels" -}}
{{ include "common.labels.matchLabels" . }}
{{ include "daml.labels.appLabels" . }}
{{- end -}}

{{- define "daml.kind" -}}
{{ include "lib.call-nested" (list . "sawtooth" "sawtooth.kind") }}
{{- end -}}

{{- define "daml.replicas" -}}
{{ include "lib.call-nested" (list . "sawtooth" "sawtooth.replicas") | int }}
{{- end -}}

{{- define "daml.sawtooth.sawcomp" -}}
{{ include "lib.call-nested" (list . "sawtooth" "sawtooth.ports.sawcomp") | int }}
{{- end -}}

{{- define "daml.sawtooth.service" -}}
{{- $svc := include "lib.call-nested" (list . "sawtooth" "common.names.fullname") -}}
{{- $ns := .Release.Namespace -}}
{{- $domain := "svc.cluster.local" -}}
{{ printf "%s.%s.%s" $svc $ns $domain }}
{{- end -}}

{{- define "daml.trigger.service.name" -}}
{{- $svc := include "common.names.fullname" . -}}
{{ printf "%s-triggers" $svc }}
{{- end -}}

{{- define "daml.jsonapi.service.name" -}}
{{- $svc := include "common.names.fullname" . -}}
{{ printf "%s-jsonapi" $svc }}
{{- end -}}

{{- define "daml.tp.service.name" -}}
{{- $svc := include "common.names.fullname" . -}}
{{ printf "%s-tp" $svc }}
{{- end -}}

{{- define "daml.service.name" -}}
{{- $svc := include "common.names.fullname" . -}}
{{ printf "%s" $svc }}
{{- end -}}

{{- define "daml.service" -}}
{{- $svc := include "daml.service.name" . -}}
{{- $ns := .Release.Namespace -}}
{{- $domain := "svc.cluster.local" -}}
{{ printf "%s.%s.%s" $svc $ns $domain }}
{{- end -}}


{{- define "daml.field.node" -}}
{{ $kind := include "daml.kind" . }}
{{- if eq $kind "DaemonSet" -}}
spec.nodeName
{{- else -}}
metadata.name
{{- end -}}
{{- end -}}}

{{/*
Return the participant id to be used in this chart
*/}}
{{- define "daml.participantId" -}}
{{- if .Values.participantId -}}
{{- .Values.participantId -}}
{{- else -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
24 changes: 0 additions & 24 deletions charts/daml-on-sawtooth/templates/_helpers.tpl

This file was deleted.

23 changes: 8 additions & 15 deletions charts/daml-on-sawtooth/templates/cert-job.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
apiVersion: batch/v1
kind: Job
metadata:
name: {{.Values.sawtooth.networkName}}-cert
namespace: {{.Release.Namespace}}
labels:
app: {{.Values.sawtooth.networkName}}-daml-rpc
daml: {{.Values.sawtooth.networkName}}-daml-rpc
name: {{ include "common.names.fullname" . }}-cert
labels: {{ include "daml.labels" . | nindent 4 }}
annotations:
helm.sh/hook: post-install
helm.sh/hook-weight: "-5"
Expand All @@ -15,17 +12,14 @@ spec:
completions: 1
template:
metadata:
labels:
app: {{.Values.sawtooth.networkName}}-daml-rpc
daml: {{.Values.sawtooth.networkName}}-daml-rpc
labels: {{ include "daml.labels" . | nindent 8 }}
spec:
serviceAccountName: {{.Values.sawtooth.networkName}}-sa
serviceAccountName: {{ include "lib.serviceAccountName" . }}
automountServiceAccountToken: true
restartPolicy: Never
containers:
- name: openssl
image: "{{.Values.openssl.image.repository }}:{{ .Values.openssl.image.tag }}"
imagePullPolicy: {{ .Values.daml.image.imagePullPolicy }}
{{- include "lib.image" (dict "imageRoot" .Values.openssl.image "global" .Values.global ) | nindent 10 }}
volumeMounts:
- name: scratch
mountPath: /scratch
Expand All @@ -42,8 +36,7 @@ spec:
-newkey rsa:1024 -keyout jwt.key -out jwt.crt
touch /scratch/openssl.done
- name: k8s
image: "{{.Values.k8s.image.repository }}:{{ .Values.k8s.image.tag }}"
imagePullPolicy: {{ .Values.daml.image.imagePullPolicy }}
{{- include "lib.image" (dict "imageRoot" .Values.k8s.image "global" .Values.global ) | nindent 10 }}
volumeMounts:
- name: scratch
mountPath: /scratch
Expand All @@ -61,13 +54,13 @@ spec:
fi
sleep 1
done
kubectl get secret {{.Values.sawtooth.networkName}}-cert
kubectl get secret {{ include "common.names.fullname" . }}-cert
if [ $? -eq 0 ]; then
exit 0
fi
kubectl create secret generic \
--namespace {{ .Release.Namespace }} \
{{.Values.sawtooth.networkName}}-cert \
{{ include "common.names.fullname" . }}-cert \
--from-file=/scratch/rsa
volumes:
- name: scratch
Expand Down
28 changes: 0 additions & 28 deletions charts/daml-on-sawtooth/templates/daml-rpc-service.yaml

This file was deleted.

Loading

0 comments on commit 869b0af

Please sign in to comment.