feat(zfspv): adding backup and restore support (#162)

This commit adds support for Backup and Restore controller, which will be watching for
the events. The velero plugin will create a Backup CR to create a backup
with the remote location information, the controller will send the data
to that remote location.

In the same way, the velero plugin will create a Restore CR to restore the
volume from the the remote location and the restore controller will restore
the data.

Steps to use velero plugin for ZFS-LocalPV are :

1. install velero

2. add openebs plugin

velero plugin add openebs/velero-plugin:latest

3. Create the volumesnapshot location :

for full backup :-

```yaml
apiVersion: velero.io/v1
kind: VolumeSnapshotLocation
metadata:
  name: default
  namespace: velero
spec:
  provider: openebs.io/zfspv-blockstore
  config:
    bucket: velero
    prefix: zfs
    namespace: openebs
    provider: aws
    region: minio
    s3ForcePathStyle: "true"
    s3Url: http://minio.velero.svc:9000
```

for incremental backup :-

```yaml
apiVersion: velero.io/v1
kind: VolumeSnapshotLocation
metadata:
  name: default
  namespace: velero
spec:
  provider: openebs.io/zfspv-blockstore
  config:
    bucket: velero
    prefix: zfs
    backup: incremental
    namespace: openebs
    provider: aws
    region: minio
    s3ForcePathStyle: "true"
    s3Url: http://minio.velero.svc:9000
```

4. Create backup

velero backup create my-backup --snapshot-volumes --include-namespaces=velero-ns --volume-snapshot-locations=aws-cloud-default --storage-location=default

5. Create Schedule

velero create schedule newschedule  --schedule="*/1 * * * *" --snapshot-volumes --include-namespaces=velero-ns --volume-snapshot-locations=aws-local-default --storage-location=default

6. Restore from backup

velero restore create --from-backup my-backup --restore-volumes=true --namespace-mappings velero-ns:ns1



Signed-off-by: Pawan <pawan@mayadata.io>
This commit is contained in:
Pawan Prakash Sharma 2020-09-08 13:44:39 +05:30 committed by GitHub
parent a5e645b43d
commit e40026c98a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 5148 additions and 7 deletions

View file

@ -28,6 +28,14 @@ type FakeZfsV1 struct {
*testing.Fake
}
func (c *FakeZfsV1) ZFSBackups(namespace string) v1.ZFSBackupInterface {
return &FakeZFSBackups{c, namespace}
}
func (c *FakeZfsV1) ZFSRestores(namespace string) v1.ZFSRestoreInterface {
return &FakeZFSRestores{c, namespace}
}
func (c *FakeZfsV1) ZFSSnapshots(namespace string) v1.ZFSSnapshotInterface {
return &FakeZFSSnapshots{c, namespace}
}

View file

@ -0,0 +1,140 @@
/*
Copyright 2019 The OpenEBS Authors
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.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
zfsv1 "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
)
// FakeZFSBackups implements ZFSBackupInterface
type FakeZFSBackups struct {
Fake *FakeZfsV1
ns string
}
var zfsbackupsResource = schema.GroupVersionResource{Group: "zfs.openebs.io", Version: "v1", Resource: "zfsbackups"}
var zfsbackupsKind = schema.GroupVersionKind{Group: "zfs.openebs.io", Version: "v1", Kind: "ZFSBackup"}
// Get takes name of the zFSBackup, and returns the corresponding zFSBackup object, and an error if there is any.
func (c *FakeZFSBackups) Get(name string, options v1.GetOptions) (result *zfsv1.ZFSBackup, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(zfsbackupsResource, c.ns, name), &zfsv1.ZFSBackup{})
if obj == nil {
return nil, err
}
return obj.(*zfsv1.ZFSBackup), err
}
// List takes label and field selectors, and returns the list of ZFSBackups that match those selectors.
func (c *FakeZFSBackups) List(opts v1.ListOptions) (result *zfsv1.ZFSBackupList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(zfsbackupsResource, zfsbackupsKind, c.ns, opts), &zfsv1.ZFSBackupList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &zfsv1.ZFSBackupList{ListMeta: obj.(*zfsv1.ZFSBackupList).ListMeta}
for _, item := range obj.(*zfsv1.ZFSBackupList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested zFSBackups.
func (c *FakeZFSBackups) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(zfsbackupsResource, c.ns, opts))
}
// Create takes the representation of a zFSBackup and creates it. Returns the server's representation of the zFSBackup, and an error, if there is any.
func (c *FakeZFSBackups) Create(zFSBackup *zfsv1.ZFSBackup) (result *zfsv1.ZFSBackup, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(zfsbackupsResource, c.ns, zFSBackup), &zfsv1.ZFSBackup{})
if obj == nil {
return nil, err
}
return obj.(*zfsv1.ZFSBackup), err
}
// Update takes the representation of a zFSBackup and updates it. Returns the server's representation of the zFSBackup, and an error, if there is any.
func (c *FakeZFSBackups) Update(zFSBackup *zfsv1.ZFSBackup) (result *zfsv1.ZFSBackup, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(zfsbackupsResource, c.ns, zFSBackup), &zfsv1.ZFSBackup{})
if obj == nil {
return nil, err
}
return obj.(*zfsv1.ZFSBackup), err
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeZFSBackups) UpdateStatus(zFSBackup *zfsv1.ZFSBackup) (*zfsv1.ZFSBackup, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(zfsbackupsResource, "status", c.ns, zFSBackup), &zfsv1.ZFSBackup{})
if obj == nil {
return nil, err
}
return obj.(*zfsv1.ZFSBackup), err
}
// Delete takes name of the zFSBackup and deletes it. Returns an error if one occurs.
func (c *FakeZFSBackups) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(zfsbackupsResource, c.ns, name), &zfsv1.ZFSBackup{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeZFSBackups) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(zfsbackupsResource, c.ns, listOptions)
_, err := c.Fake.Invokes(action, &zfsv1.ZFSBackupList{})
return err
}
// Patch applies the patch and returns the patched zFSBackup.
func (c *FakeZFSBackups) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *zfsv1.ZFSBackup, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(zfsbackupsResource, c.ns, name, pt, data, subresources...), &zfsv1.ZFSBackup{})
if obj == nil {
return nil, err
}
return obj.(*zfsv1.ZFSBackup), err
}

View file

@ -0,0 +1,140 @@
/*
Copyright 2019 The OpenEBS Authors
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.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
zfsv1 "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
)
// FakeZFSRestores implements ZFSRestoreInterface
type FakeZFSRestores struct {
Fake *FakeZfsV1
ns string
}
var zfsrestoresResource = schema.GroupVersionResource{Group: "zfs.openebs.io", Version: "v1", Resource: "zfsrestores"}
var zfsrestoresKind = schema.GroupVersionKind{Group: "zfs.openebs.io", Version: "v1", Kind: "ZFSRestore"}
// Get takes name of the zFSRestore, and returns the corresponding zFSRestore object, and an error if there is any.
func (c *FakeZFSRestores) Get(name string, options v1.GetOptions) (result *zfsv1.ZFSRestore, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(zfsrestoresResource, c.ns, name), &zfsv1.ZFSRestore{})
if obj == nil {
return nil, err
}
return obj.(*zfsv1.ZFSRestore), err
}
// List takes label and field selectors, and returns the list of ZFSRestores that match those selectors.
func (c *FakeZFSRestores) List(opts v1.ListOptions) (result *zfsv1.ZFSRestoreList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(zfsrestoresResource, zfsrestoresKind, c.ns, opts), &zfsv1.ZFSRestoreList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &zfsv1.ZFSRestoreList{ListMeta: obj.(*zfsv1.ZFSRestoreList).ListMeta}
for _, item := range obj.(*zfsv1.ZFSRestoreList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested zFSRestores.
func (c *FakeZFSRestores) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(zfsrestoresResource, c.ns, opts))
}
// Create takes the representation of a zFSRestore and creates it. Returns the server's representation of the zFSRestore, and an error, if there is any.
func (c *FakeZFSRestores) Create(zFSRestore *zfsv1.ZFSRestore) (result *zfsv1.ZFSRestore, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(zfsrestoresResource, c.ns, zFSRestore), &zfsv1.ZFSRestore{})
if obj == nil {
return nil, err
}
return obj.(*zfsv1.ZFSRestore), err
}
// Update takes the representation of a zFSRestore and updates it. Returns the server's representation of the zFSRestore, and an error, if there is any.
func (c *FakeZFSRestores) Update(zFSRestore *zfsv1.ZFSRestore) (result *zfsv1.ZFSRestore, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(zfsrestoresResource, c.ns, zFSRestore), &zfsv1.ZFSRestore{})
if obj == nil {
return nil, err
}
return obj.(*zfsv1.ZFSRestore), err
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeZFSRestores) UpdateStatus(zFSRestore *zfsv1.ZFSRestore) (*zfsv1.ZFSRestore, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(zfsrestoresResource, "status", c.ns, zFSRestore), &zfsv1.ZFSRestore{})
if obj == nil {
return nil, err
}
return obj.(*zfsv1.ZFSRestore), err
}
// Delete takes name of the zFSRestore and deletes it. Returns an error if one occurs.
func (c *FakeZFSRestores) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(zfsrestoresResource, c.ns, name), &zfsv1.ZFSRestore{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeZFSRestores) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(zfsrestoresResource, c.ns, listOptions)
_, err := c.Fake.Invokes(action, &zfsv1.ZFSRestoreList{})
return err
}
// Patch applies the patch and returns the patched zFSRestore.
func (c *FakeZFSRestores) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *zfsv1.ZFSRestore, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(zfsrestoresResource, c.ns, name, pt, data, subresources...), &zfsv1.ZFSRestore{})
if obj == nil {
return nil, err
}
return obj.(*zfsv1.ZFSRestore), err
}

View file

@ -18,6 +18,10 @@ limitations under the License.
package v1
type ZFSBackupExpansion interface{}
type ZFSRestoreExpansion interface{}
type ZFSSnapshotExpansion interface{}
type ZFSVolumeExpansion interface{}

View file

@ -26,6 +26,8 @@ import (
type ZfsV1Interface interface {
RESTClient() rest.Interface
ZFSBackupsGetter
ZFSRestoresGetter
ZFSSnapshotsGetter
ZFSVolumesGetter
}
@ -35,6 +37,14 @@ type ZfsV1Client struct {
restClient rest.Interface
}
func (c *ZfsV1Client) ZFSBackups(namespace string) ZFSBackupInterface {
return newZFSBackups(c, namespace)
}
func (c *ZfsV1Client) ZFSRestores(namespace string) ZFSRestoreInterface {
return newZFSRestores(c, namespace)
}
func (c *ZfsV1Client) ZFSSnapshots(namespace string) ZFSSnapshotInterface {
return newZFSSnapshots(c, namespace)
}

View file

@ -0,0 +1,191 @@
/*
Copyright 2019 The OpenEBS Authors
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.
*/
// Code generated by client-gen. DO NOT EDIT.
package v1
import (
"time"
v1 "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1"
scheme "github.com/openebs/zfs-localpv/pkg/generated/clientset/internalclientset/scheme"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest"
)
// ZFSBackupsGetter has a method to return a ZFSBackupInterface.
// A group's client should implement this interface.
type ZFSBackupsGetter interface {
ZFSBackups(namespace string) ZFSBackupInterface
}
// ZFSBackupInterface has methods to work with ZFSBackup resources.
type ZFSBackupInterface interface {
Create(*v1.ZFSBackup) (*v1.ZFSBackup, error)
Update(*v1.ZFSBackup) (*v1.ZFSBackup, error)
UpdateStatus(*v1.ZFSBackup) (*v1.ZFSBackup, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error
Get(name string, options metav1.GetOptions) (*v1.ZFSBackup, error)
List(opts metav1.ListOptions) (*v1.ZFSBackupList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ZFSBackup, err error)
ZFSBackupExpansion
}
// zFSBackups implements ZFSBackupInterface
type zFSBackups struct {
client rest.Interface
ns string
}
// newZFSBackups returns a ZFSBackups
func newZFSBackups(c *ZfsV1Client, namespace string) *zFSBackups {
return &zFSBackups{
client: c.RESTClient(),
ns: namespace,
}
}
// Get takes name of the zFSBackup, and returns the corresponding zFSBackup object, and an error if there is any.
func (c *zFSBackups) Get(name string, options metav1.GetOptions) (result *v1.ZFSBackup, err error) {
result = &v1.ZFSBackup{}
err = c.client.Get().
Namespace(c.ns).
Resource("zfsbackups").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do().
Into(result)
return
}
// List takes label and field selectors, and returns the list of ZFSBackups that match those selectors.
func (c *zFSBackups) List(opts metav1.ListOptions) (result *v1.ZFSBackupList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1.ZFSBackupList{}
err = c.client.Get().
Namespace(c.ns).
Resource("zfsbackups").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do().
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested zFSBackups.
func (c *zFSBackups) Watch(opts metav1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("zfsbackups").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch()
}
// Create takes the representation of a zFSBackup and creates it. Returns the server's representation of the zFSBackup, and an error, if there is any.
func (c *zFSBackups) Create(zFSBackup *v1.ZFSBackup) (result *v1.ZFSBackup, err error) {
result = &v1.ZFSBackup{}
err = c.client.Post().
Namespace(c.ns).
Resource("zfsbackups").
Body(zFSBackup).
Do().
Into(result)
return
}
// Update takes the representation of a zFSBackup and updates it. Returns the server's representation of the zFSBackup, and an error, if there is any.
func (c *zFSBackups) Update(zFSBackup *v1.ZFSBackup) (result *v1.ZFSBackup, err error) {
result = &v1.ZFSBackup{}
err = c.client.Put().
Namespace(c.ns).
Resource("zfsbackups").
Name(zFSBackup.Name).
Body(zFSBackup).
Do().
Into(result)
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *zFSBackups) UpdateStatus(zFSBackup *v1.ZFSBackup) (result *v1.ZFSBackup, err error) {
result = &v1.ZFSBackup{}
err = c.client.Put().
Namespace(c.ns).
Resource("zfsbackups").
Name(zFSBackup.Name).
SubResource("status").
Body(zFSBackup).
Do().
Into(result)
return
}
// Delete takes name of the zFSBackup and deletes it. Returns an error if one occurs.
func (c *zFSBackups) Delete(name string, options *metav1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("zfsbackups").
Name(name).
Body(options).
Do().
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *zFSBackups) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error {
var timeout time.Duration
if listOptions.TimeoutSeconds != nil {
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Namespace(c.ns).
Resource("zfsbackups").
VersionedParams(&listOptions, scheme.ParameterCodec).
Timeout(timeout).
Body(options).
Do().
Error()
}
// Patch applies the patch and returns the patched zFSBackup.
func (c *zFSBackups) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ZFSBackup, err error) {
result = &v1.ZFSBackup{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("zfsbackups").
SubResource(subresources...).
Name(name).
Body(data).
Do().
Into(result)
return
}

View file

@ -0,0 +1,191 @@
/*
Copyright 2019 The OpenEBS Authors
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.
*/
// Code generated by client-gen. DO NOT EDIT.
package v1
import (
"time"
v1 "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1"
scheme "github.com/openebs/zfs-localpv/pkg/generated/clientset/internalclientset/scheme"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest"
)
// ZFSRestoresGetter has a method to return a ZFSRestoreInterface.
// A group's client should implement this interface.
type ZFSRestoresGetter interface {
ZFSRestores(namespace string) ZFSRestoreInterface
}
// ZFSRestoreInterface has methods to work with ZFSRestore resources.
type ZFSRestoreInterface interface {
Create(*v1.ZFSRestore) (*v1.ZFSRestore, error)
Update(*v1.ZFSRestore) (*v1.ZFSRestore, error)
UpdateStatus(*v1.ZFSRestore) (*v1.ZFSRestore, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error
Get(name string, options metav1.GetOptions) (*v1.ZFSRestore, error)
List(opts metav1.ListOptions) (*v1.ZFSRestoreList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ZFSRestore, err error)
ZFSRestoreExpansion
}
// zFSRestores implements ZFSRestoreInterface
type zFSRestores struct {
client rest.Interface
ns string
}
// newZFSRestores returns a ZFSRestores
func newZFSRestores(c *ZfsV1Client, namespace string) *zFSRestores {
return &zFSRestores{
client: c.RESTClient(),
ns: namespace,
}
}
// Get takes name of the zFSRestore, and returns the corresponding zFSRestore object, and an error if there is any.
func (c *zFSRestores) Get(name string, options metav1.GetOptions) (result *v1.ZFSRestore, err error) {
result = &v1.ZFSRestore{}
err = c.client.Get().
Namespace(c.ns).
Resource("zfsrestores").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do().
Into(result)
return
}
// List takes label and field selectors, and returns the list of ZFSRestores that match those selectors.
func (c *zFSRestores) List(opts metav1.ListOptions) (result *v1.ZFSRestoreList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1.ZFSRestoreList{}
err = c.client.Get().
Namespace(c.ns).
Resource("zfsrestores").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do().
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested zFSRestores.
func (c *zFSRestores) Watch(opts metav1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("zfsrestores").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch()
}
// Create takes the representation of a zFSRestore and creates it. Returns the server's representation of the zFSRestore, and an error, if there is any.
func (c *zFSRestores) Create(zFSRestore *v1.ZFSRestore) (result *v1.ZFSRestore, err error) {
result = &v1.ZFSRestore{}
err = c.client.Post().
Namespace(c.ns).
Resource("zfsrestores").
Body(zFSRestore).
Do().
Into(result)
return
}
// Update takes the representation of a zFSRestore and updates it. Returns the server's representation of the zFSRestore, and an error, if there is any.
func (c *zFSRestores) Update(zFSRestore *v1.ZFSRestore) (result *v1.ZFSRestore, err error) {
result = &v1.ZFSRestore{}
err = c.client.Put().
Namespace(c.ns).
Resource("zfsrestores").
Name(zFSRestore.Name).
Body(zFSRestore).
Do().
Into(result)
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *zFSRestores) UpdateStatus(zFSRestore *v1.ZFSRestore) (result *v1.ZFSRestore, err error) {
result = &v1.ZFSRestore{}
err = c.client.Put().
Namespace(c.ns).
Resource("zfsrestores").
Name(zFSRestore.Name).
SubResource("status").
Body(zFSRestore).
Do().
Into(result)
return
}
// Delete takes name of the zFSRestore and deletes it. Returns an error if one occurs.
func (c *zFSRestores) Delete(name string, options *metav1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("zfsrestores").
Name(name).
Body(options).
Do().
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *zFSRestores) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error {
var timeout time.Duration
if listOptions.TimeoutSeconds != nil {
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Namespace(c.ns).
Resource("zfsrestores").
VersionedParams(&listOptions, scheme.ParameterCodec).
Timeout(timeout).
Body(options).
Do().
Error()
}
// Patch applies the patch and returns the patched zFSRestore.
func (c *zFSRestores) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ZFSRestore, err error) {
result = &v1.ZFSRestore{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("zfsrestores").
SubResource(subresources...).
Name(name).
Body(data).
Do().
Into(result)
return
}

View file

@ -53,6 +53,10 @@ func (f *genericInformer) Lister() cache.GenericLister {
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
switch resource {
// Group=zfs.openebs.io, Version=v1
case v1.SchemeGroupVersion.WithResource("zfsbackups"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Zfs().V1().ZFSBackups().Informer()}, nil
case v1.SchemeGroupVersion.WithResource("zfsrestores"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Zfs().V1().ZFSRestores().Informer()}, nil
case v1.SchemeGroupVersion.WithResource("zfssnapshots"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Zfs().V1().ZFSSnapshots().Informer()}, nil
case v1.SchemeGroupVersion.WithResource("zfsvolumes"):

View file

@ -24,6 +24,10 @@ import (
// Interface provides access to all the informers in this group version.
type Interface interface {
// ZFSBackups returns a ZFSBackupInformer.
ZFSBackups() ZFSBackupInformer
// ZFSRestores returns a ZFSRestoreInformer.
ZFSRestores() ZFSRestoreInformer
// ZFSSnapshots returns a ZFSSnapshotInformer.
ZFSSnapshots() ZFSSnapshotInformer
// ZFSVolumes returns a ZFSVolumeInformer.
@ -41,6 +45,16 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList
return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
}
// ZFSBackups returns a ZFSBackupInformer.
func (v *version) ZFSBackups() ZFSBackupInformer {
return &zFSBackupInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}
// ZFSRestores returns a ZFSRestoreInformer.
func (v *version) ZFSRestores() ZFSRestoreInformer {
return &zFSRestoreInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}
// ZFSSnapshots returns a ZFSSnapshotInformer.
func (v *version) ZFSSnapshots() ZFSSnapshotInformer {
return &zFSSnapshotInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}

View file

@ -0,0 +1,89 @@
/*
Copyright 2019 The OpenEBS Authors
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.
*/
// Code generated by informer-gen. DO NOT EDIT.
package v1
import (
time "time"
zfsv1 "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1"
internalclientset "github.com/openebs/zfs-localpv/pkg/generated/clientset/internalclientset"
internalinterfaces "github.com/openebs/zfs-localpv/pkg/generated/informer/externalversions/internalinterfaces"
v1 "github.com/openebs/zfs-localpv/pkg/generated/lister/zfs/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache"
)
// ZFSBackupInformer provides access to a shared informer and lister for
// ZFSBackups.
type ZFSBackupInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1.ZFSBackupLister
}
type zFSBackupInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
namespace string
}
// NewZFSBackupInformer constructs a new informer for ZFSBackup type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewZFSBackupInformer(client internalclientset.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredZFSBackupInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredZFSBackupInformer constructs a new informer for ZFSBackup type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredZFSBackupInformer(client internalclientset.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ZfsV1().ZFSBackups(namespace).List(options)
},
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ZfsV1().ZFSBackups(namespace).Watch(options)
},
},
&zfsv1.ZFSBackup{},
resyncPeriod,
indexers,
)
}
func (f *zFSBackupInformer) defaultInformer(client internalclientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredZFSBackupInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *zFSBackupInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&zfsv1.ZFSBackup{}, f.defaultInformer)
}
func (f *zFSBackupInformer) Lister() v1.ZFSBackupLister {
return v1.NewZFSBackupLister(f.Informer().GetIndexer())
}

View file

@ -0,0 +1,89 @@
/*
Copyright 2019 The OpenEBS Authors
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.
*/
// Code generated by informer-gen. DO NOT EDIT.
package v1
import (
time "time"
zfsv1 "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1"
internalclientset "github.com/openebs/zfs-localpv/pkg/generated/clientset/internalclientset"
internalinterfaces "github.com/openebs/zfs-localpv/pkg/generated/informer/externalversions/internalinterfaces"
v1 "github.com/openebs/zfs-localpv/pkg/generated/lister/zfs/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache"
)
// ZFSRestoreInformer provides access to a shared informer and lister for
// ZFSRestores.
type ZFSRestoreInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1.ZFSRestoreLister
}
type zFSRestoreInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
namespace string
}
// NewZFSRestoreInformer constructs a new informer for ZFSRestore type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewZFSRestoreInformer(client internalclientset.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredZFSRestoreInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredZFSRestoreInformer constructs a new informer for ZFSRestore type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredZFSRestoreInformer(client internalclientset.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ZfsV1().ZFSRestores(namespace).List(options)
},
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ZfsV1().ZFSRestores(namespace).Watch(options)
},
},
&zfsv1.ZFSRestore{},
resyncPeriod,
indexers,
)
}
func (f *zFSRestoreInformer) defaultInformer(client internalclientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredZFSRestoreInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *zFSRestoreInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&zfsv1.ZFSRestore{}, f.defaultInformer)
}
func (f *zFSRestoreInformer) Lister() v1.ZFSRestoreLister {
return v1.NewZFSRestoreLister(f.Informer().GetIndexer())
}

