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 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
- create a new profile to test the operator
minishift profile set devopsconsole
- enable the admin-user add-on
minishift addon enable admin-user
- optionally, configure the VM
minishift config set cpus 4
minishift config set memory 8GB
minishift config set vm-driver virtualbox
- start the instance
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_NAMESPACEis 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 and use myproject
oc project myproject
- Clean previously created resources
make deploy-clean
- Deploy CR
make deploy-test
- See the newly created resources
oc get is,bc,svc,component.devopsconsole,build
NAME DOCKER REPO TAGS UPDATED
imagestream.image.openshift.io/myapp-output 172.30.1.1:5000/myproject/myapp-output
imagestream.image.openshift.io/myapp-runtime 172.30.1.1:5000/myproject/myapp-runtime latest 46 seconds ago
NAME TYPE FROM LATEST
buildconfig.build.openshift.io/myapp-bc Source Git@master 1
NAME AGE
component.devopsconsole.openshift.io/myapp 48s
NAME TYPE FROM STATUS STARTED DURATION
build.build.openshift.io/myapp-bc-1 Source Git@85ac14e Running 45 seconds ago
- (optional) minishift internal registry Build the operator's controller image and make it available in internal registry
oc new-project devopsconsole
eval $(minishift docker-env)
operator-sdk build $(minishift openshift registry)/devopsconsole/devopsconsole-operator
NOTE: In
operator.yamlreplaceimagePullPolicy: AlwayswithimagePullPolicy: IfNotPresentfor 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/devopsconsole_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.yamlpoints to your local image:172.30.1.1:5000/devopsconsole/devopsconsole-operator:latest
- watch the operator's pod
oc logs pod/devopsconsole-operator-5b4bbc7d-89crs -f
- in a different shell, test CR in different project
oc new-project tina
oc create -f examples/devopsconsole_v1alpha1_component_cr.yaml --namespace tina
- check if the resources are created
oc get all,is,component,bc,build,deployment,pod
NAME READY STATUS RESTARTS AGE
pod/myapp-bc-1-build 1/1 Running 0 23s
NAME TYPE FROM LATEST
buildconfig.build.openshift.io/myapp-bc Source Git@master 1
NAME TYPE FROM STATUS STARTED DURATION
build.build.openshift.io/myapp-bc-1 Source Git@afc0f38 Running 23 seconds ago
NAME DOCKER REPO TAGS UPDATED
imagestream.image.openshift.io/myapp-output 172.30.1.1:5000/tina/myapp-output
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 DevOpsConsole CRDs using the Kubernetes API. Check for the existence of a Custom Resource Definitions with name as gitsources.devopsconsole.openshift.io. If it exists, it will enable the DevOps perspective in the Openshift Console.
To install the DevOps Console operator and run it using OLM
kubectl create -f https://raw.githubusercontent.com/operator-framework/operator-lifecycle-manager/master/deploy/upstream/quickstart/olm.yaml
kubectl create -f http://operator-hub-shbose-preview1-stage.b542.starter-us-east-2a.openshiftapps.com/install/devopsconsole.v0.1.0.yaml
A CatalogSource followed by a new Subscription is created when the above commands are executed.
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: rhd-operatorhub-catalog
namespace: olm
spec:
sourceType: grpc
image: sbose78/operator-registry:latest
displayName: Community Operators
publisher: RHD Operator Hub
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: my-devopsconsole
namespace: operators
spec:
channel: alpha
name: devopsconsole
source: rhd-operatorhub-catalog
sourceNamespace: olm