Skip to content

Commit 3231b96

Browse files
committed
Helm chart
Bring an helm chart to ease deployments. Conforming to the guidelines : https://github.com/kubernetes/charts/blob/master/REVIEW_GUIDELINES.md https://github.com/kubernetes/helm/blob/master/docs/chart_best_practices/rbac.md ... we don't provide default resources requests/limits.
1 parent 64d5a60 commit 3231b96

File tree

10 files changed

+298
-5
lines changed

10 files changed

+298
-5
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@
66
/vendor/
77
kubernetes-backup
88
dist/*
9-
katafygio
109
profile.cov
1110
katafygio.8.gz

README.md

+12-4
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,25 @@ export KF_LOG_LEVEL=info
9393
export KUBECONFIG=/tmp/kconfig
9494
```
9595

96-
## Build
96+
## Installation
9797

98-
Assuming you have go 1.10 and glide in the path, and GOPATH configured:
98+
You can find pre-built binaries in the [releases](https://github.com/bpineau/katafygio/releases) page,
99+
ready to run on your desktop or in a cluster.
100+
101+
We also provide a [docker image](https://hub.docker.com/r/bpineau/katafygio/).
102+
103+
You can also deploy with the provided [helm](https://helm.sh/) chart:
104+
```shell
105+
helm install --name kf-backups --namespace kube-system assets/helm-chart/katafygio/
106+
```
107+
108+
If you want to build from sources, assuming you have go 1.10 and glide in the path, and GOPATH configured:
99109

100110
```shell
101111
make deps
102112
make build
103113
```
104114

105-
You can also use pre-build binaries from the [releases](https://github.com/bpineau/katafygio/releases) page, or the [docker image](https://hub.docker.com/r/bpineau/katafygio/).
106-
107115
## See Also
108116

109117
* [Heptio Ark](https://github.com/heptio/ark) does sophisticated clusters backups, including volumes
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
appVersion: 0.5.0
3+
description: Continuously backup Kubernetes objets as yaml files in git
4+
name: katafygio
5+
home: https://github.com/bpineau/katafygio
6+
sources:
7+
- https://github.com/bpineau/katafygio
8+
version: 0.2.0
9+
maintainers:
10+
- name: bpineau
11+
12+
engine: gotpl
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Katafygio is dumping and versioning the cluster's content as
2+
yaml files in {{ default "/tmp/kf-dump" .Values.localDir }}.
3+
4+
You can access this repository by entering the pod:
5+
kubectl exec -i -t --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ template "katafygio.name" . }} -o jsonpath='{.items[0].metadata.name}') /bin/sh
6+
7+
{{ if .Values.gitUrl }}
8+
This local repository is pushed in real time to {{ .Values.gitUrl }}.
9+
{{ else -}}
10+
You can configure gitUrl to get this pushed to a remote repository.
11+
{{- end -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "katafygio.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
If release name contains chart name it will be used as a full name.
13+
*/}}
14+
{{- define "katafygio.fullname" -}}
15+
{{- if .Values.fullnameOverride -}}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17+
{{- else -}}
18+
{{- $name := default .Chart.Name .Values.nameOverride -}}
19+
{{- if contains $name .Release.Name -}}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
21+
{{- else -}}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23+
{{- end -}}
24+
{{- end -}}
25+
{{- end -}}
26+
27+
{{/*
28+
Create chart name and version as used by the chart label.
29+
*/}}
30+
{{- define "katafygio.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32+
{{- end -}}
33+
34+
{{/*
35+
Create the name of the service account to use
36+
*/}}
37+
{{- define "katafygio.serviceAccountName" -}}
38+
{{- if .Values.serviceAccount.create -}}
39+
{{ default (include "katafygio.fullname" .) .Values.serviceAccount.name }}
40+
{{- else -}}
41+
{{ default "default" .Values.serviceAccount.name }}
42+
{{- end -}}
43+
{{- end -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
apiVersion: apps/v1beta2
2+
kind: Deployment
3+
metadata:
4+
name: {{ template "katafygio.fullname" . }}
5+
labels:
6+
app: {{ template "katafygio.name" . }}
7+
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
8+
release: {{ .Release.Name }}
9+
heritage: {{ .Release.Service }}
10+
spec:
11+
replicas: {{ .Values.replicaCount }}
12+
selector:
13+
matchLabels:
14+
app: {{ template "katafygio.name" . }}
15+
release: {{ .Release.Name }}
16+
template:
17+
metadata:
18+
labels:
19+
app: {{ template "katafygio.name" . }}
20+
release: {{ .Release.Name }}
21+
spec:
22+
serviceAccountName: {{ template "katafygio.serviceAccountName" . }}
23+
containers:
24+
- name: {{ .Chart.Name }}
25+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
26+
imagePullPolicy: {{ .Values.image.pullPolicy }}
27+
command:
28+
- /usr/bin/katafygio
29+
- --local-dir={{ default "/tmp/kf-dump" .Values.localDir }}
30+
- --healthcheck-port={{ default 8080 .Values.healthcheckPort }}
31+
{{- if .Values.gitUrl }}
32+
- --git-url={{ .Values.gitUrl }}
33+
{{- end }}
34+
{{- if .Values.filter }}
35+
- --filter={{ .Values.filter }}
36+
{{- end }}
37+
{{- if .Values.logLevel }}
38+
- --log-level={{ .Values.logLevel }}
39+
{{- end }}
40+
{{- if .Values.logOutput }}
41+
- --log-output={{ .Values.logOutput }}
42+
{{- end }}
43+
{{- if .Values.logServer }}
44+
- --log-server={{ .Values.logServer }}
45+
{{- end }}
46+
{{- if .Values.resyncInterval }}
47+
- --resync-interval={{ .Values.resyncInterval }}
48+
{{- end }}
49+
{{- if .Values.noGit }}
50+
- --no-git
51+
{{- end }}
52+
{{- if .Values.excludeKind }}
53+
{{- range .Values.excludeKind }}
54+
- --exclude-kind={{ . }}
55+
{{- end }}
56+
{{- end }}
57+
{{- if .Values.excludeObject }}
58+
{{- range .Values.excludeObject }}
59+
- --exclude-object={{ . }}
60+
{{- end }}
61+
{{- end }}
62+
ports:
63+
- name: http
64+
containerPort: {{ default 8080 .Values.healthcheckPort }}
65+
protocol: TCP
66+
livenessProbe:
67+
httpGet:
68+
path: /health
69+
port: http
70+
readinessProbe:
71+
httpGet:
72+
path: /health
73+
port: http
74+
resources:
75+
{{ toYaml .Values.resources | indent 12 }}
76+
{{- with .Values.nodeSelector }}
77+
nodeSelector:
78+
{{ toYaml . | indent 8 }}
79+
{{- end }}
80+
{{- with .Values.affinity }}
81+
affinity:
82+
{{ toYaml . | indent 8 }}
83+
{{- end }}
84+
{{- with .Values.tolerations }}
85+
tolerations:
86+
{{ toYaml . | indent 8 }}
87+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{{- if .Values.rbac.create }}
2+
apiVersion: rbac.authorization.k8s.io/{{ required "A valid .Values.rbac.apiVersion entry required!" .Values.rbac.apiVersion }}
3+
kind: ClusterRole
4+
metadata:
5+
name: {{ template "katafygio.fullname" . }}
6+
labels:
7+
app: {{ template "katafygio.name" . }}
8+
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
9+
release: {{ .Release.Name }}
10+
heritage: {{ .Release.Service }}
11+
rules:
12+
- apiGroups: ["*"]
13+
resources: ["*"]
14+
verbs:
15+
- get
16+
- list
17+
- watch
18+
---
19+
apiVersion: rbac.authorization.k8s.io/v1beta1
20+
kind: ClusterRoleBinding
21+
metadata:
22+
name: {{ template "katafygio.fullname" . }}
23+
labels:
24+
app: {{ template "katafygio.name" . }}
25+
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
26+
release: {{ .Release.Name }}
27+
heritage: {{ .Release.Service }}
28+
roleRef:
29+
apiGroup: rbac.authorization.k8s.io
30+
kind: ClusterRole
31+
name: {{ template "katafygio.fullname" . }}
32+
subjects:
33+
- kind: ServiceAccount
34+
name: {{ template "katafygio.serviceAccountName" . }}
35+
namespace: {{ .Release.Namespace }}
36+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{- if .Values.serviceAccount.create }}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ template "katafygio.serviceAccountName" . }}
6+
labels:
7+
app: {{ template "katafygio.name" . }}
8+
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
9+
release: {{ .Release.Name }}
10+
heritage: {{ .Release.Service }}
11+
{{- end }}
+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
2+
# Where we'll dump cluster objects
3+
localDir: "/tmp/kf-dump"
4+
5+
# The port we'll listen for health checks requests
6+
healthcheckPort: 8080
7+
8+
# Frequency (in seconds) between full catch-up resyncs. 0 to disable.
9+
resyncInterval: 300
10+
11+
# Logging. Output may be: stdout, stderr, syslog.
12+
logLevel: warning
13+
logOutput: stdout
14+
15+
# Optional repository where Katafygio would push local changes
16+
#gitUrl: https://user:[email protected]/myorg/myrepos.git
17+
18+
# Optional label selector to match only certain objects
19+
#filter: "app in (foo, bar)"
20+
21+
# Optional. Address of a remote syslog server (if logOutput is "syslog").
22+
# logServer: "localhost:514"
23+
24+
# Kubernetes object kinds to exclude from the dumps
25+
excludeKind:
26+
- replicaset
27+
- endpoints
28+
- event
29+
30+
# Specific Kubernetes objets to exclude from the dumps
31+
# excludeObject:
32+
# - "configmap:kube-system/leader-elector"
33+
34+
rbac:
35+
# Specifies whether RBAC resources should be created
36+
create: true
37+
apiVersion: v1beta1
38+
39+
serviceAccount:
40+
# Specifies whether a ServiceAccount should be created
41+
create: true
42+
# The name of the ServiceAccount to use.
43+
# If not set and create is true, a name is generated using the fullname template
44+
name:
45+
46+
image:
47+
repository: bpineau/katafygio
48+
tag: v0.5.0
49+
pullPolicy: IfNotPresent
50+
51+
resources: {}
52+
# limits:
53+
# cpu: 100m
54+
# memory: 128Mi
55+
# requests:
56+
# cpu: 100m
57+
# memory: 128Mi
58+
59+
replicaCount: 1
60+
61+
nodeSelector: {}
62+
63+
tolerations: []
64+
65+
affinity: {}

0 commit comments

Comments
 (0)