Skip to content

Commit 93d2357

Browse files
committed
(fix): Add copy to clipboard
- added copy to clipboard to setup - added copy to clipboard to basics - added copy to clipboard to configs and routes - added copy to clipboard to scaling - added copy to clipboard to build - added copy to clipboard to eventing - made quarkus as default - fixes for revision pinning and traffic distribution - tutorial namespace made as asciidoc attribute - replaced yq with sed - fixed template names Fixes redhat-developer-demos#42, redhat-developer-demos#85, redhat-developer-demos#66, redhat-developer-demos#115 Fixes redhat-developer-demos#42, redhat-developer-demos#85, redhat-developer-demos#66 (fix): Add clip to copy to build chapters
1 parent 7e2a047 commit 93d2357

37 files changed

+965
-570
lines changed

02-basics/knative/service-pinned-rev2.yaml

-21
This file was deleted.

02-basics/knative/service-pinned-rev1.yaml 02-basics/knative/service-pinned.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ metadata:
44
name: greeter
55
spec:
66
release:
7-
revisions: ["greeter-00001"]
7+
revisions: $revision
88
configuration:
99
revisionTemplate:
1010
spec:

03-configs-and-routes/route/route_all_rev2.yaml

-8
This file was deleted.

03-configs-and-routes/route/route_all_rev1.yaml 03-configs-and-routes/route/route_all_to_revision.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ metadata:
44
name: greeter
55
spec:
66
traffic:
7-
- revisionName: greeter-00001
7+
- revisionName: $revision
88
percent: 100

03-configs-and-routes/route/route_rev1-10_rev2-90.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ metadata:
44
name: greeter
55
spec:
66
traffic:
7-
- revisionName: greeter-00001
7+
- revisionName: $revision1
88
percent: 10
9-
- revisionName: greeter-00002
9+
- revisionName: $revision2
1010
percent: 90

03-configs-and-routes/route/route_rev1-50_rev2-50.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ metadata:
44
name: greeter
55
spec:
66
traffic:
7-
- revisionName: greeter-00001
7+
- revisionName: $revision1
88
percent: 50
9-
- revisionName: greeter-00002
9+
- revisionName: $revision2
1010
percent: 50

03-configs-and-routes/route/route_rev1-75_rev2-25.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ metadata:
44
name: greeter
55
spec:
66
traffic:
7-
- revisionName: greeter-00001
7+
- revisionName: $revision1
88
percent: 75
9-
- revisionName: greeter-00002
9+
- revisionName: $revision2
1010
percent: 25
File renamed without changes.

05-build/knative/maven-build-template.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ spec:
1515
- "/usr/local/bin/buildah.sh"
1616
env:
1717
- name: WORK_DIR
18-
value: /workspace/${CONTEXT_DIR}
18+
value: ${CONTEXT_DIR}
1919
- name: DESTINATION_NAME
2020
value: ${IMAGE}
2121
# uncomment this if you have MAVEN_MIRROR thats is reachable from your kube cluster
@@ -33,7 +33,7 @@ spec:
3333
name: m2-cache
3434
- mountPath: /var/lib/containers
3535
name: container-storage
36-
workingDir: /workspace/${CONTEXT_DIR}
36+
workingDir: ${CONTEXT_DIR}
3737
timeout: 60m
3838
volumes:
3939
- name: m2-cache

documentation/modules/ROOT/pages/01-setup.adoc

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
= Setup
22
include::_attributes.adoc[]
33

