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 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 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 \ GOPATH=~/go \
CLOUD_PROVIDER=kind \ CLOUD_PROVIDER=kind \
OBJECT_STORE_PROVIDER=aws \ OBJECT_STORE_PROVIDER=aws \
@ -132,7 +134,9 @@ jobs:
ADDITIONAL_CREDS_FILE=/tmp/credential \ ADDITIONAL_CREDS_FILE=/tmp/credential \
ADDITIONAL_BSL_BUCKET=additional-bucket \ ADDITIONAL_BSL_BUCKET=additional-bucket \
VELERO_IMAGE=velero:pr-test-linux-amd64 \ VELERO_IMAGE=velero:pr-test-linux-amd64 \
PLUGINS=velero/velero-plugin-for-aws:latest \
GINKGO_LABELS="${{ matrix.labels }}" \ GINKGO_LABELS="${{ matrix.labels }}" \
KIBISHII_DIRECTORY=/tmp/kibishii/kubernetes/yaml/ \
make -C test/ run-e2e make -C test/ run-e2e
timeout-minutes: 30 timeout-minutes: 30
- name: Upload debug bundle - name: Upload debug bundle

View File

@ -20,15 +20,6 @@ jobs:
uses: actions/setup-go@v5 uses: actions/setup-go@v5
with: with:
go-version-file: 'go.mod' 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 - name: Set up QEMU
id: qemu id: qemu
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
@ -52,12 +43,6 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }} token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.out files: coverage.out
verbose: true 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. # 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 - name: Publish container image
if: github.repository == 'vmware-tanzu/velero' 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 # 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 # Refer to https://github.com/docker/buildx/issues/1370#issuecomment-1288516840 for more details
INSECURE_REGISTRY ?= false INSECURE_REGISTRY ?= false
GCR_REGISTRY ?= gcr.io/velero-gcp
# Image name # Image name
IMAGE ?= $(REGISTRY)/$(BIN) IMAGE ?= $(REGISTRY)/$(BIN)
GCR_IMAGE ?= $(GCR_REGISTRY)/$(BIN)
# We allow the Dockerfile to be configurable to enable the use of custom Dockerfiles # We allow the Dockerfile to be configurable to enable the use of custom Dockerfiles
# that pull base images from different registries. # that pull base images from different registries.
@ -81,10 +79,8 @@ TAG_LATEST ?= false
ifeq ($(TAG_LATEST), true) ifeq ($(TAG_LATEST), true)
IMAGE_TAGS ?= $(IMAGE):$(VERSION) $(IMAGE):latest IMAGE_TAGS ?= $(IMAGE):$(VERSION) $(IMAGE):latest
GCR_IMAGE_TAGS ?= $(GCR_IMAGE):$(VERSION) $(GCR_IMAGE):latest
else else
IMAGE_TAGS ?= $(IMAGE):$(VERSION) IMAGE_TAGS ?= $(IMAGE):$(VERSION)
GCR_IMAGE_TAGS ?= $(GCR_IMAGE):$(VERSION)
endif endif
# check buildx is enabled only if docker is in path # 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_OUTPUT_TYPE ?= docker
BUILD_OS ?= linux BUILD_OS ?= linux
BUILD_ARCH ?= amd64 BUILD_ARCH ?= amd64
BUILD_TAG_GCR ?= false
BUILD_WINDOWS_VERSION ?= ltsc2022 BUILD_WINDOWS_VERSION ?= ltsc2022
ifeq ($(BUILD_OUTPUT_TYPE), docker) 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_OS_ARCH = $(ALL_OS_ARCH.linux)$(ALL_OS_ARCH.windows)
ALL_IMAGE_TAGS = $(IMAGE_TAGS) ALL_IMAGE_TAGS = $(IMAGE_TAGS)
ifeq ($(BUILD_TAG_GCR), true)
ALL_IMAGE_TAGS += $(GCR_IMAGE_TAGS)
endif
# set git sha and tree state # set git sha and tree state
GIT_SHA = $(shell git rev-parse HEAD) GIT_SHA = $(shell git rev-parse HEAD)

View File

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

View File

@ -102,6 +102,7 @@ OBJECT_STORE_PROVIDER ?=
INSTALL_VELERO ?= true INSTALL_VELERO ?= true
REGISTRY_CREDENTIAL_FILE ?= REGISTRY_CREDENTIAL_FILE ?=
KIBISHII_DIRECTORY ?= github.com/vmware-tanzu-experiments/distributed-data-generator/kubernetes/yaml/ 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 # 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) \ --default-cls-service-account-name=$(DEFAULT_CLS_SERVICE_ACCOUNT_NAME) \
--standby-cls-service-account-name=$(STANDBY_CLS_SERVICE_ACCOUNT_NAME) \ --standby-cls-service-account-name=$(STANDBY_CLS_SERVICE_ACCOUNT_NAME) \
--kibishii-directory=$(KIBISHII_DIRECTORY) \ --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 .PHONY: run-perf
run-perf: ginkgo run-perf: ginkgo

View File

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

View File

@ -172,7 +172,9 @@ func BackupRestoreTest(backupRestoreTestConfig BackupRestoreTestConfig) {
Expect(VeleroInstall(context.Background(), &veleroCfg, false)).To(Succeed()) 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 // Create Secret for additional BSL
secretName := fmt.Sprintf("bsl-credentials-%s", UUIDgen) 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() { 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) additionalBsl := fmt.Sprintf("bsl-%s", UUIDgen)

View File

@ -349,6 +349,12 @@ func init() {
1, 1,
"Velero backup's item block worker count.", "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]: // Add label [SkipVanillaZfs]:

View File

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

View File

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

View File

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

View File

@ -19,6 +19,7 @@ package kibishii
import ( import (
"fmt" "fmt"
"os/exec" "os/exec"
"path"
"strconv" "strconv"
"strings" "strings"
"time" "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 // We use kustomize to generate YAML for Kibishii from the checked-in yaml directories
kibishiiInstallCmd := exec.CommandContext(ctx, "kubectl", "apply", "-n", namespace, "-k", kibishiiInstallCmd := exec.CommandContext(ctx, "kubectl", "apply", "-n", namespace, "-k",
kibishiiDirectory+cloudPlatform, "--timeout=90s") path.Join(kibishiiDirectory, cloudPlatform), "--timeout=90s")
_, stderr, err := veleroexec.RunCommand(kibishiiInstallCmd) _, stderr, err := veleroexec.RunCommand(kibishiiInstallCmd)
fmt.Printf("Install Kibishii cmd: %s\n", kibishiiInstallCmd) fmt.Printf("Install Kibishii cmd: %s\n", kibishiiInstallCmd)
if err != nil { 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 { if err != nil {
return errors.WithMessage(err, "Failed to get provider plugins") return errors.WithMessage(err, "Failed to get provider plugins")
} }

View File

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