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

feat: Integrate Non-Admin Controller (NAC) with OADP #1370

Merged
Merged
Show file tree
Hide file tree
Changes from 14 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
34 changes: 28 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ ifeq ($(CLUSTER_TYPE), ibmcloud)
VELERO_PLUGIN = aws
endif

# Kubernetes version from OpenShift 4.15.x https://openshift-release.apps.ci.l2s4.p1.openshiftapps.com/#4-stable
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.21
ENVTEST_K8S_VERSION = 1.28

# VERSION defines the project version for the bundle.
# Update this value when you upgrade the version of your project.
Expand Down Expand Up @@ -164,7 +165,7 @@ vet: ## Run go vet against code.
go vet -mod=mod ./...

ENVTEST := $(shell pwd)/bin/setup-envtest
ENVTESTPATH = $(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)
ENVTESTPATH = $(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(shell pwd)/bin -p path)
ifeq ($(shell $(ENVTEST) list | grep $(ENVTEST_K8S_VERSION)),)
ENVTESTPATH = $(shell $(ENVTEST) --arch=amd64 use $(ENVTEST_K8S_VERSION) -p path)
endif
Expand Down Expand Up @@ -310,7 +311,7 @@ operator-sdk:
bundle: manifests kustomize operator-sdk ## Generate bundle manifests and metadata, then validate generated files.
GOFLAGS="-mod=mod" $(OPERATOR_SDK) generate kustomize manifests -q
cd config/manager && GOFLAGS="-mod=mod" $(KUSTOMIZE) edit set image controller=$(IMG)
GOFLAGS="-mod=mod" $(KUSTOMIZE) build config/manifests | GOFLAGS="-mod=mod" $(OPERATOR_SDK) generate bundle -q --extra-service-accounts "velero" --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
GOFLAGS="-mod=mod" $(KUSTOMIZE) build config/manifests | GOFLAGS="-mod=mod" $(OPERATOR_SDK) generate bundle -q --extra-service-accounts "velero,non-admin-controller" --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
@make nullables
# Copy updated bundle.Dockerfile to CI's Dockerfile.bundle
# TODO: update CI to use generated one
Expand Down Expand Up @@ -369,18 +370,18 @@ GIT_REV:=$(shell git rev-parse --short HEAD)
deploy-olm: THIS_OPERATOR_IMAGE?=ttl.sh/oadp-operator-$(GIT_REV):1h # Set target specific variable
deploy-olm: THIS_BUNDLE_IMAGE?=ttl.sh/oadp-operator-bundle-$(GIT_REV):1h # Set target specific variable
deploy-olm: DEPLOY_TMP:=$(shell mktemp -d)/ # Set target specific variable
deploy-olm: operator-sdk undeploy-olm ## Build current branch operator image, bundle image, push and install via OLM
deploy-olm: undeploy-olm ## Build current branch operator image, bundle image, push and install via OLM
@echo "DEPLOY_TMP: $(DEPLOY_TMP)"
# build and push operator and bundle image
# use $(OPERATOR_SDK) to install bundle to authenticated cluster
cp -r . $(DEPLOY_TMP) && cd $(DEPLOY_TMP) && \
IMG=$(THIS_OPERATOR_IMAGE) BUNDLE_IMG=$(THIS_BUNDLE_IMAGE) \
make docker-build docker-push bundle bundle-build bundle-push; \
rm -rf $(DEPLOY_TMP)
chmod -R 777 $(DEPLOY_TMP) && rm -rf $(DEPLOY_TMP)
$(OPERATOR_SDK) run bundle $(THIS_BUNDLE_IMAGE) --namespace $(OADP_TEST_NAMESPACE)

.PHONY: undeploy-olm
undeploy-olm: login-required ## Uninstall current branch operator via OLM
undeploy-olm: login-required operator-sdk ## Uninstall current branch operator via OLM
$(OC_CLI) whoami # Check if logged in
$(OC_CLI) create namespace $(OADP_TEST_NAMESPACE) || true
$(OPERATOR_SDK) cleanup oadp-operator --namespace $(OADP_TEST_NAMESPACE)
Expand Down Expand Up @@ -544,3 +545,24 @@ lint: golangci-lint ## Run Go linters checks against all project's Go files.
.PHONY: lint-fix
lint-fix: golangci-lint ## Fix Go linters issues.
$(GOLANGCI_LINT) run --fix

