Skip to content

Commit f291bd7

Browse files
author
Doug Davis
committed
misc updates
Signed-off-by: Doug Davis <[email protected]>
1 parent 0db6d31 commit f291bd7

File tree

2 files changed

+35
-25
lines changed

2 files changed

+35
-25
lines changed

README.md

+29-24
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22

33
This repository demonstrates a few things:
44
- run a Docker registry as a [Knative](https://knative.dev) Service
5-
- build an image using [Tekton](https://tekton.dev) and push it to that registry
6-
- run that image as a Knative Service
5+
- build an application image using [Tekton](https://tekton.dev) and push it
6+
to that registry
7+
- run that application image as a Knative Service
78

89
Why? Couple of reasons:
910
- show how it's possible to run someting that is not traditionally thought of
1011
as a "function" as a Knative service
1112
- show how to use Tekton as a replacement for Knative's Build feature, which
1213
is almost gone now
1314
- show how to use a local registry for times when you just don't want to deal
14-
with noise like authentication and service accounts - mainly for demos
15+
with noise like authentication and service accounts - see
16+
[Some final notes](#some-final-notes)
1517

1618
## Faking it
1719

@@ -35,7 +37,7 @@ the instructions
3537

3638
As of today Tekton (the replacement for Knative Build) is not installed
3739
by default in IKS's Knative install, it will be soon, but for now you'll
38-
need to install it youself:
40+
need to install it yourself:
3941

4042
```bash
4143
$ kubectl apply -f https://storage.googleapis.com/tekton-releases/latest/release.yaml
@@ -62,12 +64,13 @@ to explain what's going on.
6264
First, we need to upload the source code for our application into
6365
Kubernetes so that our build process can use it. In this case we're going
6466
to use a ConfigMap. This has a few nice aspects to it:
65-
- it's easily populated via the `--from-file` option on `kubectl`
67+
- it's easily populated via the `--from-file` option on
68+
`kubectl create configmap`
6669
- it can be mounted as a volume into a pod fairly easily
67-
- if necessary I can switch it to use a Secret instead if security is an issue
70+
- if necessary, I can switch it to use a Secret instead if security is an issue
6871
- can use it with Knative services too at some point if I wanted to. Right now
69-
Knative doesn't allow generic Volumes to be mounted into Knative Services
70-
- sadly.
72+
Knative doesn't allow generic Volumes to be mounted into Knative Services -
73+
sadly
7174

7275
```bash
7376
$ kubectl create cm source --from-file=src
@@ -109,7 +112,7 @@ If you're not familiar with Knative yet I would suggest you look at the
109112
other intro demo I have [here](https://github.com/duglin/helloworld) to
110113
understand the basic outline of this yaml.
111114

112-
In this particular KnService I wanted to point out a couple of key things.
115+
In this particular Knative Service I wanted to point out a couple of key things.
113116
First, `minScale` and `maxScale` are both set to `1`. This means that Knative
114117
will always have exactly one instance of the `docker.io/registry` image
115118
running. In a perfect world I would let this scale up and down based on the
@@ -119,17 +122,17 @@ deleted, all images stored in this registry will be lost. Likewise, because
119122
there's no Volume, I can't share it across multiple instances of the Service
120123
to handle a large load. Thus, I'm stuck with exactly one instance.
121124

122-
Why? Because, as I mentioned previously, Knative doesn't allow generic Volumes
125+
As I mentioned previously, Knative doesn't allow generic Volumes
123126
to be mounted. Why? Because not everyone supports it yet, so therefore they
124-
decided to block it for everyone. A poor decision in to me, but that's
127+
decided to block it for everyone. A poor decision to me, but that's
125128
the current state of things. If you want to watch how this progresses
126129
you can watch [this](https://github.com/knative/serving/issues/4417).
127130

128131
Finally, notice that it says `containerPort: 5000`. By default the Registry
129132
will listen on port 5000, so I need to tell Knative to route all requests to
130133
this port number. This allows me to continue to use http and https to talk to
131134
the Registry using the normal IKS/Knative networking that's automatically
132-
setup.
135+
setup for you.
133136

134137
Now let's create the `hub` Knative Sevice:
135138

@@ -170,7 +173,7 @@ I'm not going to go into
170173
Tekton too much, for that you can go look at its [docs](https://tekton.dev)
171174
or this
172175
[tutorial](https://developer.ibm.com/tutorials/knative-build-app-development-with-tekton/).
173-
For now, just know that Tekton is a build tool similar to Jeknins, that will
176+
For now, just know that Tekton is a build tool similar to Jenkins, that will
174177
perform a set of tasks that you tell it. The above yaml file defines one
175178
such Task. Tasks can be comprised of one or more "steps" - each is just
176179
the execution of a container image. In this particular case we're running
@@ -218,15 +221,15 @@ it with this command:
218221
$ kubectl get taskrun/build-image -w
219222
```
220223

221-
When you see something that looks like this (SUCCEEDED is `true`):
224+
When you see something that looks like this (SUCCEEDED is `True`):
222225

223226
```bash
224227
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME
225228
build-image True 55s 1s
226229
```
227230

228-
then it's done. If something appears to have gone wrong, look at the
229-
TaskRun to get more info with this command:
231+
then it's done and you can stop it by pressing ctrl-c. If something appears to
232+
have gone wrong, look at the TaskRun to get more info with this command:
230233

231234
```bash
232235
$ kubectl get taskrun/build-image -o yaml
@@ -263,7 +266,8 @@ spec:
263266
```
264267

265268
Nothing too exciting here other than the `image` property points to our
266-
newly created image that's stored in our local Docker Registry.
269+
newly created image that's stored in our local Docker Registry. Make sure
270+
the image name here matches the image name from the Task used to build it.
267271

268272
Let's create it:
269273

@@ -276,7 +280,7 @@ Now wait for the service to be ready. You can run this command:
276280

277281
```bash
278282
$ kubectl get ksvc/hello
279-
NAME URL LATESTCREATED LATESTREADY READY REASON
283+
NAME URL LATESTCREATED LATESTREADY READY REASON
280284
hello http://hello-default.kntest.us-south.containers.appdomain.cloud hello-mv9bv hello-mv9bv True
281285
```
282286

@@ -287,7 +291,8 @@ until the `READY` column shows `True`.
287291
Then we can test our app using te URL shown in the output above:
288292

289293
```bash
290-
curl -s http://hello-default.kntest.us-south.containers.appdomain.cloud
294+
$ curl -s http://hello-default.kntest.us-south.containers.appdomain.cloud
295+
4fh4n: Hello World!
291296
```
292297

293298
All done, so let's clean-up:
@@ -298,14 +303,14 @@ $ kubectl delete -f service.yaml -f hub.yaml
298303

299304
## Some final notes
300305

301-
As I mentioned previsously, I picked Docker's Registry for a couple of
302-
reasons. Most noteably, it allows people to use a local Docker Registry
306+
As I mentioned previously, I picked Docker's Registry for a couple of
307+
reasons. Most notably, it allows people to use a local Docker Registry
303308
without the need to complicate demos/workshops with authentication, secrets
304309
and service accounts. Clearly, those are all needed in real-world environments
305310
but when you're trying to teach someone about Knative, those things just
306311
complicate matters and are a distraction.
307312

308-
I also liked the idea of using the Docker Registry because it allow me to
313+
I also liked the idea of using the Docker Registry because it allows me to
309314
show-off using a non-traditional serverless workload. Granted, it would have
310315
been nice if the Registry supported scaling while using a shared Volume
311316
to make the point that Knative should support generic Volumes, but
@@ -321,9 +326,9 @@ rebooted.
321326

322327
One thing I didn't hook-in yet are
323328
[Registry Notifications](https://docs.docker.com/registry/notifications/).
324-
I haven't played with this yet but it looks like we should be able to get
329+
I haven't played with this yet, but it looks like we should be able to get
325330
notifications about image updates that could then cause a new Knative
326331
Service Revision to be deployed - just like the old Knative Build feature
327-
supported.
332+
supported. Perhaps I'll work on that one next...
328333

329334
If you have any comments or questions, ping me.

demo

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ set -e
44

55
source .demoscript
66
RETRYONFAIL=1
7-
D=$(bx ks cluster-get $(kubectl config current-context) | grep "Ingress Subdomain" | sed "s/^.*: *\([^ ]*\) *$/\1/" )
7+
8+
D="kntest.us-south.containers.appdomain.cloud"
9+
if [[ -z "${USESAVED}" || -n ${DOMAIN} ]]; then
10+
D=$(bx ks cluster-get $(kubectl config current-context) | grep "Ingress Subdomain" | sed "s/^.*: *\([^ ]*\) *$/\1/" )
11+
fi
12+
813
export DOMAIN=${DOMAIN:-$D}
914
export PATH=.:$PATH
1015

0 commit comments

Comments
 (0)