Remove pushing images to GCR.

Remove dependency with GCR.

Signed-off-by: Xun Jiang <xun.jiang@broadcom.com>
pull/8913/head
Xun Jiang 2025-05-06 11:38:12 +08:00
parent 83a0badf96
commit d3e8e9a9c2
15 changed files with 117 additions and 162 deletions

View File

@ -121,6 +121,8 @@ jobs:
curl -LO https://dl.k8s.io/release/v${{ matrix.k8s }}/bin/linux/amd64/kubectl
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
git clone https://github.com/vmware-tanzu-experiments/distributed-data-generator.git -b main /tmp/kibishii
GOPATH=~/go \
CLOUD_PROVIDER=kind \
OBJECT_STORE_PROVIDER=aws \
@ -132,7 +134,9 @@ jobs:
ADDITIONAL_CREDS_FILE=/tmp/credential \
ADDITIONAL_BSL_BUCKET=additional-bucket \
VELERO_IMAGE=velero:pr-test-linux-amd64 \
PLUGINS=velero/velero-plugin-for-aws:latest \
GINKGO_LABELS="${{ matrix.labels }}" \
KIBISHII_DIRECTORY=/tmp/kibishii/kubernetes/yaml/ \
make -C test/ run-e2e
timeout-minutes: 30
- name: Upload debug bundle

View File

@ -20,15 +20,6 @@ jobs:
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- id: 'auth'
uses: google-github-actions/auth@v2
with:
credentials_json: '${{ secrets.GCS_SA_KEY }}'
- name: 'set up GCloud SDK'
uses: google-github-actions/setup-gcloud@v2
- name: 'use gcloud CLI'
run: |
gcloud info
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v3
@ -52,12 +43,6 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.out
verbose: true
# Use the JSON key in secret to login gcr.io
- uses: 'docker/login-action@v3'
with:
registry: 'gcr.io' # or REGION.docker.pkg.dev
username: '_json_key'
password: '${{ secrets.GCR_SA_KEY }}'
# Only try to publish the container image from the root repo; forks don't have permission to do so and will always get failures.
- name: Publish container image
if: github.repository == 'vmware-tanzu/velero'

View File

