Skip to content
Draft
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ bin/*
dist/
_output/
Dockerfile.cross
config/manifests/dev/kustomization.yaml

# Test binary, built with `go test -c`
*.test
Expand Down
6 changes: 3 additions & 3 deletions .tekton/hyperfleet-operator-bundle-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ metadata:
pipelinesascode.tekton.dev/cancel-in-progress: "false"
pipelinesascode.tekton.dev/max-keep-runs: "3"
pipelinesascode.tekton.dev/on-cel-expression: event == "push" && target_branch
== "main" && ( ".tekton/hyperfleet-operator-bundle-push.yaml".pathChanged() || "bundle.konflux.Dockerfile".pathChanged()
|| "bundle-hack/***".pathChanged() || "bundle/***".pathChanged() )
== "main" && ( ".tekton/hyperfleet-operator-bundle-push.yaml".pathChanged() || "bundle.Dockerfile".pathChanged() || "config/***".pathChanged())
labels:
appstudio.openshift.io/application: hyperfleet
appstudio.openshift.io/component: hyperfleet-operator-bundle
Expand All @@ -25,7 +24,7 @@ spec:
- name: output-image
value: quay.io/redhat-user-workloads/hyperfleet-tenant/hyperfleet/hyperfleet-operator-bundle:{{revision}}
- name: dockerfile
value: ./bundle.konflux.Dockerfile
value: ./bundle.Dockerfile
- name: path-context
value: .
pipelineSpec:
Expand Down Expand Up @@ -222,6 +221,7 @@ spec:
value: $(tasks.clone-repository.results.commit)
- name: BUILD_ARGS
value:
- KUSTOMIZE_VARIANT=config/manager/prod/kustomization.yaml
- $(params.build-args[*])
- name: BUILD_ARGS_FILE
value: $(params.build-args-file)
Expand Down
8 changes: 3 additions & 5 deletions .tekton/hyperfleet-operator-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
annotations:
build.appstudio.openshift.io/build-nudge-files: bundle.konflux.Dockerfile
build.appstudio.openshift.io/build-nudge-files: config/manager/prod/kustomization.yaml
build.appstudio.openshift.io/repo: https://github.com/openshift-hyperfleet/hyperfleet-operator?rev={{revision}}
build.appstudio.redhat.com/commit_sha: '{{revision}}'
build.appstudio.redhat.com/target_branch: '{{target_branch}}'
Expand All @@ -12,11 +12,9 @@ metadata:
event == "push"
&& target_branch == "main"
&& !(files.all.all(x,
x.matches('^bundle\\.konflux\\.Dockerfile$')
|| x.matches('^bundle\\.Dockerfile$')
|| x.matches('^bundle-hack/')
|| x.matches('^bundle/')
x.matches('^bundle\\.Dockerfile$')
|| x.matches('^\\.tekton/hyperfleet-operator-bundle-push\\.yaml$')
|| x.matches('^config/manifests/prod$')
))
labels:
appstudio.openshift.io/application: hyperfleet
Expand Down
55 changes: 22 additions & 33 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ IMG_REGISTRY ?= quay.io/$(QUAY_REPO)
IMG_NAME ?= hyperfleet-operator
IMG_TAG ?= $(APP_VERSION)
IMG ?= $(IMG_REGISTRY)/$(IMG_NAME):$(IMG_TAG)
export RELATED_IMAGE_HYPERFLEET_OPERATOR ?= $(IMG)
export RELATED_IMAGE_HYPERFLEET_API ?= quay.io/redhat-services-prod/hyperfleet-tenant/hyperfleet/hyperfleet-api:latest
# Base image for production builds - matches Dockerfile default
# Override with DEV_BASE_IMAGE for dev builds (see image-dev target)
BASE_IMAGE ?= registry.access.redhat.com/ubi9-micro:latest
Expand Down Expand Up @@ -268,7 +270,7 @@ uninstall: manifests ## Uninstall CRDs from the K8s cluster specified in ~/.kube
@$(KUSTOMIZE) build config/crd | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -

.PHONY: deploy
deploy: build-deployer-override-img ## Deploy controller to the K8s cluster specified in ~/.kube/config.
deploy: build-deployer ## Deploy controller to the K8s cluster specified in ~/.kube/config.
@$(KUBECTL) apply -f dist/install.yaml

.PHONY: undeploy
Expand All @@ -278,26 +280,17 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi

##@ Bundles/Catalog


# Non-olm installs
# Generates dist/install.yaml
# Install resources
# kubectl apply -f dist/install.yaml
# Uninstall resources
# kubectl delete -f dist/install.yaml
# For image overrides edit config/manager/kustomization.yaml
# Install resources: kubectl apply -f dist/install.yaml
# Uninstall resources: kubectl delete -f dist/install.yaml
# Override images via env vars:
# make build-deployer RELATED_IMAGE_HYPERFLEET_OPERATOR=<img>

.PHONY: build-deployer
build-deployer: manifests generate ## Generate a consolidated YAML with CRDs and deployment.
@mkdir -p dist
@$(KUSTOMIZE) build config/default > dist/install.yaml

.PHONY: build-deployer-override-img
build-deployer-override-img: manifests generate ## Generate deployer with IMG override, then restore kustomization.yaml
@mkdir -p dist
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
@$(KUSTOMIZE) build config/default > dist/install.yaml
@echo "Deployer generated with IMG=$(IMG)"
@echo "Note: config/manager/kustomization.yaml has been modified. Commit or reset as needed."
@$(KUSTOMIZE) build config/default | envsubst > dist/install.yaml

# For now `stable` channel is the default and only channel
# CHANNELS define the bundle channels used in the bundle.
Expand Down Expand Up @@ -349,24 +342,20 @@ ifneq ($(origin CATALOG_BASE_IMG), undefined)
FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG)
endif

.PHONY: bundle
bundle: manifests operator-sdk ## Generate bundle manifests and metadata, then validate generated files.
$(OPERATOR_SDK) generate kustomize manifests -q
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS)
$(OPERATOR_SDK) bundle validate ./bundle

.PHONY: bundle-override-img
bundle-override-img: manifests operator-sdk ## Generate bundle with IMG override, then restore kustomization.yaml
$(OPERATOR_SDK) generate kustomize manifests -q
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS)
$(OPERATOR_SDK) bundle validate ./bundle
@echo "Bundle generated with IMG=$(IMG)"
@echo "Note: config/manager/kustomization.yaml has been modified. Commit or reset as needed."

KUSTOMIZE_VARIANT ?= config/manifests/dev
# In order to override the operator image and env variables in the kustomization patches
# Use envsubst to create the config/manifests/kustomization.yaml
# for dev which is gitignored and use that to generate the bundle
.PHONY: bundle-build
bundle-build: ## Build the bundle image.
$(CONTAINER_TOOL) build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
bundle-build: ## Builds the bundle and bundle image.
cat config/manifests/dev/patch-dev.yaml | envsubst > config/manifests/dev/kustomization.yaml
$(CONTAINER_TOOL) build -f bundle.Dockerfile \
--platform $(PLATFORM) \
--build-arg VERSION=$(VERSION) \
--build-arg CHANNELS=$(CHANNELS) \
--build-arg KUSTOMIZE_VARIANT=$(KUSTOMIZE_VARIANT) \
--build-arg APP_VERSION=$(APP_VERSION) \
-t $(BUNDLE_IMG) .

.PHONY: bundle-push
bundle-push: ## Push the bundle image.
Expand Down
24 changes: 0 additions & 24 deletions bundle-hack/update_bundle.sh

This file was deleted.

42 changes: 38 additions & 4 deletions bundle.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
FROM registry.redhat.io/openshift4/ose-cli-rhel9:v4.18 AS kustomize

COPY config/ /workdir/config/

# Specify the kustomize variant, either bases/kustomization.yaml or prod/kustomization.yaml
# prod/kustomization.yaml gets image update references from konflux. Do not modify.
ARG KUSTOMIZE_VARIANT=config/manifests/dev
# ARG KUSTOMIZE_VARIANT=config/manifests/prod for konflux builds
RUN oc kustomize /workdir/${KUSTOMIZE_VARIANT} > /workdir/manifests.yaml

FROM registry.redhat.io/openshift4/ose-operator-sdk-rhel9:v4.18 AS operator
WORKDIR /workdir
COPY --from=kustomize /workdir/manifests.yaml /workdir/manifests.yaml
ARG CHANNELS=stable
ARG VERSION=0.0.1
RUN mkdir -p /workdir/bundle
RUN cat manifests.yaml | operator-sdk generate bundle -q --version ${VERSION} \
--channels=${CHANNELS} --default-channel=stable \
--package=hyperfleet-operator && \
operator-sdk bundle validate ./bundle

FROM scratch

# Core bundle labels.
Expand All @@ -15,7 +36,20 @@ LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v4
LABEL operators.operatorframework.io.test.mediatype.v1=scorecard+v1
LABEL operators.operatorframework.io.test.config.v1=tests/scorecard/

# Copy files to locations specified by labels.
COPY bundle/manifests /manifests/
COPY bundle/metadata /metadata/
COPY bundle/tests/scorecard /tests/scorecard/
# Copy patched manifests from builder, metadata and tests from source.
COPY --from=operator /workdir/bundle/manifests /manifests/
COPY --from=operator /workdir/bundle/metadata /metadata/
COPY --from=operator /workdir/bundle/tests/scorecard /tests/scorecard/

ARG APP_VERSION="0.0.0-dev"
LABEL name="hyperfleet-operator-bundle" \
vendor="Red Hat, Inc." \
version="${APP_VERSION}" \
summary="OLM bundle for the HyperFleet Operator" \
description="OLM bundle for the HyperFleet Operator, which installs and manages HyperFleet." \
com.redhat.component="hyperfleet-operator-bundle-container" \
io.k8s.description="OLM bundle for the HyperFleet Operator, which installs and manages HyperFleet." \
distribution-scope="public" \
release="1" \
url="https://github.com/openshift-hyperfleet/hyperfleet-operator" \
maintainer="Red Hat HyperFleet Team"
57 changes: 0 additions & 57 deletions bundle.konflux.Dockerfile

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading