Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ update-generated:
"all" \
"github.com/arangodb/kube-arangodb/pkg/generated" \
"github.com/arangodb/kube-arangodb/pkg/apis" \
"deployment:v1alpha replication:v1alpha storage:v1alpha backup:v1alpha" \
"deployment:v1alpha deployment:v1 replication:v1alpha replication:v1 storage:v1alpha backup:v1alpha backup:v1" \
--go-header-file "./tools/codegen/boilerplate.go.txt" \
$(VERIFYARGS)

Expand Down Expand Up @@ -316,10 +316,10 @@ manifests: helm manifests-crd manifests-operator manifests-test chart-crd chart-
.PHONY: run-unit-tests
run-unit-tests: $(SOURCES)
go test $(TESTVERBOSEOPTIONS) \
$(REPOPATH)/pkg/apis/backup/v1alpha \
$(REPOPATH)/pkg/apis/deployment/v1alpha \
$(REPOPATH)/pkg/apis/replication/v1alpha \
$(REPOPATH)/pkg/apis/storage/v1alpha \
$(REPOPATH)/pkg/apis/backup/... \
$(REPOPATH)/pkg/apis/deployment/... \
$(REPOPATH)/pkg/apis/replication/... \
$(REPOPATH)/pkg/apis/storage/... \
$(REPOPATH)/pkg/deployment/... \
$(REPOPATH)/pkg/storage \
$(REPOPATH)/pkg/util/k8sutil \
Expand Down
9 changes: 8 additions & 1 deletion chart/kube-arangodb-crd/templates/backup-policy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ spec:
- arangobp
singular: arangobackuppolicy
scope: Namespaced
version: v1alpha
subresources:
status: {}
version: v1
versions:
- name: v1
served: true
storage: true
- name: v1alpha
served: true
storage: false
11 changes: 9 additions & 2 deletions chart/kube-arangodb-crd/templates/backup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ spec:
- arangobackup
singular: arangobackup
scope: Namespaced
version: v1alpha
subresources:
status: {}
status: {}
version: v1
versions:
- name: v1
served: true
storage: true
- name: v1alpha
served: true
storage: false
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,11 @@ spec:
- arangorepl
singular: arangodeploymentreplication
scope: Namespaced
version: v1alpha
version: v1
versions:
- name: v1
served: true
storage: true
- name: v1alpha
served: true
storage: false
9 changes: 8 additions & 1 deletion chart/kube-arangodb-crd/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,11 @@ spec:
- arango
singular: arangodeployment
scope: Namespaced
version: v1alpha
version: v1
versions:
- name: v1
served: true
storage: true
- name: v1alpha
served: true
storage: false
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ replace (
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.0.0-20190409022649-727a075fdec8
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20190404173353-6a84e37a896d
k8s.io/code-generator => ./deps/k8s.io/code-generator

)

require (
Expand Down Expand Up @@ -61,6 +60,7 @@ require (
github.com/jonboulle/clockwork v0.1.0 // indirect
github.com/juju/errgo v0.0.0-20140925100237-08cceb5d0b53 // indirect
github.com/julienschmidt/httprouter v1.2.0
github.com/magiconair/properties v1.8.0
github.com/manucorporat/stats v0.0.0-20180402194714-3ba42d56d227 // indirect
github.com/mattbaird/jsonpatch v0.0.0-20171005235357-81af80346b1a // indirect
github.com/mattn/go-colorable v0.1.1 // indirect
Expand Down
41 changes: 41 additions & 0 deletions pkg/apis/backup/definitions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// DISCLAIMER
//
// Copyright 2018 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
// Author Adam Janikowski
//

package backup

const (
ArangoBackupCRDName = ArangoBackupResourcePlural + "." + ArangoBackupGroupName
ArangoBackupResourceKind = "ArangoBackup"
ArangoBackupResourcePlural = "arangobackups"

ArangoBackupPolicyCRDName = ArangoBackupPolicyResourcePlural + "." + ArangoBackupGroupName
ArangoBackupPolicyResourceKind = "ArangoBackupPolicy"
ArangoBackupPolicyResourcePlural = "arangobackuppolicies"

ArangoBackupGroupName = "backup.arangodb.com"
)

var (
ArangoBackupShortNames = []string{"arangobackup"}

ArangoBackupPolicyShortNames = []string{"arangobackuppolicy"}
)
60 changes: 60 additions & 0 deletions pkg/apis/backup/v1/backup.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//
// DISCLAIMER
//
// Copyright 2018 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
// Author Adam Janikowski
//

package v1

import (
"github.com/arangodb/kube-arangodb/pkg/apis/backup"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
FinalizerArangoBackup = backup.ArangoBackupCRDName + "/cleanup"
)

var (
FinalizersArangoBackup = []string{
FinalizerArangoBackup,
}
)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ArangoBackupList is a list of ArangoDB backups.
type ArangoBackupList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`

Items []ArangoBackup `json:"items"`
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ArangoBackup contains definition and status of the ArangoDB Backup.
type ArangoBackup struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ArangoBackupSpec `json:"spec"`
Status ArangoBackupStatus `json:"status"`
}
81 changes: 81 additions & 0 deletions pkg/apis/backup/v1/backup_policy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
//
// DISCLAIMER
//
// Copyright 2018 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
// Author Adam Janikowski
//

package v1

import (
"fmt"

deployment "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"

"github.com/arangodb/kube-arangodb/pkg/backup/utils"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ArangoBackupPolicyList is a list of ArangoDB backup policy.
type ArangoBackupPolicyList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`

Items []ArangoBackupPolicy `json:"items"`
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ArangoBackupPolicy contains definition and status of the ArangoDB Backup Policy.
type ArangoBackupPolicy struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ArangoBackupPolicySpec `json:"spec"`
Status ArangoBackupPolicyStatus `json:"status"`
}

func (a *ArangoBackupPolicy) NewBackup(d *deployment.ArangoDeployment) *ArangoBackup {
policyName := a.Name

spec := &ArangoBackupSpec{
Deployment: ArangoBackupSpecDeployment{
Name: d.Name,
},
Upload: a.Spec.BackupTemplate.Upload.DeepCopy(),
Options: a.Spec.BackupTemplate.Options.DeepCopy(),
PolicyName: &policyName,
}

return &ArangoBackup{
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("%s-%s", d.Name, utils.RandomString(8)),
Namespace: a.Namespace,

Labels: d.Labels,

Finalizers: []string{
FinalizerArangoBackup,
},
},
Spec: *spec,
}
}
41 changes: 41 additions & 0 deletions pkg/apis/backup/v1/backup_policy_spec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// DISCLAIMER
//
// Copyright 2018 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
// Author Adam Janikowski
//

package v1

import (
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type ArangoBackupPolicySpec struct {
Schedule string `json:"schedule"`

DeploymentSelector *meta.LabelSelector `json:"selector,omitempty"`

BackupTemplate ArangoBackupTemplate `json:"template"`
}

type ArangoBackupTemplate struct {
Options *ArangoBackupSpecOptions `json:"options,omitempty"`

Upload *ArangoBackupSpecOperation `json:"upload,omitempty"`
}
32 changes: 32 additions & 0 deletions pkg/apis/backup/v1/backup_policy_status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// DISCLAIMER
//
// Copyright 2018 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
// Author Adam Janikowski
//

package v1

import (
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type ArangoBackupPolicyStatus struct {
Scheduled meta.Time `json:"scheduled,omitempty"`
Message string `json:"message,omitempty"`
}
Loading