-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: convert k8s charts deployment -> statefulset
Updates the helm charts used for testnet deployments to use a StatefulSet [0], rather than a Deployment [1], as the representation for a Penumbra fullnode/validator. The goal is to leverage the k8s API as best as possible for our workloads, which are indeed stateful in the sense that they require attached storage and cannot maintain their identity absent that storage. We also benefit from ordered rollouts, meaning that future minor version bumps will be applied sequentially, and paused if any node fails to become ready. This will ensure more predictable behavior as we move toward chain upgrades. When performing a chain upgrade, the manual steps taken by a human operator are now significantly simpler. In addition to the conversion to Statefulsets, the relevant charts now boast a new future called "maintenanceMode", defaulting to false, which will place nodes in a suspended state so that a human operator can run `pd migrate`. This mode encapsulates a number of finicky manual steps: override command to be "sleep infinity", for both pd and cometbft, alter securityContext to run as root user for volume permissions, and then undo all that in the reverse order. [0] https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/ [1] https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
- Loading branch information
Showing
21 changed files
with
504 additions
and
469 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Helm charts for Penumbra | ||
|
||
These helm charts are used to deploy test infrastructure via CI. | ||
A given network deployment is composed of three charts: | ||
|
||
* `penumbra-network`, which runs `pd testnet generate` to create genesis | ||
and configure genesis validators | ||
* `penumbra-node`, which runs fullnodes joined to the network, and also | ||
exposes HTTPS frontends so their RPCs are accessible. | ||
* `penumbra-metrics`, which runs a grafana/prometheus setup scraping | ||
the metrics endpoints of the nodes and validators, and exposes | ||
the grafana dashboards over HTTPS. | ||
|
||
These charts are posted publicly as a reference. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,7 @@ | ||
apiVersion: v2 | ||
name: penumbra-network | ||
description: A Helm chart for Kubernetes | ||
description: Generate a fresh network config for Penumbra, and deploy its genesis validators. | ||
|
||
# A chart can be either an 'application' or a 'library' chart. | ||
# | ||
# Application charts are a collection of templates that can be packaged into versioned archives | ||
# to be deployed. | ||
# | ||
# Library charts provide useful utilities or functions for the chart developer. They're included as | ||
# a dependency of application charts to inject those utilities and functions into the rendering | ||
# pipeline. Library charts do not define any templates and therefore cannot be deployed. | ||
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. | ||
# Versions are expected to follow Semantic Versioning (https://semver.org/) | ||
version: 0.1.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. Versions are not expected to | ||
# follow Semantic Versioning. They should reflect the version the application is using. | ||
# It is recommended to use it with quotes. | ||
appVersion: "1.16.0" |
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#!/bin/bash | ||
# Entrypoint script to build args for Penumbra's pd, | ||
# based on StatefulSet k8s ordinal. | ||
set -euo pipefail | ||
|
||
|
||
if ! [[ $HOSTNAME =~ -([0-9]+)$ ]] ; then | ||
>&2 echo "ERROR: hostname did not have a numeric suffix" | ||
exit 1 | ||
fi | ||
|
||
|
||
# Disable shellcheck for unused variable; it can't tell we use the var | ||
# in the jq command below. | ||
# shellcheck disable=SC2034 | ||
statefulset_ordinal="${BASH_REMATCH[1]}" | ||
|
||
# Raw Helm vars translated to JSON representation in this file. | ||
node_info_filepath="/opt/penumbra/nodes.json" | ||
|
||
>&2 echo "Configuring node '$statefulset_ordinal' with node info:" | ||
jq < "$node_info_filepath" | ||
|
||
# Unpack the JSON Helm vars as Bash env vas. | ||
function get_var() { | ||
local v | ||
local json_address | ||
json_address="${1:-}" | ||
shift 1 | ||
v="$(jq -r ".[$statefulset_ordinal].$json_address" "$node_info_filepath")" | ||
if [[ $v = "null" ]]; then | ||
v="" | ||
fi | ||
echo "$v" | ||
} | ||
|
||
external_address_flag="" | ||
external_address="$(get_var "external_address")" | ||
if [[ -n $external_address ]] ; then | ||
external_address_flag="--external-address $external_address" | ||
fi | ||
|
||
moniker_flag="" | ||
moniker="$(get_var "moniker")" | ||
if [[ -n $moniker ]] ; then | ||
moniker_flag="--moniker $moniker" | ||
fi | ||
|
||
seed_mode="$(get_var "seed_mode")" | ||
if [[ "$seed_mode" = "true" ]] ; then | ||
seed_mode="true" | ||
else | ||
seed_mode="false" | ||
fi | ||
|
||
# we must write into a subdir of the volumeMount, because the "--testnet-dir" arg | ||
# to "pd testnet join" must point to a non-existent directory, and the volumeMount | ||
# will always exist. | ||
# | ||
if ! test -d /penumbra-config/testnet_data ; then | ||
echo "No pre-existing testnet data, pulling fresh info" | ||
# shellcheck disable=SC2086 | ||
pd testnet --testnet-dir /penumbra-config/testnet_data join \ | ||
--tendermint-p2p-bind 0.0.0.0:26656 \ | ||
--tendermint-rpc-bind 0.0.0.0:26657 \ | ||
$external_address_flag \ | ||
$moniker_flag \ | ||
"$PENUMBRA_BOOTSTRAP_URL" | ||
|
||
if [[ "$PENUMBRA_COMETBFT_INDEXER" = "psql" ]] ; then | ||
sed -i -e "s#^indexer.*#indexer = \"psql\"\\npsql-conn = \"$COMETBFT_POSTGRES_CONNECTION_URL\"#" \ | ||
"/penumbra-config/testnet_data/node0/cometbft/config/config.toml" | ||
fi | ||
fi | ||
|
||
# set ownership for pd user | ||
chown -R 1000:1000 /penumbra-config/testnet_data | ||
|
||
# apply external address. useful for a two-pass deploy, in which external ips | ||
# are created after first deploy. | ||
sed -i -e "s/external_address.*/external_address = \"$external_address\"/" /penumbra-config/testnet_data/node0/cometbft/config/config.toml | ||
sed -i -e "s/moniker.*/moniker = \"$moniker\"/" /penumbra-config/testnet_data/node0/cometbft/config/config.toml | ||
|
||
# configure peer settings | ||
sed -i -e "s/max_num_inbound_peers.*/max_num_inbound_peers = $COMETBFT_CONFIG_P2P_MAX_NUM_INBOUND_PEERS/" /penumbra-config/testnet_data/node0/cometbft/config/config.toml | ||
sed -i -e "s/max_num_outbound_peers.*/max_num_outbound_peers = $COMETBFT_CONFIG_P2P_MAX_NUM_OUTBOUND_PEERS/" /penumbra-config/testnet_data/node0/cometbft/config/config.toml | ||
|
||
# configure seed node, defaulting to false if unspecified. | ||
sed -i -e "s/^seed_mode.*/seed_mode = \"$seed_mode\"/" /penumbra-config/testnet_data/node0/cometbft/config/config.toml | ||
|
||
# set ownership for cometbft configs to match cometbft container "tmuser" uid/gid | ||
chown -R 100:1000 /penumbra-config/testnet_data/node0/cometbft |
Oops, something went wrong.