package
0.0.0-20200206082754-c833ae4fd044
Repository: https://github.com/dbadura/kyma.git
Documentation: pkg.go.dev

# README

Backup Plugins

Overview

Backup plugins provide the functionality necessary to properly restore the Kyma cluster and its resources using Velero. They focus mainly on resources related to the Service Catalog, such as instances or bindings. Each plugin is defined in a separate file inside the internal/plugins folder.

The structure of folders and files is based on the Velero plugin example repository.

Installation

For Velero to use plugins, run a Docker image built from the Dockerfile as an init container inside the Velero chart Deployment.

During development, you can push the image to your own image repository and add the plugin by running:

velero plugin add {yourRepo/imageName:tag}

Development

Create a new plugin

To create a new plugin for Velero to use, perform the following steps:

  1. Go to the internal/plugins folder:

This folder includes the backup and restore subfolders, where you can define plugins based on the following object types:

  • Backup Item Action - performs arbitrary logic on individual items before storing them in the backup file.
  • Restore Item Action - performs arbitrary logic on individual items before restoring them in the Kyma cluster.
  ├── internal
    ├── plugins
      ├── backup    # new Backup Item Action plugins
      ├── restore   # new Restore Item Action plugins
  1. Implement plugins as in the following example:
package restore

import (
...
)

// FunctionPluginRestore is a plugin for velero to ...
type FunctionPluginRestore struct {
  Log logrus.FieldLogger
}

// AppliesTo return list of resource kinds which should be handled by this plugin
func (p *FunctionPluginRestore) AppliesTo() (restore.ResourceSelector, error) {
  return restore.ResourceSelector{...}, nil
}

// Execute does ... on the item being restored.
// nolint
func (p *FunctionPluginRestore) Execute(item runtime.Unstructured, restore *v1.Restore) (runtime.Unstructured, error, error) {
    ...
  return item, nil, nil
}

  1. Register created plugins in the components/backup-plugins/main.go file.