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

[release-4.12] create a mechanism to deploy odf using operator-sdk #449

Merged
merged 7 commits into from
Jul 19, 2024
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
12 changes: 10 additions & 2 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ jobs:
fetch-depth: 0

- name: Build operator bundle docker image
run: make bundle-build
run: |
make bundle-build
msg='Uncommitted bundle changes. run `make bundle` and commit results.'
# We are using `--ignore-matching-lines` flag with the pattern `createdAt`
# to exclude lines with the timestamp from being considered, as the CSV file
# consistently receives a new timestamp during generation with operator-sdk 1.26 onwards.
git diff --exit-code --ignore-matching-lines createdAt bundle || (echo -e '\e[31m'"$msg"; exit 1)

catalog-build:
runs-on: ubuntu-latest
Expand All @@ -65,4 +71,6 @@ jobs:
OPM_RENDER_OPTS: --use-http
run: |
docker run -d -p 5000:5000 --name registry registry:2
make bundle-build bundle-push catalog-build
make bundle-build bundle-push catalog-build catalog-deps-build
msg='Uncommitted catalog changes. run `make catalog` and commit results.'
git diff --exit-code catalog || (echo -e '\e[31m'"$msg"; exit 1)
8 changes: 6 additions & 2 deletions .github/workflows/docker-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
required: true
default: ocs-dev
IMAGE_TAG:
required: true
default: latest
required: false
default: ""

