Skip to content

Commit

Permalink
Dev/beeconfig to raw configmap (#182)
Browse files Browse the repository at this point in the history
* first version bee helm chart 0.12

* changes

* chore: all config put in configmap

* chore: fix linting

* chore: fix linting

* chore: rename addr to port

* fix: ct install

* removed secret and bee password from beeConfig

Co-authored-by: Ivan Vandot <[email protected]>
  • Loading branch information
aleksandarknezevic and vandot authored May 17, 2022
1 parent daef4fa commit 7fe41a1
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 207 deletions.
6 changes: 3 additions & 3 deletions charts/bee/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: v2
appVersion: latest
appVersion: 1.6.0
name: bee
version: 0.11.9
kubeVersion: ">=1.15.0-0"
version: 0.12.0
kubeVersion: ">=1.19.0-0"
description: Ethereum Swarm Bee Helm chart for Kubernetes
home: https://www.ethswarm.org
icon: https://docs.ethswarm.org/img/swarm-logo-2.svg
Expand Down
4 changes: 4 additions & 0 deletions charts/bee/ci/ct-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
probesEnable: false

beeConfig:
swap-endpoint: https://rpc.gnosischain.com/
39 changes: 24 additions & 15 deletions charts/bee/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,12 @@ Create the name of the service account to use.
{{- end -}}
{{- end -}}

{{/*
Get the password secret.
*/}}
{{- define "bee.secretName" -}}
{{- if .Values.beeConfig.existingSecret -}}
{{- printf "%s" .Values.beeConfig.existingSecret -}}
{{- else -}}
{{- printf "%s" (include "bee.fullname" .) -}}
{{- end -}}
{{- end -}}

{{/*
Get the password key to be retrieved from the secret.
*/}}
{{- define "bee.secretPasswordKey" -}}
{{- if and .Values.beeConfig.existingSecret .Values.beeConfig.existingSecretPasswordKey -}}
{{- printf "%s" .Values.beeConfig.existingSecretPasswordKey -}}
{{- if and .Values.existingSecret .Values.existingSecretPasswordKey -}}
{{- printf "%s" .Values.existingSecretPasswordKey -}}
{{- else -}}
{{- printf "password" -}}
{{- end -}}
Expand All @@ -127,13 +116,33 @@ Get the password key to be retrieved from the secret.
Return Bee password.
*/}}
{{- define "bee.password" -}}
{{- if not (empty .Values.beeConfig.password) }}
{{- .Values.beeConfig.password -}}
{{- if not (empty .Values.password) }}
{{- .Values.password -}}
{{- else -}}
{{- randAlphaNum 10 -}}
{{- end -}}
{{- end -}}

{{/*
Define config parameters api-addr, debug-api-addr, debug-api-enable, p2p-addr
*/}}
{{- define "bee.config.api_port" -}}
{{- $full_api_addr := index .Values.beeConfig "api-addr" -}}
{{- $api_port := (split ":" $full_api_addr )._1 }}
{{- printf "%s" $api_port -}}
{{- end -}}
{{- define "bee.config.debug_api_port" -}}
{{- $full_debug_api_addr := index .Values.beeConfig "debug-api-addr" -}}
{{- $debug_api_port := (split ":" $full_debug_api_addr )._1 }}
{{- printf "%s" $debug_api_port -}}
{{- end -}}
{{- define "bee.config.p2p_port" -}}
{{- $full_p2p_addr := index .Values.beeConfig "p2p-addr" -}}
{{- $p2p_port := (split ":" $full_p2p_addr )._1 }}
{{- printf "%s" $p2p_port -}}
{{- end -}}


