Skip to content
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

OLM catalog fixes #153

Merged
merged 2 commits into from
Nov 18, 2019
Merged
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
14 changes: 9 additions & 5 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# we only want to take build/ into the image
# so we ignore everything else here
# we ignore everything by default
*
!build

# make sure we ignore vendor explicitly
vendor/
# we also explicitly ignore the following
pkg
test
vendor

# we un-ignore only the following
!build
!deploy
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,4 @@ script:
- make gen-api-fail-if-dirty --always-make
- make build
- make test
- make test-cli
- make test-csv
- make test-scorecard
- make test-olm
12 changes: 4 additions & 8 deletions .travis/install-minikube.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
#!/bin/bash
# exit immediately when a command fails
set -e
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
# error on unset variables
set -u
# print each command before executing it
set -x
set -e # exit immediately when a command fails
set -o pipefail # only exit with zero if all commands of the pipeline exit successfully
set -u # error on unset variables
set -x # print each command before executing it

#
# NOTE: This script was originally copied from the Cojaeger-operator build
Expand Down
9 changes: 5 additions & 4 deletions .travis/install-python.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
sudo apt-get update
sudo apt-get install python3-venv
curl -O https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
pyenv versions
pyenv global 3.7
pip3 install --upgrade pip
pip3 install operator-courier==2.1.7
operator-courier --version
74 changes: 13 additions & 61 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ TIME ?= time -p
VERSION ?= $(shell go run cmd/version/main.go)
IMAGE ?= noobaa/noobaa-operator:$(VERSION)
REPO ?= github.com/noobaa/noobaa-operator
CATALOG_IMAGE ?= noobaa/noobaa-operator-catalog:$(VERSION)

GO_LINUX ?= GOOS=linux GOARCH=amd64
GOHOSTOS ?= $(shell go env GOHOSTOS)
Expand Down Expand Up @@ -63,6 +64,7 @@ clean:

release:
docker push $(IMAGE)
docker push $(CATALOG_IMAGE)
@echo "✅ docker push"
mkdir -p build-releases
cp build/_output/bin/noobaa-operator build-releases/noobaa-linux-v$(VERSION)
Expand Down Expand Up @@ -105,17 +107,13 @@ gen-api-fail-if-dirty: gen-api

