Skip to content

Commit c445490

Browse files
Fixed broken openshift deployment (#680)
1 parent f757038 commit c445490

File tree

6 files changed

+34
-83
lines changed

6 files changed

+34
-83
lines changed

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ COPY hack/ hack/
1919

2020
ARG VERSION
2121
ENV PRODUCT_VERSION=${VERSION}
22+
ENV TARGET_ARCH=amd64
23+
ENV TARGET_OS=linux
2224

2325
RUN make manager
2426

Makefile

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@ CONTAINER_ENGINE?=docker
99
# To re-generate a bundle for another specific version without changing the standard setup, you can:
1010
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
1111
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
12-
VERSION ?= 0.8.0
13-
14-
ifndef PRODUCT_VERSION
15-
PRODUCT_VERSION := $(shell git describe --tags --dirty --broken)
16-
endif
12+
VERSION ?= $(shell git describe --tags --dirty --broken | cut -c 2-)
13+
PRODUCT_VERSION ?= $(shell git describe --tags --dirty --broken | cut -c 2-)
1714

1815
# CHANNELS define the bundle channels used in the bundle.
1916
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "preview,fast,stable")
@@ -25,6 +22,14 @@ ifneq ($(origin CHANNELS), undefined)
2522
BUNDLE_CHANNELS := --channels=$(CHANNELS)
2623
endif
2724

25+
# Used by the olm-deploy if you running on Mac and deploy to K8S/Openshift
26+
ifndef TARGET_ARCH
27+
TARGET_ARCH := $(shell go env GOARCH)
28+
endif
29+
ifndef TARGET_OS
30+
TARGET_OS := $(shell go env GOOS)
31+
endif
32+
2833
# DEFAULT_CHANNEL defines the default channel used in the bundle.
2934
# Add a new line here if you would like to change its default config. (E.g DEFAULT_CHANNEL = "stable")
3035
# To re-generate a bundle for any other default channel without changing the default setup, you can:
@@ -40,16 +45,21 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
4045
REGISTRY ?= quay.io/mongodb
4146
# BUNDLE_IMG defines the image:tag used for the bundle.
4247
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
43-
BUNDLE_IMG ?= $(REGISTRY)/mongodb-atlas-controller-bundle:$(VERSION)
48+
BUNDLE_IMG ?= $(REGISTRY)/mongodb-atlas-kubernetes-operator-prerelease-bundle:$(VERSION)
4449

45-
# Image URL to use all building/pushing image targets
46-
IMG ?= mongodb-atlas-controller:latest
50+
#IMG ?= mongodb-atlas-kubernetes-operator:latest
4751
#BUNDLE_REGISTRY ?= $(REGISTRY)/mongodb-atlas-operator-bundle
48-
OPERATOR_REGISTRY ?= $(REGISTRY)/mongodb-atlas-operator
49-
CATALOG_REGISTRY ?= $(REGISTRY)/mongodb-atlas-catalog
52+
OPERATOR_REGISTRY ?= $(REGISTRY)/mongodb-atlas-kubernetes-operator-prerelease
53+
CATALOG_REGISTRY ?= $(REGISTRY)/mongodb-atlas-kubernetes-operator-prerelease-catalog
5054
OPERATOR_IMAGE ?= ${OPERATOR_REGISTRY}:${VERSION}
5155
CATALOG_IMAGE ?= ${CATALOG_REGISTRY}:${VERSION}
5256
TARGET_NAMESPACE ?= mongodb-atlas-operator-system-test
57+
58+
# Image URL to use all building/pushing image targets
59+
ifndef IMG
60+
IMG := ${OPERATOR_REGISTRY}:${VERSION}
61+
endif
62+
5363
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
5464
ifeq (,$(shell go env GOBIN))
5565
GOBIN=$(shell go env GOPATH)/bin
@@ -97,7 +107,7 @@ e2e-openshift-upgrade:
97107

98108
.PHONY: manager
99109
manager: generate fmt vet ## Build manager binary
100-
go build -o bin/manager -ldflags="-X main.version=$(PRODUCT_VERSION)" cmd/manager/main.go
110+
GOOS=$(TARGET_OS) GOARCH=$(TARGET_ARCH) go build -o bin/manager -ldflags="-X main.version=$(PRODUCT_VERSION)" cmd/manager/main.go
101111

