Skip to content

Commit

Permalink
Merge pull request #137 from DerekTBrown/add-helm-chart
Browse files Browse the repository at this point in the history
feat: add helm chart
  • Loading branch information
skamboj authored May 14, 2024
2 parents a8f1a76 + a909e03 commit 36b0aed
Show file tree
Hide file tree
Showing 21 changed files with 824 additions and 3 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/helm-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Helm Publish
on:
push:
branches:
- master

jobs:
helm_publish:
# depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions
# see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@v4
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

- name: Run chart-releaser
uses: helm/[email protected]
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
74 changes: 74 additions & 0 deletions .github/workflows/helm-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Helm Test
on:
pull_request:
jobs:
helm_test:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.22

- name: Install Tools
shell: bash
id: tool-versions
env:
TILT_TOOL_CTLPTL_VERSION: "0.8.28"
TILT_TOOL_KIND_VERSION: "0.23.0"
TILT_TOOL_KUBECTL_VERSION: "1.30.0"
TILT_TOOL_HELM_VERSION: "3.14.4"
TILT_TOOL_TILT_VERSION: "0.33.13"
run: |
# Create Tools Directory
TOOLS_DIR=/opt/helm_tools
mkdir -p "${TOOLS_DIR}"
# Download ctlptl
echo "Downloading ctlptl"
curl -fsSL https://github.com/tilt-dev/ctlptl/releases/download/v${TILT_TOOL_CTLPTL_VERSION}/ctlptl.${TILT_TOOL_CTLPTL_VERSION}.linux.x86_64.tar.gz | sudo tar -xzv -C "${TOOLS_DIR}" ctlptl
# Download kind
echo "Downloading kind"
curl -fsSL https://kind.sigs.k8s.io/dl/v${TILT_TOOL_KIND_VERSION}/kind-linux-amd64 -o "${TOOLS_DIR}/kind"
# Download kubectl
echo "Downloading kubectl"
curl -fsSL https://dl.k8s.io/release/v${TILT_TOOL_KUBECTL_VERSION}/bin/linux/amd64/kubectl -o "${TOOLS_DIR}/kubectl"
# Download helm
echo "Downloading helm"
curl -fsSL https://get.helm.sh/helm-v${TILT_TOOL_HELM_VERSION}-linux-amd64.tar.gz | tar -xzv -C "${TOOLS_DIR}" --strip-components=1 linux-amd64/helm
# Download tilt
echo "Downloading tilt"
curl -fsSL https://github.com/tilt-dev/tilt/releases/download/v${TILT_TOOL_TILT_VERSION}/tilt.${TILT_TOOL_TILT_VERSION}.linux.x86_64.tar.gz | tar -xzv -C "${TOOLS_DIR}" tilt
# Make the binaries runnable
echo "Making binaries executable"
sudo chmod -R +x "${TOOLS_DIR}"
# Add tools to path
echo "PATH=${PATH}:${TOOLS_DIR}" >> $GITHUB_ENV
- name: Start Kind Cluster
shell: bash
run: |
ctlptl apply -f kind.yaml
- name: Run Tilt Tests
shell: bash
run: |
tilt ci --debug --output-snapshot-on-exit=/tmp/tilt-snapshot.json
- name: Upload Tilt Snapshot
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: tilt-snapshot
path: |
/tmp/tilt-snapshot.json
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,25 @@ docker push $(namespace="docker.io/myhandle/" make version)
```

## Installation

`Goldpinger` works by asking `Kubernetes` for pods with particular labels (`app=goldpinger`). While you can deploy `Goldpinger` in a variety of ways, it works very nicely as a `DaemonSet` out of the box.

### Authentication with Kubernetes API
### Helm Installation
Goldpinger can be installed via [Helm](https://helm.sh/) using the following:

```
helm repo add goldpinger https://bloomberg.github.io/goldpinger
helm repo update
helm install goldpinger goldpinger/goldpinger
```

### Manual Installation
`Goldpinger` can be installed manually via configuration similar to the following:

#### Authentication with Kubernetes API

`Goldpinger` supports using a `kubeconfig` (specify with `--kubeconfig-path`) or service accounts.

### Example YAML
#### Example YAML

Here's an example of what you can do (using the in-cluster authentication to `Kubernetes` apiserver).

Expand Down
30 changes: 30 additions & 0 deletions Tiltfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# -*- mode: bazel-starlark -*-

# Build the image
docker_build('goldpinger-local', '.')

# Deploy with Helm
k8s_yaml(
helm(
'charts/goldpinger',
set = [
# Set the image to the one built by Tilt
'image.repository=goldpinger-local',
],
)
)

# Track Goldpinger Resource
k8s_resource(
'chart-goldpinger',
port_forwards = [8080],
)

# Validate that all 2 nodes can talk to eachother
local_resource(
'check_reachability',
cmd='./extras/check_reachability.sh 2',
resource_deps = [
'chart-goldpinger',
],
)
23 changes: 23 additions & 0 deletions charts/goldpinger/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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

OWNERS
8 changes: 8 additions & 0 deletions charts/goldpinger/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
name: goldpinger
appVersion: "3.10.1"
version: 1.0.0
description: Goldpinger is a tool to help debug, troublshoot and visualize network connectivity and slowness issues.
home: https://github.com/bloomberg/goldpinger
sources:
- https://github.com/bloomberg/goldpinger
62 changes: 62 additions & 0 deletions charts/goldpinger/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "goldpinger.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "goldpinger.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "goldpinger.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "goldpinger.labels" -}}
helm.sh/chart: {{ include "goldpinger.chart" . }}
{{ include "goldpinger.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "goldpinger.selectorLabels" -}}
app.kubernetes.io/name: {{ include "goldpinger.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "goldpinger.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "goldpinger.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
12 changes: 12 additions & 0 deletions charts/goldpinger/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if and .Values.rbac.create .Values.rbac.clusterscoped }}
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ include "goldpinger.fullname" . }}-clusterrole
labels:
{{- include "goldpinger.labels" . | nindent 4 }}
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["list"]
{{- end }}
16 changes: 16 additions & 0 deletions charts/goldpinger/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if and .Values.rbac.create .Values.rbac.clusterscoped }}
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ include "goldpinger.fullname" . }}-clusterrolebinding
labels:
{{- include "goldpinger.labels" . | nindent 4 }}
subjects:
- kind: ServiceAccount
name: {{ include "goldpinger.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: {{ include "goldpinger.fullname" . }}-clusterrole
apiGroup: rbac.authorization.k8s.io
{{- end }}
8 changes: 8 additions & 0 deletions charts/goldpinger/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "goldpinger.fullname" . }}-zap
labels:
{{- include "goldpinger.labels" . | nindent 4 }}
data:
zap.json: {{ .Values.goldpinger.zapConfig | toJson }}
Loading

0 comments on commit 36b0aed

Please sign in to comment.