From 3475a65a35ec0aacc725e959af334407f34e2448 Mon Sep 17 00:00:00 2001 From: Rakshith R Date: Wed, 12 Nov 2025 16:09:40 +0530 Subject: [PATCH] Modify image names and initial mover code This commit modifies image names to quay.io/ramendr/ceph-volsync-plugin-operator and adds initial mover code with image name quay.io/ramendr/ceph-volsync-plugin-mover. Signed-off-by: Rakshith R --- Makefile | 42 ++++++++++++++++++----- Dockerfile => build/Containerfile.manager | 4 +-- build/Containerfile.mover | 31 +++++++++++++++++ cmd/{ => manager}/main.go | 0 cmd/mover/main.go | 21 ++++++++++++ test/e2e/e2e_suite_test.go | 15 ++++++++ 6 files changed, 102 insertions(+), 11 deletions(-) rename Dockerfile => build/Containerfile.manager (92%) create mode 100644 build/Containerfile.mover rename cmd/{ => manager}/main.go (100%) create mode 100644 cmd/mover/main.go diff --git a/Makefile b/Makefile index cfcada4..3ab1806 100644 --- a/Makefile +++ b/Makefile @@ -28,8 +28,11 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL) # This variable is used to construct full image tags for bundle and catalog images. # # For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both -# openshift.io/ceph-volsync-plugin-operator-bundle:$VERSION and openshift.io/ceph-volsync-plugin-operator-catalog:$VERSION. -IMAGE_TAG_BASE ?= openshift.io/ceph-volsync-plugin-operator +# quay.io/ramendr/ceph-volsync-plugin-operator-bundle:$VERSION and quay.io/ramendr/ceph-volsync-plugin-operator-catalog:$VERSION. +IMAGE_TAG_BASE ?= quay.io/ramendr/ceph-volsync-plugin-operator + +# MOVER_IMAGE_TAG_BASE defines the docker.io namespace and part of the image name for the mover plugin image. +MOVER_IMAGE_TAG_BASE ?= quay.io/ramendr/ceph-volsync-plugin-mover # BUNDLE_IMG defines the image:tag used for the bundle. # You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=/:) @@ -50,7 +53,10 @@ endif # This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit. OPERATOR_SDK_VERSION ?= v1.41.1 # Image URL to use all building/pushing image targets -IMG ?= controller:latest +IMG ?= $(IMAGE_TAG_BASE):v$(VERSION) + +# MOVER_IMG defines the image:tag used for the mover plugin image. +MOVER_IMG ?= $(MOVER_IMAGE_TAG_BASE):v$(VERSION) # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) ifeq (,$(shell go env GOBIN)) @@ -168,7 +174,7 @@ run: manifests generate fmt vet ## Run a controller from your host. # More info: https://docs.docker.com/develop/develop-images/build_enhancements/ .PHONY: docker-build docker-build: ## Build docker image with the manager. - $(CONTAINER_TOOL) build -t ${IMG} . + $(CONTAINER_TOOL) build -t ${IMG} -f build/Containerfile.manager . .PHONY: docker-push docker-push: ## Push docker image with the manager. @@ -183,13 +189,31 @@ docker-push: ## Push docker image with the manager. PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le .PHONY: docker-buildx docker-buildx: ## Build and push docker image for the manager for cross-platform support - # copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile - sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross + # copy existing Containerfile.manager and insert --platform=${BUILDPLATFORM} into Containerfile.manager.cross, and preserve the original Containerfile.manager + sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Containerfile.manager > Containerfile.manager.cross - $(CONTAINER_TOOL) buildx create --name ceph-volsync-plugin-operator-builder $(CONTAINER_TOOL) buildx use ceph-volsync-plugin-operator-builder - - $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross . + - $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Containerfile.manager.cross . - $(CONTAINER_TOOL) buildx rm ceph-volsync-plugin-operator-builder - rm Dockerfile.cross + rm Containerfile.manager.cross + +.PHONY: docker-build-mover +docker-build-mover: ## Build docker image with the mover. + $(CONTAINER_TOOL) build -t ${MOVER_IMG} -f build/Containerfile.mover . + +.PHONY: docker-push-mover +docker-push-mover: ## Push docker image with the mover. + $(CONTAINER_TOOL) push ${MOVER_IMG} + +.PHONY: docker-buildx-mover +docker-buildx-mover: ## Build and push docker image for the mover for cross-platform support + # copy existing Containerfile.mover and insert --platform=${BUILDPLATFORM} into Containerfile.mover.cross, and preserve the original Containerfile.mover + sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' build/Containerfile.mover > build/Containerfile.mover.cross + - $(CONTAINER_TOOL) buildx create --name ceph-volsync-plugin-mover-builder + $(CONTAINER_TOOL) buildx use ceph-volsync-plugin-mover-builder + - $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${MOVER_IMG} -f build/Containerfile.mover.cross . + - $(CONTAINER_TOOL) buildx rm ceph-volsync-plugin-mover-builder + rm build/Containerfile.mover.cross .PHONY: build-installer build-installer: manifests generate kustomize ## Generate a consolidated YAML with CRDs and deployment. @@ -314,7 +338,7 @@ bundle: manifests kustomize operator-sdk ## Generate bundle manifests and metada .PHONY: bundle-build bundle-build: ## Build the bundle image. - $(CONTAINER_TOOL) build -f bundle.Dockerfile -t $(BUNDLE_IMG) . + $(CONTAINER_TOOL) build -f bundle.Containerfile.manager -t $(BUNDLE_IMG) . .PHONY: bundle-push bundle-push: ## Push the bundle image. diff --git a/Dockerfile b/build/Containerfile.manager similarity index 92% rename from Dockerfile rename to build/Containerfile.manager index d5a75d3..901d8e5 100644 --- a/Dockerfile +++ b/build/Containerfile.manager @@ -12,14 +12,14 @@ COPY go.sum go.sum RUN go mod download # Copy the go source -COPY cmd/main.go cmd/main.go +COPY cmd/manager/main.go cmd/manager/main.go # Build # the GOARCH has not a default value to allow the binary be built according to the host where the command # was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO # the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore, # by leaving it empty we can ensure that the container and binary shipped on it will have the same platform. -RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go +RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/manager/main.go # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details diff --git a/build/Containerfile.mover b/build/Containerfile.mover new file mode 100644 index 0000000..c7c0e63 --- /dev/null +++ b/build/Containerfile.mover @@ -0,0 +1,31 @@ +# Build the mover binary +FROM golang:1.24 AS builder +ARG TARGETOS +ARG TARGETARCH + +WORKDIR /workspace +# Copy the Go Modules manifests +COPY go.mod go.mod +COPY go.sum go.sum +# cache deps before building and copying source so that we don't need to re-download as much +# and so that source changes don't invalidate our downloaded layer +RUN go mod download + +# Copy the go source +COPY cmd/mover/main.go cmd/mover/main.go + +# Build +# the GOARCH has not a default value to allow the binary be built according to the host where the command +# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO +# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore, +# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform. +RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o mover cmd/mover/main.go + +# Use distroless as minimal base image to package the mover binary +# Refer to https://github.com/GoogleContainerTools/distroless for more details +FROM gcr.io/distroless/static:nonroot +WORKDIR / +COPY --from=builder /workspace/mover . +USER 65532:65532 + +ENTRYPOINT ["/mover"] diff --git a/cmd/main.go b/cmd/manager/main.go similarity index 100% rename from cmd/main.go rename to cmd/manager/main.go diff --git a/cmd/mover/main.go b/cmd/mover/main.go new file mode 100644 index 0000000..3bdd5d9 --- /dev/null +++ b/cmd/mover/main.go @@ -0,0 +1,21 @@ +/* +Copyright 2025. + +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. +*/ + +package main + +func main() { + // TODO: add mover job code here. +} diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index f294cbe..1f4a488 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -40,6 +40,10 @@ var ( // projectImage is the name of the image which will be build and loaded // with the code source changes to be tested. projectImage = "example.com/ceph-volsync-plugin-operator:v0.0.1" + + // projectMoverImage is the name of the mover image which will be build and loaded + // with the code source changes to be tested. + projectMoverImage = "example.com/ceph-volsync-plugin-mover:v0.0.1" ) // TestE2E runs the end-to-end (e2e) test suite for the project. These tests execute in an isolated, @@ -64,6 +68,17 @@ var _ = BeforeSuite(func() { err = utils.LoadImageToKindClusterWithName(projectImage) ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to load the manager(Operator) image into Kind") + By("building the mover image") + cmd = exec.Command("make", "docker-build-mover", fmt.Sprintf("MOVER_IMG=%s", projectMoverImage)) + _, err = utils.Run(cmd) + ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to build the mover) image") + + // TODO(user): If you want to change the e2e test vendor from Kind, ensure the image is + // built and available before running the tests. Also, remove the following block. + By("loading the manager(Operator) image on Kind") + err = utils.LoadImageToKindClusterWithName(projectMoverImage) + ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to load the mover image into Kind") + // The tests-e2e are intended to run on a temporary cluster that is created and destroyed for testing. // To prevent errors when tests run in environments with CertManager already installed, // we check for its presence before execution.