Skip to content

Commit d1dcccc

Browse files
committed
updated to latest
1 parent 626bc7f commit d1dcccc

File tree

6 files changed

+202
-90
lines changed

6 files changed

+202
-90
lines changed

README.adoc

+68-22
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@ An OpenShift4 cluster with following components:
2020
[source,bash]
2121
----
2222
oc new-project tutorial && \
23-
oc create serviceaccount pipeline && \
23+
! oc create serviceaccount pipeline && \
2424
oc adm policy add-scc-to-user privileged -z pipeline && \
2525
oc adm policy add-role-to-user edit -z pipeline && \
2626
oc adm policy add-scc-to-user privileged -z default && \
2727
oc adm policy add-scc-to-user anyuid -z default && \
28-
oc create -f https://raw.githubusercontent.com/redhat-developer-demos/pipelines-catalog/master/knative-client/pipeline-sa-roles.yaml -n tutorial && \
28+
oc create -f https://raw.githubusercontent.com/redhat-developer-demos/tutorials-pipelines/pipelines-common/pipeline-role-sa.yaml
29+
-n tutorial && \
2930
oc policy add-role-to-user pipeline-roles -z pipeline --role-namespace=tutorial
3031
----
3132

32-
== Deploy Nexus
33+
== Deploy Nexus(Optional)
3334

3435
To make maven builds faster, we will deploy Sonatype Nexus
3536

@@ -44,11 +45,15 @@ Create the following Tekton tasks which will be used in the `Pipelines`
4445

4546
[source,bash]
4647
----
47-
oc create -f https://raw.githubusercontent.com/tektoncd/catalog/master/openshift-client/openshift-client-task.yaml \
48-
-f https://raw.githubusercontent.com/redhat-developer-demos/pipelines-catalog/master/quarkus/s2i-quarkus-task.yaml \
49-
-f https://raw.githubusercontent.com/redhat-developer-demos/pipelines-catalog/master/quarkus/quarkus-native-task.yaml \
50-
-f https://raw.githubusercontent.com/redhat-developer-demos/pipelines-catalog/master/quarkus/quarkus-jvm-task.yaml \
51-
-f https://raw.githubusercontent.com/redhat-developer-demos/pipelines-catalog/master/knative-client/kn-service-create-task.yaml
48+
oc create -n tutorial \
49+
-f https://raw.githubusercontent.com/tektoncd/catalog/master/kn/kn.yaml
50+
51+
oc create -n tutorial \
52+
-f https://raw.githubusercontent.com/tektoncd/catalog/master/openshift-client/openshift-client-task.yaml
53+
54+
oc create -n tutorial \
55+
-f https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/master/06-pipelines/build-app-task.yaml
56+
5257
----
5358

5459
Check the tasks created
@@ -60,11 +65,10 @@ tkn task ls
6065

6166
```
6267
NAME AGE
63-
kn-create-service 12 seconds ago
64-
openshift-client 13 seconds ago
65-
quarkus-jvm 12 seconds ago
66-
quarkus-native 12 seconds ago
67-
s2i-quarkus 13 seconds ago
68+
NAME AGE
69+
build-app 3 seconds ago
70+
kn 5 seconds ago
71+
openshift-client 4 seconds ago
6872
```
6973

7074
== Application Deployment
@@ -93,8 +97,17 @@ oc create -f pipelines-common/resources.yaml \
9397

9498
[source,bash]
9599
----
100+
# create customer deployment config
96101
oc create -f customer/app.yaml
97-
oc create -f customer/pipeline-run.yaml
102+
103+
# start the customer deploy pipeline
104+
tkn pipeline start rhd-tutorial-deploy \
105+
--param="applicationSrcDir=customer" \
106+
--param="deploymentConfig=customer" \
107+
--param="mavenMirrorUrl=http://nexus:8081/nexus/content/groups/public" \
108+
--resource="app-git=git-source" \
109+
--resource="app-image=customer-openshift-image" \
110+
--serviceaccount='pipeline'
98111
----
99112

100113
Watch the logs of pipeline run using the command
@@ -110,8 +123,17 @@ tkn pipelinerun logs -a -f <id-from-previous-command>
110123

111124
[source,bash]
112125
----
113-
oc create -f preference/app.yaml \
114-
-f preference/pipeline-run.yaml
126+
# create preference deployment config
127+
oc create -f preference/app.yaml
128+
129+
# start preference deployment pipeline
130+
tkn pipeline start rhd-tutorial-deploy \
131+
--param="applicationSrcDir=preference" \
132+
--param="deploymentConfig=preference" \
133+
--param="mavenMirrorUrl=http://nexus:8081/nexus/content/groups/public" \
134+
--resource="app-git=git-source" \
135+
--resource="app-image=preference-openshift-image" \
136+
--serviceaccount='pipeline'
115137
----
116138

