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

feat(charts): sablier helm chart for kube deployement #274

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions .github/configs/ct-install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
remote: origin
target-branch: main
chart-dirs:
- charts
chart-repos:
helm-extra-args: --timeout 180s
check-version-increment: false
validate-maintainers: false
validate-yaml: true
exclude-deprecated: true
excluded-charts: []
9 changes: 9 additions & 0 deletions .github/configs/ct-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
remote: origin
target-branch: main
chart-dirs:
- charts
check-version-increment: false
validate-maintainers: false
exclude-deprecated: true
excluded-charts: []
81 changes: 81 additions & 0 deletions .github/workflows/chart-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
name: "Lint and Test Chart"

on:
push:
branches:
- main
pull_request:

jobs:
linter-artifacthub:
runs-on: ubuntu-latest
container:
image: public.ecr.aws/artifacthub/ah:v1.14.0
options: --user 1001
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run ah lint
working-directory: ./charts
run: ah lint

lint-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Helm
uses: azure/setup-helm@v4

- name: Set up python
uses: actions/setup-python@v5
with:
python-version: "3.9"

- name: Run helm unittest
uses: d3adb5/helm-unittest-action@v2
with:
github-token: ${{ secrets.GH_TOKEN }}
charts: charts/sablier

- name: Setup Chart Linting
id: lint
uses: helm/chart-testing-action@v2

- name: List changed charts
id: list-changed
run: |
changed=$(ct --config ./.github/configs/ct-lint.yaml list-changed)
charts=$(echo "$changed" | tr '\n' ' ' | xargs)
if [[ -n "$changed" ]]; then
echo "changed=true" >> $GITHUB_OUTPUT
echo "changed_charts=$charts" >> $GITHUB_OUTPUT
fi

- name: Run chart-testing (lint)
run: ct lint --debug --config ./.github/configs/ct-lint.yaml

- name: Run docs-testing (helm-docs)
id: helm-docs
run: |
./scripts/helm-docs.sh
if [[ $(git diff --stat) != '' ]]; then
echo -e '\033[0;31mDocumentation outdated!\033[0m ❌'
git diff --color
exit 1
else
echo -e '\033[0;32mDocumentation up to date\033[0m ✔'
fi
- name: Create kind cluster
uses: helm/kind-action@v1.9.0
if: steps.list-changed.outputs.changed == 'true'

- name: Run chart-testing (install)
run: |
namespace=sablier-$(uuidgen)
ct install --namespace=$namespace --config ./.github/configs/ct-install.yaml
if: steps.list-changed.outputs.changed == 'true'
57 changes: 57 additions & 0 deletions .github/workflows/chart-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Release Charts

on:
push:
branches:
- main
workflow_call:

permissions:
contents: write
packages: write

jobs:
release:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure Git
run: |
git config --global user.name "$GITHUB_ACTOR"
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"

- name: Set up Helm
uses: azure/setup-helm@v4

- id: generate_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.GH_APP_ID }}
private_key: ${{ secrets.GH_APP_PRIVATE_KEY }}

- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.6.0
env:
CR_TOKEN: ${{ steps.generate_token.outputs.token }}
CR_SKIP_EXISTING: "true"
CR_GENERATE_RELEASE_NOTES: "true"

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GH_TOKEN }}