View file

@ -18,6 +18,22 @@ limitations under the License.
package v1
// ZFSBackupListerExpansion allows custom methods to be added to
// ZFSBackupLister.
type ZFSBackupListerExpansion interface{}
// ZFSBackupNamespaceListerExpansion allows custom methods to be added to
// ZFSBackupNamespaceLister.
type ZFSBackupNamespaceListerExpansion interface{}
// ZFSRestoreListerExpansion allows custom methods to be added to
// ZFSRestoreLister.
type ZFSRestoreListerExpansion interface{}
// ZFSRestoreNamespaceListerExpansion allows custom methods to be added to
// ZFSRestoreNamespaceLister.
type ZFSRestoreNamespaceListerExpansion interface{}
// ZFSSnapshotListerExpansion allows custom methods to be added to
// ZFSSnapshotLister.
type ZFSSnapshotListerExpansion interface{}

View file

@ -0,0 +1,94 @@
/*
Copyright 2019 The OpenEBS Authors
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.
*/
// Code generated by lister-gen. DO NOT EDIT.
package v1
import (
v1 "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// ZFSBackupLister helps list ZFSBackups.
type ZFSBackupLister interface {
// List lists all ZFSBackups in the indexer.
List(selector labels.Selector) (ret []*v1.ZFSBackup, err error)
// ZFSBackups returns an object that can list and get ZFSBackups.
ZFSBackups(namespace string) ZFSBackupNamespaceLister
ZFSBackupListerExpansion
}
// zFSBackupLister implements the ZFSBackupLister interface.
type zFSBackupLister struct {
indexer cache.Indexer
}
// NewZFSBackupLister returns a new ZFSBackupLister.
func NewZFSBackupLister(indexer cache.Indexer) ZFSBackupLister {
return &zFSBackupLister{indexer: indexer}
}
// List lists all ZFSBackups in the indexer.
func (s *zFSBackupLister) List(selector labels.Selector) (ret []*v1.ZFSBackup, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1.ZFSBackup))
})
return ret, err
}
// ZFSBackups returns an object that can list and get ZFSBackups.
func (s *zFSBackupLister) ZFSBackups(namespace string) ZFSBackupNamespaceLister {
return zFSBackupNamespaceLister{indexer: s.indexer, namespace: namespace}
}
// ZFSBackupNamespaceLister helps list and get ZFSBackups.
type ZFSBackupNamespaceLister interface {
// List lists all ZFSBackups in the indexer for a given namespace.
List(selector labels.Selector) (ret []*v1.ZFSBackup, err error)
// Get retrieves the ZFSBackup from the indexer for a given namespace and name.
Get(name string) (*v1.ZFSBackup, error)
ZFSBackupNamespaceListerExpansion
}
// zFSBackupNamespaceLister implements the ZFSBackupNamespaceLister
// interface.
type zFSBackupNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all ZFSBackups in the indexer for a given namespace.
func (s zFSBackupNamespaceLister) List(selector labels.Selector) (ret []*v1.ZFSBackup, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v1.ZFSBackup))
})
return ret, err
}
// Get retrieves the ZFSBackup from the indexer for a given namespace and name.
func (s zFSBackupNamespaceLister) Get(name string) (*v1.ZFSBackup, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1.Resource("zfsbackup"), name)
}
return obj.(*v1.ZFSBackup), nil
}

