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

Add disturbed-cli #1

Merged
merged 5 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
42 changes: 42 additions & 0 deletions .github/workflows/pr-checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: PR Checks

on:
pull_request:
branches:
- '*'

jobs:
checks:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Install Helm
uses: azure/[email protected]
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
check-latest: true
- name: Set up chart-testing
uses: helm/[email protected]
- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }})
if [[ -n "${changed}" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Run chart-testing (lint)
if: steps.list-changed.outputs.changed == 'true'
run: ct lint --target-branch ${{ github.event.repository.default_branch }}
- name: Create kind cluster
if: steps.list-changed.outputs.changed == 'true'
uses: helm/[email protected]
- name: Run chart-testing (install)
if: steps.list-changed.outputs.changed == 'true'
run: ct install --target-branch ${{ github.event.repository.default_branch }}
46 changes: 46 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Release charts

on:
push:
branches:
- main

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
id-token: write
steps:
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Install Helm
uses: azure/[email protected]
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
- name: Publish charts
uses: helm/[email protected]
env:
CR_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push charts to GHCR
run: |
shopt -s nullglob
for pkg in .cr-release-packages/*; do
if [ -z "${pkg:-}" ]; then
break
fi
helm push "${pkg}" "oci://ghcr.io/${GITHUB_REPOSITORY_OWNER}/charts"
done
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Folder

.idea

# File

*.iml
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
# helm-charts
Personal Helm charts
# Helm Charts

Personal Helm charts for Kubernetes.

## Charts

- [disturbed-cli](./charts/disturbed-cli)

## Reference

- [helm template](https://helm.sh/docs/helm/helm_template)
14 changes: 14 additions & 0 deletions charts/disturbed-cli/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v2
name: disturbed-cli
description: Disturbed CLI
version: 0.1.0
appVersion: 1.0.9
home: https://github.com/hpedrorodrigues/disturbed_cli
sources:
- https://github.com/hpedrorodrigues/disturbed_cli
- https://github.com/hpedrorodrigues/helm-charts/tree/main/charts/disturbed-cli
keywords:
- on-call
- schedule
maintainers:
- name: hpedrorodrigues
62 changes: 62 additions & 0 deletions charts/disturbed-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Disturbed CLI

Simple CLI that update users in Slack user groups based on OpsGenie on-call schedules.

Learn more: [disturbed_cli][github-repository].

This chart creates a disturbed-cli cronjob on a [Kubernetes][kubernetes] cluster using the [Helm][helm] package manager.

## Get Repository Info

```console
helm repo add hpedrorodrigues-charts https://hpedrorodrigues.github.io/helm-charts
helm repo update
```

_See [`helm repo`][helm-cli-repo] for command documentation._

## Install Chart

```console
helm install [RELEASE_NAME] hpedrorodrigues-charts/disturbed-cli
```

_See [configuration](#configuration) below._

_See [helm install][helm-cli-install] for command documentation._

## Uninstall Chart

```console
helm uninstall [RELEASE_NAME]
```

This removes all the Kubernetes components associated with the chart and deletes the release.

_See [helm uninstall][helm-cli-uninstall] for command documentation._

## Upgrading Chart

```console
helm upgrade [RELEASE_NAME] [CHART] --install
```

_See [helm upgrade][helm-cli-upgrade] for command documentation._

## Configuration

See [Customizing the chart before installing][helm-intro-chart-customization]. To check all configurable options with
detailed comments, visit the chart's [values.yaml](./values.yaml), or run these configuration commands:

```console
helm show values hpedrorodrigues-charts/disturbed-cli
```

[kubernetes]: https://kubernetes.io
[helm]: https://helm.sh
[helm-cli-repo]: https://helm.sh/docs/helm/helm_repo
[helm-cli-install]: https://helm.sh/docs/helm/helm_install
[helm-cli-uninstall]: https://helm.sh/docs/helm/helm_uninstall
[helm-cli-upgrade]: https://helm.sh/docs/helm/helm_upgrade
[helm-intro-chart-customization]: https://helm.sh/docs/intro/using_helm/#customizing-the-chart-before-installing
[github-repository]: https://github.com/hpedrorodrigues/disturbed_cli
33 changes: 33 additions & 0 deletions charts/disturbed-cli/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{/* Expand the name of the chart. */}}
{{- define "disturbed.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/* Expand the version of the chart. */}}
{{- define "disturbed.version" -}}
{{ .Chart.AppVersion | quote }}
{{- end }}

{{/* Expand the name and version of the chart. */}}
{{- define "disturbed.chart" -}}
{{ .Chart.Name }}-{{ .Chart.Version }}
{{- end }}

{{/* Common labels. */}}
{{- define "disturbed.labels" -}}
app.kubernetes.io/name: {{ include "disturbed.name" . }}
app.kubernetes.io/version: {{ include "disturbed.version" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
helm.sh/chart: {{ include "disturbed.chart" . }}
{{- if .Values.commonLabels }}
{{ toYaml .Values.commonLabels }}
{{- end }}
{{- end }}

{{/* Image. */}}
{{- define "disturbed.image" -}}
{{- $image := .Values.image.repository -}}
{{- $version := default .Chart.AppVersion .Values.image.tag -}}
{{- printf "%s:%s" $image $version -}}
{{- end }}
7 changes: 7 additions & 0 deletions charts/disturbed-cli/templates/configuration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "disturbed.name" . }}-config
data:
config.yaml:
{{ toYaml .Values.configuration.content | nindent 4}}
33 changes: 33 additions & 0 deletions charts/disturbed-cli/templates/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ template "disturbed.name" . }}
labels:
{{- include "disturbed.labels" . | nindent 4 }}
spec:
concurrencyPolicy: Forbid
schedule: {{ .Values.cron.schedule | quote }}
jobTemplate:
spec:
template:
metadata:
labels:
{{- include "disturbed.labels" . | nindent 12 }}
spec:
restartPolicy: OnFailure
containers:
- name: {{ template "disturbed.name" . }}
image: disturbed
imagePullPolicy: IfNotPresent
env:
{{- toYaml .Values.env | nindent 16 }}
resources:
{{- toYaml .Values.resources | nindent 16 }}
volumeMounts:
- name: config-file
subPath: config.yaml
mountPath: {{ .Values.configuration.filePath }}
volumes:
- name: config-file
configMap:
name: {{ template "disturbed.name" . }}-config
8 changes: 8 additions & 0 deletions charts/disturbed-cli/templates/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{- if .Values.namespace.create }}
apiVersion: v1
kind: Namespace
metadata:
name: {{ template "disturbed.name" . }}
labels:
{{- include "disturbed.labels" . | nindent 4 }}
{{- end}}
44 changes: 44 additions & 0 deletions charts/disturbed-cli/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Default values for `disturbed-cli`.

commonLabels: {}

namespace:
create: true

cron:
schedule: '*/10 * * * *'

image:
repository: ghcr.io/hpedrorodrigues/disturbed_cli
# Optional. Defaults to Chart's appVersion (declared in Chart.yaml).
tag: ''

# Optional. No resources are set by default.
resources:
{}
# limits:
# cpu: 100m
# memory: 64Mi
# requests:
# cpu: 100m
# memory: 64Mi

# See: https://github.com/hpedrorodrigues/disturbed_cli#configuration-file.
configuration:
filePath: /app/config.yaml
content: ''

env:
[]
# - name: DISTURBED_SLACK_API_TOKEN
# valueFrom:
# secretKeyRef:
# name: disturbed-cli
# key: disturbed-cli
# - name: DISTURBED_OPSGENIE_API_KEY
# valueFrom:
# secretKeyRef:
# name: disturbed-cli
# key: disturbed-cli
# - name: DISTURBED_LOG_LEVEL
# value: "INFO"