gen-olm: operator-sdk gen
rm -rf $(OLM)
mkdir -p $(OLM)
cp deploy/crds/*_crd.yaml $(OLM)/
operator-sdk up local --operator-flags "olm csv -n my-noobaa-operator" \
> $(OLM)/noobaa-operator.v$(VERSION).clusterserviceversion.yaml
operator-sdk up local --operator-flags "olm package -n my-noobaa-operator" \
> $(OLM)/noobaa-operator.package.yaml
operator-sdk up local --operator-flags "olm catalog -n my-noobaa-operator --dir $(OLM)"
python3 -m venv $(VENV) && \
. $(VENV)/bin/activate && \
pip3 install --upgrade pip && \
pip3 install operator-courier && \
operator-courier verify --ui_validate_io $(OLM)
pip3 install operator-courier==2.1.7 && \
operator-courier --verbose verify --ui_validate_io $(OLM)
docker build -t $(CATALOG_IMAGE) -f build/catalog-source.Dockerfile .
@echo "✅ gen-olm"
.PHONY: gen-olm

Expand All @@ -124,74 +122,28 @@ gen-olm: operator-sdk gen
#- Testing -#
#-----------#

test: lint unittest
test: lint test-go
@echo "✅ test"
.PHONY: test

lint: gen
$(TIME) go run golang.org/x/lint/golint \
-set_exit_status=1 \
$$(go list ./... | cut -d'/' -f4- | sed 's/^\(.*\)$$/\.\/\1\//' | grep -v ./pkg/apis/noobaa/v1alpha1/)
$$(go list ./... | cut -d'/' -f5- | sed 's/^\(.*\)$$/\.\/\1\//' | grep -v ./pkg/apis/noobaa/v1alpha1/ | grep -v ./pkg/bundle/)
@echo
$(TIME) go run golang.org/x/lint/golint \
-set_exit_status=1 \
$$(echo ./pkg/apis/noobaa/v1alpha1/* | tr ' ' '\n' | grep -v '/zz_generated')
@echo "✅ lint"
.PHONY: lint

unittest: gen
test-go: gen cli
$(TIME) go test ./pkg/... ./cmd/... ./version/...
@echo "✅ unittest"
.PHONY: unittest

test-cli:
$(TIME) go test ./test/cli/...
@echo "✅ test-cli"
.PHONY: test-cli

test-csv: operator-sdk gen-olm
operator-sdk alpha olm install || exit 0
kubectl create ns my-noobaa-operator || exit 0
operator-sdk up local --operator-flags "crd create -n my-noobaa-operator"
operator-sdk up local --operator-flags "operator install --no-deploy -n my-noobaa-operator"
kubectl apply -f deploy/olm-catalog/operator-group.yaml
kubectl apply -f $(OLM)/noobaa-operator.v$(VERSION).clusterserviceversion.yaml
sleep 30
kubectl wait pod -n my-noobaa-operator -l noobaa-operator=deployment --for condition=ready
@echo "✅ test-csv"
.PHONY: test-csv
@echo "✅ test-go"
.PHONY: test-go

# test-olm runs tests for the OLM package
test-olm: operator-sdk gen-olm
./test/test-olm.sh
$(TIME) ./test/test-olm.sh $(CATALOG_IMAGE)
@echo "✅ test-olm"
.PHONY: test-olm

test-scorecard: operator-sdk $(OUTPUT)/olm-global-manifest.yaml gen-olm
kubectl create ns noobaa-scorecard || exit 0
$(TIME) operator-sdk scorecard --verbose \
--csv-path $(OLM)/noobaa-operator.v$(VERSION).clusterserviceversion.yaml \
--crds-dir $(OLM)/ \
--cr-manifest deploy/crds/noobaa_v1alpha1_noobaa_cr.yaml \
--cr-manifest deploy/crds/noobaa_v1alpha1_backingstore_cr.yaml \
--cr-manifest deploy/crds/noobaa_v1alpha1_bucketclass_cr.yaml \
--global-manifest $(OUTPUT)/olm-global-manifest.yaml \
--namespace noobaa-scorecard
@echo "✅ test-scorecard"
.PHONY: test-scorecard

$(OUTPUT)/olm-global-manifest.yaml: operator-sdk gen
operator-sdk up local --operator-flags "crd yaml" > $(OUTPUT)/olm-global-manifest.yaml
echo "---" >> $(OUTPUT)/olm-global-manifest.yaml
cat deploy/cluster_role.yaml >> $(OUTPUT)/olm-global-manifest.yaml
echo "---" >> $(OUTPUT)/olm-global-manifest.yaml
yq write deploy/cluster_role_binding.yaml subjects.0.namespace noobaa-scorecard >> $(OUTPUT)/olm-global-manifest.yaml
echo "---" >> $(OUTPUT)/olm-global-manifest.yaml
yq write deploy/obc/storage_class.yaml provisioner "noobaa.io/noobaa-scorecard.bucket" >> $(OUTPUT)/olm-global-manifest.yaml

# TODO operator-sdk test local is not working on CI !
# test-e2e: gen
# operator-sdk test local ./test/e2e \
# --global-manifest deploy/cluster_role_binding.yaml \
# --debug \
# --go-test-flags "-v -parallel=1"
# .PHONY: test-e2e
17 changes: 17 additions & 0 deletions build/catalog-source.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM quay.io/operator-framework/upstream-registry-builder as builder
# Add noobaa manifests
COPY build/_output/olm manifests/noobaa
# Add lib-bucket-provisioner manifests
COPY deploy/obc/lib-bucket-provisioner.package.yaml manifests/lib-bucket-provisioner/
COPY deploy/obc/lib-bucket-provisioner.v1.0.0.clusterserviceversion.yaml manifests/lib-bucket-provisioner/1.0.0/
COPY deploy/obc/objectbucket_v1alpha1_objectbucket_crd.yaml manifests/lib-bucket-provisioner/1.0.0/
COPY deploy/obc/objectbucket_v1alpha1_objectbucketclaim_crd.yaml manifests/lib-bucket-provisioner/1.0.0/
RUN ./bin/initializer -o ./bundles.db

FROM scratch
COPY --from=builder /build/bundles.db /bundles.db
COPY --from=builder /build/bin/registry-server /registry-server
COPY --from=builder /bin/grpc_health_probe /bin/grpc_health_probe
EXPOSE 50051
ENTRYPOINT ["/registry-server"]
CMD ["--database", "bundles.db"]
5 changes: 5 additions & 0 deletions deploy/obc/lib-bucket-provisioner.package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
packageName: lib-bucket-provisioner
channels:
- name: alpha
currentCSV: lib-bucket-provisioner.v1.0.0
defaultChannel: alpha
186 changes: 186 additions & 0 deletions deploy/obc/lib-bucket-provisioner.v1.0.0.clusterserviceversion.yaml

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions deploy/olm-catalog/catalog-source-config.yaml

This file was deleted.

8 changes: 8 additions & 0 deletions deploy/olm/catalog-source.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: noobaa-operator-catalog
namespace: default
spec:
sourceType: grpc
image: noobaa/noobaa-operator-catalog
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ For more information on using NooBaa refer to [Github](https://github.com/noobaa

### 1. Install OLM (if you don't have it already):
```
curl -sL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/0.10.0/install.sh | bash -s 0.10.0
curl -sL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/0.12.0/install.sh | bash -s 0.12.0
```

### 2. Install noobaa-operator:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,60 +10,13 @@ metadata:
certified: "false"
description: NooBaa is an object data service for hybrid and multi cloud environments.
support: Red Hat
alm-examples: |-
[
{
"apiVersion": "noobaa.io/v1alpha1",
"kind": "NooBaa",
"metadata": {
"name": "noobaa",
"namespace": "my-noobaa-operator"
},
"spec": {}
},
{
"apiVersion": "noobaa.io/v1alpha1",
"kind": "BackingStore",
"metadata": {
"name": "aws1",
"namespace": "my-noobaa-operator"
},
"spec": {
"type": "aws-s3",
"bucketName": "noobaa-aws1",
"secret": {
"name": "backing-store-secret-aws1",
"namespace": "my-noobaa-operator"
}
}
},
{
"apiVersion": "noobaa.io/v1alpha1",
"kind": "BucketClass",
"metadata": {
"name": "default",
"namespace": "my-noobaa-operator"
},
"spec": {
"placementPolicy": {
"tiers": [{
"tier": {
"mirrors": [{
"mirror": {
"spread": ["aws1"]
}
}]
}
}]
}
}
}
]
alm-examples: placeholder
name: placeholder
namespace: placeholder
spec:
displayName: NooBaa Operator
version: "999.999.999-placeholder"
minKubeVersion: 1.10.0
maturity: alpha
provider:
name: NooBaa
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: noobaa-operator-group
namespace: my-noobaa-operator
namespace: default
spec:
targetNamespaces:
- my-noobaa-operator
- default
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: noobaa-operator-subscription
namespace: my-noobaa-operator
namespace: default
spec:
channel: alpha
name: noobaa-operator
source: noobaa-operator-source
sourceNamespace: marketplace
source: noobaa-operator-catalog
sourceNamespace: default
2 changes: 1 addition & 1 deletion deploy/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
serviceAccountName: noobaa
containers:
- name: noobaa-operator
image: noobaa/noobaa-operator:2.0.8
image: NOOBAA_OPERATOR_IMAGE
resources:
limits:
cpu: "250m"
Expand Down
2 changes: 1 addition & 1 deletion doc/noobaa-crd.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ status:
secretRef:
name: noobaa-admin
namespace: noobaa
actualImage: noobaa/noobaa-core:5
actualImage: noobaa/noobaa-core:X.Y.Z
conditions:
- lastHeartbeatTime: "2019-11-05T13:50:20Z"
lastTransitionTime: "2019-11-06T07:03:48Z"
Expand Down
Loading