- name: Push Charts to GHCR
run: |
for pkg in .cr-release-packages/*; do
if [ -z "${pkg:-}" ]; then
break
fi
helm push "${pkg}" oci://ghcr.io/${GITHUB_REPOSITORY_OWNER}/helm-charts
done
14 changes: 14 additions & 0 deletions charts/sablier/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v2
name: sablier
description: An free and open-source software to start workloads on demand and stop them after a period of inactivity.
type: application
version: "0.1.0"
appVersion: 1.6.0
deprecated: false
sources:
- "https://github.com/acouvreur/sablier"
keywords:
- Orchestration & Management
maintainers:
- email: TODO
name: TODO
34 changes: 34 additions & 0 deletions charts/sablier/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# sablier

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

An free and open-source software to start workloads on demand and stop them after a period of inactivity.

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| TODO | <TODO> | |

## Source Code

* <https://github.com/acouvreur/sablier>

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| deploymentAnnotations | object | `{}` | Annotations for all deployed Deployments |
| deploymentLabels | object | `{}` | Labels for all deployed Deployments |
| deploymentStrategy | object | `{"rollingUpdate":{"maxSurge":"25%","maxUnavailable":"25%"},"type":"RollingUpdate"}` | Deployment strategy for all deployed Deployments |
| image.repository | string | `"acouvreur/sablier"` | Sablier image repository |
| image.tag | string | `""` | Sablier image tag (deafult) appVersion |
| imagePullPolicy | string | `"IfNotPresent"` | Sablier imagePullPolicy |
| livenessProbe | object | `{"failureThreshold":3,"httpGet":{"path":"/healthz","port":10000},"initialDelaySeconds":5,"periodSeconds":5,"successThreshold":1,"timeoutSeconds":1}` | Sablier livenessProbe |
| logLevel | string | `"trace"` | Sablier log level |
| podAnnotations | object | `{}` | Annotations for all deployed pods |
| podLabels | object | `{}` | Labels for all deployed pods |
| readinessProbe | object | `{"failureThreshold":3,"httpGet":{"path":"/healthz","port":10000},"initialDelaySeconds":5,"periodSeconds":5,"successThreshold":1,"timeoutSeconds":1}` | Sablier readinessProbe |
| replicas | int | `1` | Sablier's replicas |
| resources | object | `{}` | Resource limits and requests for sablier |

53 changes: 53 additions & 0 deletions charts/sablier/templates/deployement.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: sablier-{{ .Release.Name }}
namespace: {{ .Release.Namespace }}
labels:
app: sablier-{{ .Release.Name }}
{{- with .Values.deploymentLabels }}
{{ toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.deploymentAnnotations }}
annotations:
{{ toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.replicas }}
{{- with .Values.deploymentStrategy }}
strategy:
{{- toYaml . | nindent 4 }}
{{- end }}
selector:
matchLabels:
app: sablier-{{ .Release.Name }}
template:
metadata:
labels:
app: sablier-{{ .Release.Name }}
{{- with .Values.podLabels }}
{{ toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.podAnnotations }}
annotations:
{{ toYaml . | nindent 8 }}
{{- end }}
spec:

Check warning

Code scanning / SonarCloud

Service account tokens should not be mounted in pods Medium

Set automountServiceAccountToken to false for this specification of kind Deployment. See more on SonarCloud
serviceAccountName: sablier-{{ .Release.Name }}
containers:
- name: sablier

Check warning

Code scanning / SonarCloud

Memory limits should be enforced Medium

Specify a memory limit for this container. See more on SonarCloud
image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}"
imagePullPolicy: IfNotPresent
args: ["start", "--provider.name=kubernetes", "--logging.level={{ .Values.logLevel}}"]
ports:
- containerPort: 10000
{{- with .Values.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
33 changes: 33 additions & 0 deletions charts/sablier/templates/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: sablier-{{ .Release.Name }}
rules:
- apiGroups:
- apps
- ""
resources:
- deployments
- deployments/scale
- statefulsets
- statefulsets/scale
verbs:
- patch # Scale up and down
- get # Retrieve info about specific dep
- update # Scale up and down
- list # Events
- watch # Events
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: sablier-{{ .Release.Name }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: sablier-{{ .Release.Name }}
subjects:
- kind: ServiceAccount
name: sablier
namespace: {{ .Release.Namespace }}
6 changes: 6 additions & 0 deletions charts/sablier/templates/sa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: sablier-{{ .Release.Name }}
namespace: {{ .Release.Namespace }}
13 changes: 13 additions & 0 deletions charts/sablier/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
apiVersion: v1
kind: Service
metadata:
name: sablier-{{ .Release.Name }}
namespace: {{ .Release.Namespace }}
spec:
selector:
app: sablier-{{ .Release.Name }}
ports:
- protocol: TCP
port: 10000
targetPort: 10000
Loading