Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional delay in BIA plugin for parallel item testing #75

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.21
go-version: 1.22
id: go
- name: Check out the code
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.21-bookworm AS build
FROM golang:1.22-bookworm AS build
ENV GOPROXY=https://proxy.golang.org
WORKDIR /go/src/github.com/vmware-tanzu/velero-plugin-example
COPY . .
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Velero currently supports the following kinds of plugins:
- **Backup Item Action** - performs arbitrary logic on individual items prior to storing them in the backup file.
- **Restore Item Action** - performs arbitrary logic on individual items prior to restoring them in the Kubernetes cluster.
- **Delete Item Action** - performs arbitrary logic on individual items prior to deleting them from the backup file.
- **Item Block Action** - executes arbitrary logic for individual items to determine which items should be backed up together

Velero can host multiple plugins inside of a single, resumable process. The plugins can be of any supported type. See `main.go`.

Expand Down Expand Up @@ -61,7 +62,7 @@ Volume snapshot storage:
2. Change the value of `spec.provider` to enable a **Volume Snapshotter** plugin
3. Save and quit. The plugin will be used for the next `backup/restore`

Backup/Restore actions:
Backup/Restore/ItemBlock actions:

1. Add the plugin to Velero as described in the Deploying the plugins section.
2. The plugin will be used for the next `backup/restore`.
Expand All @@ -84,6 +85,7 @@ To run with the example plugins, do the following:

5. Run `kubectl create -f examples/with-pv.yaml` to apply a sample nginx application that uses the example block store plugin. ***Note***: This example works best on a virtual machine, as it uses the host's `/tmp` directory for data storage.
6. Save and quit. The plugins will be used for the next `backup/restore`
7. To see the ItemBlockAction example in action, run `kubectl create -f examples/itemblock-pods.yaml` to apply a sample nginx application that uses the example ItemBlockAction plugin. The example IBA plugin will put both pods in the same itemblock, and you can see this from the sequence of pod hook execution -- both pre hooks run, then after ItemBlock backup, both post hooks run.

## Creating your own plugin project

Expand Down
147 changes: 147 additions & 0 deletions examples/itemblock-pods.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Copyright 2017, 2019 the Velero contributors.
#
# 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.

---
apiVersion: v1
kind: Namespace
metadata:
name: nginx-itemblock

---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: mypvc1
namespace: nginx-itemblock
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 3Gi


---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: mypvc2
namespace: nginx-itemblock
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 3Gi


---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment1
namespace: nginx-itemblock
spec:
selector:
matchLabels:
app: nginx1
replicas: 1
template:
metadata:
annotations:
pre.hook.backup.velero.io/command: '["/usr/bin/echo", "pre-hook"]'
post.hook.backup.velero.io/command: '["/usr/bin/echo", "post-hook"]'
labels:
app: nginx1
itemblock: myblock
spec:
volumes:
- name: nginx-logs
persistentVolumeClaim:
claimName: mypvc1
containers:
- image: docker.io/bitnami/nginx
name: nginx
ports:
- containerPort: 80
volumeMounts:
- mountPath: "/var/log/nginx"
name: nginx-logs
readOnly: false

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment2
namespace: nginx-itemblock
spec:
selector:
matchLabels:
app: nginx2
replicas: 1
template:
metadata:
annotations:
pre.hook.backup.velero.io/command: '["/usr/bin/echo", "pre-hook"]'
post.hook.backup.velero.io/command: '["/usr/bin/echo", "post-hook"]'
labels:
app: nginx2
itemblock: myblock
spec:
volumes:
- name: nginx-logs
persistentVolumeClaim:
claimName: mypvc2
containers:
- image: docker.io/bitnami/nginx
name: nginx
ports:
- containerPort: 80
volumeMounts:
- mountPath: "/var/log/nginx"
name: nginx-logs
readOnly: false

---
apiVersion: v1
kind: Service
metadata:
labels:
app: nginx1
name: my-nginx1
namespace: nginx-itemblock
spec:
ports:
- port: 80
targetPort: 80
selector:
app: nginx1
type: LoadBalancer

---
apiVersion: v1
kind: Service
metadata:
labels:
app: nginx2
name: my-nginx2
namespace: nginx-itemblock
spec:
ports:
- port: 80
targetPort: 80
selector:
app: nginx2
type: LoadBalancer
96 changes: 56 additions & 40 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,70 +1,86 @@
module github.com/vmware-tanzu/velero-plugin-example

go 1.21

toolchain go1.21.3
go 1.22.6

require (
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.8.1
github.com/vmware-tanzu/velero v1.7.1
k8s.io/api v0.25.6
k8s.io/apimachinery v0.25.6
k8s.io/client-go v0.25.6
github.com/sirupsen/logrus v1.9.3
github.com/vmware-tanzu/velero v1.15.0
k8s.io/api v0.29.0
k8s.io/apimachinery v0.29.0
k8s.io/client-go v0.29.0
sigs.k8s.io/controller-runtime v0.17.2
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch/v5 v5.8.0 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/go-hclog v0.14.1 // indirect
github.com/hashicorp/go-plugin v1.4.3 // indirect
github.com/hashicorp/yamux v0.0.0-20190923154419-df201c70410d // indirect
github.com/hashicorp/go-plugin v1.6.0 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kopia/kopia v0.10.7 // indirect
github.com/kubernetes-csi/external-snapshotter/client/v7 v7.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/spf13/cobra v1.4.0 // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.52.3 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.0.0-20220609170525-579cf78fd858 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.56.3 // indirect
google.golang.org/protobuf v1.30.0 // indirect
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/oauth2 v0.19.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/term v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/klog/v2 v2.70.1 // indirect
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
k8s.io/apiextensions-apiserver v0.29.0 // indirect
k8s.io/component-base v0.29.0 // indirect
k8s.io/klog/v2 v2.110.1 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.2

replace github.com/vmware-tanzu/velero => github.com/vmware-tanzu/velero v1.10.0-rc.1.0.20230321103129-29b5894be6f1
replace github.com/vmware-tanzu/velero => github.com/vmware-tanzu/velero v1.10.0-rc.1.0.20240913022151-3f9c2dc789af

replace github.com/kopia/kopia => github.com/project-velero/kopia v0.0.0-20240829032136-7fca59662a06
Loading
Loading