Skip to content

Commit

Permalink
Add katafygio chart (helm#5543)
Browse files Browse the repository at this point in the history
* Add katafygio chart

Katafygio discovers Kubernetes objects (deployments, services, ...),
and continuously save them as yaml files in a git repository
(optionally pushing those changes to a remote repository).

This provides real time, continuous backups, and detailled Kubernetes
clusters changes history.

* Assorted fixes, per review feedback

* Per review feedback: requires current Kube and apiVersions

* Update to point release
  • Loading branch information
bpineau authored and k8s-ci-robot committed Jun 25, 2018
1 parent 7a4832a commit cbd5e81
Show file tree
Hide file tree
Showing 10 changed files with 433 additions and 0 deletions.
21 changes: 21 additions & 0 deletions stable/katafygio/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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
*~
# Various IDEs
.project
.idea/
*.tmproj
18 changes: 18 additions & 0 deletions stable/katafygio/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
appVersion: 0.7.1
description: Continuously backup Kubernetes objets as YAML files in git
name: katafygio
home: https://github.com/bpineau/katafygio
sources:
- https://github.com/bpineau/katafygio
version: 0.4.0
keywords:
- backup
- dump
- katafygio
- git
maintainers:
- name: bpineau
email: [email protected]
icon: https://raw.githubusercontent.com/bpineau/katafygio/master/assets/logo/480px-katafygio.png
engine: gotpl
80 changes: 80 additions & 0 deletions stable/katafygio/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Katafygio

[Katafygio](https://github.com/bpineau/katafygio) discovers Kubernetes objects (deployments, services, ...), and continuously saves them as YAML files in a Git repository. This provides real-time, continuous backups, and keeps detailed changes history.

## TL;DR;

```bash
$ helm install stable/katafygio
```

## Introduction

This chart installs a [Katafygio](https://github.com/bpineau/katafygio) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.

## Prerequisites

- Kubernetes 1.9+

## Chart Details

You may filter out irrelevant objects using the `excludeKind` and `excludeObject` options, to keep your backups' repository lean.

By default, the chart will dump (and version) the clusters content in /var/lib/katafygio/data (configurable with `localDir`).
This can be useful as is, to keep a local changes history. To benefit from long term, out of cluster, and centrally reachable persistence, you may provide the address of a remote Git repository (with `gitUrl`), where all changes will be pushed.

## Installing the Chart

To install the chart with the release name `my-release`:

```bash
$ helm install --name my-release stable/katafygio
```

## Uninstalling the Chart

To uninstall/delete the `my-release` deployment:

```console
$ helm delete my-release
```

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

## Configuration

The following table lists the configurable parameters of the Katafygio chart and their default values.

| Parameter | Description | Default |
|-------------------------|-------------------------------------------------------------|--------------------------------------|
| `replicaCount` | Desired number of pods | `1` |
| `image.repository` | Katafygio container image name | `bpineau/katafygio` |
| `image.tag` | Katafygio container image tag | `v0.7.1` |
| `image.pullPolicy` | Katafygio container image pull policy | `IfNotPresent` |
| `localDir` | Container's local path where Katafygio will dump and commit | `/tmp/kf-dump` |
| `gitUrl` | Optional remote repository where changes will be pushed | `nil` |
| `noGit` | Disable Git versioning | `false` |
| `filter` | Label selector to dump only matched objects | `nil` |
| `healthcheckPort` | The port Katafygio will listen for health checks requests | `8080` |
| `excludeKind` | Object kinds to ignore | `{"replicaset","endpoints","event"}` |
| `excludeObject` | Specific objects to ignore (eg. "configmap:default/foo") | `nil` |
| `rbac.create` | Enable or disable RBAC roles and bindings | `true` |
| `serviceAccount.create` | Whether a ServiceAccount should be created | `true` |
| `serviceAccount.name` | Service account to be used | `nil` |
| `resyncInterval` | Seconds between full catch-up resyncs. 0 to disable | `300` |
| `logLevel` | Log verbosity (ie. info, warning, error) | `warning` |
| `logOutput` | Logs destination (stdout, stderr or syslog) | `stdout` |
| `logServer` | Syslog server address (eg. "rsyslog:514") | `nil` |
| `resources` | CPU/Memory resource requests/limits | `{}` |
| `tolerations` | List of node taints to tolerate | `[]` |
| `affinity` | Node affinity for pod assignment | `{}` |
| `nodeSelector` | Node labels for pod assignment | `{}` |

Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`.

Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example,

```bash
$ helm install --name my-release -f values.yaml stable/katafygio
```
> **Tip**: You can use the default [values.yaml](values.yaml)
11 changes: 11 additions & 0 deletions stable/katafygio/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Katafygio is dumping and versioning the cluster's content as
YAML files in {{ .Values.localDir }}.

You can access this repository by entering the pod:
kubectl exec -i -t --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ template "katafygio.name" . }} -o jsonpath='{.items[0].metadata.name}') ls {{ .Values.localDir }}

{{ if .Values.gitUrl }}
This local repository is pushed in real time to {{ .Values.gitUrl }}.
{{ else -}}
You can configure gitUrl to get the dumps pushed to a remote repository.
{{- end }}
56 changes: 56 additions & 0 deletions stable/katafygio/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "katafygio.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 "katafygio.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 "katafygio.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "katafygio.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "katafygio.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}

{{- /*
Credit: @technosophos
https://github.com/technosophos/common-chart/
labels.standard prints the standard Helm labels.
The standard labels are frequently used in metadata.
*/ -}}
{{- define "katafygio.labels.standard" -}}
app: {{ template "katafygio.name" . }}
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
{{- end -}}
91 changes: 91 additions & 0 deletions stable/katafygio/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "katafygio.fullname" . }}
labels:
{{ include "katafygio.labels.standard" . | indent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "katafygio.name" . }}
release: {{ .Release.Name }}
template:
metadata:
labels:
{{ include "katafygio.labels.standard" . | indent 8 }}
spec:
serviceAccountName: {{ template "katafygio.serviceAccountName" . }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- /usr/bin/katafygio
- --local-dir={{ .Values.localDir }}
- --healthcheck-port={{ .Values.healthcheckPort }}
{{- if .Values.gitUrl }}
- --git-url={{ .Values.gitUrl }}
{{- end }}
{{- if .Values.filter }}
- --filter={{ .Values.filter }}
{{- end }}
{{- if .Values.logLevel }}
- --log-level={{ .Values.logLevel }}
{{- end }}
{{- if .Values.logOutput }}
- --log-output={{ .Values.logOutput }}
{{- end }}
{{- if .Values.logServer }}
- --log-server={{ .Values.logServer }}
{{- end }}
{{- if .Values.resyncInterval }}
- --resync-interval={{ .Values.resyncInterval }}
{{- end }}
{{- if .Values.noGit }}
- --no-git
{{- end }}
{{- if .Values.excludeKind }}
{{- range .Values.excludeKind }}
- --exclude-kind={{ . }}
{{- end }}
{{- end }}
{{- if .Values.excludeObject }}
{{- range .Values.excludeObject }}
- --exclude-object={{ . }}
{{- end }}
{{- end }}
ports:
- name: http
containerPort: {{ .Values.healthcheckPort }}
protocol: TCP
livenessProbe:
httpGet:
path: /health
port: http
readinessProbe:
httpGet:
path: /health
port: http
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
volumes:
- name: katafygio-data
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ .Values.persistence.existingClaim | default (include "katafygio.fullname" .) }}
{{- else }}
emptyDir: {}
{{- end -}}
21 changes: 21 additions & 0 deletions stable/katafygio/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ template "katafygio.fullname" . }}
labels:
{{ include "katafygio.labels.standard" . | indent 4 }}
spec:
accessModes:
- {{ .Values.persistence.accessMode | quote }}
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
{{- if .Values.persistence.storageClass }}
{{- if (eq "-" .Values.persistence.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.persistence.storageClass }}"
{{- end }}
{{- end }}
{{- end }}
30 changes: 30 additions & 0 deletions stable/katafygio/templates/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{- if .Values.rbac.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ template "katafygio.fullname" . }}
labels:
{{ include "katafygio.labels.standard" . | indent 4 }}
rules:
- apiGroups: ["*"]
resources: ["*"]
verbs:
- get
- list
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ template "katafygio.fullname" . }}
labels:
{{ include "katafygio.labels.standard" . | indent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ template "katafygio.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ template "katafygio.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end }}
8 changes: 8 additions & 0 deletions stable/katafygio/templates/service-account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{- if .Values.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "katafygio.serviceAccountName" . }}
labels:
{{ include "katafygio.labels.standard" . | indent 4 }}
{{- end }}
Loading

0 comments on commit cbd5e81

Please sign in to comment.