Skip to content

Commit

Permalink
kanister charts added (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
vktr-brlv authored Oct 25, 2022
1 parent 7014d46 commit 5ecd3d5
Show file tree
Hide file tree
Showing 16 changed files with 630 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/kanister-actionset/.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
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions charts/kanister-actionset/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: kanister-actionset
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
18 changes: 18 additions & 0 deletions charts/kanister-actionset/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Mysql backup helm chart with kanister actionset

Helm Chart Resources:
- Actionset
- cronJob
- Secret

{{- if .Values.actionSet.create -}}
Actionset {{ include "kanister-actionset.actionSetName" . }} added
Get actionset details run command:
kubectl describe actionset -n {{ .Release.Namespace }} {{ include "kanister-actionset.actionSetName" . }}
{{- end }}

{{- if .Values.cronJob.create -}}
Cronjob {{ include "kanister-actionset.cronJobName" . }} added
Get cronjob details run command:
kubectl descrobe cronjob -n {{ .Release.Namespace }} {{ include "kanister-actionset.actionSetName" . }}
{{- end }}
84 changes: 84 additions & 0 deletions charts/kanister-actionset/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "kanister-actionset.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 "kanister-actionset.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 "kanister-actionset.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the secret to use
*/}}
{{- define "kanister-actionset.secretName" -}}
{{- if .Values.secret.create }}
{{- default (include "kanister-actionset.fullname" .) .Values.secret.name }}
{{- else }}
{{- default "default" .Values.secret.name }}
{{- end }}
{{- end }}

{{/*
Create the name of the cronjob to use
*/}}
{{- define "kanister-actionset.cronJobName" -}}
{{- if .Values.cronJob.create }}
{{- default (include "kanister-actionset.fullname" .) .Values.cronJob.name }}
{{- else }}
{{- default "default" .Values.cronJob.name }}
{{- end }}
{{- end }}

{{/*
Create the name of the actionset to use
*/}}
{{- define "kanister-actionset.actionSetName" -}}
{{- if .Values.actionSet.create }}
{{- default (include "kanister-actionset.fullname" .) .Values.actionSet.name }}
{{- else }}
{{- default "default" .Values.actionSet.name }}
{{- end }}
{{- end }}
30 changes: 30 additions & 0 deletions charts/kanister-actionset/templates/actionset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{- if .Values.actionSet.create -}}
apiVersion: cr.kanister.io/v1alpha1
kind: ActionSet
metadata:
creationTimestamp: null
name: {{ include "kanister-actionset.actionSetName" . }}
spec:
actions:
- blueprint: {{ .Values.blueprintName }}
name: backup
object:
apiVersion: v1
group: ""
kind: ""
name: {{ include "kanister-actionset.secretName" . }}
namespace: {{ .Release.Namespace }}
resource: secrets
options:
application: {{ .Values.application }}
tenant: {{ .Values.tenant }}
environment: {{ .Values.environment }}
preferredVersion: ""
profile:
apiVersion: ""
group: ""
kind: ""
name: {{ .Values.profileName }}
namespace: {{ .Release.Namespace }}
resource: ""
{{- end }}
34 changes: 34 additions & 0 deletions charts/kanister-actionset/templates/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{- if .Values.cronJob.create -}}
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "kanister-actionset.cronJobName" . }}
labels:
{{- include "kanister-actionset.labels" . | nindent 4 }}
{{- with .Values.cronJob.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
schedule: "@daily"
jobTemplate:
spec:
template:
spec:
containers:
- name: kanctl
image: ghcr.io/kanisterio/kanister-tools
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- |
microdnf install -y perl-Digest-SHA tar
curl https://raw.githubusercontent.com/kanisterio/kanister/master/scripts/get.sh | bash
kanctl create actionset --action backup -A {{ .Values.actionsetName }} --namespace {{ .Release.Namespace }} \
--blueprint {{ .Values.blueprintName }} --profile kanister/default-profile \
--objects v1/secrets/{{ .Release.Namespace }}/{{ include "kanister-actionset.secretName" . }} \
--options tenant={{ .Values.tenant }},environment={{ .Values.environment }},application={{ .Values.application }}
resources: {}
restartPolicy: Never
{{- end }}
16 changes: 16 additions & 0 deletions charts/kanister-actionset/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if .Values.secret.create -}}
apiVersion: v1
kind: Secret
data:
postgres-username: {{ .Values.secret.username | b64enc | quote }}
postgres-password: {{ .Values.secret.password | b64enc | quote }}
postgres-host: {{ .Values.secret.backupHost | b64enc | quote }}
metadata:
name: {{ include "kanister-actionset.secretName" . }}
labels:
{{- include "kanister-actionset.labels" . | nindent 4 }}
{{- with .Values.secret.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
40 changes: 40 additions & 0 deletions charts/kanister-actionset/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Default values for mysql-backup.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

blueprintName: ""
profileName: "default-profile"
actionsetName: ""
application: ""
tenant: ""
environment: ""

secret:
# Specifies whether a secret should be created
create: true
# Annotations to add to the secret
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""
# Database username Secret data
username: root
# Database user password Secret data
password: strongpass
# Database host
backupHost: ""
restoreHost: ""

cronJob:
create: true
name: ""
annotations: {}

actionSet:
create: false
name: ""
annotations: {}
23 changes: 23 additions & 0 deletions charts/kanister-blueprint/.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
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions charts/kanister-blueprint/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: kanister-blueprint
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
11 changes: 11 additions & 0 deletions charts/kanister-blueprint/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Kanister bueprint backup helm chart

Resources included:
- kanister blueprint
- role and rolebinding
- serviceAccount

{{- if .Values.blueprint.create -}}
Get blueprint {{ include "kanister-blueprint.blueprintName" . }} details
kubectl describe blueprint -n {{ .Release.Namespace }} {{ include "kanister-blueprint.blueprintName" . }}
{{- end }}
Loading

0 comments on commit 5ecd3d5

Please sign in to comment.