.PHONY: update-non-admin-manifests
update-non-admin-manifests: NON_ADMIN_CONTROLLER_IMG?=quay.io/konveyor/oadp-non-admin:latest
update-non-admin-manifests: ## Update Non Admin Controller (NAC) manifests shipped with OADP, from NON_ADMIN_CONTROLLER_PATH
ifeq ($(NON_ADMIN_CONTROLLER_PATH),)
$(error You must set NON_ADMIN_CONTROLLER_PATH to run this command)
endif
@for file_name in $(shell ls $(NON_ADMIN_CONTROLLER_PATH)/config/crd/bases);do \
Copy link
Contributor

Choose a reason for hiding this comment

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

Such long shell logic could be moved out to a shell script instead of using Makefile to run each of the command. This way Makefile will invoke one shell script.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

going to ask to this to be a future enhancement

cp $(NON_ADMIN_CONTROLLER_PATH)/config/crd/bases/$$file_name $(shell pwd)/config/crd/bases/$$file_name && \
grep -q "\- bases/$$file_name" $(shell pwd)/config/crd/kustomization.yaml || \
sed -i "s%resources:%resources:\n- bases/$$file_name%" $(shell pwd)/config/crd/kustomization.yaml;done
@sed -i "$(shell grep -Inr 'RELATED_IMAGE_NON_ADMIN_CONTROLLER' $(shell pwd)/config/manager/manager.yaml | awk -F':' '{print $$1+1}')s%.*% value: $(NON_ADMIN_CONTROLLER_IMG)%" $(shell pwd)/config/manager/manager.yaml
@mkdir -p $(shell pwd)/config/non-admin-controller_rbac
@for file_name in $(shell grep -I '^\-' $(NON_ADMIN_CONTROLLER_PATH)/config/rbac/kustomization.yaml | awk -F'- ' '{print $$2}');do \
cp $(NON_ADMIN_CONTROLLER_PATH)/config/rbac/$$file_name $(shell pwd)/config/non-admin-controller_rbac/$$file_name;done
@cp $(NON_ADMIN_CONTROLLER_PATH)/config/rbac/kustomization.yaml $(shell pwd)/config/non-admin-controller_rbac/kustomization.yaml
@for file_name in $(shell grep -I '^\-' $(NON_ADMIN_CONTROLLER_PATH)/config/samples/kustomization.yaml | awk -F'- ' '{print $$2}');do \
cp $(NON_ADMIN_CONTROLLER_PATH)/config/samples/$$file_name $(shell pwd)/config/samples/$$file_name && \
grep -q "\- $$file_name" $(shell pwd)/config/samples/kustomization.yaml || \
sed -i "s%resources:%resources:\n- $$file_name%" $(shell pwd)/config/samples/kustomization.yaml;done
@make bundle
14 changes: 13 additions & 1 deletion api/v1alpha1/oadp_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const GCPPluginImageKey UnsupportedImageKey = "gcpPluginImageFqin"
const CSIPluginImageKey UnsupportedImageKey = "csiPluginImageFqin"
const ResticRestoreImageKey UnsupportedImageKey = "resticRestoreImageFqin"
const KubeVirtPluginImageKey UnsupportedImageKey = "kubevirtPluginImageFqin"
const NonAdminControllerImageKey UnsupportedImageKey = "nonAdminControllerImageFqin"
mateusoliveira43 marked this conversation as resolved.
Show resolved Hide resolved
const OperatorTypeKey UnsupportedImageKey = "operator-type"

const OperatorTypeMTC = "mtc"
Expand Down Expand Up @@ -232,8 +233,18 @@ type SnapshotLocation struct {
Velero *velero.VolumeSnapshotLocationSpec `json:"velero"`
}

// NonAdmin defines the configuration for the non admin feature
type NonAdmin struct {
// Enables non admin feature, by default is disabled
// +optional
Enable *bool `json:"enable,omitempty"`
}

// Features defines the configuration for the DPA to enable the tech preview features
type Features struct{}
type Features struct {
// +optional
NonAdmin *NonAdmin `json:"nonAdmin"`
}

// DataProtectionApplicationSpec defines the desired state of Velero
type DataProtectionApplicationSpec struct {
Expand All @@ -253,6 +264,7 @@ type DataProtectionApplicationSpec struct {
// - csiPluginImageFqin
// - resticRestoreImageFqin
// - kubevirtPluginImageFqin
// - nonAdminControllerImageFqin
// - operator-type
// +optional
UnsupportedOverrides map[UnsupportedImageKey]string `json:"unsupportedOverrides,omitempty"`
Expand Down
27 changes: 26 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading