Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply refactorization of coda k8s/helm infra constructs #6111

Merged
merged 29 commits into from
Sep 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e9a4dba
apply initial refactorization of coda k8s/helm infra constructs
O1ahmad Sep 22, 2020
327a11a
add initial example README and more updates
O1ahmad Sep 22, 2020
4ed84b2
fix helm linting errors
O1ahmad Sep 24, 2020
bff35dd
add node_port to buildkite exporter service and refactor values
O1ahmad Sep 24, 2020
605d295
port buildkite exporter changes from coda-automation
O1ahmad Sep 24, 2020
0a52ad6
update buildkite-exporter README and refactor listening port var
O1ahmad Sep 24, 2020
679fe64
add volume/volumeMount template vars to bot helm chart + README
O1ahmad Sep 24, 2020
37d0dc0
README updates
O1ahmad Sep 24, 2020
2ca6471
more README updates
O1ahmad Sep 24, 2020
ee19b43
add helm lint script (looks for Chart.yaml in DIR of changed files)
O1ahmad Sep 24, 2020
60000e1
update leaderboard helm README
O1ahmad Sep 24, 2020
f68b1ea
add dry-run and initial chart version bump checks and fix existing er…
O1ahmad Sep 25, 2020
83fb257
update helm install logic in toolchain dockerfile
O1ahmad Sep 25, 2020
ca281eb
add ports var value to o1-bot chart
O1ahmad Sep 25, 2020
9c35f81
execute helm lint steps from agent
O1ahmad Sep 25, 2020
0e0122f
change helm lint dry-run to operate on default namespace
O1ahmad Sep 25, 2020
52eab87
add dir labeling to helm lint operation announce
O1ahmad Sep 25, 2020
84891c0
reduce helm lint agent target sizing to Small
O1ahmad Sep 25, 2020
530086a
add helm release script
O1ahmad Sep 25, 2020
c5c2ae0
add helm release dependency on linting step
O1ahmad Sep 25, 2020
c6d68e3
only release helm charts if AUTO_DEPLOY envvar is set
O1ahmad Sep 25, 2020
29833d0
remove helm chart version bump check from lint script
O1ahmad Sep 25, 2020
bec442c
add key signing for helm install within toolchain
O1ahmad Sep 25, 2020
ab82fc9
refactor helm lint/release script and only upload updated helm packages
O1ahmad Sep 28, 2020
d6b4ed2
add helm experimental OCI GCR registry upload support
O1ahmad Sep 28, 2020
f814505
helm-ci script refactorizations
O1ahmad Sep 29, 2020
e31bd18
add archive-node helm chart README
O1ahmad Sep 29, 2020
cc3a5ad
fix helm-ci dirname bug (remove extraneous doc echos from output)
O1ahmad Sep 30, 2020
f827843
add block-producer, seed-node and snark-worker README skeletons
O1ahmad Sep 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions buildkite/helm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## Introduction

This chart bootstraps a Buildkite GraphQL API metrics exporter providing job and agent statistics to a Prometheus compatible endpoint.

## Add Coda Helm chart repository:

```console
helm repo add coda <insert-repository-url>
helm repo update
```

## Configuration

The following table lists the configurable parameters of the `buildkite-exporter` chart and its default values.

### Required Settings

Parameter | Description
--- | ---
`exporter.buildkiteApiKey` | Buildkite GraphQL API access key

### Optional Settings

Parameter | Description | Default
--- | --- | ---
`exporter.pipeline` | Buildkite pipeline to scrape and export | `coda`
`exporter.image` | Buildkite exporter container image to deploy | `codaprotocol/buildkite-exporter:0.1.0`
`exporter.listeningPort` | port on which to listen for data collection requests | `8000`
`exporter.optionalEnv` | optional environment variable configuration settings | `[]`

## buildkite-exporter launch examples

