diff --git a/charts/bee/Chart.yaml b/charts/bee/Chart.yaml index 5033796..93884b6 100644 --- a/charts/bee/Chart.yaml +++ b/charts/bee/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v2 appVersion: 2.5.0 name: bee -version: 0.17.4 +version: 0.17.5 kubeVersion: ">=1.19.0-0" description: Ethereum Swarm Bee Helm chart for Kubernetes home: https://www.ethswarm.org diff --git a/charts/bee/README.md b/charts/bee/README.md index bc8ac62..c647015 100644 --- a/charts/bee/README.md +++ b/charts/bee/README.md @@ -88,6 +88,18 @@ Alternatively, a YAML file that specifies the values for the parameters can be p $ helm install --name my-release -f values.yaml ethersphere/bee ``` +### Running bee through bee-runner + +With `beeRunner.enabled: true`, the container runs [bee-runner](https://github.com/ethersphere/swarm-oci-registry) instead of the bee in the image. Each time it starts, the runner gets the latest release of its channel (`stable`, `rc` or `dev`). It checks the release signature and the binary's sha256. Then it execs that bee with the usual `beeCommand` arguments. The bee version now comes from the channel, not from `image.tag`. + +Verified binaries are kept in `/home/bee/.bee/bin`, on the data volume. If a new release keeps crashing, the runner goes back to the last release that ran well. It will not go below a release marked no-rollback. + +With `beeRunner.updateRestart: true`, bee also exits by itself in its own slot of a new release's rollout window. It does this at a safe point for storage incentives. Then Kubernetes starts the runner again. This needs a bee that has the `update-restart` option. + +```bash +$ helm install my-release ethersphere/bee --set beeRunner.enabled=true +``` + ## Helmsman Usage ### Prerequisites diff --git a/charts/bee/templates/_helpers.tpl b/charts/bee/templates/_helpers.tpl index 64f0e40..35aa671 100644 --- a/charts/bee/templates/_helpers.tpl +++ b/charts/bee/templates/_helpers.tpl @@ -36,12 +36,40 @@ Create image name combining repository and tag or digest. Digest takes presedance over tag. */}} {{- define "bee.image" -}} +{{- if .Values.beeRunner.enabled -}} +{{- printf "%s:%s" .Values.beeRunner.image.repository (toString .Values.beeRunner.image.tag) -}} +{{- else -}} {{- if .Values.image.digest -}} {{- printf "%s@%s" .Values.image.repository .Values.image.digest -}} {{- else -}} {{- printf "%s:%s" .Values.image.repository .Values.image.tag -}} {{- end -}} {{- end -}} +{{- end -}} + +{{/* +bee-runner registries: the configured list, or the public defaults for the channel. +*/}} +{{- define "bee.runner.registries" -}} +{{- if .Values.beeRunner.registries -}} +{{- join "," .Values.beeRunner.registries -}} +{{- else -}} +{{- $manifests := dict "stable" "606003fd0630a101bd472317225934f5911cafd362e63b1fd2bd8bc20d43b5d0" "rc" "671b68801602fe67abca598e6eed0b55b0d0e7a75a8ba26d21dcdc2bef1620dd" "dev" "5c7b8cdf59839cb7736db3e30bda3cc4bacaa76535b3ec96783a5a0a9f5dd11a" -}} +{{- $ch := .Values.beeRunner.channel -}} +{{- $list := list -}} +{{- if has $ch (list "stable" "rc") -}} +{{- $list = append $list (printf "https://api.gateway.ethswarm.org/bzz/%s.bee-releases.swarm.eth" $ch) -}} +{{- end -}} +{{- with index $manifests $ch -}} +{{- $list = append $list (printf "https://api.gateway.ethswarm.org/bzz/%s" .) -}} +{{- end -}} +{{- if eq $ch "stable" -}} +{{- /* registry.ethswarm.org follows the stable feed only. */ -}} +{{- $list = append $list "https://registry.ethswarm.org" -}} +{{- end -}} +{{- join "," $list -}} +{{- end -}} +{{- end -}} {{/* Common labels. diff --git a/charts/bee/templates/statefulset.yaml b/charts/bee/templates/statefulset.yaml index a0ed5d3..441a17a 100644 --- a/charts/bee/templates/statefulset.yaml +++ b/charts/bee/templates/statefulset.yaml @@ -193,10 +193,34 @@ spec: {{- toYaml . | nindent 12 }} {{- end }} {{- end }} + {{- if .Values.beeRunner.enabled }} + {{- $r := .Values.beeRunner }} + command: + - bee-runner + - -registry={{ include "bee.runner.registries" . }} + - -channel={{ $r.channel }} + - -healthy-after={{ $r.healthyAfter }} + - -max-crash-starts={{ $r.maxCrashStarts }} + - -timeout={{ $r.timeout }} + - -registry-timeout={{ $r.registryTimeout }} + {{- range $r.extraArgs }} + - {{ . }} + {{- end }} + - -- + {{- range $i, $a := .Values.beeCommand }} + {{- if not (and (eq $i 0) (eq $a "bee")) }} + - {{ $a }} + {{- end }} + {{- end }} + {{- if $r.updateRestart }} + - --update-restart + {{- end }} + {{- else }} command: {{- range .Values.beeCommand }} - {{ . }} {{- end }} + {{- end }} ports: - containerPort: {{ int (include "bee.config.api_port" .) }} name: api diff --git a/charts/bee/values.yaml b/charts/bee/values.yaml index 4bd9440..444981f 100644 --- a/charts/bee/values.yaml +++ b/charts/bee/values.yaml @@ -192,6 +192,40 @@ autoNeighborhood: beeCommand: ["bee", "start", "--config=.bee.yaml"] +## bee-runner: instead of the bee in the image, run the bee release published to +## a signed release channel. On every start the runner fetches the channel's +## release, checks its signature and sha256, and execs it. It keeps verified +## binaries in /home/bee/.bee/bin on the data volume, which is also where it +## remembers what it may not downgrade from. image.tag no longer decides the +## bee version; the channel does. See +## https://github.com/ethersphere/swarm-oci-registry +## With persistence.separateLocalstore or separateStatestore, keep those +## volumes and the data volume together: replacing only the data volume +## forgets what bee may not downgrade from, while the database it protects stays. +beeRunner: + enabled: false + image: + repository: ghcr.io/ethersphere/bee-runner + tag: "0.5.3" + ## stable, rc or dev + channel: stable + ## Registry base URLs, tried in order. Empty: a public gateway with the + ## channel's ENS name, the same gateway with the channel's feed manifest + ## (works without ENS), then, for stable only, registry.ethswarm.org. + registries: [] + ## A release that ran this long is known good and becomes the rollback target. + healthyAfter: 10m + ## Roll back after this many starts in a row that each ran less than healthyAfter. + maxCrashStarts: 3 + ## Time for one start: asking the registries plus downloading bee (~60 MB). + timeout: 5m + ## Time each registry gets before the next one is tried. + registryTimeout: 30s + ## Let bee exit in its rollout slot when a newer release is published, so the + ## runner starts it. Needs a bee with the update-restart option. + updateRestart: false + extraArgs: [] + beeConfig: ## HTTP API listen address api-addr: :1633