Skip to content

Commit 6869451

Browse files
committed
Improve friendbot helm chart
The changes should be backwards compatible * add support for pre-existing secret * move non-sensitive config from a Secret to a ConfigMap * add support for otel config options * add support for using rpc_url * add support for using fund_contract_addresses * add support for adding Deployment annotations * add support for non-standard deployment strategy * add support for setting ingressClassName
1 parent 598647a commit 6869451

7 files changed

Lines changed: 117 additions & 25 deletions

File tree

charts/friendbot/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v2
22
name: friendbot
33
description: This chart will deploy friendbot to your private network
4-
version: 0.0.3
4+
version: 0.0.4
55
appVersion: "bbdf3132"
66
maintainers:
77
- name: Stellar Development Foundation

charts/friendbot/templates/_helpers.tpl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,12 @@
2222
{{- define "common.friendbotImage" -}}
2323
{{ .Values.global.image.friendbot.registry }}/{{ .Values.global.image.friendbot.repository }}:{{ .Values.global.image.friendbot.tag | default .Chart.AppVersion }}
2424
{{- end -}}
25+
26+
{{- define "friendbot.secretName" -}}
27+
{{- $friendbotSecret := get .Values.friendbot "secret" | default dict -}}
28+
{{- if (get $friendbotSecret "existingSecret") -}}
29+
{{- get $friendbotSecret "existingSecret" -}}
30+
{{- else -}}
31+
{{- printf "%s-secret" (include "common.fullname" .) -}}
32+
{{- end -}}
33+
{{- end -}}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: {{ template "common.fullname" . }}-config
6+
{{- if .Release.Namespace }}
7+
namespace: {{ .Release.Namespace }}
8+
{{- end }}
9+
labels:
10+
app: {{ template "common.fullname" . }}
11+
chart: {{ template "common.chart" . }}
12+
release: {{ .Release.Name }}
13+
heritage: {{ .Release.Service }}
14+
data:
15+
friendbot.conf: |
16+
{{- $config := .Values.friendbot.configmap | default dict }}
17+
{{- $horizonUrl := coalesce .Values.friendbot.configmap.horizon_url .Values.global.horizonUrl (printf "%s-horizon-ingest" .Release.Name) }}
18+
port = {{ .Values.friendbot.configmap.port | default 8000 }}
19+
network_passphrase = {{ .Values.global.networkPassphrase | quote }}
20+
{{- if .Values.friendbot.configmap.rpc_url }}
21+
rpc_url = {{ .Values.friendbot.configmap.rpc_url | quote }}
22+
{{- else }}
23+
horizon_url = {{ $horizonUrl | quote }}
24+
{{- end }}
25+
starting_balance = {{ .Values.friendbot.configmap.starting_balance | default 10000 | quote }}
26+
num_minions = {{ .Values.friendbot.configmap.num_minions | default 1000 }}
27+
base_fee = {{ .Values.friendbot.configmap.base_fee | default 100000 }}
28+
minion_batch_size = {{ .Values.friendbot.configmap.minion_batch_size | default 50 }}
29+
submit_tx_retries_allowed = {{ .Values.friendbot.configmap.submit_tx_retries_allowed | default .Values.friendbot.configmap.tx | default 5 }}
30+
{{- if hasKey $config "otel_enabled" }}
31+
otel_enabled = {{ .Values.friendbot.configmap.otel_enabled }}
32+
{{- end }}
33+
{{- if .Values.friendbot.configmap.otel_enabled }}
34+
otel_endpoint = {{ required "Set friendbot.configmap.otel_endpoint when friendbot.configmap.otel_enabled=true" .Values.friendbot.configmap.otel_endpoint | quote }}
35+
{{- end }}
36+
{{- if hasKey $config "fund_contract_addresses" }}
37+
fund_contract_addresses = {{ .Values.friendbot.configmap.fund_contract_addresses }}
38+
{{- end }}