```console
helm install buildkite-exporter \
--set exporter.buildkiteApiKey=<api-key> \
--set exporter.optionalEnv=[{'name': 'BUILDKITE_BRANCH', 'value': 'release'}]
```
14 changes: 14 additions & 0 deletions buildkite/helm/buildkite-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v2
name: buildkite-exporter
description: A Helm chart for O(1) Lab's Buildkite graphql exporter
type: application
version: 0.1.0
appVersion: 0.1.0
icon: https://pbs.twimg.com/profile_images/968998928241733632/Rhxmu_9O_400x400.jpg
keywords:
- buildkite
- prometheus exporter
- graphql
home: https://o1labs.org/
sources:
- https://github.com/CodaProtocol
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{tpl $.Values.exporter.name .}}
labels:
app: {{tpl $.Values.exporter.name .}}
spec:
replicas: 1
selector:
matchLabels:
app: {{tpl $.Values.exporter.name .}}
template:
metadata:
labels:
app: {{tpl $.Values.exporter.name .}}
pipeline: {{ $.Values.exporter.pipeline }}
annotations:
prometheus.io/scrape: 'true'
prometheus.io/port: {{ $.Values.exporter.listeningPort | quote }}
prometheus.io/path: '/metrics'
spec:
containers:
- name: exporter
resources:
limits:
memory: 2.0Gi
requests:
memory: 2.0Gi
cpu: 1000m
image: {{ $.Values.exporter.image }}
env:
- name: BUILDKITE_API_KEY
value: {{ .Values.exporter.buildkiteApiKey }}
{{- if .Values.exporter.optionalEnv }}
{{ toYaml .Values.exporter.optionalEnv | nindent 10 }}
{{- end }}
ports:
- containerPort: {{ .Values.exporter.listeningPort }}
hostPort: {{ .Values.exporter.listeningPort }}
protocol: TCP
imagePullPolicy: Always
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
apiVersion: v1
kind: Service
metadata:
name: {{ tpl $.Values.exporter.name . }}
spec:
type: NodePort
selector:
app: {{ tpl $.Values.exporter.name . }}
ports:
- name: metric-collection
protocol: TCP
port: {{ $.Values.exporter.listeningPort }}
targetPort: {{ $.Values.exporter.listeningPort }}
10 changes: 10 additions & 0 deletions buildkite/helm/buildkite-exporter/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
exporter:
pipeline: coda
name: "buildkite-{{ .Values.exporter.pipeline }}-exporter"
image: codaprotocol/buildkite-exporter:0.1.0
listeningPort: 8000
optionalEnv:
# - name: BUILDKITE_EXPORTER_SCAN_INTERVAL
# value: 1800
# - name: BUILDKITE_BRANCH
# value: develop
3 changes: 0 additions & 3 deletions buildkite/scripts/generate-diff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ COMMIT=$(diff -u <(git rev-list --first-parent HEAD) \

if [[ $COMMIT != "" ]]; then
# Get the files that have changed since that shared commit
echo "--- Generating diff based on shared commit: ${COMMIT}"
git diff $COMMIT --name-only
else
if [ -n "${BUILDKITE_INCREMENTAL+x}" ]; then
Expand All @@ -22,12 +21,10 @@ else
| jq '.data.pipeline.builds.edges[0].node.commit' | tr -d '"'
)

echo "--- Generating incremental diff against: ${ci_recent_pass_commit}"
git diff "${ci_recent_pass_commit}" --name-only
else
# TODO: Dump commits as artifacts when build succeeds so we can diff against
# that on develop instead of always running all the tests
git ls-files
fi
fi

64 changes: 64 additions & 0 deletions buildkite/scripts/helm-ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash

set -eou pipefail

echo "--- Generating change DIFF"
diff=$(
./buildkite/scripts/generate-diff.sh
)

# Identifying modifications to helm charts (based on existence of Chart.yaml at change root)
charts=$(
for val in $diff; do
find $(dirname $val) -name 'Chart.yaml';
done
)

# filter duplicates
charts=$(echo $charts | xargs -n1 | sort -u | xargs)
dirs=$(dirname $charts | xargs -n1 | sort -u | xargs)

if [ -n "${HELM_LINT+x}" ]; then
for dir in $dirs; do
echo "--- Linting: ${dir}"
helm lint $dir

echo "--- Executing dry-run: ${dir}"
helm install test $dir --dry-run --namespace default
done
fi

if [ -n "${HELM_RELEASE+x}" ]; then
syncDir="sync_dir"
stageDir="updates"
mkdir -p $stageDir $syncDir

echo "--- Syncing with remote GCS Helm chart repository"
gsutil -m rsync ${CODA_CHART_REPO:-"gs://coda-charts/"} $syncDir

echo "--- Preparing the following charts for Release: ${charts}"
for dir in $dirs; do
git diff develop... "${dir}/Chart.yaml" | grep version

helm package $dir --destination $stageDir

if [ -n "${HELM_EXPERIMENTAL_OCI+x}" ]; then
echo "--- Helm experimental OCI activated - deploying to GCR registry"
helm chart save $(basename $dir)

gcloud auth configure-docker
docker login "gcr.io/o1labs-192920/coda-charts/$(basename ${dir})"

helm chart push "gcr.io/o1labs-192920/coda-charts/$(basename ${dir})"
fi
done

cp --force --recursive "${stageDir}" "${syncDir}"

helm repo index $syncDir

