Skip to content

Commit

Permalink
Add Helm chart (#17)
Browse files Browse the repository at this point in the history
Ref BuoyantIO/bcloud#3451

Initial stab at the Helm chart for the linkerd-buoyant extension. The
required parameters in `values.yaml` are `accountID`, `accountKey`,
`accountDownloadKey` and `clusterName`. Please correct if those are not
right.

### How to test:
```
$ helm install linkerd-buoyant --set clusterName=foobar --set accountID=abc --set accountKey=xyz --set accountDownloadKey=rst chart/linkerd-buoyant

NAME: linkerd-buoyant
LAST DEPLOYED: Thu Jul  1 17:41:48 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Thank you for installing linkerd-buoyant.

Your release is named linkerd-buoyant.

To help you manage your Buoyant Cloud agent, you can install the CLI extension by running:

  curl -sL https://buoyant.cloud/install | sh

Alternatively, you can download the CLI directly via the linkerd-buoyant releases page:

  https://github.com/BuoyantIO/linkerd-buoyant/releases

To make sure everything works as expected, run the following:

  linkerd-buoyant check

Looking for more? Visit https://buoyant.io/cloud/
```

Summary of changes:
- For tagged releases, attach a new versioned Helm chart to the GitHub
  release, update the `gh-pages` branch, and publish the release to
  our Helm repo at `helm.buoyant.cloud`.
- Helm testing and linting via `chart-testing-action`.
- Helm release via `chart-releaser-action`.
- Helm doc generation and validation via `helm-docs`.
- Remove namespace from the templates when installed via Helm.
- Require the user to set `--namespace buoyant-cloud` during install.
- Introduce `namespace-metadata` pre-install hook, to annotate and
  existing `buoyant-cloud` namespace.

Signed-off-by: Andrew Seigner <[email protected]>

Co-authored-by: Alejandro Pedraza <[email protected]>
  • Loading branch information
alpeb authored Dec 27, 2021
1 parent c827be8 commit 6da9ede
Show file tree
Hide file tree
Showing 18 changed files with 1,085 additions and 4 deletions.
115 changes: 111 additions & 4 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,62 @@ jobs:
chmod +x ${{ env.linkerd-buoyant-bin }}
./${{ env.linkerd-buoyant-bin }} version --cli
helm_tests:
name: Helm Tests
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Helm
uses: azure/setup-helm@v1
with:
version: v3.7.1

- uses: actions/setup-python@v2
with:
python-version: 3.7

- name: Set up chart-testing
uses: helm/[email protected]

- name: Validate chart README.md is up to date
run: |
bin/helm-docs --chart-search-root=charts
git diff --exit-code charts/linkerd-buoyant/README.md
- name: Update Chart version
run: |
sed -i "s/0.0.0-undefined/0.0.0/g" charts/linkerd-buoyant/Chart.yaml
- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --config charts/ct.yaml)
if [[ -n "$changed" ]]; then
echo "::set-output name=changed::true"
fi
- name: Run chart-testing (lint)
run: ct lint --config charts/ct.yaml

- name: Create kind cluster
uses: helm/[email protected]
if: steps.list-changed.outputs.changed == 'true'

- name: Create buoyant-cloud namespace
run: |
kubectl create ns buoyant-cloud
- name: Run chart-testing (install)
run: ct install --config charts/ct.yaml

# everything below here for main merges or releases (tags)
docker_build_and_push:
name: Docker Build and Push
if: startsWith(github.ref, 'refs/tags') || github.ref == 'refs/heads/main'
if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main'
needs:
- go_unit_tests
- go_lint
Expand Down Expand Up @@ -164,7 +216,7 @@ jobs:
echo "platforms=linux/amd64" >> $GITHUB_ENV
echo "docker_tags=ghcr.io/buoyantio/linkerd-buoyant:latest" >> $GITHUB_ENV
- name: Generate Docker tags (for tagged release)
if: startsWith(github.ref, 'refs/tags')
if: startsWith(github.ref, 'refs/tags/v')
run: |
echo "platforms=linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7" >> $GITHUB_ENV
echo "docker_tags=ghcr.io/buoyantio/linkerd-buoyant:latest,ghcr.io/buoyantio/linkerd-buoyant:${GITHUB_REF##*/}" >> $GITHUB_ENV
Expand All @@ -189,12 +241,13 @@ jobs:
# everything below here for releases (tags)
create_release:
if: startsWith(github.ref, 'refs/tags')
if: startsWith(github.ref, 'refs/tags/v')
name: Create Release
needs:
- go_unit_tests
- go_lint
- smoke_test_cli
- helm_tests
- docker_build_and_push
runs-on: ubuntu-20.04
outputs:
Expand All @@ -212,7 +265,7 @@ jobs:
prerelease: false