charts/friendbot/templates/friendbot-deployment.yaml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,23 @@ metadata:
1313
chart: {{ template "common.chart" . }}
1414
release: {{ .Release.Name }}
1515
heritage: {{ .Release.Service }}
16+
{{- if (.Values.friendbot.deployment).deploymentAnnotations }}
17+
annotations:
18+
{{- range $key, $value := .Values.friendbot.deployment.deploymentAnnotations }}
19+
{{ $key }}: {{ $value | quote }}
20+
{{- end }}
21+
{{- end }}
1622
spec:
1723
replicas: {{ .Values.friendbot.deployment.container.replicaCount }}
1824
selector:
1925
matchLabels:
2026
app: {{ template "common.fullname" . }}
2127
strategy:
28+
{{- if .Values.friendbot.deployment.strategy }}
29+
{{- toYaml .Values.friendbot.deployment.strategy | nindent 4 }}
30+
{{- else }}
2231
type: RollingUpdate
32+
{{- end }}
2333
template:
2434
metadata:
2535
labels:
@@ -50,6 +60,9 @@ spec:
5060
{{- end }}
5161
{{- end }}
5262
imagePullPolicy: {{ .Values.global.image.friendbot.pullPolicy }}
63+
ports:
64+
- containerPort: {{ .Values.friendbot.service.targetport | default 8004 }}
65+
protocol: TCP
5366
startupProbe:
5467
tcpSocket:
5568
port: {{ .Values.friendbot.deployment.container.startupProbe.tcpSocketPort }}
@@ -58,10 +71,20 @@ spec:
5871
periodSeconds: {{ .Values.friendbot.deployment.container.startupProbe.periodSeconds }}
5972
timeoutSeconds: {{ .Values.friendbot.deployment.container.startupProbe.timeoutSeconds }}
6073
volumeMounts:
61-
- name: config-volume
62-
mountPath: /config
74+
- name: friendbot-secret
75+
mountPath: /secret
76+
readOnly: true
77+
- name: friendbot-conf
78+
mountPath: /config/friendbot.conf
79+
subPath: friendbot.conf
6380
readOnly: true
6481
volumes:
65-
- name: config-volume
82+
- name: friendbot-secret
6683
secret:
67-
secretName: {{ template "common.fullname" . }}-vol
84+
secretName: {{ include "friendbot.secretName" . }}
85+
- name: friendbot-conf
86+
configMap:
87+
name: {{ template "common.fullname" . }}-config
88+
items:
89+
- key: friendbot.conf
90+
path: friendbot.conf

charts/friendbot/templates/friendbot-ingress.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ metadata:
1313
{{- end }}
1414
{{- end }}
1515
spec:
16+
{{- if .Values.friendbot.ingress.ingressClassName }}
17+
ingressClassName: {{ .Values.friendbot.ingress.ingressClassName }}
18+
{{- end }}
1619
tls:
1720
- secretName: {{ template "common.fullname" . }}-cert
1821
hosts:
Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
{{- $friendbotSecret := get .Values.friendbot "secret" | default dict }}
2+
{{- $friendbotConfig := get .Values.friendbot "configmap" | default dict }}
3+
{{- $friendbotAccountSeed := coalesce (get $friendbotSecret "friendbotAccountSeed") (get $friendbotConfig "friendbotAccountSeed") "" }}
4+
{{- if not (get $friendbotSecret "existingSecret") }}
15
---
26
apiVersion: v1
37
kind: Secret
48
metadata:
5-
name: {{ template "common.fullname" . }}-vol
9+
name: {{ include "friendbot.secretName" . }}
610
{{- if .Release.Namespace }}
711
namespace: {{ .Release.Namespace }}
812
{{- end }}
@@ -12,17 +16,6 @@ metadata:
1216
release: {{ .Release.Name }}
1317
heritage: {{ .Release.Service }}
1418
stringData:
15-
friendbot.conf: |
16-
port = {{ .Values.friendbot.configmap.port | default 8000 }}
17-
friendbot_secret = {{ .Values.friendbot.configmap.friendbotAccountSeed | quote }}
18-
network_passphrase = {{ .Values.global.networkPassphrase | quote }}
19-
starting_balance = {{ .Values.friendbot.configmap.starting_balance | default 10000 | quote }}
20-
num_minions = {{ .Values.friendbot.configmap.num_minions | default 1000 }}
21-
base_fee = {{ .Values.friendbot.configmap.base_fee | default 100000 }}
22-
minion_batch_size = {{ .Values.friendbot.configmap.minion_batch_size | default 50 }}
23-
submit_tx_retries_allowed = {{ .Values.friendbot.configmap.submit_tx_retries_allowed | default .Values.friendbot.configmap.tx | default 5 }}
24-
{{- if (.Values.global).horizonUrl }}
25-
horizon_url = {{ .Values.global.horizonUrl | quote }}
26-
{{- else }}
27-
horizon_url = {{ .Release.Name }}-horizon-ingest
28-
{{- end }}
19+
secret.conf: |
20+
friendbot_secret = {{ required "Set friendbot.secret.existingSecret or set friendbot.secret.friendbotAccountSeed (legacy fallback: friendbot.configmap.friendbotAccountSeed)" $friendbotAccountSeed | quote }}
21+
{{- end }}