if [ -n "${AUTO_DEPLOY+x}" ]; then
echo "--- Deploying/Syncing with remote repository"
gsutil -m rsync $syncDir ${CODA_CHART_REPO:-"gs://coda-charts/"}
fi
fi
35 changes: 35 additions & 0 deletions buildkite/src/Jobs/HelmRelease.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
let Prelude = ../External/Prelude.dhall

let S = ../Lib/SelectFiles.dhall
let Cmd = ../Lib/Cmds.dhall

let Pipeline = ../Pipeline/Dsl.dhall
let JobSpec = ../Pipeline/JobSpec.dhall

let Command = ../Command/Base.dhall
let Docker = ../Command/Docker/Type.dhall
let Size = ../Command/Size.dhall

let jobDocker = Cmd.Docker::{image = (../Constants/ContainerImages.dhall).codaToolchain}

in

Pipeline.build
Pipeline.Config::{
spec = JobSpec::{
dirtyWhen = [ S.contains "helm", S.strictly (S.contains "Chart.yaml") ],
name = "HelmRelease"
},
steps = [
Command.build
Command.Config::{
commands = [ Cmd.run "HELM_RELEASE=true buildkite/scripts/helm-ci.sh" ]
, label = "Helm chart release"
, key = "release-helm-chart"
, target = Size.Medium
, docker = None Docker.Type
, artifact_paths = [ S.contains "updates/*" ]
, depends_on = [ { name = "HelmChart", key = "lint-helm-chart" } ]
}
]
}
34 changes: 34 additions & 0 deletions buildkite/src/Jobs/Lint/HelmChart.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
let Prelude = ../../External/Prelude.dhall

let S = ../../Lib/SelectFiles.dhall
let Cmd = ../../Lib/Cmds.dhall

let Pipeline = ../../Pipeline/Dsl.dhall
let JobSpec = ../../Pipeline/JobSpec.dhall

let Command = ../../Command/Base.dhall
let Docker = ../../Command/Docker/Type.dhall
let Size = ../../Command/Size.dhall

let jobDocker = Cmd.Docker::{image = (../../Constants/ContainerImages.dhall).codaToolchain}

in

Pipeline.build
Pipeline.Config::{
spec = JobSpec::{
dirtyWhen = [ S.contains "helm" ],
path = "Lint",
name = "HelmChart"
},
steps = [
Command.build
Command.Config::{
commands = [ Cmd.run "HELM_LINT=true buildkite/scripts/helm-ci.sh" ]
, label = "Helm chart lint steps"
, key = "lint-helm-chart"
, target = Size.Small
, docker = None Docker.Type
}
]
}
5 changes: 5 additions & 0 deletions dockerfiles/Dockerfile-toolchain
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ RUN export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" && \
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - && \
sudo apt-get update -y && sudo apt-get install google-cloud-sdk kubectl -y

# Helm tools
RUN curl https://baltocdn.com/helm/signing.asc | apt-key add - && \
echo "deb https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list && \
sudo apt-get update -y && sudo apt-get install helm -y

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /tmp/rust_install.sh
RUN chmod +x /tmp/rust_install.sh
RUN /tmp/rust_install.sh -y
Expand Down
22 changes: 22 additions & 0 deletions frontend/bot/helm/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
15 changes: 15 additions & 0 deletions frontend/bot/helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v2
name: o1-bot
description: A Helm chart for Coda Protocol's O(1) role-based testnet service bots
type: application
version: 0.0.1
appVersion: 0.0.1
icon: https://github.com/CodaProtocol/coda/blob/develop/frontend/website/public/static/img/[email protected]
keywords:
- bot
- faucet
- echo
- community
home: https://codaprotocol.com/
sources:
- https://github.com/CodaProtocol
40 changes: 40 additions & 0 deletions frontend/bot/helm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## Introduction

This chart bootstraps O(1) Lab's Coda protocol bot for providing various services to deployed testnets.

## Add Coda Helm chart repository:

```console
helm repo add coda <insert-repository-url>
helm repo update
```

## Configuration

The following table lists the configurable parameters of the `o1-bot` chart and its default values.

### Required Settings

Parameter | Description
--- | ---
`bot.name` | name of bot to deploy
`bot.image` | container image representing bot function/role
`bot.role` | role/function of bot to deploy
`bot.testnet` | coda protocol testnet to deploy to

### Optional Settings

Parameter | Description | Default
--- | --- | ---
`bot.command` | override command to run on bot startup | `[]`
`bot.args` | arguments to pass to startup override command | `[]`
`bot.resources` | bot resource specification/mapping | `see default Values.yaml`
`bot.optionalEnv` | optional environment variable configuration settings | `[]`
`bot.volumes` | k8s volume objects to launch bot with | `[]`
`bot.volumeMounts` | bot pod volume mount path settings | `[]`

## buildkite-exporter launch examples

```console
helm install faucet ...
```
Loading