Skip to content

Commit

Permalink
Adds velero plugin for vsphere rock and sanity test
Browse files Browse the repository at this point in the history
Adds the rock for the mentioned velero plugin.

Note that we're only building for amd64, since the plugin depends on
VDDX libraries from VMWare, and there doesn't seem to be support for arm64.
  • Loading branch information
claudiubelu committed Jul 26, 2024
1 parent b936b12 commit d20360d
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 0 deletions.
82 changes: 82 additions & 0 deletions plugins/vsphere/rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Dockerfile: https://github.com/vmware-tanzu/velero/blob/v1.13.2/Dockerfile
name: velero-plugin-for-vsphere
summary: Velero Plugin for vSphere rock
description: |
A rock containing the Velero Plugin for vSphere.
Velero gives you tools to back up and restore your Kubernetes cluster
resources and persistent volumes.
license: Apache-2.0
version: 1.5.2

base: [email protected]
build-base: [email protected]
run-user: _daemon_

platforms:
amd64:

environment:
APP_VERSION: 1.5.2
LD_LIBRARY_PATH: /plugins

# Services to be loaded by the Pebble entrypoint
services:
install-plugin:
override: replace
startup: enabled
command: "bash /scripts/install.sh"
on-success: shutdown
on-failure: shutdown

parts:
dependencies:
plugin: dump
source: https://gvddk-libs.s3-us-west-1.amazonaws.com/VMware-vix-disklib-7.0.2-17696664.x86_64.tar.gz
source-type: tar
override-build: |
craftctl default
# We need these libs for building and running the plugin.
mkdir /usr/local/vmware-vix-disklib-distrib
cp -r ./* /usr/local/vmware-vix-disklib-distrib/
organize:
# The LD_LIBRARY_PATH is set to /plugins.
lib64: ./plugins
prime:
- ./plugins

build-plugin:
after: [dependencies]
plugin: go
source: https://github.com/vmware-tanzu/velero-plugin-for-vsphere.git
source-type: git
source-tag: v${CRAFT_PROJECT_VERSION}
source-depth: 1
build-snaps:
- go/1.18/stable
build-environment:
- CGO_ENABLED: 1
- GO111MODULE: "on"
- GOOS: linux
- GOARCH: $CRAFT_ARCH_BUILD_FOR
- VERSION: ${CRAFT_PROJECT_VERSION}
- PKG: github.com/vmware-tanzu/velero-plugin-for-vsphere
- REGISTRY: canonical
- LDFLAGS: >
-X ${PKG}/pkg/buildinfo.Version=${VERSION} -X ${PKG}/pkg/buildinfo.Registry=${REGISTRY}
go-buildtags:
- mod=readonly
- installsuffix=static
go-generate:
- ./cmd/datamgr
- ./cmd/backup-driver
- ./cmd/plugin
override-build: |
craftctl default
mkdir -p "${CRAFT_PART_INSTALL}/scripts/"
cp scripts/install.sh "${CRAFT_PART_INSTALL}/scripts/"
chmod +x "${CRAFT_PART_INSTALL}/scripts/install.sh"
organize:
bin/data-*: ./
bin/backup-driver*: ./
bin/velero-*: ./plugins/
45 changes: 45 additions & 0 deletions tests/sanity/test_velero_plugin_for_vsphere.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#
# Copyright 2024 Canonical, Ltd.
#

import os

from k8s_test_harness.util import docker_util

ROCK_EXPECTED_FILES = [
"/backup-driver",
"/data-manager-for-plugin",
"/plugins/libvixDiskLib.so",
"/plugins/velero-plugin-for-vsphere",
"/scripts/install.sh",
]


def test_velero_plugin_for_vsphere_rock():
"""Test Velero plugin for vSphere rock."""

image_variable = "ROCK_VELERO_PLUGIN_FOR_VSPHERE"
image = os.getenv(image_variable)
assert image is not None, f"${image_variable} is not set"

# check rock filesystem.
docker_util.ensure_image_contains_paths(image, ROCK_EXPECTED_FILES)

# check binaries.
process = docker_util.run_in_docker(image, ["/backup-driver", "--help"])
assert "Backup driver is a component in Velero vSphere plugin" in process.stdout

process = docker_util.run_in_docker(image, ["/data-manager-for-plugin", "--help"])
assert "Data manager is a component in Velero vSphere plugin" in process.stdout

process = docker_util.run_in_docker(
image, ["/plugins/velero-plugin-for-vsphere"], False
)
expected_err = (
"This binary is a plugin. These are not meant to be executed directly."
)
assert expected_err in process.stderr

# check script.
process = docker_util.run_in_docker(image, ["/scripts/install.sh"], False)
assert "No namespace specified in the namespace file" in process.stdout

0 comments on commit d20360d

Please sign in to comment.