Skip to content

Commit

Permalink
fixup! fix: Add contribution documenation to project
Browse files Browse the repository at this point in the history
Signed-off-by: Mateus Oliveira <[email protected]>
  • Loading branch information
mateusoliveira43 committed Mar 25, 2024
1 parent 10e9b51 commit 3e3f0bb
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 51 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
branches:
- master
schedule:
- cron: '0 0 * * 1' # Every Monday at 00:00 UTC
- cron: '0 0 * * 1' # Every Monday at 00:00 UTC

jobs:
golang-check:
Expand All @@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
go-version: ${{ matrix.go-version }}

- name: Install Go dependencies
run: go mod download
Expand Down Expand Up @@ -69,4 +69,5 @@ jobs:
- name: Check all files format
run: make ec

# TODO do not allow overwrite of production image
- name: Check if images are the same in Makefile and config/manager/kustomization.yaml
run: make check-images
46 changes: 46 additions & 0 deletions .github/workflows/oadp-compatibility-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: OADP version compatibility check

on:
push:
branches:
- master
# add release branches
schedule:
- cron: '0 0 * * 1' # Every Monday at 00:00 UTC
# TODO remove, just for test
pull_request:
branches:
- master

jobs:
golang-check:
runs-on: ubuntu-latest
strategy:
matrix:
oadp-version: [
"master",
# add release branches
]

steps:
- name: Checkout OADP operator
uses: actions/checkout@v4
with:
repository: openshift/oadp-operator
ref: ${{ matrix.oadp-version }}

- uses: actions/setup-go@v5
with:
go-version: "1.20"

- name: Checkout Non Admin Controller (NAC)
uses: actions/checkout@v4
with:
repository: migtools/oadp-non-admin
ref: ${{ matrix.oadp-version }}
path: oadp-non-admin

- name: Check Non Admin Controller (NAC) manifests
run: |
NON_ADMIN_CONTROLLER_PATH=./oadp-non-admin make update-non-admin-manifests
test -z "$(git status --short)" || (echo "run 'make update-non-admin-manifests' in OADP repository to update Non Admin Controller (NAC) manifests" && exit 1)
50 changes: 38 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

# Image URL to use all building/pushing image targets
IMG ?= controller:latest
IMG ?= quay.io/konveyor/non-admin-controller:latest
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.29.0

Expand Down Expand Up @@ -116,11 +116,14 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform
rm Dockerfile.cross

.PHONY: build-installer
build-installer: DIR?=dist
build-installer: manifests generate kustomize ## Generate a consolidated YAML with CRDs and deployment.
mkdir -p $(DIR)
mkdir -p dist
@if [ -d "config/crd" ]; then \
$(KUSTOMIZE) build config/crd > dist/install.yaml; \
fi
echo "---" >> dist/install.yaml # Add a document separator before appending
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/default > $(DIR)/install.yaml
$(KUSTOMIZE) build config/default >> dist/install.yaml

##@ Deployment

Expand Down Expand Up @@ -221,7 +224,7 @@ editorconfig: $(LOCALBIN) ## Download editorconfig locally if necessary.
}

.PHONY: ci
ci: simulation-test lint docker-build hadolint check-generate check-manifests ec ## Run all checks run by the project continuous integration (CI) locally.
ci: simulation-test lint docker-build hadolint check-generate check-manifests ec check-images ## Run all checks run by the project continuous integration (CI) locally.

.PHONY: simulation-test
simulation-test: envtest ## Run unit and integration tests.
Expand All @@ -243,14 +246,37 @@ check-manifests: manifests ## Check if 'make manifests' was run.
ec: editorconfig ## Run file formatter checks against all project's files.
$(EC)

.PHONY: check-images
check-images: MANAGER_IMAGE:=$(shell grep -I 'newName: ' ./config/manager/kustomization.yaml | awk -F': ' '{print $$2}')
check-images: MANAGER_TAG:=$(shell grep -I 'newTag: ' ./config/manager/kustomization.yaml | awk -F': ' '{print $$2}')
check-images: ## Check if images are the same in Makefile and config/manager/kustomization.yaml
@if [ "$(MANAGER_IMAGE)" == "" ];then echo "No manager image found" && exit 1;fi
@if [ "$(MANAGER_TAG)" == "" ];then echo "No manager tag found" && exit 1;fi
@grep -Iq "IMG ?= $(MANAGER_IMAGE):$(MANAGER_TAG)" ./Makefile || (echo "Images differ" && exit 1)

# A valid oadp-operator git repo fork (for example https://github.com/openshift/oadp-operator)
OADP_FORK ?= openshift
# A valid branch or tag from oadp-operator git repo
OADP_VERSION ?= master
# namespace to deploy development OADP operator
OADP_NAMESPACE ?= openshift-adp