upload_release_assets:
if: startsWith(github.ref, 'refs/tags')
if: startsWith(github.ref, 'refs/tags/v')
name: Upload Release Assets
needs:
- create_release
Expand Down Expand Up @@ -253,3 +306,57 @@ jobs:
asset_path: ./${{ env.linkerd-buoyant-bin }}
asset_name: ${{ env.linkerd-buoyant-bin }}
asset_content_type: application/octet-stream

create_helm_release:
if: startsWith(github.ref, 'refs/tags/v')
name: Create Helm Release
needs:
- create_release
- upload_release_assets
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set Helm tag version
run: |
echo "helm_tag=${GITHUB_REF##*/v}" >> $GITHUB_ENV
- name: Set Helm package name
run: echo "helm_package=linkerd-buoyant-${{ env.helm_tag }}.tgz" >> $GITHUB_ENV

# this step modifies the Helm chart in-place, in preparation for release
- name: Update Chart version
env:
helm_tag: ${{ env.helm_tag }}
run: |
sed -i "s/0.0.0-undefined/$helm_tag/g" charts/linkerd-buoyant/Chart.yaml
- name: Configure Git
run: |
git config user.name "Helm Releaser"
git config user.email [email protected]
- name: Set up Helm
uses: azure/setup-helm@v1
with:
version: v3.4.0

- name: Run chart-releaser
uses: helm/[email protected]
with:
config: charts/cr.yaml
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

