准备实践环境
[root@master ~]# kn service create sq-appender-01 --image ikubernetes/appender --env MESSAGE=" - Handled by SQ-01"
Creating service 'sq-appender-01' in namespace 'default':
0.084s The Route is still working to reflect the latest desired specification.
0.084s Configuration "sq-appender-01" is waiting for a Revision to become ready.
30.036s ...
30.134s Ingress has not yet been reconciled.
30.231s Waiting for load balancer to be ready
30.412s Ready to serve.
Service 'sq-appender-01' created to latest revision 'sq-appender-01-00001' is available at URL:
http://sq-appender-01.default.yang.com
[root@master ~]# kn service create sq-appender-02 --image ikubernetes/appender --env MESSAGE=" - Handled by SQ-02"
Creating service 'sq-appender-02' in namespace 'default':
0.044s The Route is still working to reflect the latest desired specification.
0.071s Configuration "sq-appender-02" is waiting for a Revision to become ready.
7.300s ...
7.364s Ingress has not yet been reconciled.
7.420s Waiting for load balancer to be ready
7.627s Ready to serve.
Service 'sq-appender-02' created to latest revision 'sq-appender-02-00001' is available at URL:
http://sq-appender-02.default.yang.com
[root@master ~]# kn service create sq-appender-03 --image ikubernetes/appender --env MESSAGE=" - Handled by SQ-03"
Creating service 'sq-appender-03' in namespace 'default':
0.043s The Route is still working to reflect the latest desired specification.
0.063s ...
0.076s Configuration "sq-appender-03" is waiting for a Revision to become ready.
7.254s ...
7.298s Ingress has not yet been reconciled.
7.359s Waiting for load balancer to be ready
7.612s Ready to serve.
Service 'sq-appender-03' created to latest revision 'sq-appender-03-00001' is available at URL:
http://sq-appender-03.default.yang.com
[root@master ~]# kn service list
NAME URL LATEST AGE CONDITIONS READY REASON
event-display-01 http://event-display-01.default.yang.com event-display-01-00001 34s 3 OK / 3 True
sq-appender-01 http://sq-appender-01.default.yang.com sq-appender-01-00001 17m 3 OK / 3 True
sq-appender-02 http://sq-appender-02.default.yang.com sq-appender-02-00001 16m 3 OK / 3 True
sq-appender-03 http://sq-appender-03.default.yang.com sq-appender-03-00001 16m 3 OK / 3 True
[root@master sequence-demo]# kubectl apply -f 04-sequence-demo.yaml
sequence.flows.knative.dev/sq-demo created
[root@master sequence-demo]# cat 04-sequence-demo.yaml
apiVersion: flows.knative.dev/v1
kind: Sequence
metadata:
name: sq-demo
namespace: default
spec:
channelTemplate:
apiVersion: messaging.knative.dev/v1
kind: InMemoryChannel
steps:
- ref:
apiVersion: serving.knative.dev/v1
kind: Service
name: sq-appender-01
- ref:
apiVersion: serving.knative.dev/v1
kind: Service
name: sq-appender-02
- ref:
apiVersion: serving.knative.dev/v1
kind: Service
name: sq-appender-03
reply:
ref:
kind: Service
apiVersion: serving.knative.dev/v1
name: event-display-01
[root@master sequence-demo]# kubectl get sequence
NAME URL AGE READY REASON
sq-demo http://sq-demo-kn-sequence-0-kn-channel.default.svc.cluster.local 68s True
创建一个pod进行curl请求测试
kubectl run client-$RANDOM --image=ikubernetes/admin-box:v1.2 --restart=Never -it --command -- /bin/sh
curl -v "http://sq-demo-kn-sequence-0-kn-channel.default.svc.cluster.local" -X POST -H "Content-Type: application/cloudevents+json" \
-d '{"id": "say-bye", "specversion": "1.0", "type": "com.yang.saybye", "source": "sendoff", "data": {"message":"Hello Knative Sequence Flow"}}'
查看消息
[root@master ~]# kubectl logs -f event-display-01-00001-deployment-68d48cbdf8-lv9m4
标签:02,03,01,Sequence,default,sq,示例,Flow,appender
From: https://www.cnblogs.com/zyyang1993/p/16820518.html