{{/*
Get the libp2pKeys secret.
*/}}
Expand Down
60 changes: 3 additions & 57 deletions charts/bee/templates/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,61 +8,7 @@ metadata:
{{- include "bee.labels" . | nindent 4 }}
data:
.bee.yaml: |+
allow-private-cidrs: {{ .Values.beeConfig.allow_private_cidrs }}
api-addr: {{ .Values.beeConfig.api_addr }}
block-time: {{ .Values.beeConfig.block_time }}
bootnode: {{ .Values.beeConfig.bootnode }}
bootnode-mode: {{ .Values.beeConfig.bootnode_mode }}
clef-signer-enable: {{ .Values.beeConfig.clef_signer_enable }}
clef-signer-endpoint: {{ .Values.beeConfig.clef_signer_endpoint }}
cors-allowed-origins: {{ .Values.beeConfig.cors_allowed_origins }}
data-dir: {{ .Values.beeConfig.data_dir }}
cache-capacity: {{ .Values.beeConfig.cache_capacity }}
db-open-files-limit: {{ .Values.beeConfig.db_open_files_limit }}
db-block-cache-capacity: {{ .Values.beeConfig.db_block_cache_capacity }}
db-write-buffer-size: {{ .Values.beeConfig.db_write_buffer_size }}
db-disable-seeks-compaction: {{ .Values.beeConfig.db_disable_seeks_compaction }}
debug-api-addr: {{ .Values.beeConfig.debug_api_addr }}
debug-api-enable: {{ .Values.beeConfig.debug_api_enable }}
full-node: {{ .Values.beeConfig.full_node }}
gateway-mode: {{ .Values.beeConfig.gateway_mode }}
mainnet: {{ .Values.beeConfig.mainnet }}
nat-addr: {{ .Values.beeConfig.nat_addr }}
network-id: {{ .Values.beeConfig.network_id }}
{{- if .Values.beeConfig.usePasswordFile }}
{{- range $k, $v := .Values.beeConfig }}
{{ $k | replace "_" "-" }}: {{ $v }}
{{- end }}
password-file: /home/bee/.secret/password
{{- else }}
password: {{ include "bee.password" . }}
{{- end }}
payment-early-percent: {{ .Values.beeConfig.payment_early_percent }}
payment-threshold: {{ .Values.beeConfig.payment_threshold }}
payment-tolerance-percent: {{ .Values.beeConfig.payment_tolerance_percent }}
postage-stamp-address: {{ .Values.beeConfig.postage_stamp_address }}
price-oracle-address: {{ .Values.beeConfig.price_oracle_address }}
p2p-addr: {{ .Values.beeConfig.p2p_addr }}
p2p-quic-enable: {{ .Values.beeConfig.p2p_quic_enable }}
p2p-ws-enable: {{ .Values.beeConfig.p2p_ws_enable }}
resolver-options: {{ .Values.beeConfig.resolver_options }}
resync: {{ .Values.beeConfig.resync }}
standalone: {{ .Values.beeConfig.standalone }}
swap-enable: {{ .Values.beeConfig.swap_enable }}
swap-endpoint: {{ .Values.beeConfig.swap_endpoint }}
swap-factory-address: {{ .Values.beeConfig.swap_factory_address }}
swap-legacy-factory-addresses: {{ .Values.beeConfig.swap_legacy_factory_addresses }}
swap-deployment-gas-price: {{ .Values.beeConfig.swap_deployment_gas_price }}
swap-initial-deposit: {{ .Values.beeConfig.swap_initial_deposit }}
tracing-enable: {{ .Values.beeConfig.tracing_enable }}
tracing-endpoint: {{ .Values.beeConfig.tracing_endpoint }}
tracing-service-name: {{ .Values.beeConfig.tracing_service_name }}
transaction: {{ .Values.beeConfig.transaction }}
use-postage-snapshot: {{ .Values.beeConfig.use_postage_snapshot }}
verbosity: {{ .Values.beeConfig.verbosity }}
warmup-time: {{ .Values.beeConfig.warmup_time }}
welcome-message: {{ .Values.beeConfig.welcome_message }}
{{- if .Values.beeConfig.bootnode_mode }}
static-nodes:
{{- range .Values.beeConfig.static_nodes }}
- {{ . }}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/bee/templates/ingress-debug.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and .Values.beeConfig.debug_api_enable .Values.ingressDebug.enabled -}}
{{- if and (index .Values.beeConfig "debug-api-enable") .Values.ingressDebug.enabled -}}

{{- $root := . -}}
{{- $fullName := include "bee.fullname" $root -}}
Expand Down
4 changes: 2 additions & 2 deletions charts/bee/templates/secret-password.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{{- if and .Values.beeConfig.usePasswordFile (not .Values.beeConfig.existingSecret) -}}
{{- if not .Values.existingSecret -}}
---
apiVersion: v1
kind: Secret
metadata:
name: {{ template "bee.fullname" . }}
name: {{ template "bee.fullname" . }}-password
namespace: {{ .Release.Namespace }}
labels:
{{- include "bee.labels" . | nindent 4 }}
Expand Down
1 change: 0 additions & 1 deletion charts/bee/templates/secret-swarmkeys.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ stringData:
{{- range $key, $val := .Values.swarmSettings.swarmKeys }}
{{ $key }}: {{ $val }}
{{- end }}
{{- end -}}
2 changes: 1 addition & 1 deletion charts/bee/templates/service-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ spec:
type: ClusterIP
ports:
- name: api
port: {{ int (split ":" $root.Values.beeConfig.api_addr )._1 }}
port: {{ int (include "bee.config.api_port" $root) }}
protocol: TCP
targetPort: api
selector:
Expand Down
4 changes: 2 additions & 2 deletions charts/bee/templates/service-debug.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.beeConfig.debug_api_enable -}}
{{- if index .Values.beeConfig "debug-api-enable" }}

{{- $root := . -}}