.PHONY: deploy-dev
deploy-dev: TEMP:=$(shell mktemp -d)
deploy-dev: NAC_PATH:=$(shell pwd)
deploy-dev: DEV_IMG?=ttl.sh/oadp-nac-controller-$(shell git rev-parse --short HEAD)-$(shell echo $$RANDOM):1h
deploy-dev: ## Build and push development controller image from current branch and deploy development controller to cluster
PROD_IMG=$(IMG) IMG=$(DEV_IMG) DIR=dev make docker-build docker-push build-installer
IMG=$(PROD_IMG) cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} && cd -
$(OC_CLI) apply -f dev/install.yaml
deploy-dev: ## Build and push development controller image from current branch and deploy development OADP operator using that image
IMG=$(DEV_IMG) make docker-build docker-push
git clone --depth=1 [email protected]:$(OADP_FORK)/oadp-operator.git -b $(OADP_VERSION) $(TEMP)/oadp-operator
cd $(TEMP)/oadp-operator && \
NON_ADMIN_CONTROLLER_PATH=$(NAC_PATH) NON_ADMIN_CONTROLLER_IMG=$(DEV_IMG) OADP_TEST_NAMESPACE=$(OADP_NAMESPACE) \
make update-non-admin-manifests deploy-olm && cd -
chmod -R 777 $(TEMP) && rm -rf $(TEMP)

# TODO prior delete CR instances, to avoid finalizers problem
.PHONY: undeploy-dev
undeploy-dev: ## Undeploy development controller from cluster
$(OC_CLI) delete -f dev/install.yaml
undeploy-dev: ## Undeploy development OADP operator from cluster
git clone --depth=1 [email protected]:$(OADP_FORK)/oadp-operator.git -b $(OADP_VERSION) $(TEMP)/oadp-operator
cd $(TEMP)/oadp-operator && \
OADP_TEST_NAMESPACE=$(OADP_NAMESPACE) \
make undeploy-olm && cd -
chmod -R 777 $(TEMP) && rm -rf $(TEMP)
54 changes: 20 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Non Admin Controller

[![Continuos Integration](https://github.com/migtools/oadp-non-admin/actions/workflows/ci.yml/badge.svg)](https://github.com/migtools/oadp-non-admin/actions/workflows/ci.yml)
[![OADP version compatibility check](https://github.com/migtools/oadp-non-admin/actions/workflows/oadp-compatibility-check.yml/badge.svg)](https://github.com/migtools/oadp-non-admin/actions/workflows/oadp-compatibility-check.yml)

<!-- TODO add Official documentation link once it is created -->

Expand All @@ -18,54 +19,40 @@ This open source controller adds the non admin feature to [OADP operator](https:
- go version v1.21.0+
- oc
- Access to a OpenShift cluster
- [OADP operator](https://github.com/openshift/oadp-operator) installed in the cluster

<!-- TODO update in future, probably will need to use unsupported override in DPA -->

### Install

To install latest OADP NAC in `oadp-nac-system` namespace in your cluster, run
To install OADP operator in your cluster, with OADP NAC from current branch, run
```sh
make deploy
make deploy-dev
```

To check the deployment, run
The command can be customized by setting the following environment variables
```sh
oc get all -n oadp-nac-system
```

you should have an output similar to this:
```
NAME READY STATUS RESTARTS AGE
pod/oadp-nac-controller-manager-74bbf4577b-nssw4 2/2 Running 0 3m7s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/oadp-nac-controller-manager-metrics-service ClusterIP 172.30.201.185 <none> 8443/TCP 3m8s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/oadp-nac-controller-manager 1/1 1 1 3m7s
NAME DESIRED CURRENT READY AGE
replicaset.apps/oadp-nac-controller-manager-74bbf4577b 1 1 1 3m7s
OADP_FORK=<OADP_operator_user_or_org>
OADP_VERSION=<OADP_operator_branch_or_tag>
OADP_NAMESPACE=<OADP_operator_installation_namespace>
```

### Testing

To test NAC functionality, create non admin CRs. For example, run
```sh
oc apply -f config/samples/nac_v1alpha1_nonadminbackup.yaml
```
To test NAC functionality:
- create DPA with non admin feature enabled
- create non admin CRs. For example, run
```sh
oc apply -f config/samples/nac_v1alpha1_nonadminbackup.yaml
```

To create a non admin user to test NAC, check [non admin user documentation](docs/non_admin_user.md).

### Uninstall

To uninstall the previously installed OADP NAC in your cluster, run
To uninstall the previously installed OADP operator in your cluster, run
```sh
make undeploy
make undeploy-dev
```

> **NOTE:** make sure there are no running instances of CRDs. Finalizers in those objects can fail the `undeploy` command.
> **NOTE:** make sure there are no running instances of CRDs. Finalizers in those objects can fail `undeploy-dev` command.

## Contributing

Expand All @@ -77,12 +64,11 @@ For a better understanding of the project, check our [architecture documentation

## OADP version compatibility

OADP NAC needs OADP operator to work. The relationship between compatible versions is presented below.
OADP NAC needs OADP operator to work. The relationship between compatible branches is presented below.

| NAC version | OADP version |
|-------------|--------------|
| master | master |
| v0.1.0 | v1.4.0 |
| NAC branch | OADP branch |
|------------|-------------|
| master | master |

## License

Expand Down
2 changes: 1 addition & 1 deletion config/default/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Adds namespace to all resources.
namespace: oadp-nac-system # TODO change
namespace: oadp-nac-system

# Value of this field is prepended to the
# names of all resources, e.g. a deployment named
Expand Down
2 changes: 1 addition & 1 deletion config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: controller
newName: quay.io/konveyor/non-admin-controller
newTag: latest

0 comments on commit 3e3f0bb

Please sign in to comment.