Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
leonbrandt committed Aug 2, 2024
0 parents commit d0b5472
Show file tree
Hide file tree
Showing 9 changed files with 270 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: CI

on: [ push ]

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Helm
uses: azure/setup-helm@v4
id: install
with:
version: "latest"

- name: Lint Helm
id: lint
run: helm lint .
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Release

on:
release:
types: [ published ]

env:
CHART_NAME: "grafana-pdc-agent"
OCI_URL: "oci://ghcr.io/smartsquaregmbh/helm"
VERSION: ${{ github.event.release.tag_name }}

permissions:
packages: write

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Helm
uses: azure/setup-helm@v4
id: install
with:
version: "latest"

- name: Registry-Login Helm
run: |
helm registry login $REGISTRY -u $USERNAME -p $PASSWORD
env:
REGISTRY: ghcr.io
USERNAME: ${{ github.actor }}
PASSWORD: ${{ secrets.GITHUB_TOKEN }}

- name: Package Helm
id: package
run: |
helm package . --version $VERSION
echo "package=${CHART_NAME}-${VERSION}.tgz" >> "$GITHUB_OUTPUT"
- name: Push Helm
id: push
run: |
helm push $PACKAGE $OCI_URL
env:
PACKAGE: ${{ steps.package.outputs.package }}
3 changes: 3 additions & 0 deletions .helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.helmignore
.git
.github
7 changes: 7 additions & 0 deletions Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v2
name: grafana-pdc-agent
description: Grafana Private Datasource Connect Agent

type: application
version: 0.1.0
appVersion: "0.0.31"
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Leon Brandt

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Grafana pdc-agent Helm

A Helm chart for Grafana's [pdc-agent](https://github.com/grafana/pdc-agent).

If you know what your doing just start using this chart from our OCI-registry:
### `oci://ghcr.io/smartsquaregmbh/helm/grafana-pdc-agent`

# Usage

This chart is stored in a OCI-based registry. Please either use Helm v3.8.0+ or consult the [Helm documentation](https://helm.sh/docs/topics/registries) for how to use OCI-registries in older versions.

Helm currently does not support adding OCI-registries as Helm-repositories. So use this chart like this:

```
$ helm install <release> oci://ghcr.io/smartsquaregmbh/helm/grafana-pdc-agent --version 0.1.0 -f path/to/values.yaml
```

Minimal required values.yaml (for all possible values see [values.yaml](./values.yaml)):

```yaml
secret:
values:
token: "<YOUR-GRAFANA-TOKEN>"
hostedgrafanaid: "<YOUR-HOSTED-GRAFANA-ID>"
cluster: "<YOUR-GRAFANA-CLUSTER>"
```
# Chart compability
This chart is confirmed to work with grafana-pdc-versions `v0.0.30` and `v0.0.31` but every version prior should work too.

100 changes: 100 additions & 0 deletions templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: grafana-pdc-agent
labels:
{{- $deploymentLabels := dict "app" "grafana-pdc-agent" "name" "grafana-pdc-agent" }}
{{- if .Values.agent }}
{{- $deploymentLabels := .Values.agent | dig "deployment" "extraLabels" dict | merge $deploymentLabels }}
{{- end }}
{{- $deploymentLabels | toYaml | nindent 4 }}
spec:
{{- if .Values.agent }}
replicas: {{ .Values.agent | dig "replicaCount" 1 }}
{{- else }}
replicas: 1
{{- end }}
selector:
matchLabels:
name: grafana-pdc-agent
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
metadata:
labels:
{{- $podLabels := dict "name" "grafana-pdc-agent" }}
{{- if .Values.agent }}
{{- $podLabels := .Values.agent | dig "pod" "extraLabels" dict | merge $podLabels }}
{{- end }}
{{- $podLabels | toYaml | nindent 8 }}
spec:
containers:
- name: grafana-pdc-agent
env:
- name: TOKEN
valueFrom:
secretKeyRef:
key: token
name: {{ .Values.secret.name | default "grafana-pdc-agent" }}
- name: CLUSTER
valueFrom:
secretKeyRef:
key: cluster
name: {{ .Values.secret.name | default "grafana-pdc-agent" }}
- name: HOSTED_GRAFANA_ID
valueFrom:
secretKeyRef:
key: hosted-grafana-id
name: {{ .Values.secret.name | default "grafana-pdc-agent" }}
args:
- -cluster
- $(CLUSTER)
- -token
- $(TOKEN)
- -gcloud-hosted-grafana-id
- "$(HOSTED_GRAFANA_ID)"
{{- if .Values.agent }}
image: "grafana/pdc-agent:{{ .Values.agent | dig "image" "tag" .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.agent | dig "image" "pullPolicy" "Always" }}
{{- else}}
image: "grafana/pdc-agent:{{ .Chart.AppVersion }}"
imagePullPolicy: Always
{{- end}}
{{- with .Values.agent }}
{{- with .resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
securityContext:
allowPrivilegeEscalation: false
privileged: false
runAsNonRoot: true
capabilities:
drop:
- all
securityContext:
runAsUser: 30000
runAsGroup: 30000
fsGroup: 30000
{{- with .Values.agent }}
{{- with .nodeSelector}}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- with .Values.agent }}
{{- with .affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- with .Values.agent }}
{{- with .tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
9 changes: 9 additions & 0 deletions templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ .Values.secret.name | default "grafana-pdc-agent" }}
type: Opaque
data:
"token": {{ .Values.secret.values.token | required "secret-value missing: token" }}
"hosted-grafana-id": {{ .Values.secret.values.hostedgrafanaid | required "secret-value missing: hostedgrafanaid" }}
"cluster": {{ .Values.secret.values.cluster | required "secret-value missing: cluster" }}
32 changes: 32 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# The minimal values-file looks like this - everything else can be omitted:
#
# secret:
# values:
# token: "<YOUR-GRAFANA-TOKEN>"
# hostedgrafanaid: "<YOUR-HOSTED-GRAFANA-ID>"
# cluster: "<YOUR-GRAFANA-CLUSTER>"

agent:
replicaCount: 1
image:
pullPolicy: Always
tag: ""
resources:
limits:
memory: 1Gi
requests:
cpu: 1
memory: 1Gi
nodeSelector: {}
tolerations: []
affinity: {}
deployment:
extraLabels: {}
pod:
extraLabels: {}
secret:
name: ""
values:
token: "CHANGEME"
hostedgrafanaid: "CHANGEME"
cluster: "CHANGEME"

0 comments on commit d0b5472

Please sign in to comment.