117139
Watch the logs of pipeline run using the command
@@ -133,15 +155,27 @@ tkn pipelinerun logs -a -f <id-from-previous-command>
133155

134156
[source,bash]
135157
----
136-
oc create -f recommendation/app-v1.yaml \
137-
-f recommendation/pipeline-run.yaml
158+
oc create -f recommendation/app-v1.yaml
159+
160+
tkn pipeline start rhd-tutorial-deploy \
161+
--param="applicationSrcDir=recommendation" \
162+
--param="deploymentConfig=recommendation" \
163+
--param="mavenMirrorUrl=http://nexus:8081/nexus/content/groups/public" \
164+
--resource="app-git=git-source" \
165+
--resource="app-image=recommendation-openshift-image-v1" \
166+
--serviceaccount='pipeline'
138167
----
139168

140169
==== Knative Service Deployment
141170

142171
[source,bash]
143172
----
144-
oc create -f recommendation/kn-pipeline-run.yaml
173+
tkn pipeline start rhd-tutorial-kn-deploy \
174+
--param="applicationSrcDir=recommendation" \
175+
--param="mavenMirrorUrl=http://nexus:8081/nexus/content/groups/public" \
176+
--resource="app-git=git-source" \
177+
--resource="app-image=recommendation-openshift-image-v1" \
178+
--serviceaccount='pipeline'
145179
----
146180

147181
Watch the logs of pipeline run using the command
@@ -160,15 +194,27 @@ tkn pipelinerun logs -a -f <id-from-previous-command>
160194

161195
[source,bash]
162196
----
163-
oc create -f recommendation/app-v2.yaml \
164-
-f recommendation/pipeline-run-v2.yaml
197+
oc create -f recommendation/app-v2.yaml
198+
199+
tkn pipeline start rhd-tutorial-deploy \
200+
--param="applicationSrcDir=recommendation" \
201+
--param="deploymentConfig=recommendation" \
202+
--param="mavenMirrorUrl=http://nexus:8081/nexus/content/groups/public" \
203+
--resource="app-git=git-source-v2" \
204+
--resource="app-image=recommendation-openshift-image-v2" \
205+
--serviceaccount='pipeline'
165206
----
166207

167208
==== Knative Service Deployment
168209

169210
[source,bash]
170211
----
171-
oc create -f recommendation/kn-pipeline-v2-run.yaml
212+
tkn pipeline start rhd-tutorial-kn-deploy \
213+
--param="applicationSrcDir=recommendation" \
214+
--param="mavenMirrorUrl=http://nexus.rhd-workshop-infra:8081/nexus/content/groups/public" \
215+
--resource="app-git=git-source-v2" \
216+
--resource="app-image=recommendation-openshift-image-v2" \
217+
--serviceaccount='pipeline'
172218
----
173219

174220
Watch the logs of pipeline run using the command

customer/pipeline-run.yaml

+7-9
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@ spec:
1010
value: customer
1111
- name: applicationSrcDir
1212
value: customer
13-
trigger:
14-
type: manual
15-
serviceAccount: 'pipeline'
13+
serviceAccount: "pipeline"
1614
resources:
17-
- name: app-git
18-
resourceRef:
19-
name: korea-keynote-demo-git
20-
- name: app-image
21-
resourceRef:
22-
name: customer-openshift-image
15+
- name: app-git
16+
resourceRef:
17+
name: korea-keynote-demo-git
18+
- name: app-image
19+
resourceRef:
20+
name: customer-openshift-image

pipelines-common/pipeline-deploy.yaml

