Skip to content

Commit

Permalink
feat: rename helm-release-cleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
ialejandro committed Sep 4, 2024
1 parent f419367 commit 1b4ec77
Show file tree
Hide file tree
Showing 13 changed files with 164 additions and 165 deletions.
69 changes: 0 additions & 69 deletions charts/helm-release-cleaner/README.md

This file was deleted.

8 changes: 0 additions & 8 deletions charts/helm-release-cleaner/templates/serviceaccount.yaml

This file was deleted.

59 changes: 0 additions & 59 deletions charts/helm-release-cleaner/values.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
apiVersion: v2
description: A Helm chart for Helm Charts to clean up the releases installed in the declared namespaces
name: helm-release-cleaner
name: release-cleaner
type: application
maintainers:
- name: amartingarcia
email: [email protected]
url: https://github.com/devops-ia
version: 1.1.1
version: 1.0.0
appVersion: 1.0.0
home: https://github.com/devops-ia/helm-charts/tree/main/charts/helm-release-cleaner
home: https://github.com/devops-ia/helm-charts/tree/main/charts/release-cleaner
sources:
- https://devops-ia.github.io/helm-charts
keywords:
- helm-release-cleaner
- release-cleaner
- helm
- kubernetes
66 changes: 66 additions & 0 deletions charts/release-cleaner/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# release-cleaner

A Helm chart for Helm Charts to clean up the releases installed in the declared namespaces

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| amartingarcia | <[email protected]> | <https://github.com/devops-ia> |

## Prerequisites

* Helm 3+

## Add repository

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

## Install Helm chart

```console
helm install [RELEASE_NAME] devops-ia/release-cleaner
```

This install all the Kubernetes components associated with the chart and creates the release.

_See [helm install](https://helm.sh/docs/helm/helm_install/) for command documentation._

## Uninstall Helm chart

```console
# Helm
helm uninstall [RELEASE_NAME]
```

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

_See [helm uninstall](https://helm.sh/docs/helm/helm_uninstall/) for command documentation._

## Configuration

See [Customizing the chart before installing](https://helm.sh/docs/intro/using_helm/#customizing-the-chart-before-installing). To see all configurable options with comments:

```console
helm show values devops-ia/release-cleaner
```

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | Assign custom affinity rules |
| fullnameOverride | string | `""` | Provide a name to substitute for the full names of resources |
| image | object | `{"pullPolicy":"IfNotPresent","repository":"devopsiaci/release-cleaner","tag":"latest"}` | Image of replika deployment |
| imagePullSecrets | list | `[]` | ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images |
| nameOverride | string | `""` | Provide a name in place of replika |
| namespacesClean | string | `"default"` | Text string with the namespace names where the cleaner will work If none is specified, by default it will be executed in the default namespace Example: "default, monitoring" |
| nodeSelector | object | `{}` | Define which Nodes the Pods are scheduled on |
| releasesExclude | object | `{"enabled":false,"releases":["my-release"]}` | Exclusion of releases List of releases to be excluded by the cleaner |
| replicaCount | int | `1` | Provide desired replicas |
| resources | object | `{}` | Resource limits & requests |
| schedule | string | `"5 * * * *"` | Schedule job |
| tolerations | list | `[]` | Pods tolerations |
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "helm-release-cleaner.name" -}}
{{- define "release-cleaner.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

Expand All @@ -11,7 +11,7 @@ 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 "helm-release-cleaner.fullname" -}}
{{- define "release-cleaner.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
Expand All @@ -27,16 +27,16 @@ If release name contains chart name it will be used as a full name.
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "helm-release-cleaner.chart" -}}
{{- define "release-cleaner.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "helm-release-cleaner.labels" -}}
app.kubernetes.io/name: {{ include "helm-release-cleaner.name" . }}
helm.sh/chart: {{ include "helm-release-cleaner.chart" . }}
{{- define "release-cleaner.labels" -}}
app.kubernetes.io/name: {{ include "release-cleaner.name" . }}
helm.sh/chart: {{ include "release-cleaner.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "helm-release-cleaner.name" . }}
name: {{ include "release-cleaner.name" . }}
labels:
{{ include "helm-release-cleaner.labels" . | indent 4 }}
{{- include "release-cleaner.labels" . | nindent 4 }}
rules:
- apiGroups: ["*"]
resources: ["*"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "helm-release-cleaner.name" . }}
name: {{ include "release-cleaner.name" . }}
labels:
{{ include "helm-release-cleaner.labels" . | indent 4 }}
{{- include "release-cleaner.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "helm-release-cleaner.name" . }}
name: {{ include "release-cleaner.name" . }}
subjects:
- kind: ServiceAccount
name: {{ include "helm-release-cleaner.name" . }}
name: {{ include "release-cleaner.name" . }}
namespace: "{{ .Release.Namespace }}"
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "helm-release-cleaner.name" . }}
name: {{ include "release-cleaner.name" . }}
labels:
{{ include "helm-release-cleaner.labels" . | indent 4 }}
{{- include "release-cleaner.labels" . | nindent 4 }}
data:
helm-release-cleaner.sh: |
release-cleaner.sh: |
#!/bin/bash
NAMESPACES=({{ .Values.namespacesClean }})
for ns in "${NAMESPACES[@]}"; do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ apiVersion: batch/v1beta1
{{- end }}
kind: CronJob
metadata:
name: {{ include "helm-release-cleaner.name" . }}
name: {{ include "release-cleaner.name" . }}
labels:
{{ include "helm-release-cleaner.labels" . | indent 4 }}
{{- include "release-cleaner.labels" . | nindent 4 }}
spec:
schedule: "{{ .Values.schedule }}"
concurrencyPolicy: Replace
Expand All @@ -19,13 +19,13 @@ spec:
template:
metadata:
labels:
{{ include "helm-release-cleaner.labels" . | indent 12 }}
{{ include "release-cleaner.labels" . | indent 12 }}
{{- if .Values.podAnnotations }}
annotations:
{{ toYaml .Values.podAnnotations | indent 8 }}
{{- end }}
spec:
serviceAccountName: {{ include "helm-release-cleaner.name" . }}
serviceAccountName: {{ include "release-cleaner.name" . }}
restartPolicy: Never
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
Expand All @@ -35,11 +35,11 @@ spec:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:latest"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ["/bin/bash", "/tmp/helm-release-cleaner.sh"]
command: ["/bin/bash", "/tmp/release-cleaner.sh"]
volumeMounts:
- name: {{ include "helm-release-cleaner.name" . }}
mountPath: /tmp/helm-release-cleaner.sh
subPath: helm-release-cleaner.sh
- name: {{ include "release-cleaner.name" . }}
mountPath: /tmp/release-cleaner.sh
subPath: release-cleaner.sh
resources:
{{ toYaml .Values.resources | indent 14 }}
{{- with .Values.nodeSelector }}
Expand All @@ -55,7 +55,7 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}
volumes:
- name: {{ include "helm-release-cleaner.name" . }}
- name: {{ include "release-cleaner.name" . }}
configMap:
name: {{ include "helm-release-cleaner.name" . }}
name: {{ include "release-cleaner.name" . }}
defaultMode: 0755
8 changes: 8 additions & 0 deletions charts/release-cleaner/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
{{- include "release-cleaner.labels" . | nindent 4 }}
name: {{ include "release-cleaner.name" . }}
namespace: {{ .Values.namespace }}
Loading

0 comments on commit 1b4ec77

Please sign in to comment.