diff --git a/config/manifests/bases/mongodb-kubernetes.clusterserviceversion.yaml b/config/manifests/bases/mongodb-kubernetes.clusterserviceversion.yaml index fdde19397..810b0a97d 100644 --- a/config/manifests/bases/mongodb-kubernetes.clusterserviceversion.yaml +++ b/config/manifests/bases/mongodb-kubernetes.clusterserviceversion.yaml @@ -8,9 +8,9 @@ metadata: certified: "true" containerImage: quay.io/mongodb/mongodb-kubernetes:1.1.0 createdAt: "" - description: The MongoDB Controllers for Kubernetes enable easy deploys of - MongoDB into Kubernetes clusters, using our management, monitoring and - backup platforms, Ops Manager and Cloud Manager. + description: The MongoDB Controllers for Kubernetes enable easy deploys of MongoDB + into Kubernetes clusters, using our management, monitoring and backup platforms, + Ops Manager and Cloud Manager. features.operators.openshift.io/disconnected: "true" features.operators.openshift.io/fips-compliant: "false" features.operators.openshift.io/proxy-aware: "false" @@ -51,8 +51,7 @@ spec: x-descriptors: - urn:alm:descriptor:com.tectonic.ui:text - urn:alm:descriptor:com.tectonic.ui:fieldGroup:ClusterConfiguration - - description: In a Replica Set deployment type, specifies the amount of - members. + - description: In a Replica Set deployment type, specifies the amount of members. displayName: Members of a Replica Set path: members x-descriptors: @@ -66,8 +65,7 @@ spec: - description: Project configuration for this deployment displayName: Ops Manager project configuration path: opsManager - - description: Name of the ConfigMap with the configuration for this - project + - description: Name of the ConfigMap with the configuration for this project displayName: Ops Manager Project Configuration path: opsManager.configMapRef.name x-descriptors: @@ -166,8 +164,7 @@ spec: x-descriptors: - urn:alm:descriptor:com.tectonic.ui:text - urn:alm:descriptor:com.tectonic.ui:fieldGroup:ClusterConfiguration - - description: In a Replica Set deployment type, specifies the amount of - members. + - description: In a Replica Set deployment type, specifies the amount of members. displayName: Members of a Replica Set path: members x-descriptors: @@ -181,8 +178,7 @@ spec: - description: Project configuration for this deployment displayName: Ops Manager project configuration path: opsManager - - description: Name of the ConfigMap with the configuration for this - project + - description: Name of the ConfigMap with the configuration for this project displayName: Ops Manager Project Configuration path: opsManager.configMapRef.name x-descriptors: @@ -194,8 +190,8 @@ spec: x-descriptors: - urn:alm:descriptor:com.tectonic.ui:booleanSwitch - urn:alm:descriptor:com.tectonic.ui:fieldGroup:ClusterConfiguration - - description: Optional. Specify whether to duplicate service objects - among different Kubernetes clusters. + - description: Optional. Specify whether to duplicate service objects among + different Kubernetes clusters. displayName: Duplicate Service Objects path: duplicateServiceObjects x-descriptors: @@ -256,8 +252,7 @@ spec: path: passwordSecretKeyRef.name x-descriptors: - urn:alm:descriptor:io.kubernetes:Secret - - displayName: Name of the MongoDB resource to which this user is - associated. + - displayName: Name of the MongoDB resource to which this user is associated. path: mongodbResourceRef.name x-descriptors: - urn:alm:descriptor:io.kubernetes:mongodb @@ -313,8 +308,8 @@ spec: x-descriptors: - urn:alm:descriptor:io.kubernetes:Secret - urn:alm:descriptor:com.tectonic.ui:fieldGroup:OpsManagerConfiguration - - displayName: Secret to enable TLS for Ops Manager allowing it to serve - traffic over HTTPS. + - displayName: Secret to enable TLS for Ops Manager allowing it to serve traffic + over HTTPS. path: security.tls.secretRef.name x-descriptors: - urn:alm:descriptor:io.kubernetes:Secret @@ -324,8 +319,8 @@ spec: x-descriptors: - urn:alm:descriptor:com.tectonic.ui:number - urn:alm:descriptor:com.tectonic.ui:fieldGroup:ApplicationDatabase - - displayName: Secret containing the TLS certificate signed by known or - custom CA. + - displayName: Secret containing the TLS certificate signed by known or custom + CA. path: applicationDatabase.security.tls.secretRef.name x-descriptors: - urn:alm:descriptor:io.kubernetes:Secret diff --git a/docker/mongodb-kubernetes-operator/Dockerfile.builder b/docker/mongodb-kubernetes-operator/Dockerfile.builder index 019ca7829..5663cf16e 100644 --- a/docker/mongodb-kubernetes-operator/Dockerfile.builder +++ b/docker/mongodb-kubernetes-operator/Dockerfile.builder @@ -9,6 +9,8 @@ FROM public.ecr.aws/docker/library/golang:1.24 as builder ARG release_version ARG log_automation_config_diff ARG use_race +ARG TARGETOS +ARG TARGETARCH COPY go.sum go.mod /go/src/github.com/mongodb/mongodb-kubernetes/ @@ -22,14 +24,14 @@ RUN git version RUN mkdir /build && \ if [ $use_race = "true" ]; then \ echo "Building with race detector" && \ - CGO_ENABLED=1 go build -o /build/mongodb-kubernetes-operator \ + CGO_ENABLED=1 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /build/mongodb-kubernetes-operator \ -buildvcs=false \ -race \ -ldflags=" -X github.com/mongodb/mongodb-kubernetes/pkg/util.OperatorVersion=${release_version} \ -X github.com/mongodb/mongodb-kubernetes/pkg/util.LogAutomationConfigDiff=${log_automation_config_diff}"; \ else \ echo "Building without race detector" && \ - CGO_ENABLED=0 go build -o /build/mongodb-kubernetes-operator \ + CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /build/mongodb-kubernetes-operator \ -buildvcs=false \ -ldflags="-s -w -X github.com/mongodb/mongodb-kubernetes/pkg/util.OperatorVersion=${release_version} \ -X github.com/mongodb/mongodb-kubernetes/pkg/util.LogAutomationConfigDiff=${log_automation_config_diff}"; \ diff --git a/helm_chart/Chart.yaml b/helm_chart/Chart.yaml index aadb482da..140da18b8 100644 --- a/helm_chart/Chart.yaml +++ b/helm_chart/Chart.yaml @@ -1,8 +1,7 @@ apiVersion: v2 name: mongodb-kubernetes -description: MongoDB Controllers for Kubernetes translate the human knowledge of - creating a MongoDB instance into a scalable, repeatable, and standardized - method. +description: MongoDB Controllers for Kubernetes translate the human knowledge of creating + a MongoDB instance into a scalable, repeatable, and standardized method. version: 1.1.0 kubeVersion: '>=1.16-0' type: application diff --git a/inventory.yaml b/inventory.yaml index d4beb4137..a14ed3754 100644 --- a/inventory.yaml +++ b/inventory.yaml @@ -8,34 +8,39 @@ images: vars: context: . template_context: docker/mongodb-kubernetes-operator - platform: linux/amd64 + platform: linux/$(inputs.params.architecture) inputs: - version - log_automation_config_diff + - architecture stages: - - name: operator-context-dockerfile + - name: mongodb-kubernetes-context task_type: docker_build dockerfile: docker/mongodb-kubernetes-operator/Dockerfile.builder buildargs: release_version: $(inputs.params.version) log_automation_config_diff: $(inputs.params.log_automation_config_diff) use_race: "false" + TARGETOS: linux + TARGETARCH: $(inputs.params.architecture) output: - - registry: $(inputs.params.registry)/operator-context - tag: $(inputs.params.version_id) + - registry: $(inputs.params.registry)/mongodb-kubernetes + tag: $(inputs.params.version_id)-context-$(inputs.params.architecture) - - name: operator-race-context-dockerfile + - name: operator-race-context task_type: docker_build dockerfile: docker/mongodb-kubernetes-operator/Dockerfile.builder buildargs: release_version: $(inputs.params.version) log_automation_config_diff: $(inputs.params.log_automation_config_diff) use_race: "true" + TARGETOS: linux + TARGETARCH: $(inputs.params.architecture) output: - - registry: $(inputs.params.registry)/operator-context - tag: $(inputs.params.version_id)-race + - registry: $(inputs.params.registry)/mongodb-kubernetes + tag: $(inputs.params.version_id)-context-race-$(inputs.params.architecture) - name: operator-template-ubi task_type: dockerfile_template @@ -50,39 +55,39 @@ images: task_type: docker_build dockerfile: $(stages['operator-template-ubi'].outputs[0].dockerfile) buildargs: - imagebase: $(inputs.params.registry)/operator-context:$(inputs.params.version_id) + imagebase: $(inputs.params.registry)/mongodb-kubernetes:$(inputs.params.version_id)-context-$(inputs.params.architecture) output: - registry: $(inputs.params.registry)/mongodb-kubernetes - tag: $(inputs.params.version_id) + tag: $(inputs.params.version_id)-$(inputs.params.architecture) - name: operator-ubi-race-build task_type: docker_build dockerfile: $(stages['operator-template-ubi'].outputs[0].dockerfile) buildargs: - imagebase: $(inputs.params.registry)/operator-context:$(inputs.params.version_id)-race + imagebase: $(inputs.params.registry)/mongodb-kubernetes:$(inputs.params.version_id)-context-race-$(inputs.params.architecture) output: - registry: $(inputs.params.registry)/mongodb-kubernetes - tag: $(inputs.params.version_id)-race + tag: $(inputs.params.version_id)-race-$(inputs.params.architecture) - name: master-latest task_type: tag_image tags: [ "master" ] source: registry: $(inputs.params.registry)/mongodb-kubernetes - tag: $(inputs.params.version_id) + tag: $(inputs.params.version_id)-$(inputs.params.architecture) destination: - registry: $(inputs.params.registry)/mongodb-kubernetes - tag: latest + tag: latest-$(inputs.params.architecture) - - name: operator-context-release + - name: mongodb-kubernetes-release task_type: tag_image tags: ["release"] source: - registry: $(inputs.params.registry)/operator-context - tag: $(inputs.params.version_id) + registry: $(inputs.params.registry)/mongodb-kubernetes + tag: $(inputs.params.version_id)-context-$(inputs.params.architecture) destination: - registry: $(inputs.params.quay_registry) - tag: $(inputs.params.version)-context + tag: $(inputs.params.version)-context-$(inputs.params.architecture) - name: operator-template-ubi task_type: dockerfile_template diff --git a/pipeline.py b/pipeline.py index f33f85d1e..9c24919f7 100755 --- a/pipeline.py +++ b/pipeline.py @@ -483,30 +483,54 @@ def build_mco_tests_image(build_configuration: BuildConfiguration): sonar_build_image(image_name, build_configuration, buildargs, "inventories/mco_test.yaml") +TRACER.start_as_current_span("build_operator_image") + + def build_operator_image(build_configuration: BuildConfiguration): """Calculates arguments required to build the operator image, and starts the build process.""" # In evergreen, we can pass test_suffix env to publish the operator to a quay # repository with a given suffix. test_suffix = os.environ.get("test_suffix", "") log_automation_config_diff = os.environ.get("LOG_AUTOMATION_CONFIG_DIFF", "false") - version, _ = get_git_release_tag() + version, is_release = get_git_release_tag() - args = { - "version": version, - "log_automation_config_diff": log_automation_config_diff, - "test_suffix": test_suffix, - "debug": build_configuration.debug, - } + # Use only amd64 if we should skip arm64 builds + if should_skip_arm64(): + architectures = ["amd64"] + logger.info("Skipping ARM64 builds for operator image as this is running in EVG pipeline as a patch") + else: + architectures = build_configuration.architecture or ["amd64", "arm64"] - logger.info(f"Building Operator args: {args}") + multi_arch_args_list = [] + + for arch in architectures: + arch_args = { + "version": version, + "log_automation_config_diff": log_automation_config_diff, + "test_suffix": test_suffix, + "debug": build_configuration.debug, + "architecture": arch, + } + multi_arch_args_list.append(arch_args) + + logger.info(f"Building Operator args: {multi_arch_args_list}") image_name = "mongodb-kubernetes" + + current_span = trace.get_current_span() + current_span.set_attribute("mck.image_name", image_name) + current_span.set_attribute("mck.architecture", architectures) + + ecr_registry = os.environ.get("BASE_REPO_URL", "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev") + base_repo = QUAY_REGISTRY_URL if is_release else ecr_registry + build_image_generic( config=build_configuration, image_name=image_name, inventory_file="inventory.yaml", - extra_args=args, - registry_address=f"{QUAY_REGISTRY_URL}/{image_name}", + registry_address=f"{base_repo}/{image_name}", + multi_arch_args_list=multi_arch_args_list, + is_multi_arch=True, )