Skip to content

[pipeline] add multiarch mco #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions docker/mongodb-kubernetes-operator/Dockerfile.builder
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand All @@ -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}"; \
Expand Down
5 changes: 2 additions & 3 deletions helm_chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
39 changes: 22 additions & 17 deletions inventory.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all of those repo changes should be fine as they are targeting $(inputs.params.registry) which points to ecr

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
Expand All @@ -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
Expand Down
44 changes: 34 additions & 10 deletions pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)


Expand Down