charts/friendbot/values.yaml

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,19 @@ friendbot:
2121
# serviceAccountName: default
2222

2323
deployment:
24+
# deploymentAnnotations:
25+
# reloader.stakater.com/auto: "true"
26+
strategy:
27+
type: RollingUpdate
28+
# rollingUpdate:
29+
# maxUnavailable: 0
30+
# maxSurge: 1
2431
container:
2532
cliArgs:
2633
- --conf
2734
- /config/friendbot.conf
35+
- --secret
36+
- /secret/secret.conf
2837
replicaCount: 1
2938
startupProbe:
3039
tcpSocketPort: 8004
@@ -44,18 +53,35 @@ friendbot:
4453
targetport: 8004
4554

4655
ingress:
47-
# port: 80
48-
#annotations:
49-
# kubernetes.io/ingress.class: "public"
50-
# cert-manager.io/cluster-issuer: "default"
5156
host: "friendbot.example.com"
57+
# ingressClassName: ""
58+
# port: 80
59+
# annotations:
60+
# cert-manager.io/cluster-issuer: "default"
61+
62+
secret:
63+
## Friendbot requires account seed to be configured. This can be provided using two mutually exclusive ways:
64+
## 1. Using the friendbotAccountSeed value. The chart will create secret with the required content
65+
## If not set, chart falls back to legacy friendbot.configmap.friendbotAccountSeed
66+
## 2. Using the existingSecret value. The chart will mount the secret in the Deployment.
67+
## Required format for existingSecret:
68+
## - Secret must contain a key named `secret.conf`
69+
## - That key is mounted as /secret/secret.conf (used by container args)
70+
## - secret.conf content must use: friendbot_secret = "<stellar_secret_seed>"
71+
# friendbotAccountSeed: "XXXXXXX"
72+
# existingSecret: ""
5273

5374
configmap:
5475
port: 8000
55-
# friendbotAccountSeed: "XXXXXXX" # this comes from stellar-network parent chart
76+
# friendbotAccountSeed: "XXXXXXX" # legacy fallback; prefer friendbot.secret.friendbotAccountSeed
77+
# otel_enabled: false
78+
# otel_endpoint: "http://otel-collector:4318"
79+
# rpc_url: "https://soroban-rpc.example.com"
80+
# horizon_url: "https://horizon-testnet.stellar.org"
5681
# starting_balance: 10000
5782
# num_minions: 1000
5883
# base_fee: 10000
5984
# minion_batch_size: 50
6085
# submit_tx_retries_allowed: 5
86+
# fund_contract_addresses: true
6187

0 commit comments

Comments
 (0)