Skip to content

Commit 6cef89b

Browse files
authored
Arango Backup support in Operator (#438)
1 parent 10181e5 commit 6cef89b

File tree

159 files changed

+13576
-116
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+13576
-116
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pkg/generated/** linguist-generated
2+
**/zz_generated.deepcopy.go linguist-generated

Makefile

+39-8
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ endif
7171
MANIFESTPATHCRD := manifests/arango-crd$(MANIFESTSUFFIX).yaml
7272
MANIFESTPATHDEPLOYMENT := manifests/arango-deployment$(MANIFESTSUFFIX).yaml
7373
MANIFESTPATHDEPLOYMENTREPLICATION := manifests/arango-deployment-replication$(MANIFESTSUFFIX).yaml
74+
MANIFESTPATHBACKUP := manifests/arango-backup$(MANIFESTSUFFIX).yaml
7475
MANIFESTPATHSTORAGE := manifests/arango-storage$(MANIFESTSUFFIX).yaml
7576
MANIFESTPATHTEST := manifests/arango-test$(MANIFESTSUFFIX).yaml
7677
ifndef DEPLOYMENTNAMESPACE
@@ -111,7 +112,7 @@ TESTLENGTHOPTIONS := -test.short
111112
TESTTIMEOUT := 30m
112113
ifeq ($(LONG), 1)
113114
TESTLENGTHOPTIONS :=
114-
TESTTIMEOUT := 240m
115+
TESTTIMEOUT := 300m
115116
endif
116117
ifdef VERBOSE
117118
TESTVERBOSEOPTIONS := -v
@@ -151,6 +152,14 @@ allall: all
151152
# Tip: Run `eval $(minikube docker-env)` before calling make if you're developing on minikube.
152153
#
153154

155+
.PHONY: fmt
156+
fmt:
157+
golangci-lint run --no-config --issues-exit-code=1 --deadline=30m --disable-all --enable=deadcode --enable=gocyclo \
158+
--enable=golint --enable=varcheck --enable=structcheck --enable=maligned --enable=errcheck \
159+
--enable=dupl --enable=ineffassign --enable=interfacer --enable=unconvert --enable=goconst \
160+
--enable=gosec --enable=megacheck --exclude-use-default=false \
161+
$(ROOTDIR)/pkg/backup/...
162+
154163
.PHONY: build
155164
build: docker manifests
156165

@@ -182,7 +191,7 @@ update-generated:
182191
"all" \
183192
"github.com/arangodb/kube-arangodb/pkg/generated" \
184193
"github.com/arangodb/kube-arangodb/pkg/apis" \
185-
"deployment:v1alpha replication:v1alpha storage:v1alpha" \
194+
"deployment:v1alpha replication:v1alpha storage:v1alpha backup:v1alpha" \
186195
--go-header-file "./tools/codegen/boilerplate.go.txt" \
187196
$(VERIFYARGS)
188197

@@ -236,7 +245,8 @@ manifests-operator-deployment: helm
236245
@$(HELM_CMD) \
237246
--set "operator.features.deployment=true" \
238247
--set "operator.features.deploymentReplications=false" \
239-
--set "operator.features.storage=false" > "$(MANIFESTPATHDEPLOYMENT)"
248+
--set "operator.features.storage=false" \
249+
--set "operator.features.backup=false" > "$(MANIFESTPATHDEPLOYMENT)"
240250

241251
.PHONY: manifests-operator-deployment-replication
242252
manifests-operator-deployment-replication: export CHART_NAME := kube-arangodb
@@ -246,7 +256,8 @@ manifests-operator-deployment-replication: helm
246256
@$(HELM_CMD) \
247257
--set "operator.features.deployment=false" \
248258
--set "operator.features.deploymentReplications=true" \
249-
--set "operator.features.storage=false" > "$(MANIFESTPATHDEPLOYMENTREPLICATION)"
259+
--set "operator.features.storage=false" \
260+
--set "operator.features.backup=false" > "$(MANIFESTPATHDEPLOYMENTREPLICATION)"
250261

251262
.PHONY: manifests-operator-storage
252263
manifests-operator-storage: export CHART_NAME := kube-arangodb
@@ -256,10 +267,22 @@ manifests-operator-storage: helm
256267
@$(HELM_CMD) \
257268
--set "operator.features.deployment=false" \
258269
--set "operator.features.deploymentReplications=false" \
259-
--set "operator.features.storage=true" > "$(MANIFESTPATHSTORAGE)"
270+
--set "operator.features.storage=true" \
271+
--set "operator.features.backup=false" > "$(MANIFESTPATHSTORAGE)"
272+
273+
.PHONY: manifests-operator-backup
274+
manifests-operator-backup: export CHART_NAME := kube-arangodb
275+
manifests-operator-backup: export NAME := backup
276+
manifests-operator-backup: helm
277+
@echo Building manifests for Operator Backup - $(MANIFESTPATHBACKUP)
278+
@$(HELM_CMD) \
279+
--set "operator.features.deployment=false" \
280+
--set "operator.features.deploymentReplications=false" \
281+
--set "operator.features.storage=false" \
282+
--set "operator.features.backup=true" > "$(MANIFESTPATHBACKUP)"
260283

261284
.PHONY: manifests-operator
262-
manifests-operator: manifests-operator-deployment manifests-operator-deployment-replication manifests-operator-storage
285+
manifests-operator: manifests-operator-deployment manifests-operator-deployment-replication manifests-operator-storage manifests-operator-backup
263286

264287
.PHONY: chart-crd
265288
chart-crd: export CHART_NAME := kube-arangodb-crd
@@ -281,6 +304,7 @@ manifests: helm manifests-crd manifests-operator manifests-test chart-crd chart-
281304
.PHONY: run-unit-tests
282305
run-unit-tests: $(SOURCES)
283306
go test $(TESTVERBOSEOPTIONS) \
307+
$(REPOPATH)/pkg/apis/backup/v1alpha \
284308
$(REPOPATH)/pkg/apis/deployment/v1alpha \
285309
$(REPOPATH)/pkg/apis/replication/v1alpha \
286310
$(REPOPATH)/pkg/apis/storage/v1alpha \
@@ -290,7 +314,8 @@ run-unit-tests: $(SOURCES)
290314
$(REPOPATH)/pkg/util/k8sutil \
291315
$(REPOPATH)/pkg/util/k8sutil/test \
292316
$(REPOPATH)/pkg/util/probe \
293-
$(REPOPATH)/pkg/util/validation
317+
$(REPOPATH)/pkg/util/validation \
318+
$(REPOPATH)/pkg/backup/...
294319

295320
$(TESTBIN): $(GOBUILDDIR) $(SOURCES)
296321
@mkdir -p $(BINDIR)
@@ -318,9 +343,11 @@ endif
318343
kubectl apply -f $(MANIFESTPATHSTORAGE)
319344
kubectl apply -f $(MANIFESTPATHDEPLOYMENT)
320345
kubectl apply -f $(MANIFESTPATHDEPLOYMENTREPLICATION)
346+
kubectl apply -f $(MANIFESTPATHBACKUP)
321347
kubectl apply -f $(MANIFESTPATHTEST)
322348
$(ROOTDIR)/scripts/kube_create_storage.sh $(DEPLOYMENTNAMESPACE)
323349
$(ROOTDIR)/scripts/kube_create_license_key_secret.sh "$(DEPLOYMENTNAMESPACE)" '$(ENTERPRISELICENSE)'
350+
$(ROOTDIR)/scripts/kube_create_backup_remote_secret.sh "$(DEPLOYMENTNAMESPACE)" '$(TEST_REMOTE_SECRET)'
324351

325352
.PHONY: run-tests
326353
run-tests: docker-test
@@ -336,10 +363,12 @@ endif
336363
kubectl apply -f $(MANIFESTPATHSTORAGE)
337364
kubectl apply -f $(MANIFESTPATHDEPLOYMENT)
338365
kubectl apply -f $(MANIFESTPATHDEPLOYMENTREPLICATION)
366+
kubectl apply -f $(MANIFESTPATHBACKUP)
339367
kubectl apply -f $(MANIFESTPATHTEST)
340368
$(ROOTDIR)/scripts/kube_create_storage.sh $(DEPLOYMENTNAMESPACE)
341369
$(ROOTDIR)/scripts/kube_create_license_key_secret.sh "$(DEPLOYMENTNAMESPACE)" '$(ENTERPRISELICENSE)'
342-
$(ROOTDIR)/scripts/kube_run_tests.sh $(DEPLOYMENTNAMESPACE) $(TESTIMAGE) "$(ARANGODIMAGE)" '$(ENTERPRISEIMAGE)' '$(TESTTIMEOUT)' '$(TESTLENGTHOPTIONS)' '$(TESTOPTIONS)'
370+
$(ROOTDIR)/scripts/kube_create_backup_remote_secret.sh "$(DEPLOYMENTNAMESPACE)" '$(TEST_REMOTE_SECRET)'
371+
$(ROOTDIR)/scripts/kube_run_tests.sh $(DEPLOYMENTNAMESPACE) $(TESTIMAGE) "$(ARANGODIMAGE)" '$(ENTERPRISEIMAGE)' '$(TESTTIMEOUT)' '$(TESTLENGTHOPTIONS)' '$(TESTOPTIONS)' '$(TEST_REMOTE_REPOSITORY)'
343372

344373
$(DURATIONTESTBIN): $(SOURCES)
345374
CGO_ENABLED=0 go build -installsuffix cgo -ldflags "-X main.projectVersion=$(VERSION) -X main.projectBuild=$(COMMIT)" -o $(DURATIONTESTBINNAME) $(REPOPATH)/tests/duration
@@ -430,6 +459,7 @@ delete-operator:
430459
kubectl delete -f $(MANIFESTPATHTEST) --ignore-not-found
431460
kubectl delete -f $(MANIFESTPATHDEPLOYMENT) --ignore-not-found
432461
kubectl delete -f $(MANIFESTPATHDEPLOYMENTREPLICATION) --ignore-not-found
462+
kubectl delete -f $(MANIFESTPATHBACKUP) --ignore-not-found
433463
kubectl delete -f $(MANIFESTPATHSTORAGE) --ignore-not-found
434464
kubectl delete -f $(MANIFESTPATHCRD) --ignore-not-found
435465

@@ -439,6 +469,7 @@ redeploy-operator: delete-operator manifests
439469
kubectl apply -f $(MANIFESTPATHSTORAGE)
440470
kubectl apply -f $(MANIFESTPATHDEPLOYMENT)
441471
kubectl apply -f $(MANIFESTPATHDEPLOYMENTREPLICATION)
472+
kubectl apply -f $(MANIFESTPATHBACKUP)
442473
kubectl apply -f $(MANIFESTPATHTEST)
443474
kubectl get pods
444475

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
apiVersion: apiextensions.k8s.io/v1beta1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
name: arangobackups.backup.arangodb.com
5+
labels:
6+
app.kubernetes.io/name: {{ template "kube-arangodb-crd.name" . }}
7+
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
8+
app.kubernetes.io/managed-by: {{ .Release.Service }}
9+
app.kubernetes.io/instance: {{ .Release.Name }}
10+
release: {{ .Release.Name }}
11+
spec:
12+
group: backup.arangodb.com
13+
additionalPrinterColumns:
14+
- JSONPath: .spec.policyName
15+
description: Policy name
16+
name: Policy
17+
type: string
18+
- JSONPath: .spec.deployment.name
19+
description: Deployment name
20+
name: Deployment
21+
type: string
22+
- JSONPath: .status.backup.version
23+
description: Backup Version
24+
name: Version
25+
type: string
26+
- JSONPath: .status.backup.createdAt
27+
description: Backup Creation Timestamp
28+
name: Created
29+
type: string
30+
- JSONPath: .status.state
31+
description: The actual state of the ArangoBackup
32+
name: State
33+
type: string
34+
- JSONPath: .status.message
35+
priority: 1
36+
description: Message of the ArangoBackup object
37+
name: Message
38+
type: string
39+
names:
40+
kind: ArangoBackup
41+
listKind: ArangoBackupList
42+
plural: arangobackups
43+
shortNames:
44+
- arangobackup
45+
singular: arangobackup
46+
scope: Namespaced
47+
version: v1alpha
48+
subresources:
49+
status: {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
apiVersion: apiextensions.k8s.io/v1beta1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
name: arangobackuppolicies.backup.arangodb.com
5+
labels:
6+
app.kubernetes.io/name: {{ template "kube-arangodb-crd.name" . }}
7+
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
8+
app.kubernetes.io/managed-by: {{ .Release.Service }}
9+
app.kubernetes.io/instance: {{ .Release.Name }}
10+
release: {{ .Release.Name }}
11+
spec:
12+
group: backup.arangodb.com
13+
additionalPrinterColumns:
14+
- JSONPath: .spec.schedule
15+
description: Schedule
16+
name: Schedule
17+
type: string
18+
- JSONPath: .status.scheduled
19+
description: Scheduled
20+
name: Scheduled
21+
type: string
22+
- JSONPath: .status.message
23+
priority: 1
24+
description: Message of the ArangoBackupPolicy object
25+
name: Message
26+
type: string
27+
names:
28+
kind: ArangoBackupPolicy
29+
listKind: ArangoBackupPolicyList
30+
plural: arangobackuppolicies
31+
shortNames:
32+
- arangobackuppolicy
33+
- arangobp
34+
singular: arangobackuppolicy
35+
scope: Namespaced
36+
version: v1alpha
37+
subresources:
38+
status: {}

chart/kube-arangodb/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ Define if ArangoLocalStorage Operator should be enabled.
133133

134134
Default: `false`
135135

136+
### `operator.features.backup`
137+
138+
Define if ArangoBackup Operator should be enabled.
139+
140+
Default: `false`
141+
136142
### `rbac.enabled`
137143

138144
Define if RBAC should be enabled.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{{ if .Values.rbac.enabled -}}
2+
{{ if .Values.operator.features.backup -}}
3+
4+
apiVersion: rbac.authorization.k8s.io/v1
5+
kind: ClusterRoleBinding
6+
metadata:
7+
name: {{ template "kube-arangodb.rbac" . }}-storage
8+
namespace: {{ .Release.Namespace }}
9+
labels:
10+
app.kubernetes.io/name: {{ template "kube-arangodb.name" . }}
11+
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
12+
app.kubernetes.io/managed-by: {{ .Release.Service }}
13+
app.kubernetes.io/instance: {{ .Release.Name }}
14+
release: {{ .Release.Name }}
15+
roleRef:
16+
apiGroup: rbac.authorization.k8s.io
17+
kind: ClusterRole
18+
name: {{ template "kube-arangodb.rbac" . }}-backup
19+
subjects:
20+
- kind: ServiceAccount
21+
name: {{ template "kube-arangodb.operatorName" . }}
22+
namespace: {{ .Release.Namespace }}
23+
24+
25+
{{- end }}
26+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{{ if .Values.rbac.enabled -}}
2+
{{ if .Values.operator.features.backup -}}
3+
4+
apiVersion: rbac.authorization.k8s.io/v1
5+
kind: ClusterRole
6+
metadata:
7+
name: {{ template "kube-arangodb.rbac" . }}-backup
8+
namespace: {{ .Release.Namespace }}
9+
labels:
10+
app.kubernetes.io/name: {{ template "kube-arangodb.name" . }}
11+
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
12+
app.kubernetes.io/managed-by: {{ .Release.Service }}
13+
app.kubernetes.io/instance: {{ .Release.Name }}
14+
release: {{ .Release.Name }}
15+
rules:
16+
- apiGroups: ["apiextensions.k8s.io"]
17+
resources: ["customresourcedefinitions"]
18+
verbs: ["get", "list", "watch"]
19+
{{- end }}
20+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{{ if .Values.rbac.enabled -}}
2+
{{ if .Values.operator.features.backup -}}
3+
4+
apiVersion: rbac.authorization.k8s.io/v1
5+
kind: RoleBinding
6+
metadata:
7+
name: {{ template "kube-arangodb.rbac" . }}-backup
8+
namespace: {{ .Release.Namespace }}
9+
labels:
10+
app.kubernetes.io/name: {{ template "kube-arangodb.name" . }}
11+
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
12+
app.kubernetes.io/managed-by: {{ .Release.Service }}
13+
app.kubernetes.io/instance: {{ .Release.Name }}
14+
release: {{ .Release.Name }}
15+
roleRef:
16+
apiGroup: rbac.authorization.k8s.io
17+
kind: Role
18+
name: {{ template "kube-arangodb.rbac" . }}-backup
19+
subjects:
20+
- kind: ServiceAccount
21+
name: {{ template "kube-arangodb.operatorName" . }}
22+
namespace: {{ .Release.Namespace }}
23+
24+
25+
{{- end }}
26+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{{ if .Values.rbac.enabled -}}
2+
{{ if .Values.operator.features.backup -}}
3+
4+
apiVersion: rbac.authorization.k8s.io/v1
5+
kind: Role
6+
metadata:
7+
name: {{ template "kube-arangodb.rbac" . }}-backup
8+
namespace: {{ .Release.Namespace }}
9+
labels:
10+
app.kubernetes.io/name: {{ template "kube-arangodb.name" . }}
11+
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
12+
app.kubernetes.io/managed-by: {{ .Release.Service }}
13+
app.kubernetes.io/instance: {{ .Release.Name }}
14+
release: {{ .Release.Name }}
15+
rules:
16+
- apiGroups: [""]
17+
resources: ["pods", "services", "endpoints"]
18+
verbs: ["get", "update"]
19+
- apiGroups: [""]
20+
resources: ["secrets"]
21+
verbs: ["get"]
22+
- apiGroups: ["apps"]
23+
resources: ["deployments", "replicasets"]
24+
verbs: ["get"]
25+
- apiGroups: ["backup.arangodb.com"]
26+
resources: ["arangobackuppolicies", "arangobackuppolicies/status", "arangobackups", "arangobackups/status"]
27+
verbs: ["*"]
28+
- apiGroups: ["database.arangodb.com"]
29+
resources: ["arangodeployments"]
30+
verbs: ["get", "list", "watch"]
31+
{{- end }}
32+
{{- end }}

chart/kube-arangodb/templates/deployment-operator/role.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ rules:
2525
- apiGroups: ["policy"]
2626
resources: ["poddisruptionbudgets"]
2727
verbs: ["get", "create", "delete"]
28+
- apiGroups: ["backup.arangodb.com"]
29+
resources: ["arangobackuppolicies", "arangobackups"]
30+
verbs: ["get", "list", "watch"]
2831
- apiGroups: ["monitoring.coreos.com"]
2932
resources: ["servicemonitors"]
3033
verbs: ["get", "create", "delete"]

chart/kube-arangodb/templates/deployment.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ spec:
5959
{{- end -}}
6060
{{ if .Values.operator.features.storage }}
6161
- --operator.storage
62+
{{- end }}
63+
{{ if .Values.operator.features.backup }}
64+
- --operator.backup
6265
{{- end }}
6366
- --chaos.allowed={{ .Values.operator.allowChaos }}
6467
env:

chart/kube-arangodb/values.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ operator:
2929
deployment: true
3030
deploymentReplications: true
3131
storage: false
32+
backup: false
3233

3334
rbac:
3435
enabled: true

dashboard/assets.go

+64-64
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)