View file

@ -0,0 +1,94 @@
/*
Copyright 2019 The OpenEBS Authors
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.
*/
// Code generated by lister-gen. DO NOT EDIT.
package v1
import (
v1 "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// ZFSRestoreLister helps list ZFSRestores.
type ZFSRestoreLister interface {
// List lists all ZFSRestores in the indexer.
List(selector labels.Selector) (ret []*v1.ZFSRestore, err error)
// ZFSRestores returns an object that can list and get ZFSRestores.
ZFSRestores(namespace string) ZFSRestoreNamespaceLister
ZFSRestoreListerExpansion
}
// zFSRestoreLister implements the ZFSRestoreLister interface.
type zFSRestoreLister struct {
indexer cache.Indexer
}
// NewZFSRestoreLister returns a new ZFSRestoreLister.
func NewZFSRestoreLister(indexer cache.Indexer) ZFSRestoreLister {
return &zFSRestoreLister{indexer: indexer}
}
// List lists all ZFSRestores in the indexer.
func (s *zFSRestoreLister) List(selector labels.Selector) (ret []*v1.ZFSRestore, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1.ZFSRestore))
})
return ret, err
}
// ZFSRestores returns an object that can list and get ZFSRestores.
func (s *zFSRestoreLister) ZFSRestores(namespace string) ZFSRestoreNamespaceLister {
return zFSRestoreNamespaceLister{indexer: s.indexer, namespace: namespace}
}
// ZFSRestoreNamespaceLister helps list and get ZFSRestores.
type ZFSRestoreNamespaceLister interface {
// List lists all ZFSRestores in the indexer for a given namespace.
List(selector labels.Selector) (ret []*v1.ZFSRestore, err error)
// Get retrieves the ZFSRestore from the indexer for a given namespace and name.
Get(name string) (*v1.ZFSRestore, error)
ZFSRestoreNamespaceListerExpansion
}
// zFSRestoreNamespaceLister implements the ZFSRestoreNamespaceLister
// interface.
type zFSRestoreNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all ZFSRestores in the indexer for a given namespace.
func (s zFSRestoreNamespaceLister) List(selector labels.Selector) (ret []*v1.ZFSRestore, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v1.ZFSRestore))
})
return ret, err
}
// Get retrieves the ZFSRestore from the indexer for a given namespace and name.
func (s zFSRestoreNamespaceLister) Get(name string) (*v1.ZFSRestore, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1.Resource("zfsrestore"), name)
}
return obj.(*v1.ZFSRestore), nil
}