- name: Upload Helm chart to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./.cr-release-packages/${{ env.helm_package }}
asset_name: ${{ env.helm_package }}
asset_content_type: application/octet-stream
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,30 @@ go test -race -cover ./...
bin/lint
```

### Helm

Test template:
```bash
helm template --namespace buoyant-cloud --values charts/linkerd-buoyant/ci/fake-values.yaml linkerd-buoyant charts/linkerd-buoyant
```

Install:
```bash
helm install --create-namespace --namespace buoyant-cloud --values charts/linkerd-buoyant/ci/fake-values.yaml linkerd-buoyant charts/linkerd-buoyant
```

To install a live agent from buoyant.cloud, register a new agent, get its
`values.yml`:
```bash
VALLUES_URL=https://buoyant.cloud/agent-helm-values/buoyant-cloud-k8s-XXX.yml
helm install --create-namespace --namespace buoyant-cloud --values $VALUES_URL linkerd-buoyant charts/linkerd-buoyant
```

Update chart README.md:
```bash
bin/helm-docs --chart-search-root=charts
```

## Release

Note the latest release:
Expand Down
57 changes: 57 additions & 0 deletions bin/helm-docs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env sh

set -eu

helmdocsv=1.5.0
bindir=$( cd "${0%/*}" && pwd ) # Change to script dir and set bin dir to this
targetbin=$( cd "$bindir"/.. && pwd )/target/bin
helmdocsbin=$targetbin/helm-docs-$helmdocsv
os=""
arch=""

if [ ! -f "$helmdocsbin" ]; then
case $(uname | tr '[:upper:]' '[:lower:]') in
darwin*)
os=darwin
arch=x86_64
;;
linux*)
os=linux
case $(uname -m) in
x86_64) arch=x86_64 ;;
amd64) arch=amd64 ;;
arm)
tmp=$(dpkg --print-architecture)
if echo "$tmp" | grep -q arm64; then
arch=arm64
elif echo "$tmp" | grep -q armv7; then
arch=armv7
elif echo "$tmp" | grep -q armv6; then
arch=armv6
fi
;;
esac
;;
msys*)
os=windows
arch=x86_64
;;
esac

if [ -z "$os" ]; then
echo "Couldn't find a matching binary"
exit 126
fi
helmdocscurl="https://github.com/norwoodj/helm-docs/releases/download/v$helmdocsv/helm-docs_${helmdocsv}_${os}_${arch}.tar.gz"
tmp=$(mktemp -d -t helm-docs.XXX)
mkdir -p "$targetbin"
(
cd "$tmp"
curl -Lsf -o "./helm-docs.tar.gz" "$helmdocscurl"
tar zf "./helm-docs.tar.gz" -x "helm-docs"
chmod +x "helm-docs"
)
mv "$tmp/helm-docs" "$helmdocsbin"
fi

"$helmdocsbin" "$@"
37 changes: 37 additions & 0 deletions charts/chart_schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: str()
home: str(required=False)
version: str()
apiVersion: str()
appVersion: any(str(), num(), required=False)
description: str()
keywords: list(str(), required=False)
sources: list(str(), required=False)
maintainers: list(include('maintainer'), required=False)
dependencies: list(include('dependency'), required=False)
icon: str(required=False)
engine: str(required=False)
condition: str(required=False)
tags: str(required=False)
deprecated: bool(required=False)
kubeVersion: str(required=False)
annotations: map(str(), str(), required=False)
type: str(required=False)
---
maintainer:
name: str()
email: str(required=False)
url: str(required=False)
---
dependency:
name: str()
version: str()
repository: str(required=False)
condition: str(required=False)
tags: list(str(), required=False)
enabled: bool(required=False)
import-values: any(list(str()), list(include('import-value')), required=False)
alias: str(required=False)
---
import-value:
child: str()
parent: str()
2 changes: 2 additions & 0 deletions charts/cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
release-name-template: "v{{ .Version }}"
skip-existing: true
5 changes: 5 additions & 0 deletions charts/ct.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
chart-yaml-schema: charts/chart_schema.yaml
lint-conf: charts/lintconf.yaml
namespace: buoyant-cloud
release-label: test-release-label
target-branch: main
19 changes: 19 additions & 0 deletions charts/linkerd-buoyant/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v2
appVersion: 0.0.0-undefined
description: The Linkerd Buoyant extension connects your Linkerd-enabled Kubernetes cluster to Buoyant Cloud, the global platform health dashboard for Linkerd.
home: https://buoyant.io/cloud
icon: https://buoyant.io/images/buoyant_logo.svg
keywords:
- linkerd
- Buoyant
- Service Mesh
kubeVersion: '>=1.20.0-0'
maintainers:
- email: [email protected]
name: BuoyantIO
url: https://buoyant.io/cloud
name: linkerd-buoyant
sources:
- https://github.com/BuoyantIO/linkerd-buoyant
type: application
version: 0.0.0-undefined
40 changes: 40 additions & 0 deletions charts/linkerd-buoyant/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# linkerd-buoyant

![Version: 0.0.0-undefined](https://img.shields.io/badge/Version-0.0.0--undefined-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.0.0-undefined](https://img.shields.io/badge/AppVersion-0.0.0--undefined-informational?style=flat-square)

The Linkerd Buoyant extension connects your Linkerd-enabled Kubernetes cluster to Buoyant Cloud, the global platform health dashboard for Linkerd.

**Homepage:** <https://buoyant.io/cloud>

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| BuoyantIO | [email protected] | https://buoyant.io/cloud |

## Source Code

* <https://github.com/BuoyantIO/linkerd-buoyant>

## Requirements

Kubernetes: `>=1.20.0-0`

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| agent.apiAddress | string | `"api.buoyant.cloud:443"` | API address for Buoyant Cloud |
| agent.imageVersion | string | `nil` | imageVersion of the buoyant-cloud-agent pod |
| agent.insecure | bool | `false` | Disable TLS. Only use for testing. |
| agent.logLevel | string | `"info"` | Log level for the buoyant-cloud-agent pod |
| agentClusterName | string | `nil` | The name of the cluster observed by this agent, as it should appear in Buoyant Cloud. Required. |
| agentDownloadKey | string | `nil` | The download key for this agent. Required. |
| agentID | string | `nil` | The ID for this agent. Required. |
| agentKey | string | `nil` | The key for this agent. Required. |
| metrics.apiAddress | string | `"api.buoyant.cloud:443"` | API address for Buoyant Cloud |
| metrics.insecure | bool | `false` | Disable TLS. Only use for testing. |
| metrics.logLevel | string | `"info"` | Log level for the buoyant-cloud-metrics pod |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0)
13 changes: 13 additions & 0 deletions charts/linkerd-buoyant/ci/dev-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
agentID: fake-agent-id
agentKey: fake-agent-key
agentDownloadKey: fake-agent-download-key
agentClusterName: fake-agent-cluster-name
agent:
apiAddress: dockerhost:8086
imageVersion: latest
insecure: true
logLevel: debug
metrics:
apiAddress: dockerhost:8087
insecure: true
logLevel: debug
6 changes: 6 additions & 0 deletions charts/linkerd-buoyant/ci/fake-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
agentID: fake-agent-id
agentKey: fake-agent-key
agentDownloadKey: fake-agent-download-key
agentClusterName: fake-agent-cluster-name
agent:
imageVersion: latest
22 changes: 22 additions & 0 deletions charts/linkerd-buoyant/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Thank you for installing {{ .Chart.Name }}.

Your release is named {{ .Release.Name }}.

To help you manage your Buoyant Cloud agent, you can install the CLI extension
by running:

curl -sL https://buoyant.cloud/install | sh

Alternatively, you can download the CLI directly via the linkerd-buoyant
releases page:

https://github.com/BuoyantIO/linkerd-buoyant/releases

To make sure everything works as expected, run the following:

linkerd-buoyant check

Need help? Message us in the #buoyant-cloud Slack channel:
https://linkerd.slack.com/archives/C01QSTM20BY

Looking for more? Visit https://buoyant.io/cloud/
Loading

0 comments on commit 6da9ede

Please sign in to comment.