4-
[#prerequisite]
4+
[[prerequisite]]
55
== Prerequisite CLI tools
66

77
The following CLI tools are required for running the exercises in this tutorial. Please have them installed and configured before you get started with any of the tutorial chapters.
@@ -64,10 +64,12 @@ The following CLI tools are required for running the exercises in this tutorial.
6464
== Download Tutorial Sources
6565
Before we start setting up the environment, let's clone the tutorial sources and set the `TUTORIAL_HOME` environment variable to point to the root directory of the tutorial:
6666

67-
[source,bash]
67+
[#cloneRepo]
68+
[source,bash,subs="+macros,+attributes"]
6869
----
69-
git clone https://github.com/redhat-developer-demos/knative-tutorial
70+
git clone https://github.com/redhat-developer-demos/knative-tutorial
7071
----
72+
copyToClipboard::cloneRepo[]
7173

7274
The `work` folder in `$TUTORIAL_HOME` can be used to download the demo application resources and refer to them during the exercises. The `work` folder has a README with instructions on the source code repo and git commands to clone the sources.
7375

documentation/modules/ROOT/pages/02-basic-fundas.adoc

+66-31
Original file line numberDiff line numberDiff line change
@@ -51,38 +51,43 @@ spec:
5151

5252
The service could be deployed using the command:
5353

54+
[#basics-run-svc-apply]
5455
[source,bash,subs="+macros,+attributes"]
5556
----
56-
kubectl apply -n knativetutorial -f link:{github-repo}/{basics-repo}/knative/service.yaml[service.yaml]
57+
kubectl apply -n {tutorial-namespace} -f link:{github-repo}/{basics-repo}/knative/service.yaml[service.yaml]
5758
----
59+
copyToClipboard::basics-run-svc-apply[]
5860

59-
.(OR)
61+
**(OR)**
6062

63+
[#basics-run-oc-svc-apply]
6164
[source,bash,linenums,subs="+macros,+attributes"]
6265
----
63-
oc apply -n knativetutorial -f link:{github-repo}/{basics-repo}/knative/service.yaml[service.yaml]
66+
oc apply -n {tutorial-namespace} -f link:{github-repo}/{basics-repo}/knative/service.yaml[service.yaml]
6467
----
68+
copyToClipboard::basics-run-oc-svc-apply[]
6569

70+
After successful deployment of the service we should see a kubernetes deployment like `greeter-nsrbr-deployment` available.
6671

67-
After successful deployment of the service we should see a kubernetes deployment called `greeter-00001-deployment` available.
68-
69-
[.thumb]
70-
image::greeter-00001.png[Greeter Service]
72+
[NOTE]
73+
====
74+
* The actual deployment name may vary in your setup
75+
====
7176

7277
[#basics-invoke-service]
7378
== Invoke Service
74-
7579
:k8s-env: minikube
7680
:k8s-cli: kubectl
81+
7782
include::ROOT:partial$invoke-service.adoc[tag=*]
7883

79-
.(OR)
84+
**(OR)**
8085

8186
:k8s-env: minishift
8287
:k8s-cli: oc
8388
include::ROOT:partial$invoke-service.adoc[tag=*]
8489

85-
The last curl command should return a response like **Hi greeter => greeter-00001-deployment-5d696cc6c8-m65s5: 1**
90+
The last curl command should return a response like **Hi greeter => '6fee83923a9f' : 1**
8691

8792
NOTE: Sometimes the response might not be returned immediately especially when the pod is coming up from dormant state, at those times try giving request again
8893

@@ -93,14 +98,17 @@ The service-based deployment strategy that we did now will create many Knative r
9398

9499
[#basics-show-knative-services]
95100
=== service
101+
96102
include::partial$knative-objects.adoc[tag=knative-services]
97103

98104
[#basics-show-knative-configs]
99105
=== configuration
106+
100107
include::partial$knative-objects.adoc[tag=knative-configs]
101108

102109
[#basics-show-knative-routes]
103110
=== routes
111+
104112
include::partial$knative-objects.adoc[tag=knative-routes]
105113

106114
When the service was invoked with `curl -H "Host:greeter.knativetutorial.example.com" $IP_ADDRESS`,you noticed that we added a **Host** header to the request with value `greeter.knativetutorial.example.com`,this FQDN is automatically assigned to your Knative service by the Knative Routes,it uses the format like `**<service-name>.<namespace>.<domain-suffix>**`.
@@ -152,41 +160,42 @@ spec:
152160

153161
Let us deploy the new revision using the command:
154162

163+
[#basics-run-service-env]
155164
[source,bash,subs="+macros,+attributes"]
156165
----
157-
kubectl apply -n knativetutorial -f link:{github-repo}/{basics-repo}/knative/service-env.yaml[service-env.yaml]
166+
kubectl apply -n {tutorial-namespace} -f link:{github-repo}/{basics-repo}/knative/service-env.yaml[service-env.yaml]
158167
----
168+
copyToClipboard::basics-run-service-env[]
159169

160-
.(OR)
161-
170+
**(OR)**
171+
[#oc-basics-run-service-env]
162172
[source,bash,subs="+macros,+attributes"]
163173
----
164-
oc apply -n knativetutorial -f link:{github-repo}/{basics-repo}/knative/service-env.yaml[service-env.yaml]
174+
oc apply -n {tutorial-namespace} -f link:{github-repo}/{basics-repo}/knative/service-env.yaml[service-env.yaml]
165175
----
176+
copyToClipboard::oc-basics-run-service-env[]
166177

167-
After successful deployment of the service we should see a kubernetes deployment called `greeter-00002-deployment` available in the OpenShift dashboard:
178+
After successful deployment of the service we should see a kubernetes deployment called `greeter-cqgcf-deployment`.
168179

169-
image::greeter-00002.png[Greeter Service rev2]
180+
Now running the <<basics-show-knative-revisions,command>> will show two revisions namely `greeter-cqgcf` and `greeter-nsrbr`.
170181

171-
Now running the <<basics-show-knative-revisions,command>> will show two revisions namely `greeter-00001` and `greeter-0002`.
172-
173-
<<basics-invoke-service,Invoking Service>> will now show an output like **Namaste greeter => greeter-00002-deployment-8d9984dc8-rgzx6: 2**, where __Namaste__ is the value that we configured via environment variable in the Knative service resource file.
182+
<<basics-invoke-service,Invoking Service>> will now show an output like **Namaste greeter => '6fee83923a9f' : 1**, where __Namaste__ is the value that we configured via environment variable in the Knative service resource file.
174183

175184
[#basics-pinning-revision]
176185
== Pinning service to a revision
177186

178187
As you noticed that the Knative services always routes the traffic to the **latest** revision of the service deployment, thats because of the **runLatest** attribute in <<basics-service-rev2,service resource file>>.
179188

180-
Let us now make the greeter service use earlier revision `greeter-00001`.
189+
Let us now make the greeter service use first revision created i.e. the one using the default `MESSAGE_PREFIX`.
181190

182191
[TIP]
183192
====
184193
You can use the get <<basics-show-knative-revisions, show knative revisions>> command to find the available revisions for the greeter service.
185194
====
186195

187-
=== Service pinned to revision 1
196+
=== Service pinned to first revision
188197

189-
.link:{github-repo}/{basics-repo}/knative/service-pinned-rev1.yaml[service-pinned-rev1.yaml]
198+
.link:{github-repo}/{basics-repo}/knative/service-pinned-rev1.yaml[service-pinned.yaml]
190199
[source,yaml,linenums]
191200
----
192201
apiVersion: serving.knative.dev/v1alpha1
@@ -195,43 +204,69 @@ metadata:
195204
name: greeter
196205
spec:
197206
release: #<1>
198-
revisions: ["greeter-00001"]
207+
revisions:
208+
- greeter-nsrbr
199209
configuration:
200210
revisionTemplate:
201211
spec:
202212
container:
203213
image: dev.local/rhdevelopers/greeter:0.0.1
214+
env:
215+
- name: MESSAGE_PREFIX
216+
value: Namaste
217+
livenessProbe:
218+
httpGet:
219+
path: /healthz
220+
readinessProbe:
221+
httpGet:
222+
path: /healthz
204223
----
205224

206225
<1> The **release** attribute in service resource file will make Knative use the revision specified in the **revisions** attribute.
207226

208-
Let redeploy the greeter service to be pinned to revision __greeter-00001__:
227+
[IMPORTANT]
228+
====
229+
The value of revisions might be different in your setup
230+
====
231+
232+
Let redeploy the greeter service by pinning it to the first revision that was created:
209233

234+
[#run-pinned-revision]
210235
[source,bash,subs="+macros,+attributes"]
211236
----
212-
kubectl apply -n knativetutorial -f link:{github-repo}/{basics-repo}/knative/service-pinned-rev1.yaml[service-pinned-rev1.yaml]
237+
PIN_REVISION=`kubectl get rev -l serving.knative.dev/service=greeter -l serving.knative.dev/configurationGeneration=1 | awk 'NR==2{print $1}'` && \
238+
cat service-pinned.yaml | yq w - "spec.release.revisions[+]" $FIRST_REVISION | kubectl -n {tutorial-namespace} apply -f -
213239
----
240+
copyToClipboard::run-pinned-revision[]
214241

215-
.(OR)
242+
**(OR)**
216243

244+
[#run-oc-pinned-revision]
217245
[source,bash,subs="+macros,+attributes"]
218246
----
219-
oc apply -n knativetutorial -f link:{github-repo}/{basics-repo}/knative/service-pinned-rev1.yaml[service-pinned-rev1.yaml]
247+
PIN_REVISION=`kubectl get rev -l serving.knative.dev/service=greeter -l serving.knative.dev/configurationGeneration=1 | awk 'NR==2{print $1}'` && \
248+
cat service-pinned.yaml | yq w - "spec.release.revisions[+]" $FIRST_REVISION | oc -n {tutorial-namespace} apply -f -
220249
----
250+
copyToClipboard::run-oc-pinned-revision[]
221251

222-
<<basics-invoke-service,Invoking Service>> will now show an output like **Hi greeter => greeter-00001-deployment-5d696cc6c8-m65s5: 3**.
252+
<<basics-invoke-service,Invoking Service>> will now show an output like **Hi greeter => '6fee83923a9f' : 1**
223253

224254
[#basics-cleanup]
225255
== Cleanup
226256

257+
[#basics-run-cleanup]
227258
[source,bash,subs="+macros,+attributes"]
228259
----
229-
kubectl -n knativetutorial delete services.serving.knative.dev greeter
260+
kubectl -n {tutorial-namespace} delete services.serving.knative.dev greeter
230261
----
262+
copyToClipboard::basics-run-cleanup[]
231263

232-
.(OR)
264+
**(OR)**
233265

266+
[#basics-run-oc-cleanup]
234267
[source,bash,subs="+macros,+attributes"]
235268
----
236-
oc -n knativetutorial delete services.serving.knative.dev greeter
269+
oc -n {tutorial-namespace} delete services.serving.knative.dev greeter
237270
----
271+
copyToClipboard::basics-run-oc-cleanup[]
272+

0 commit comments

Comments
 (0)