Skip to content

Commit 37d8d92

Browse files
committed
ci: add relayer deployment
Adds a new "relayer" helm chart for deploying the custom relayer container image for penumbra preview <-> testnet paths. In the process, reorganizes the helm charts for ci into a subdir. Towards #465.
1 parent 3e52038 commit 37d8d92

31 files changed

+260
-5
lines changed

.github/workflows/deploy-preview.yml

+6
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,9 @@ jobs:
7474
export PENUMBRA_UID_GID='${{ github.event.inputs.image_uid_gid }}'
7575
export HELM_RELEASE='penumbra-testnet-preview'
7676
./ci.sh
77+
78+
# We only run one (1) relayer instance, and re-deploy it as part of the preview update.
79+
# The other end of the configured path is the long-running testnet.
80+
- name: deploy relayer
81+
run: |-
82+
./deployments/scripts/bounce-relayer

deployments/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The networks are completely separate.
1616
```
1717
.
1818
├── ci.sh # runner script for executing a deploy against k8s
19-
├── helm/ # helm chart used to configure full-node/validator layout
19+
├── charts/ # helm charts used to configure full-node/validator layout
2020
├── networks/ # logic specific to network, e.g. "testnet" or "testnet-preview"
2121
│ └── testnet/
2222
└── terraform/ # server and cluster provisioning logic
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

deployments/charts/relayer/Chart.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v2
2+
name: relayer
3+
description: Run the Cosmos relayer against Penumbra chains
4+
5+
type: application
6+
7+
# This is the chart version. This version number should be incremented each time you make changes
8+
# to the chart and its templates, including the app version.
9+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
10+
version: 0.1.0
11+
12+
# This is the version number of the application being deployed. This version number should be
13+
# incremented each time you make changes to the application. Versions are not expected to
14+
# follow Semantic Versioning. They should reflect the version the application is using.
15+
# It is recommended to use it with quotes.
16+
appVersion: "1.16.0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "relayer.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "relayer.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "relayer.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "relayer.labels" -}}
37+
helm.sh/chart: {{ include "relayer.chart" . }}
38+
{{ include "relayer.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "relayer.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "relayer.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "relayer.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "relayer.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "relayer.fullname" . }}
5+
labels:
6+
{{- include "relayer.labels" . | nindent 4 }}
7+
spec:
8+
replicas: {{ .Values.replicaCount }}
9+
selector:
10+
matchLabels:
11+
{{- include "relayer.selectorLabels" . | nindent 6 }}
12+
template:
13+
metadata:
14+
{{- with .Values.podAnnotations }}
15+
annotations:
16+
{{- toYaml . | nindent 8 }}
17+
{{- end }}
18+
labels:
19+
{{- include "relayer.selectorLabels" . | nindent 8 }}
20+
spec:
21+
{{- with .Values.imagePullSecrets }}
22+
imagePullSecrets:
23+
{{- toYaml . | nindent 8 }}
24+
{{- end }}
25+
securityContext:
26+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
27+
containers:
28+
- name: {{ .Chart.Name }}
29+
securityContext:
30+
{{- toYaml .Values.securityContext | nindent 12 }}
31+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
32+
imagePullPolicy: {{ .Values.image.pullPolicy }}
33+
# The relayer exposes an API by default on localhost:5183; in our container entrypoint,
34+
# we set localhost:5100 on the `rly start` command. Doing so allows us to check
35+
# sockets on the container; if 5183 is open, it's still configuring; if 5100 is open,
36+
# then the service is actually running.
37+
ports:
38+
- containerPort: 5100
39+
startupProbe:
40+
tcpSocket:
41+
port: 5100
42+
# The container entrypoint will block for a while, building relayer config
43+
# from remote chain info. Let's give the relayer 10m to start up.
44+
initialDelaySeconds: 10
45+
periodSeconds: 10
46+
failureThreshold: 60
47+
resources:
48+
{{- toYaml .Values.resources | nindent 12 }}
49+
{{- with .Values.nodeSelector }}
50+
nodeSelector:
51+
{{- toYaml . | nindent 8 }}
52+
{{- end }}
53+
{{- with .Values.affinity }}
54+
affinity:
55+
{{- toYaml . | nindent 8 }}
56+
{{- end }}
57+
{{- with .Values.tolerations }}
58+
tolerations:
59+
{{- toYaml . | nindent 8 }}
60+
{{- end }}
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Default values for relayer.
2+
# This is a YAML-formatted file.
3+
# Declare variables to be passed into your templates.
4+
5+
replicaCount: 1
6+
7+
image:
8+
repository: ghcr.io/penumbra-zone/relayer
9+
# always pull, because we'll be reusing "main" (i.e. latest) tag for now,
10+
# frequently redeploying preview.
11+
pullPolicy: Always
12+
# Overrides the image tag whose default is the chart appVersion.
13+
tag: "main"
14+
15+
imagePullSecrets: []
16+
nameOverride: ""
17+
fullnameOverride: ""
18+
19+
podAnnotations: {}
20+
21+
podSecurityContext: {}
22+
# fsGroup: 2000
23+
24+
securityContext: {}
25+
# capabilities:
26+
# drop:
27+
# - ALL
28+
# readOnlyRootFilesystem: true
29+
# runAsNonRoot: true
30+
# runAsUser: 1000
31+
32+
resources: {}
33+
# We usually recommend not to specify default resources and to leave this as a conscious
34+
# choice for the user. This also increases chances charts run on environments with little
35+
# resources, such as Minikube. If you do want to specify resources, uncomment the following
36+
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
37+
# limits:
38+
# cpu: 100m
39+
# memory: 128Mi
40+
# requests:
41+
# cpu: 100m
42+
# memory: 128Mi
43+
44+
nodeSelector: {}
45+
46+
tolerations: []
47+
48+
affinity: {}

deployments/ci.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ set -euo pipefail
1515
# The following env vars can be used to override config fars
1616
# for the helm chart. N.B. these env vars are also configured
1717
# in GitHub Actions, so the values below may be out of date.
18-
WORKDIR="${WORKDIR:=$(pwd)/helm/pdcli}"
18+
WORKDIR="${WORKDIR:=$(pwd)/charts/penumbra/pdcli}"
1919
IMAGE="${IMAGE:-ghcr.io/penumbra-zone/penumbra}"
2020
PENUMBRA_VERSION="${PENUMBRA_VERSION:-main}"
2121
PENUMBRA_UID_GID="${PENUMBRA_UID_GID:-1000\:1000}"
@@ -118,7 +118,7 @@ done
118118
# as necessary. Will *not* replace certain durable resources like
119119
# the ManagedCertificate, which is annotated with helm.sh/resource-policy=keep.
120120
function helm_install() {
121-
helm upgrade --install "$HELM_RELEASE" ./helm \
121+
helm upgrade --install "$HELM_RELEASE" ./charts/penumbra \
122122
--set "numValidators=$NVALS" \
123123
--set "numFullNodes=$NFULLNODES" \
124124
--set "penumbra.image=$IMAGE" \

deployments/relayer/entrypoint.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,7 @@ Finished configuring the relayer for Penumbra!
1818
Starting service...
1919
##############################################
2020
EOM
21-
# Run the relayer as a blocking service
22-
exec rly start penumbra_path
21+
# Run the relayer as a blocking service.
22+
# We set a custom debug address (default is 5183) to support
23+
# healthchecks determining whether it's running.
24+
exec rly start penumbra_path --debug-addr 127.0.0.1:5100

deployments/scripts/bounce-relayer

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
# CI script to handle re-deploying the IBC relayer deployment.
3+
# Unlike most of our CI deployments, we only run one (1) relayer instance.
4+
# It's deployed right after a new preview deploy goes out, referencing the
5+
# freshly generated preview chain, as well as the currently running testnet.
6+
#
7+
# At all times, we expect there to be one (1) relayer deployment, and we're
8+
# currently deploying the latest image built from "main". Therefore we cannot
9+
# expect helm to handle resetting the deployment, because on the surface,
10+
# the config looks identical: same container tag, same vars, same number of replicas.
11+
# To accommodate, we'll look up whether a relayer deployment exists, and if so,
12+
# bounce it via `rollout deployment restart`, which will trigger a new image pull
13+
# due to the chart's `image.pull=Always` setting. If and when we decide to redeploy
14+
# the relayer as part of the testnets, rather than preview, we should modify this
15+
# logic to set a specific version, e.g. `image.tag=049-pasiphae.1` or similar.
16+
set -euo pipefail
17+
18+
19+
# Set name for expected deployment.
20+
relayer_deployment="relayer-preview"
21+
22+
# If any deployments with the string "relayer" in the name are found,
23+
# consider the relayer to be running already, in which case we'll bounce.
24+
if kubectl get deployments --output json | jq .items[].metadata.name -r | grep -q "$relayer_deployment" ; then
25+
>&2 echo "Found existing relayer deployment, bouncing it..."
26+
kubectl rollout restart deployment "$relayer_deployment"
27+
# Block until deployment is complete. The entrypoint script builds configs,
28+
# and blocks for a while. The helm chart waits 10m before giving up, so let's
29+
# wait slightly longer than that on this timeout.
30+
kubectl rollout status deployment "$relayer_deployment" --timeout=15m
31+
# Otherwise, relayer is not running. Maybe it was manually destroyed?
32+
# Enforce state again by applying the helm chart.
33+
else
34+
>&2 echo "Relayer NOT currently running. Deploying it..."
35+
repo_root="$(git rev-parse --show-toplevel)"
36+
cd "${repo_root}/deployments" || exit 1
37+
helm upgrade --install "$relayer_deployment" ./charts/relayer
38+
fi

0 commit comments

Comments
 (0)