Serverless Canary Deployment using Knative
Serverless refers to a cloud computing model whereby application developers don’t have to provision servers or manage scaling for their app. Instead, those routine tasks are abstracted away by the cloud provider, allowing developers to push code to production much faster than in traditional models.
In short, serverless lets developers focus on their code, and mostly ignore the infrastructure. Hence “serverless” because the server specifications don’t affect developers. Of course, the servers do still exist — it’s just that they are managed by the cloud provider.
This is step by step instruction for demonstrating Canary Deployment with knative. Application in this demo is using my custom apps on Quay.io. Application will consume message from Kafka Topic and stream to REST API.
Demo scenario:
Prerequisite
- Openshift Container Platform 4.4
- Install OpenShift Serveless or knative using operator
- Install knative (kn) CLI
- Preinstalled Kafka on Openshift using Strimzi.io
Step 0: Login to Openshift CLI and choose designated namespace
$ oc login$ oc new-project erfin-serverless-demo
Step 1: Deploy knative apps v3
$ kn service create quarkus-kafka-consumer \
--image quay.io/efeluzy/quarkus-kafka-consumer:v3 \
--revision-name quarkus-kafka-consumer-v3 \
Step 2: Revise knative apps v4 and distribute 50% traffic
$ kn service update quarkus-kafka-consumer \
--image quay.io/efeluzy/quarkus-kafka-consumer:latest \
--revision-name quarkus-kafka-consumer-v4
--traffic quarkus-kafka-consumer-v4=50 \
--traffic quarkus-kafka-consumer-v3=50 \
or using Openshift web console:
Note:
- quarkus-kafka-consumer-v3 is previous service revision name.
- new service v4 will serve 50%, previous service v3 will serve 50%
Result on OpenShift Console
Step 4: Check service status
$ kn service describe quarkus-kafka-consumer
Result
Name: quarkus-kafka-consumer
Namespace: erfin-demo
Age: 21m
URL: http://quarkus-kafka-consumer-erfin-demo.apps.erfin-cluster.sandbox1459.opentlc.comRevisions:
50% quarkus-kafka-consumer-v4 (current @latest) #v4 [2] (19m)
Image: quay.io/efeluzy/quarkus-kafka-consumer:latest (pinned to 09d28f)
50% quarkus-kafka-consumer-v3 #v3 [1] (21m)
Image: quay.io/efeluzy/quarkus-kafka-consumer:v3 (pinned to 09d28f)Conditions:
OK TYPE AGE REASON
++ Ready 6s
++ ConfigurationsReady 6s
++ RoutesReady 1m
Step 5: Invoke the Service
invoke stream API on your browser or using curl
$ curl http://quarkus-kafka-consumer-erfin-serverless-demo.apps.erfin-cluster.sandbox1459.opentlc.com/stream
Or result on browser page:
Notes:
Deploy demo apps for kafka message producer from my previous tutorial. link will be updated.