Skip to content
This repository was archived by the owner on Oct 3, 2019. It is now read-only.

Commit b5644ae

Browse files
authored
add deployment config creation in component S2I flow (#44)
* add deployment config creation in component S2I flow * make gofmt happy * refactor component controller * fix unit test * change deployment strategy * make deployment triggered automatically
1 parent 5ba948e commit b5644ae

File tree

10 files changed

+325
-210
lines changed

10 files changed

+325
-210
lines changed

Makefile

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,10 @@ build: prebuild-check deps check-go-format
283283

284284
# to watch all namespaces, keep namespace empty
285285
APP_NAMESPACE ?= ""
286+
LOCAL_TEST_NAMESPACE ?= "local-test"
286287
.PHONY: local
287288
## Run Operator locally
288289
local: deploy-rbac build deploy-crd
289-
@-oc new-project $(APP_NAMESPACE)
290290
operator-sdk up local --namespace=$(APP_NAMESPACE)
291291

292292
.PHONY: deploy-rbac
@@ -311,13 +311,10 @@ deploy-operator: deploy-crd
311311
.PHONY: deploy-clean
312312
## Deploy a CR as test
313313
deploy-clean:
314-
@-oc delete component.devopsconsole.openshift.io/myapp
315-
@-oc delete imagestream.image.openshift.io/myapp-builder
316-
@-oc delete imagestream.image.openshift.io/myapp-output
317-
@-oc delete buildconfig.build.openshift.io/myapp-bc
318-
@-oc delete deploymentconfig.apps.openshift.io/myapp
314+
@-oc delete project $(LOCAL_TEST_NAMESPACE)
319315

320316
.PHONY: deploy-test
321317
## Deploy a CR as test
322318
deploy-test:
323-
oc create -f examples/devopsconsole_v1alpha1_component_cr.yaml
319+
@-oc new-project $(LOCAL_TEST_NAMESPACE)
320+
@-oc apply -f examples/devopsconsole_v1alpha1_component_cr.yaml

README.md

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -164,43 +164,4 @@ Please consult [the documentation](https://github.com/operator-framework/operato
164164

165165
The frontend can check for the presence of the DevOpsConsole CRDs using the Kubernetes API. Check for [the existence of a Custom Resource Definitions](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.13/#list-customresourcedefinition-v1beta1-apiextensions) with name as `gitsources.devopsconsole.openshift.io`. If it exists, it will enable the DevOps perspective in the Openshift Console.
166166

167-
To install the DevOps Console operator and run it using OLM
168-
169-
```
170-
kubectl create -f https://raw.githubusercontent.com/operator-framework/operator-lifecycle-manager/master/deploy/upstream/quickstart/olm.yaml
171-
172-
kubectl create -f http://operator-hub-shbose-preview1-stage.b542.starter-us-east-2a.openshiftapps.com/install/devopsconsole.v0.1.0.yaml
173-
```
174-
175-
A `CatalogSource` followed by a new `Subscription` is created when the above commands are executed.
176-
177-
```
178-
apiVersion: operators.coreos.com/v1alpha1
179-
kind: CatalogSource
180-
metadata:
181-
name: rhd-operatorhub-catalog
182-
namespace: olm
183-
spec:
184-
sourceType: grpc
185-
image: sbose78/operator-registry:latest
186-
displayName: Community Operators
187-
publisher: RHD Operator Hub
188-
---
189-
apiVersion: operators.coreos.com/v1alpha1
190-
kind: Subscription
191-
metadata:
192-
name: my-devopsconsole
193-
namespace: operators
194-
spec:
195-
channel: alpha
196-
name: devopsconsole
197-
source: rhd-operatorhub-catalog
198-
sourceNamespace: olm
199-
```
200-
201-
[dep_tool]:https://golang.github.io/dep/docs/installation.html
202-
[git_tool]:https://git-scm.com/downloads
203-
[go_tool]:https://golang.org/dl/
204-
[docker_tool]:https://docs.docker.com/install/
205-
[kubectl_tool]:https://kubernetes.io/docs/tasks/tools/install-kubectl/
206-
167+
Refer to OLM test [README](test/README.md) to install the DevOps Console operator.

deploy/role.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,10 @@ rules:
4444
verbs:
4545
- create
4646
- get
47+
- apiGroups:
48+
- apps.openshift.io
49+
resources:
50+
- deploymentconfigs
51+
verbs:
52+
- create
53+
- get

examples/devopsconsole_v1alpha1_component_cr.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ metadata:
44
name: myapp
55
spec:
66
buildType: "nodejs"
7-
codebase: "https://github.com/nodeshift-starters/nodejs-rest-http-crud"
7+
codebase: "https://github.com/sclorg/nodejs-ex" #"https://github.com/nodeshift-starters/nodejs-rest-http-crud"
8+

manifests/devopsconsole/0.1.0/devopsconsole-operator.v0.1.0.clusterserviceversion.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@ spec:
124124
verbs:
125125
- create
126126
- get
127+
- apiGroups:
128+
- apps.openshift.io
129+
resources:
130+
- deploymentconfigs
131+
verbs:
132+
- create
133+
- get
127134
serviceAccountName: devopsconsole-operator
128135
strategy: deployment
129136
installModes:

pkg/apis/devopsconsole/v1alpha1/component_types.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,15 @@ type Component struct {
2727
metav1.TypeMeta `json:",inline"`
2828
metav1.ObjectMeta `json:"metadata,omitempty"`
2929

30-
Spec ComponentSpec `json:"spec,omitempty"`
30+
Spec ComponentSpec `json:"spec,omitempty"`
31+
3132
Status ComponentStatus `json:"status,omitempty"`
3233
}
3334

35+
func (c *Component) GetName() string {
36+
return c.Name
37+
}
38+
3439
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
3540

3641
// ComponentList contains a list of Component

0 commit comments

Comments
 (0)