Upgrade to Pro — share decks privately, control downloads, hide ads and more …

riffing_on_Knative.pdf

Avatar for Eric Bottard Eric Bottard
September 27, 2018

 riffing_on_Knative.pdf

Avatar for Eric Bottard

Eric Bottard

September 27, 2018
Tweet

More Decks by Eric Bottard

Other Decks in Technology

Transcript

  1. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Safe Harbor Statement The following is intended to outline the general direction of Pivotal's offerings. It is intended for information purposes only and may not be incorporated into any contract. Any information regarding pre-release of Pivotal offerings, future updates or other planned modifications is subject to ongoing evaluation by Pivotal and is subject to change. This information is provided without warranty or any kind, express or implied, and is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions regarding Pivotal's offerings. These purchasing decisions should only be based on features currently available. The development, release, and timing of any features or functionality described for Pivotal's offerings in this presentation remain at the sole discretion of Pivotal. Pivotal has no obligation to update forward looking information in this presentation. 2
  2. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Disclaimer everything is alpha Have fun(ctions), but not in production
  3. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Demo driven talk • Installing riff into a Kubernetes cluster • Building and deploying a riff Function from source • Invoking a riff Function • command driven functions • event driven functions Overview 4
  4. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Tools we’ll use • riff - riff is for functions https://github.com/projectriff/riff/releases • kubectl - Kubernetes CLI https://kubernetes.io/docs/tasks/tools/install-kubectl/ • gcloud - Google Cloud SDK https://cloud.google.com/sdk/gcloud/ • kail - kubernetes tail https://github.com/boz/kail • watch - execute a program periodically, showing output fullscreen https://gitlab.com/procps-ng/procps 5 
  5. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ What is riff
  6. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Knative Kubernetes-based platform to build, deploy, and manage modern serverless workloads Three core components: • Build - Source-to-container build orchestration • Serving - Request-driven compute that can scale to zero • Eventing - Management and delivery of events 100% open source. Created by Google with contributions from Pivotal and others 7 
  7. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ riff on Knative Community-driven ecosystem of Sources, Channels, Functions, Invokers, BuildTemplates, etc. Kubernetes BuildTemplates Channels CLI Invokers CLI Invokers Build Topics
  8. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ riff is for functions • event driven Function as a Service • opinionated experience built atop Knative, Kubernetes and Istio • functions practice Inversion of Control • no servers, ports or HTTP, just your logic • pick your language runtime: • Java/Spring • JavaScript/Node • executable commands • more from the community 9 
  9. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Installing riff
  10. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Creating a Kubernetes cluster 11 # https://projectriff.io/docs/getting-started-on-gke/ # create cluster gcloud container clusters create $CLUSTER_NAME \ --cluster-version=latest --machine-type=n1-standard-4 \ --enable-autoscaling --min-nodes=1 --max-nodes=3 --num-nodes=3 \ --enable-autorepair \ --scopes=service-control,service-management,compute-rw,storage-ro,cloud-platform,logging- write,monitoring-write,pubsub,datastore # grant yourself cluster-admin kubectl create clusterrolebinding cluster-admin-binding \ --clusterrole=cluster-admin \ --user=$(gcloud config get-value core/account)
  11. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Install riff ...and dependencies including: • Knative Serving • Istio • Knative Build • Knative Eventing • Stub Bus • Kafka and Cloud Pub/Sub are also available, but not installed • credentials to push builds to an image registry • riff BuildTemplate - convert source to riff Function container images 1 2 
  12. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Install riff 13 # https://projectriff.io/docs/getting-started-on-gke/ # once per cluster riff system install # once per namespace riff namespace init $NAMESPACE --gcr $PATH_TO_GCR_CREDENTIALS
  13. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Using riff
  14. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Create a riff Function 15 # square.js module.exports = x => { const xx = x ** 2; console.log(`the square of ${x} is ${xx}`); return xx; }
  15. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Demo
  16. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Invoke a riff Function with events 17 correlator numbers squares square riff invoke /numbers
  17. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Deploy a riff Function 18 riff function create node square \ --git-repo https://github.com/projectriff-samples/node-square \ --artifact square.js \ --image gcr.io/$GCP_PROJECT/square \ --verbose kail -d square-00001-deployment -c user-container
  18. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Invoke a riff Function 19 riff service invoke square --json -- \ -w '\n' \ -d 7
  19. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Invoke a riff Function with events 2 0 riff channel create numbers --cluster-bus stub riff channel create squares --cluster-bus stub riff subscription create --channel numbers \ --subscriber square --reply-to squares riff service create correlator \ --image projectriff/correlator:s1p2018
  20. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Invoke a riff Function with events 21 riff service invoke correlator /numbers --json -- \ -w '\n' \ -v \ -d 7
  21. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Let’s create another function 2 2 riff function create command greet \ --git-repo https://github.com/projectriff-samples/command-hello \ --image gcr.io/$GCP_PROJECT/riff-sample-greet \ --artifact greet.sh riff service invoke greet --text -- \ -w '\n' \ -d "Spring One"
  22. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Demo
  23. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Invoke the riff Function with events 2 4 correlator numbers replies squares square greet riff invoke /numbers
  24. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Let’s chain our functions 2 5 riff channel create replies --cluster-bus stub riff subscription create --channel squares \ --subscriber greet --reply-to replies riff subscription create --channel replies \ --subscriber correlator
  25. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Invoke a riff Function with events 2 6 riff service invoke correlator /numbers --json -- \ -H "Knative-Blocking-Request: true" \ -w '\n' \ -d 7
  26. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Invoke the riff Function with events 2 7
  27. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Invoke the riff Function with events 2 8
  28. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Invoke the riff Function with events 2 9
  29. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Invoke the riff Function with events 3 0
  30. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Invoke the riff Function with events 31
  31. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Invoke the riff Function with events 3 2
  32. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Other patterns are possible 3 3 correlator numbers replies squares square greet riff invoke /numbers dead-beef-00 GET /dead-beef-00
  33. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ There's more we didn't have time to show... 3 4 • YAML • Java/Spring (yes, we know this is SpringOne) • alternate Eventing Buses • Google Cloud PubSub • Kafka • Eventing Sources • Cloud Events • alternate BuildTemplates • Buildah • jib • kaniko • deploying Knative from source • Istio • public DNS • Autoscaler tuning • monitoring • Grafana • Prometheus • Zipkin You can learn more at https://github.com/knative/docs