jobs:
docker-push:
Expand All @@ -32,7 +32,11 @@ jobs:
env:
REGISTRY_NAMESPACE: ${{ github.event.inputs.REGISTRY_NAMESPACE }}
IMAGE_TAG: ${{ github.event.inputs.IMAGE_TAG }}
IMAGE_TAG_SHA: ${{ github.ref_name }}-${{ github.sha }}
run: |
# Set IMAGE_TAG to a calculated <branch>-<sha> if not specified
export IMAGE_TAG=${IMAGE_TAG:-${IMAGE_TAG_SHA:0:-33}}
make docker-build docker-push
make bundle-build bundle-push
make catalog-build catalog-push
make catalog-deps-build catalog-deps-push
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ testbin/*
*.swp
*.swo
*~

# catalog manifests
catalog/odf.yaml
25 changes: 21 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl delete -f -

install-odf: operator-sdk ## install odf using the hack/install-odf.sh script
hack/install-odf.sh $(OPERATOR_SDK) $(BUNDLE_IMG) $(CATALOG_DEPS_IMG) $(STARTING_CSVS)

deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
cd config/default && $(KUSTOMIZE) edit set image rbac-proxy=$(RBAC_PROXY_IMG)
Expand Down Expand Up @@ -172,13 +175,27 @@ bundle-push: ## Push the bundle image.
# Build a catalog image by adding bundle images to an empty catalog using the operator package manager tool, 'opm'.
# This recipe invokes 'opm' in 'semver' bundle add mode. For more information on add modes, see:
# https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
.PHONY: catalog-build
catalog-build: opm ## Build a catalog image.
$(OPM) render --output=yaml $(BUNDLE_IMGS) $(OPM_RENDER_OPTS) > catalog/bundle.yaml
.PHONY: catalog
catalog: opm ## Generate catalog manifests and then validate generated files.
$(OPM) render --output=yaml $(BUNDLE_IMG) $(OPM_RENDER_OPTS) > catalog/odf.yaml
$(OPM) render --output=yaml $(OCS_BUNDLE_IMG) $(OPM_RENDER_OPTS) > catalog/ocs.yaml
$(OPM) render --output=yaml $(IBM_BUNDLE_IMG) $(OPM_RENDER_OPTS) > catalog/ibm.yaml
$(OPM) render --output=yaml $(NOOBAA_BUNDLE_IMG) $(OPM_RENDER_OPTS) > catalog/noobaa.yaml
$(OPM) render --output=yaml $(CSIADDONS_BUNDLE_IMG) $(OPM_RENDER_OPTS) > catalog/csiaddons.yaml
$(OPM) validate catalog

.PHONY: catalog-build
catalog-build: catalog ## Build a catalog image.
docker build -f catalog.Dockerfile -t $(CATALOG_IMG) .

# Push the catalog image.
.PHONY: catalog-push
catalog-push: ## Push a catalog image.
$(MAKE) docker-push IMG=$(CATALOG_IMG)

.PHONY: catalog-deps-build
catalog-deps-build: catalog ## Build a catalog-deps image.
docker build -f catalog.deps.Dockerfile -t $(CATALOG_DEPS_IMG) .

.PHONY: catalog-deps-push
catalog-deps-push: ## Push a catalog-deps image.
$(MAKE) docker-push IMG=$(CATALOG_DEPS_IMG)
2 changes: 1 addition & 1 deletion bundle.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
LABEL operators.operatorframework.io.bundle.package.v1=odf-operator
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
LABEL operators.operatorframework.io.bundle.channel.default.v1=alpha
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.13.0+git
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.31.0
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3

Expand Down
12 changes: 9 additions & 3 deletions bundle/manifests/odf-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ metadata:
categories: Storage
console.openshift.io/plugins: '["odf-console"]'
containerImage: quay.io/ocs-dev/odf-operator:latest
createdAt: "2024-07-18T13:54:24Z"
description: OpenShift Data Foundation provides a common control plane for storage
solutions on OpenShift Container Platform.
olm.properties: '[{"type": "olm.maxOpenShiftVersion", "value": "4.13"}]'
Expand All @@ -57,7 +58,7 @@ metadata:
operators.openshift.io/infrastructure-features: '["disconnected"]'
operators.openshift.io/valid-subscription: '["OpenShift Platform Plus","OpenShift
Data Foundation Essentials","OpenShift Data Foundation Advanced"]'
operators.operatorframework.io/builder: operator-sdk-v1.13.0+git
operators.operatorframework.io/builder: operator-sdk-v1.31.0
operators.operatorframework.io/operator-type: standalone
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
repository: https://github.com/red-hat-storage/odf-operator
Expand Down Expand Up @@ -368,7 +369,10 @@ spec:
- create
serviceAccountName: odf-operator-controller-manager
deployments:
- name: odf-operator-controller-manager
- label:
app.kubernetes.io/name: odf-operator
control-plane: controller-manager
name: odf-operator-controller-manager
spec:
replicas: 1
selector:
Expand Down Expand Up @@ -448,7 +452,9 @@ spec:
key: node.ocs.openshift.io/storage
operator: Equal
value: "true"
- name: odf-console
- label:
app: odf-console
name: odf-console
spec:
selector:
matchLabels:
Expand Down
2 changes: 1 addition & 1 deletion bundle/metadata/annotations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ annotations:
operators.operatorframework.io.bundle.package.v1: odf-operator
operators.operatorframework.io.bundle.channels.v1: alpha
operators.operatorframework.io.bundle.channel.default.v1: alpha
operators.operatorframework.io.metrics.builder: operator-sdk-v1.13.0+git
operators.operatorframework.io.metrics.builder: operator-sdk-v1.31.0
operators.operatorframework.io.metrics.mediatype.v1: metrics+v1
operators.operatorframework.io.metrics.project_layout: go.kubebuilder.io/v3

Expand Down
26 changes: 26 additions & 0 deletions catalog.deps.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# The base image which contain rm and sed command
FROM cirros as builder

# Copy catalog files
COPY catalog /configs

# Remove odf bundle from the files
RUN rm -f /configs/odf.yaml

# Remove odf bundle details from the index file
RUN sed -i '1,11d' /configs/index.yaml


# The base image is expected to contain
# /bin/opm (with a serve subcommand) and /bin/grpc_health_probe
FROM quay.io/operator-framework/opm:v1.26.0

# Configure the entrypoint and command
ENTRYPOINT ["/bin/opm"]
CMD ["serve", "/configs"]

# Copy declarative config root into image at /configs
COPY --from=builder /configs /configs

# Set DC-specific label for the location of the DC root directory in the image
LABEL operators.operatorframework.io.index.configs.v1=/configs
Loading
Loading