+34-31
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,43 @@ metadata:
44
name: rhd-tutorial-deploy
55
spec:
66
resources:
7-
- name: app-git
8-
type: git
9-
- name: app-image
10-
type: image
7+
- name: app-git
8+
type: git
9+
- name: app-image
10+
type: image
1111
params:
1212
- name: deploymentConfig
1313
description: The application name i.e. OpenShift/Kubernetes Deployment name
1414
- name: applicationSrcDir
1515
description: The source directory of the application within the source repository
1616
tasks:
17-
- name: build
18-
taskRef:
19-
name: quarkus-native
20-
params:
21-
- name: tlsVerify
22-
value: "false"
23-
- name: contextDir
24-
value: "${params.applicationSrcDir}"
25-
# if you have different repository manager update the value below
26-
# if don't wish to use nexus or repo manager then comment the name/value below
27-
- name: mavenMirrorUrl
28-
value: 'http://nexus:8081/nexus/content/groups/public'
29-
resources:
30-
inputs:
31-
- name: source
32-
resource: app-git
33-
outputs:
34-
- name: image
35-
resource: app-image
36-
- name: deploy
37-
taskRef:
38-
name: openshift-client
39-
runAfter:
40-
- build
41-
params:
42-
- name: ARGS
43-
value: "rollout latest ${params.deploymentConfig}"
17+
- name: build
18+
taskRef:
19+
name: build-app
20+
params:
21+
- name: contextDir
22+
value: "$(params.applicationSrcDir)"
23+
# if you have different repository manager update the value below
24+
# if don't wish to use nexus or repo manager then comment the name/value below
25+
- name: mavenMirrorUrl
26+
value: "http://nexus.rhd-workshop-infra:8081/nexus/content/groups/public"
27+
- name: dockerFile
28+
value: "Dockerfile"
29+
resources:
30+
inputs:
31+
- name: source
32+
resource: app-git
33+
outputs:
34+
- name: builtImage
35+
resource: app-image
36+
- name: deploy
37+
taskRef:
38+
name: openshift-client
39+
runAfter:
40+
- build
41+
params:
42+
- name: ARGS
43+
value:
44+
- "rollout"
45+
- "latest"
46+
- "$(params.deploymentConfig)"

pipelines-common/pipeline-kn-deploy.yaml

+13-8
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,36 @@ spec:
1616
tasks:
1717
- name: build
1818
taskRef:
19-
name: quarkus-native
19+
name: build-app
2020
params:
21-
- name: tlsVerify
22-
value: "false"
2321
- name: contextDir
24-
value: "${params.applicationSrcDir}"
22+
value: "$(params.applicationSrcDir)"
2523
# if you have different repository manager update the value below
2624
# if don't wish to use nexus or repo manager then comment the name/value below
2725
- name: mavenMirrorUrl
2826
value: "http://nexus.rhd-workshop-infra:8081/nexus/content/groups/public"
27+
- name: dockerFile
28+
value: "Dockerfile"
2929
resources:
3030
inputs:
3131
- name: source
3232
resource: app-git
3333
outputs:
34-
- name: image
34+
- name: builtImage
3535
resource: app-image
3636
- name: deploy
3737
taskRef:
38-
name: kn-create-service
38+
name: kn
3939
runAfter:
4040
- build
4141
params:
42-
- name: name
43-
value: ${params.serviceName}
42+
- name: ARGS
43+
value:
44+
- "service"
45+
- "create"
46+
- "recommendation"
47+
- "--force"
48+
- "--image=$(inputs.resources.image.url)"
4449
resources:
4550
inputs:
4651
- name: image
+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: Role
3+
metadata:
4+
name: pipeline-role
5+
namespace: tutorial
6+
rules:
7+
- apiGroups: ["serving.knative.dev"]
8+
resources: ["*"]
9+
verbs: ["*"]
10+
- apiGroups: ["eventing.knative.dev"]
11+
resources: ["*"]
12+
verbs: ["*"]
13+
- apiGroups: ["sources.eventing.knative.dev"]
14+
resources: ["*"]
15+
verbs: ["*"]
16+
- apiGroups:
17+
- ""
18+
resources:
19+
- pods
20+
- services
21+
- endpoints
22+
- configmaps
23+
- secrets
24+
verbs:
25+
- '*'
26+
- apiGroups:
27+
- apps
28+
resources:
29+
- deployments
30+
- daemonsets
31+
- replicasets
32+
- statefulsets
33+
verbs:
34+
- '*'
35+
- apiGroups:
36+
- ""
37+
resources:
38+
- pods
39+
verbs:
40+
- get
41+
- apiGroups:
42+
- apps
43+
resources:
44+
- replicasets
45+
verbs:
46+
- get
47+
---
48+
apiVersion: rbac.authorization.k8s.io/v1
49+
kind: RoleBinding
50+
metadata:
51+
name: pipeline-role-binding
52+
namespace: tutorial
53+
roleRef:
54+
kind: Role
55+
name: pipeline-role
56+
apiGroup: rbac.authorization.k8s.io
57+
subjects:
58+
- kind: ServiceAccount
59+
name: pipeline
60+
namespace: tutorial

0 commit comments

Comments
 (0)