Expand All @@ -20,7 +20,7 @@ spec:
type: ClusterIP
ports:
- name: debug
port: {{ int (split ":" $root.Values.beeConfig.debug_api_addr )._1 }}
port: {{ int (include "bee.config.debug_api_port" $root) }}
protocol: TCP
targetPort: debug
selector:
Expand Down
10 changes: 5 additions & 5 deletions charts/bee/templates/service-headless.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ spec:
clusterIP: None
ports:
- name: api
port: {{ int (split ":" .Values.beeConfig.api_addr )._1 }}
port: {{ int (include "bee.config.api_port" .) }}
protocol: TCP
targetPort: api
- name: p2p
port: {{ int (split ":" .Values.beeConfig.p2p_addr )._1 }}
port: {{ int (include "bee.config.p2p_port" .) }}
protocol: TCP
targetPort: p2p
{{- if .Values.beeConfig.debug_api_enable }}
{{- if index .Values.beeConfig "debug-api-enable" }}
- name: debug
port: {{ int (split ":" .Values.beeConfig.debug_api_addr )._1 }}
port: {{ int (include "bee.config.debug_api_port" .) }}
protocol: TCP
targetPort: debug
{{- end }}
Expand All @@ -45,7 +45,7 @@ spec:
clusterIP: None
ports:
- name: p2p
port: {{ int (split ":" $root.Values.beeConfig.p2p_addr )._1 }}
port: {{ int (include "bee.config.p2p_port" $root) }}
protocol: TCP
targetPort: p2p
selector:
Expand Down
2 changes: 1 addition & 1 deletion charts/bee/templates/service-p2p.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
externalTrafficPolicy: Local
ports:
- name: p2p
port: {{ int (split ":" $root.Values.beeConfig.p2p_addr )._1 }}
port: {{ int (include "bee.config.p2p_port" $root) }}
protocol: TCP
targetPort: p2p
{{- if $root.Values.p2pFixedPort.enabled }}
Expand Down
2 changes: 1 addition & 1 deletion charts/bee/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and .Values.serviceMonitor.enabled .Values.beeConfig.debug_api_enable -}}
{{- if and .Values.serviceMonitor.enabled (index .Values.beeConfig "debug-api-enable") -}}

---
apiVersion: monitoring.coreos.com/v1
Expand Down
24 changes: 14 additions & 10 deletions charts/bee/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,15 @@ spec:
- {{ . }}
{{- end }}
ports:
- containerPort: {{ int (split ":" .Values.beeConfig.api_addr )._1 }}
- containerPort: {{ int (include "bee.config.api_port" .) }}
name: api
protocol: TCP
- containerPort: {{ int (split ":" .Values.beeConfig.p2p_addr )._1 }}
- containerPort: {{ int (include "bee.config.p2p_port" .) }}
name: p2p
protocol: TCP
{{- if .Values.probesEnable }}
{{- if .Values.beeConfig.debug_api_enable }}
- containerPort: {{ int (split ":" .Values.beeConfig.debug_api_addr )._1 }}
{{- if index .Values.beeConfig "debug-api-enable" }}
- containerPort: {{ int (include "bee.config.debug_api_port" .) }}
name: debug
protocol: TCP
livenessProbe:
Expand Down Expand Up @@ -232,11 +232,10 @@ spec:
- name: localstore
mountPath: /home/bee/.bee/localstore
{{- end }}
{{- if .Values.beeConfig.usePasswordFile }}
- name: bee-secret
mountPath: /home/bee/.secret
mountPath: /home/bee/.secret/password
subPath: password
readOnly: true
{{- end }}
{{- if .Values.clefSettings.enabled }}
- name: clef
image: "{{ include "clef.image" . }}"
Expand Down Expand Up @@ -308,14 +307,19 @@ spec:
- name: config
configMap:
name: {{ template "bee.fullname" . }}
{{- if .Values.beeConfig.usePasswordFile }}
- name: bee-secret
secret:
secretName: {{ template "bee.secretName" . }}
{{- if .Values.existingSecret }}
secretName: {{ .Values.existingSecret }}
items:
- key: {{ template "bee.secretPasswordKey" . }}
path: password
{{- end }}
{{- else }}
secretName: {{ template "bee.fullname" . }}-password
items:
- key: password
path: password
{{- end }}
{{- if .Values.libp2pSettings.enabled }}
- name: bee-libp2p
secret:
Expand Down
6 changes: 4 additions & 2 deletions charts/bee/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{- $root := . -}}

apiVersion: v1
kind: Pod
metadata:
Expand All @@ -10,6 +12,6 @@ spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "bee.fullname" . }}:{{ .Values.service.port }}']
command: ['echo']
args: ['{{ include "bee.fullname" . }}:{{ int (include "bee.config.debug_api_port" $root) }}/addresses']
restartPolicy: Never
Loading

0 comments on commit 7fe41a1

Please sign in to comment.