102112
.PHONY: run
103113
run: generate fmt vet manifests ## Run against the configured Kubernetes cluster in ~/.kube/config
@@ -167,6 +177,7 @@ endef
167177

168178
.PHONY: bundle
169179
bundle: manifests kustomize ## Generate bundle manifests and metadata, then validate generated files.
180+
@echo "Building bundle $(VERSION)"
170181
operator-sdk generate kustomize manifests -q --apis-dir=pkg/api
171182
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
172183
$(KUSTOMIZE) build --load-restrictor LoadRestrictionsNone config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
@@ -187,8 +198,7 @@ bundle-push:
187198

188199
.PHONY: catalog-build
189200
CATALOG_DIR ?= ./scripts/openshift/atlas-catalog
190-
catalog-build: ## bundle bundle-push ## Build file-based bundle
191-
$(MAKE) image IMG=$(REGISTRY)/mongodb-atlas-operator:$(VERSION)
201+
catalog-build: image
192202
CATALOG_DIR=$(CATALOG_DIR) \
193203
CHANNEL=$(DEFAULT_CHANNEL) \
194204
CATALOG_IMAGE=$(CATALOG_IMAGE) \
@@ -211,11 +221,11 @@ build-subscription:
211221
build-catalogsource:
212222
CATALOG_DIR=$(shell dirname "$(CATALOG_DIR)") \
213223
CATALOG_IMAGE=$(CATALOG_IMAGE) \
224+
CATALOG_DISPLAY_NAME="MongoDB Atlas operator $(VERSION)" \
214225
./scripts/build_catalogsource.sh
215226

216227
.PHONY: deploy-olm
217228
# Deploy atlas operator to the running openshift cluster with OLM
218-
deploy-olm: export IMG=$(REGISTRY)/mongodb-atlas-operator:$(VERSION)
219229
deploy-olm: bundle-build bundle-push catalog-build catalog-push build-catalogsource build-subscription
220230
oc -n openshift-marketplace delete catalogsource mongodb-atlas-kubernetes-local --ignore-not-found
221231
oc delete namespace $(TARGET_NAMESPACE) --ignore-not-found
@@ -259,4 +269,4 @@ post-install-hook:
259269

260270
.PHONY: x509-cert
261271
x509-cert: ## Create X.509 cert at path tmp/x509/ (see docs/x509-user.md)
262-
go run scripts/create_x509.go
272+
go run scripts/create_x509.go

scripts/build_catalog.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ echo "Adding ${BUNDLE_IMAGE} to the catalog"
4545
opm render "${BUNDLE_IMAGE}" --output=yaml \
4646
>> "${CATALOG_DIR}"/operator.yaml
4747

48-
echo "Adding ${CHANNEL} channel to the catalog"
48+
echo "Adding ${CHANNEL} channel to the catalog. Version: ${VERSION}"
4949
cat <<EOF> "${CATALOG_DIR}"/channel.yaml
5050
---
5151
schema: olm.channel

scripts/build_catalogsource.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ if [ -z "${CATALOG_IMAGE+x}" ]; then
1212
exit 1
1313
fi
1414

15+
if [ -z "${CATALOG_DISPLAY_NAME+x}" ]; then
16+
CATALOG_DISPLAY_NAME="MongoDB Atlas operator local"
17+
echo "CATALOG_DISPLAY_NAME is not set. Setting to default: ${CATALOG_DISPLAY_NAME}"
18+
fi
19+
1520
echo "Building catalog ${CATALOG_IMAGE}"
1621

1722
cat <<EOF> "${CATALOG_DIR}/catalogsource.yaml"
@@ -22,7 +27,7 @@ metadata:
2227
spec:
2328
sourceType: grpc
2429
image: ${CATALOG_IMAGE}
25-
displayName: MongoDB Atlas operator
30+
displayName: ${CATALOG_DISPLAY_NAME}
2631
publisher: MongoDB
2732
updateStrategy:
2833
registryPoll:

scripts/openshift/atlas-catalog.Dockerfile

Lines changed: 0 additions & 14 deletions
This file was deleted.

scripts/openshift/atlas-catalog/operator.yaml

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)