This repository was initially bootstrapped using CoreOS operator.
- operator-sdk v0.5.0
- dep version v0.5.0+.
- git
- go version v1.10+.
- docker version 17.03+.
- [kubectl][kubectl_tool] version v1.11.0+ or [oc] version 3.11
- Access to a kubernetes v.1.11.0+ cluster or openshift cluster version 3.11
make build
- run unit test:
make test
- run e2e test: For running e2e tests, have minishift started.
make test-e2e-local
Note: e2e test will deploy operator in project
devconsole-e2e-test
, if your tests timeout and you wan to debug:
- oc project devconsole-e2e-test
- oc get deployment,pod
- oc logs pod/devconsole-operator-5b4bbc7d-4p7hr
- create a new profile to test the operator
minishift profile set devconsole
- enable the admin-user add-on
minishift addon enable admin-user
- start the instance
make minishift-start
NOTE: this setup should be deprecated in favor of OCP4 install.
- In dev mode, simply run your operator locally:
make local
NOTE: To watch all namespaces,
APP_NAMESPACE
is set to empty string. If a specific namespace is provided only that project will watched. As we reuseopenshift
's imagestreams for build, we need to access all namespaces.
- Make sure minishift is running
- Clean previously created resources
make deploy-clean
- Deploy CR
make deploy-test
- See the newly created resources
oc get is,bc,svc,component.devconsole,build
- (optional) minishift internal registry Build the operator's controller image and make it available in internal registry
oc new-project devconsole
eval $(minishift docker-env)
operator-sdk build $(minishift openshift registry)/devconsole/devconsole-operator
NOTE: In
operator.yaml
replaceimagePullPolicy: Always
withimagePullPolicy: IfNotPresent
for local dev to avoid pulling image and be able to use docker cached image instead.
- deploy cr, role and rbac
oc login -u system:admin
oc apply -f deploy/crds/devconsole_v1alpha1_component_crd.yaml
oc apply -f deploy/service_account.yaml
oc apply -f deploy/role.yaml
oc apply -f deploy/role_binding.yaml
oc apply -f deploy/operator.yaml
NOTE: make sure
deploy/operator.yaml
points to your local image:172.30.1.1:5000/devconsole/devconsole-operator:latest
- watch the operator's pod
oc logs pod/devconsole-operator-5b4bbc7d-89crs -f
- in a different shell, test CR in different project
oc new-project tina
oc create -f examples/devconsole_v1alpha1_component_cr.yaml --namespace tina
- check if the resources are created
oc get all,is,component,bc,build,deployment,pod
Please consult the documentation in order to learn about this project's structure:
File/Folders | Purpose |
---|---|
cmd | Contains manager/main.go which is the main program of the operator. This instantiates a new manager which registers all custom resource definitions under pkg/apis/... and starts all controllers under pkg/controllers/... . |
pkg/apis | Contains the directory tree that defines the APIs of the Custom Resource Definitions(CRD). Users are expected to edit the pkg/apis/<group>/<version>/<kind>_types.go files to define the API for each resource type and import these packages in their controllers to watch for these resource types. |
pkg/controller | This pkg contains the controller implementations. Users are expected to edit the pkg/controller/<kind>/<kind>_controller.go to define the controller's reconcile logic for handling a resource type of the specified kind . |
build | Contains the Dockerfile and build scripts used to build the operator. |
deploy | Contains various YAML manifests for registering CRDs, setting up RBAC, and deploying the operator as a Deployment. |
Gopkg.toml Gopkg.lock | The dep manifests that describe the external dependencies of this operator. |
vendor | The golang Vendor folder that contains the local copies of the external dependencies that satisfy the imports of this project. dep manages the vendor directly. |
The frontend can check for the presence of the devconsole CRDs using the Kubernetes API. Check for the existence of a Custom Resource Definitions with name as gitsources.devconsole.openshift.io
. If it exists, it will enable the Developer perspective in the Openshift Console.
Refer to OLM test README to install the DevOps Console operator.