$ kn service create hello --image gcr.io/knative-samples/helloworld-go --env TARGET=Knative
Creating service'hello'in namespace 'knative-demo':
0.296s The Route is still working to reflect the latest desired specification.
0.393s Configuration "hello" is waiting for a Revision to become ready.
33.138s ...
33.369s Ingress has not yet been reconciled.
33.466s Configuration "hello" is waiting for a Revision to become ready.
33.543s Ingress has not yet been reconciled.
74.629s Ready to serve.
Service 'hello' created with latest revision 'hello-nvhqs-1' and URL:
http://hello.knative-demo.apps.cluster-shanghai-3d3e.shanghai-3d3e.example.opentlc.com
查看Knative的Service對象列表。
$ kn service list
NAME URL LATEST AGE CONDITIONS READY REASON
hello http://hello.knative-demo.apps.cluster-shanghai-3d3e.shanghai-3d3e.example.opentlc.com hello-nvhqs-1 2m4s 3 OK / 3 True
$ oc get pod
NAME READY STATUS RESTARTS AGE
pod/hello-rfgt4-1-deployment-a0cd0125-cfvny 2/2 Running 0 22s
更新名爲hello的service的環境變量內容。
$ kn service update hello --env TARGET=Kn
Updating Service 'hello'in namespace 'knative-demo':
10.760s Traffic is not yet migrated to the latest revision.
10.871s Ingress has not yet been reconciled.
12.231s Ready to serve.
Service 'hello' updated with latest revision 'hello-cfvny-2' and URL:
http://hello.knative-demo.apps.cluster-shanghai-3d3e.shanghai-3d3e.example.opentlc.com
$ kn revision list
NAME SERVICE GENERATION AGE CONDITIONS READY REASON
hello-cfvny-2 hello 2 45m 3 OK / 4 True
hello-nvhqs-1 hello 1 5h46m 3 OK / 4 True
$ kn service update hello --traffic @latest=50 --traffic hello-nvhqs-1=50
Updating Service 'hello'in namespace 'knative-demo':
0.066s The Route is still working to reflect the latest desired specification.
0.090s Ingress has not yet been reconciled.
1.450s Ready to serve.
Service 'hello' updated with latest revision 'hello-cfvny-2'(unchanged) and URL:
http://hello.knative-demo.apps.cluster-shanghai-3d3e.shanghai-3d3e.example.opentlc.com
查看Knative的service對象,確認配置修改爲2個revision各自接收50%的請求。
$ kn service describe hello
Name: hello
Namespace: knative-demo
Age: 5h
URL: http://hello.knative-demo.apps.cluster-shanghai-3d3e.shanghai-3d3e.example.opentlc.com
Revisions:
50% @latest (hello-cfvny-2)[2](41m)
Image: gcr.io/knative-samples/helloworld-go (pinned to 5ea96b)
50% hello-nvhqs-1 [1](5h)
Image: gcr.io/knative-samples/helloworld-go (pinned to 5ea96b)
Conditions:
OK TYPE AGE REASON
++ Ready 6m
++ ConfigurationsReady 41m
++ RoutesReady 6m
$ kn service update hello --tag hello-cfvny-2=latest,hello-nvhqs-1=stable
Updating Service 'hello'in namespace 'knative-demo':
0.033s The Route is still working to reflect the latest desired specification.
0.174s Ingress has not yet been reconciled.
1.608s Ready to serve.
Service 'hello' updated with latest revision 'hello-cfvny-2'(unchanged) and URL:
http://hello.knative-demo.apps.cluster-shanghai-3d3e.shanghai-3d3e.example.opentlc.com
$ kn service update hello --tag hello-cfvny-2=v2,hello-nvhqs-1=v1
Updating Service 'hello'in namespace 'knative-demo':
0.158s The Route is still working to reflect the latest desired specification.
0.326s Ingress has not yet been reconciled.
1.500s Ready to serve.
Service 'hello' updated with latest revision 'hello-cfvny-2'(unchanged) and URL:
http://hello.knative-demo.apps.cluster-shanghai-3d3e.shanghai-3d3e.example.opentlc.com
$ kn service update hello --traffic v1=10,v2=90
Updating Service 'hello'in namespace 'knative-demo':
0.091s The Route is still working to reflect the latest desired specification.
0.195s Ingress has not yet been reconciled.
2.020s Ready to serve.
Service 'hello' updated with latest revision 'hello-cfvny-2'(unchanged) and URL:
http://hello.knative-demo.apps.cluster-shanghai-3d3e.shanghai-3d3e.example.opentlc.com