@ -34,11 +34,9 @@ REGISTRY ?= velero
# docker buildx create --name=velero-builder --driver=docker-container --bootstrap --use --config ./buildkitd.toml
# Refer to https://github.com/docker/buildx/issues/1370#issuecomment-1288516840 for more details
INSECURE_REGISTRY ?= false
GCR_REGISTRY ?= gcr.io/velero-gcp
# Image name
IMAGE ?= $(REGISTRY)/$(BIN)
GCR_IMAGE ?= $(GCR_REGISTRY)/$(BIN)
# We allow the Dockerfile to be configurable to enable the use of custom Dockerfiles
# that pull base images from different registries.
@ -81,10 +79,8 @@ TAG_LATEST ?= false
ifeq ($(TAG_LATEST), true)
IMAGE_TAGS ?= $(IMAGE):$(VERSION) $(IMAGE):latest
GCR_IMAGE_TAGS ?= $(GCR_IMAGE):$(VERSION) $(GCR_IMAGE):latest
else
IMAGE_TAGS ?= $(IMAGE):$(VERSION)
GCR_IMAGE_TAGS ?= $(GCR_IMAGE):$(VERSION)
endif
# check buildx is enabled only if docker is in path
@ -116,7 +112,6 @@ CLI_PLATFORMS ?= linux-amd64 linux-arm linux-arm64 darwin-amd64 darwin-arm64 win
BUILD_OUTPUT_TYPE ?= docker
BUILD_OS ?= linux
BUILD_ARCH ?= amd64
BUILD_TAG_GCR ?= false
BUILD_WINDOWS_VERSION ?= ltsc2022
ifeq ($(BUILD_OUTPUT_TYPE), docker)
@ -134,9 +129,6 @@ ALL_OS_ARCH.windows = $(foreach os, $(filter windows,$(ALL_OS)), $(foreach arch,
ALL_OS_ARCH = $(ALL_OS_ARCH.linux)$(ALL_OS_ARCH.windows)
ALL_IMAGE_TAGS = $(IMAGE_TAGS)
ifeq ($(BUILD_TAG_GCR), true)
ALL_IMAGE_TAGS += $(GCR_IMAGE_TAGS)
endif
# set git sha and tree state
GIT_SHA = $(shell git rev-parse HEAD)

View File

@ -113,5 +113,4 @@ TAG_LATEST="$TAG_LATEST" \
BUILD_OS="$BUILD_OS" \
BUILD_ARCH="$BUILD_ARCH" \
BUILD_OUTPUT_TYPE=$OUTPUT_TYPE \
BUILD_TAG_GCR=true \
make all-containers

View File

@ -102,6 +102,7 @@ OBJECT_STORE_PROVIDER ?=
INSTALL_VELERO ?= true
REGISTRY_CREDENTIAL_FILE ?=
KIBISHII_DIRECTORY ?= github.com/vmware-tanzu-experiments/distributed-data-generator/kubernetes/yaml/
IMAGE_REGISTRY_PROXY ?=
# Flags to create an additional BSL for multiple credentials tests
@ -219,7 +220,8 @@ run-e2e: ginkgo
--default-cls-service-account-name=$(DEFAULT_CLS_SERVICE_ACCOUNT_NAME) \
--standby-cls-service-account-name=$(STANDBY_CLS_SERVICE_ACCOUNT_NAME) \
--kibishii-directory=$(KIBISHII_DIRECTORY) \
--disable-informer-cache=$(DISABLE_INFORMER_CACHE)
--disable-informer-cache=$(DISABLE_INFORMER_CACHE) \
--image-registry-proxy=$(IMAGE_REGISTRY_PROXY)
.PHONY: run-perf
run-perf: ginkgo

View File

@ -328,26 +328,26 @@ STANDBY_CLUSTER=wl-antreav1311 \
DEFAULT_CLUSTER_NAME=192.168.0.4 \
STANDBY_CLUSTER_NAME=192.168.0.3 \
FEATURES=EnableCSI \
PLUGINS=gcr.io/velero-gcp/velero-plugin-for-aws:main \
PLUGINS=velero/velero-plugin-for-aws:main \
HAS_VSPHERE_PLUGIN=false \
OBJECT_STORE_PROVIDER=aws \
CREDS_FILE=$HOME/aws-credential \
BSL_CONFIG=region=us-east-1 \
BSL_BUCKET=nightly-normal-account4-test \
BSL_PREFIX=nightly \
ADDITIONAL_BSL_PLUGINS=gcr.io/velero-gcp/velero-plugin-for-aws:main \
ADDITIONAL_BSL_PLUGINS=velero/velero-plugin-for-aws:main \
ADDITIONAL_OBJECT_STORE_PROVIDER=aws \
ADDITIONAL_BSL_CONFIG=region=us-east-1 \
ADDITIONAL_BSL_BUCKET=nightly-restrict-account-test \
ADDITIONAL_BSL_PREFIX=nightly \
ADDITIONAL_CREDS_FILE=$HOME/aws-credential \
VELERO_IMAGE=gcr.io/velero-gcp/velero:main \
RESTORE_HELPER_IMAGE=gcr.io/velero-gcp/velero-restore-helper:main \
VELERO_IMAGE=velero/velero:main \
RESTORE_HELPER_IMAGE=velero/velero:main \
VERSION=main \
SNAPSHOT_MOVE_DATA=true \
STANDBY_CLUSTER_CLOUD_PROVIDER=vsphere \
STANDBY_CLUSTER_OBJECT_STORE_PROVIDER=aws \
STANDBY_CLUSTER_PLUGINS=gcr.io/velero-gcp/velero-plugin-for-aws:main \
STANDBY_CLUSTER_PLUGINS=velero/velero-plugin-for-aws:main \
DISABLE_INFORMER_CACHE=true \
REGISTRY_CREDENTIAL_FILE=$HOME/.docker/config.json \
GINKGO_LABELS=Migration \

View File

@ -172,7 +172,9 @@ func BackupRestoreTest(backupRestoreTestConfig BackupRestoreTestConfig) {
Expect(VeleroInstall(context.Background(), &veleroCfg, false)).To(Succeed())
}
Expect(VeleroAddPluginsForProvider(context.TODO(), veleroCfg.VeleroCLI, veleroCfg.VeleroNamespace, veleroCfg.AdditionalBSLProvider, veleroCfg.AddBSLPlugins)).To(Succeed())
plugins, err := GetPlugins(context.TODO(), veleroCfg, false)
Expect(err).To(Succeed())
Expect(AddPlugins(plugins, veleroCfg)).To(Succeed())
// Create Secret for additional BSL
secretName := fmt.Sprintf("bsl-credentials-%s", UUIDgen)

View File

@ -106,7 +106,9 @@ func BslDeletionTest(useVolumeSnapshots bool) {
}
By(fmt.Sprintf("Add an additional plugin for provider %s", veleroCfg.AdditionalBSLProvider), func() {
Expect(VeleroAddPluginsForProvider(context.TODO(), veleroCfg.VeleroCLI, veleroCfg.VeleroNamespace, veleroCfg.AdditionalBSLProvider, veleroCfg.AddBSLPlugins)).To(Succeed())
plugins, err := GetPlugins(context.TODO(), veleroCfg, false)
Expect(err).To(Succeed())
Expect(AddPlugins(plugins, veleroCfg)).To(Succeed())
})
additionalBsl := fmt.Sprintf("bsl-%s", UUIDgen)

View File

@ -349,6 +349,12 @@ func init() {
1,
"Velero backup's item block worker count.",
)
flag.StringVar(
&test.VeleroCfg.ImageRegistryProxy,
"image-registry-proxy",
"",
"The image registry proxy, e.g. when the DockerHub access limitation is reached, can use available proxy to replace. Default is nil.",
)
}
// Add label [SkipVanillaZfs]:

View File

@ -128,6 +128,7 @@ type VeleroConfig struct {
EKSPolicyARN string
FailFast bool
HasVspherePlugin bool
ImageRegistryProxy string
}
type VeleroCfgInPerf struct {

View File

@ -53,7 +53,7 @@ func NewDeployment(name, ns string, replicas int32, labels map[string]string, co
containers = []corev1api.Container{
{
Name: DefaultContainerName,
Image: "gcr.io/velero-gcp/busybox:latest",
Image: "busybox:1.37.0",
Command: []string{"sleep", "1000000"},
// Make pod obeys the restricted pod security standards.
SecurityContext: &corev1api.SecurityContext{

View File

@ -76,7 +76,7 @@ func CreatePod(client TestClient, ns, name, sc, pvcName string, volumeNameList [
Containers: []corev1api.Container{
{
Name: name,
Image: "gcr.io/velero-gcp/busybox",
Image: "busybox:1.37.0",
Command: []string{"sleep", "3600"},
VolumeMounts: vmList,
// Make pod obeys the restricted pod security standards.

View File

@ -19,6 +19,7 @@ package kibishii
import (
"fmt"
"os/exec"
"path"
"strconv"
"strings"
"time"
@ -275,7 +276,7 @@ func installKibishii(ctx context.Context, namespace string, cloudPlatform, veler
}
// We use kustomize to generate YAML for Kibishii from the checked-in yaml directories
kibishiiInstallCmd := exec.CommandContext(ctx, "kubectl", "apply", "-n", namespace, "-k",
kibishiiDirectory+cloudPlatform, "--timeout=90s")
path.Join(kibishiiDirectory, cloudPlatform), "--timeout=90s")
_, stderr, err := veleroexec.RunCommand(kibishiiInstallCmd)
fmt.Printf("Install Kibishii cmd: %s\n", kibishiiInstallCmd)
if err != nil {

View File

@ -84,7 +84,7 @@ func VeleroInstall(ctx context.Context, veleroCfg *test.VeleroConfig, isStandbyC
}
}
pluginsTmp, err := getPlugins(ctx, *veleroCfg)
pluginsTmp, err := GetPlugins(ctx, *veleroCfg, true)
if err != nil {
return errors.WithMessage(err, "Failed to get provider plugins")
}

View File

@ -27,6 +27,7 @@ import (
"os"
"os/exec"
"os/user"
"path"
"path/filepath"
"reflect"
"regexp"
@ -57,78 +58,51 @@ const RestoreObjectsPrefix = "restores"
const PluginsObjectsPrefix = "plugins"
var ImagesMatrix = map[string]map[string][]string{
"v1.10": {
"aws": {"gcr.io/velero-gcp/velero-plugin-for-aws:v1.6.0"},
"azure": {"gcr.io/velero-gcp/velero-plugin-for-microsoft-azure:v1.6.0"},
"vsphere": {"gcr.io/velero-gcp/velero-plugin-for-vsphere:v1.5.1"},
"gcp": {"gcr.io/velero-gcp/velero-plugin-for-gcp:v1.6.0"},
"csi": {"gcr.io/velero-gcp/velero-plugin-for-csi:v0.4.0"},
"velero": {"gcr.io/velero-gcp/velero:v1.10.2"},
"velero-restore-helper": {"gcr.io/velero-gcp/velero-restore-helper:v1.10.2"},
},
"v1.11": {
"aws": {"gcr.io/velero-gcp/velero-plugin-for-aws:v1.7.0"},
"azure": {"gcr.io/velero-gcp/velero-plugin-for-microsoft-azure:v1.7.0"},
"vsphere": {"gcr.io/velero-gcp/velero-plugin-for-vsphere:v1.5.1"},
"gcp": {"gcr.io/velero-gcp/velero-plugin-for-gcp:v1.7.0"},
"csi": {"gcr.io/velero-gcp/velero-plugin-for-csi:v0.5.0"},
"velero": {"gcr.io/velero-gcp/velero:v1.11.1"},
"velero-restore-helper": {"gcr.io/velero-gcp/velero-restore-helper:v1.11.1"},
},
"v1.12": {
"aws": {"gcr.io/velero-gcp/velero-plugin-for-aws:v1.8.0"},
"azure": {"gcr.io/velero-gcp/velero-plugin-for-microsoft-azure:v1.8.0"},
"vsphere": {"gcr.io/velero-gcp/velero-plugin-for-vsphere:v1.5.1"},
"gcp": {"gcr.io/velero-gcp/velero-plugin-for-gcp:v1.8.0"},
"csi": {"gcr.io/velero-gcp/velero-plugin-for-csi:v0.6.0"},
"velero": {"gcr.io/velero-gcp/velero:v1.12.4"},
"velero-restore-helper": {"gcr.io/velero-gcp/velero-restore-helper:v1.12.4"},
},
"v1.13": {
"aws": {"gcr.io/velero-gcp/velero-plugin-for-aws:v1.9.2"},
"azure": {"gcr.io/velero-gcp/velero-plugin-for-microsoft-azure:v1.9.2"},
"vsphere": {"gcr.io/velero-gcp/velero-plugin-for-vsphere:v1.5.2"},
"gcp": {"gcr.io/velero-gcp/velero-plugin-for-gcp:v1.9.2"},
"csi": {"gcr.io/velero-gcp/velero-plugin-for-csi:v0.7.1"},
"datamover": {"gcr.io/velero-gcp/velero-plugin-for-aws:v1.9.2"},
"velero": {"gcr.io/velero-gcp/velero:v1.13.2"},
"velero-restore-helper": {"gcr.io/velero-gcp/velero-restore-helper:v1.13.2"},
"aws": {"velero/velero-plugin-for-aws:v1.9.2"},
"azure": {"velero/velero-plugin-for-microsoft-azure:v1.9.2"},
"vsphere": {"velero/velero-plugin-for-vsphere:v1.5.2"},
"gcp": {"velero/velero-plugin-for-gcp:v1.9.2"},
"csi": {"velero/velero-plugin-for-csi:v0.7.1"},
"datamover": {"velero/velero-plugin-for-aws:v1.9.2"},
"velero": {"velero/velero:v1.13.2"},
"velero-restore-helper": {"velero/velero-restore-helper:v1.13.2"},
},
"v1.14": {
"aws": {"gcr.io/velero-gcp/velero-plugin-for-aws:v1.10.1"},
"azure": {"gcr.io/velero-gcp/velero-plugin-for-microsoft-azure:v1.10.1"},
"vsphere": {"gcr.io/velero-gcp/velero-plugin-for-vsphere:v1.5.2"},
"gcp": {"gcr.io/velero-gcp/velero-plugin-for-gcp:v1.10.1"},
"datamover": {"gcr.io/velero-gcp/velero-plugin-for-aws:v1.10.1"},
"velero": {"gcr.io/velero-gcp/velero:v1.14.1"},
"velero-restore-helper": {"gcr.io/velero-gcp/velero-restore-helper:v1.14.1"},
"aws": {"velero/velero-plugin-for-aws:v1.10.1"},
"azure": {"velero/velero-plugin-for-microsoft-azure:v1.10.1"},
"vsphere": {"velero/velero-plugin-for-vsphere:v1.5.2"},
"gcp": {"velero/velero-plugin-for-gcp:v1.10.1"},
"datamover": {"velero/velero-plugin-for-aws:v1.10.1"},
"velero": {"velero/velero:v1.14.1"},
"velero-restore-helper": {"velero/velero-restore-helper:v1.14.1"},
},
"v1.15": {
"aws": {"gcr.io/velero-gcp/velero-plugin-for-aws:v1.11.0"},
"azure": {"gcr.io/velero-gcp/velero-plugin-for-microsoft-azure:v1.11.0"},
"vsphere": {"gcr.io/velero-gcp/velero-plugin-for-vsphere:v1.5.2"},
"gcp": {"gcr.io/velero-gcp/velero-plugin-for-gcp:v1.11.0"},
"datamover": {"gcr.io/velero-gcp/velero-plugin-for-aws:v1.11.0"},
"velero": {"gcr.io/velero-gcp/velero:v1.15.2"},
"velero-restore-helper": {"gcr.io/velero-gcp/velero-restore-helper:v1.15.2"},
"aws": {"velero/velero-plugin-for-aws:v1.11.0"},
"azure": {"velero/velero-plugin-for-microsoft-azure:v1.11.0"},
"vsphere": {"velero/velero-plugin-for-vsphere:v1.5.2"},
"gcp": {"velero/velero-plugin-for-gcp:v1.11.0"},
"datamover": {"velero/velero-plugin-for-aws:v1.11.0"},
"velero": {"velero/velero:v1.15.2"},
"velero-restore-helper": {"velero/velero-restore-helper:v1.15.2"},
},
"v1.16": {
"aws": {"gcr.io/velero-gcp/velero-plugin-for-aws:v1.12.0"},
"azure": {"gcr.io/velero-gcp/velero-plugin-for-microsoft-azure:v1.12.0"},
"vsphere": {"gcr.io/velero-gcp/velero-plugin-for-vsphere:v1.5.2"},
"gcp": {"gcr.io/velero-gcp/velero-plugin-for-gcp:v1.12.0"},
"datamover": {"gcr.io/velero-gcp/velero-plugin-for-aws:v1.12.0"},
"velero": {"gcr.io/velero-gcp/velero:v1.15.0"},
"velero-restore-helper": {"gcr.io/velero-gcp/velero:v1.16.0"},
"aws": {"velero/velero-plugin-for-aws:v1.12.0"},
"azure": {"velero/velero-plugin-for-microsoft-azure:v1.12.0"},
"vsphere": {"velero/velero-plugin-for-vsphere:v1.5.2"},
"gcp": {"velero/velero-plugin-for-gcp:v1.12.0"},
"datamover": {"velero/velero-plugin-for-aws:v1.12.0"},
"velero": {"velero/velero:v1.15.0"},
"velero-restore-helper": {"velero/velero:v1.16.0"},
},
"main": {
"aws": {"gcr.io/velero-gcp/velero-plugin-for-aws:main"},
"azure": {"gcr.io/velero-gcp/velero-plugin-for-microsoft-azure:main"},
"vsphere": {"gcr.io/velero-gcp/velero-plugin-for-vsphere:v1.5.2"},
"gcp": {"gcr.io/velero-gcp/velero-plugin-for-gcp:main"},
"datamover": {"gcr.io/velero-gcp/velero-plugin-for-aws:main"},
"velero": {"gcr.io/velero-gcp/velero:main"},
"velero-restore-helper": {"gcr.io/velero-gcp/velero-restore-helper:main"},
"aws": {"velero/velero-plugin-for-aws:main"},
"azure": {"velero/velero-plugin-for-microsoft-azure:main"},
"vsphere": {"velero/velero-plugin-for-vsphere:v1.5.2"},
"gcp": {"velero/velero-plugin-for-gcp:main"},
"datamover": {"velero/velero-plugin-for-aws:main"},
"velero": {"velero/velero:main"},
"velero-restore-helper": {"velero/velero-restore-helper:main"},
},
}
@ -147,6 +121,12 @@ func SetImagesToDefaultValues(config VeleroConfig, version string) (VeleroConfig
versionWithoutPatch)
}
if config.ImageRegistryProxy != "" {
for index := range images {
images[index][0] = path.Join(config.ImageRegistryProxy, images[index][0])
}
}
ret.VeleroImage = images[Velero][0]
ret.RestoreHelperImage = images[VeleroRestoreHelper][0]
@ -177,7 +157,7 @@ func SetImagesToDefaultValues(config VeleroConfig, version string) (VeleroConfig
return ret, nil
}
func getPluginsByVersion(version string, cloudProvider string, needDataMoverPlugin bool) ([]string, error) {
func getPluginsByVersion(version string, cloudProvider string, needDataMoverPlugin bool, imageRegistryProxy string) ([]string, error) {
var cloudMap map[string][]string
arr := strings.Split(version, ".")
if len(arr) >= 3 {
@ -192,6 +172,12 @@ func getPluginsByVersion(version string, cloudProvider string, needDataMoverPlug
var plugins []string
var ok bool
if imageRegistryProxy != "" {
for index := range cloudMap {
cloudMap[index][0] = path.Join(imageRegistryProxy, cloudMap[index][0])
}
}
if slices.Contains(LocalCloudProviders, cloudProvider) {
plugins, ok = cloudMap[AWS]
if !ok {
@ -673,37 +659,45 @@ func VeleroVersion(ctx context.Context, veleroCLI, veleroNamespace string) error
return nil
}
// getProviderPlugins only provide plugin for specific cloud provider
func getProviderPlugins(ctx context.Context, veleroCLI string, cloudProvider string) ([]string, error) {
if cloudProvider == "" {
return []string{}, errors.New("CloudProvider should be provided")
}
// GetPlugins will collect all kinds plugins for VeleroInstall, such as provider
// plugins(cloud provider/object store provider, if object store provider is not
// provided, it should be set to value as cloud provider's), feature plugins (CSI/Datamover)
func GetPlugins(ctx context.Context, veleroCfg VeleroConfig, defaultBSL bool) ([]string, error) {
veleroCLI := veleroCfg.VeleroCLI
cloudProvider := veleroCfg.CloudProvider
objectStoreProvider := veleroCfg.ObjectStoreProvider
providerPlugins := veleroCfg.Plugins
imageRegistryProxy := veleroCfg.ImageRegistryProxy
needDataMoverPlugin := false
var plugins []string
version, err := GetVeleroVersion(ctx, veleroCLI, true)
if err != nil {
return nil, errors.WithMessage(err, "failed to get velero version")
}
plugins, err := getPluginsByVersion(version, cloudProvider, false)
if err != nil {
return nil, errors.WithMessagef(err, "Fail to get plugin by provider %s and version %s", cloudProvider, version)
// Read the plugins for the additional BSL here.
if defaultBSL == false {
fmt.Printf("Additional BSL provider = %s\n", veleroCfg.AdditionalBSLProvider)
fmt.Printf("Additional BSL plugins = %v\n", veleroCfg.AddBSLPlugins)
if veleroCfg.AddBSLPlugins == "" {
if veleroCfg.AdditionalBSLProvider == "" {
return []string{}, errors.New("AdditionalBSLProvider should be provided.")
}
plugins, err = getPluginsByVersion(version, cloudProvider, false, imageRegistryProxy)
if err != nil {
return nil, errors.WithMessagef(err, "Fail to get plugin by provider %s and version %s", cloudProvider, version)
}
} else {
plugins = append(plugins, veleroCfg.AddBSLPlugins)
}
return plugins, nil
}
return plugins, nil
}
// getPlugins will collect all kinds plugins for VeleroInstall, such as provider
// plugins(cloud provider/object store provider, if object store provider is not
// provided, it should be set to value as cloud provider's), feature plugins (CSI/Datamover)
func getPlugins(ctx context.Context, veleroCfg VeleroConfig) ([]string, error) {
veleroCLI := veleroCfg.VeleroCLI
cloudProvider := veleroCfg.CloudProvider
objectStoreProvider := veleroCfg.ObjectStoreProvider
providerPlugins := veleroCfg.Plugins
needDataMoverPlugin := false
// Fetch the plugins for the provider before checking for the object store provider below.
var plugins []string
if len(providerPlugins) > 0 {
plugins = strings.Split(providerPlugins, ",")
} else {
@ -714,47 +708,30 @@ func getPlugins(ctx context.Context, veleroCfg VeleroConfig) ([]string, error) {
objectStoreProvider = cloudProvider
}
var version string
var err error
if veleroCfg.VeleroVersion != "" {
version = veleroCfg.VeleroVersion
} else {
version, err = GetVeleroVersion(ctx, veleroCLI, true)
if err != nil {
return nil, errors.WithMessage(err, "failed to get velero version")
}
}
if veleroCfg.SnapshotMoveData && veleroCfg.DataMoverPlugin == "" && !veleroCfg.IsUpgradeTest {
needDataMoverPlugin = true
}
plugins, err = getPluginsByVersion(version, cloudProvider, needDataMoverPlugin)
plugins, err = getPluginsByVersion(version, cloudProvider, needDataMoverPlugin, imageRegistryProxy)
if err != nil {
return nil, errors.WithMessagef(err, "Fail to get plugin by provider %s and version %s", objectStoreProvider, version)
}
}
return plugins, nil
}
// VeleroAddPluginsForProvider determines which plugins need to be installed for a provider and
// installs them in the current Velero installation, skipping over those that are already installed.
func VeleroAddPluginsForProvider(ctx context.Context, veleroCLI string, veleroNamespace string, provider string, plugin string) error {
var err error
var plugins []string
if plugin == "" {
plugins, err = getProviderPlugins(ctx, veleroCLI, provider)
} else {
plugins = append(plugins, plugin)
}
fmt.Printf("provider cmd = %v\n", provider)
fmt.Printf("plugins cmd = %v\n", plugins)
if err != nil {
return errors.WithMessage(err, "Failed to get plugins")
}
// AddPlugins installs them in the current Velero installation, skipping over those that are already installed.
func AddPlugins(plugins []string, veleroCfg VeleroConfig) error {
for _, plugin := range plugins {
stdoutBuf := new(bytes.Buffer)
stderrBuf := new(bytes.Buffer)
installPluginCmd := exec.CommandContext(ctx, veleroCLI, "--namespace", veleroNamespace, "plugin", "add", plugin, "--confirm")
installPluginCmd := exec.CommandContext(context.TODO(), veleroCfg.VeleroCLI, "--namespace", veleroCfg.VeleroNamespace, "plugin", "add", plugin, "--confirm")
fmt.Printf("installPluginCmd cmd =%v\n", installPluginCmd)
installPluginCmd.Stdout = stdoutBuf
installPluginCmd.Stderr = stderrBuf
@ -1447,14 +1424,6 @@ func UpdateVeleroDeployment(ctx context.Context, veleroCfg VeleroConfig) ([]stri
}
cmds = append(cmds, cmd)
args := fmt.Sprintf("s#\\\"image\\\"\\: \\\"velero\\/velero\\:v[0-9]*.[0-9]*.[0-9]\\\"#\\\"image\\\"\\: \\\"gcr.io\\/velero-gcp\\/nightly\\/velero\\:%s\\\"#g", veleroCfg.VeleroVersion)
cmd = &common.OsCommandLine{
Cmd: "sed",
Args: []string{args},
}
cmds = append(cmds, cmd)
cmd = &common.OsCommandLine{
Cmd: "sed",
Args: []string{fmt.Sprintf("s#\\\"server\\\",#\\\"server\\\",\\\"--uploader-type=%s\\\",#g", veleroCfg.UploaderType)},
@ -1497,14 +1466,6 @@ func UpdateNodeAgent(ctx context.Context, veleroCfg VeleroConfig, dsjson string)
}
cmds = append(cmds, cmd)
args := fmt.Sprintf("s#\\\"image\\\"\\: \\\"velero\\/velero\\:v[0-9]*.[0-9]*.[0-9]\\\"#\\\"image\\\"\\: \\\"gcr.io\\/velero-gcp\\/nightly\\/velero\\:%s\\\"#g", veleroCfg.VeleroVersion)
cmd = &common.OsCommandLine{
Cmd: "sed",
Args: []string{args},
}
cmds = append(cmds, cmd)
cmd = &common.OsCommandLine{
Cmd: "sed",
Args: []string{"s#\\\"name\\\"\\: \\\"restic\\\"#\\\"name\\\"\\: \\\"node-agent\\\"#g"},