Weitere ähnliche Inhalte
Ähnlich wie riffing on Knative - Scott Andrews (20)
Mehr von VMware Tanzu (20)
Kürzlich hochgeladen (20)
riffing on Knative - Scott Andrews
- 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/
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
- 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/
Disclaimer
everything is alpha
Have fun(ctions), but not in production
- 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/
Demo driven talk
• Kubernetes primer
• Serverless Kubernetes with Knative
• Building and deploying a riff Function from source
• Java
• Node.js
• commands
• Invoking a riff Function
• command driven functions
• event driven functions
Overview
4
- 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/
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/
• kail - kubernetes tail
https://github.com/boz/kail
• watch - execute a program periodically, showing output fullscreen
https://gitlab.com/procps-ng/procps
5

- 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/
Demo: Using k8s
- 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/
What is riff
- 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/
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
8

- 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/ 9
BuildTemplate
Source
Channel
Build
Knative Custom Resource Definitions
Subscription
refers to
refers to
creates and
registers
instance of
Eventing
Serving
Build
- 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/
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 messaging protocols, just your logic
• pick your language runtime:
• Java/Spring
• JavaScript/Node
• executable commands
• more from the community
1
0

- 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/
riff on Knative
Community-driven
ecosystem of
Sources,
Channels,
Functions,
Invokers,
BuildTemplates,
etc.
Kubernetes
BuildTemplates
Channels
CLI
Invokers
CLI
Invokers
Build
Topics
- 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/
Installing riff (and Knative)
- 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/
Creating a Kubernetes cluster
13
# https://projectriff.io/docs/getting-started/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)
- 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/
Install riff
14
# https://projectriff.io/docs/getting-started/gke/
# once per cluster
riff system install
# once per namespace
riff namespace init $NAMESPACE --gcr $PATH_TO_GCR_CREDENTIALS
- 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/
Install riff
...and dependencies including:
• Istio
• Knative Build
• Knative Serving
• Knative Eventing
• In Memory Channel Provisioner
• Kafka, Cloud Pub/Sub, NATSS are also available, but not installed
• riff BuildTemplate - convert source to riff Function container images
• credentials to push builds to an image registry
1
5

- 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/
Demo: Exploring Knative
- 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/ 17
BuildTemplate
Source
Channel
Build
Knative Custom Resource Definitions
Subscription
refers to
refers to
creates and
registers
instance of
Eventing
Serving
Build
- 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/
riff Functions
- 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/
a riff Java Function
19
// https://github.com/projectriff-samples/fats-uppercase-java
package functions;
import java.util.function.Function;
public class Upper implements Function<String, String> {
public String apply(String s) {
return s.toUpperCase();
}
}
- 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/
a riff JavaScript Function
2
0
// https://github.com/projectriff-samples/fats-uppercase-node
module.exports = s => s.toUpperCase();
- 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/
a riff Command Function
21
# https://github.com/projectriff-samples/fats-uppercase-command
#!/bin/sh
tr '[a-z]' '[A-Z]'
- 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: riff Functions
- 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/
Deploy a riff Function
2
3
riff function create square
--git-repo https://github.com/projectriff-samples/node-square
--artifact square.js
--verbose
kail -l riff.projectriff.io/function=square -c user-container
- 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/
Invoke a riff Function
2
4
riff service invoke square --json --
-w 'n'
-d 7
- 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/
Let’s create another function
2
5
riff function create greet
--git-repo https://github.com/projectriff-samples/command-hello
--artifact greet.sh
riff service invoke greet --text --
-w 'n'
-d "Washington"
- 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/
Demo: Local Functions
- 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/
Iterating quickly (in development)
2
7
riff function local run
--local-path ./uppercase
curl localhost:8080
-H 'Content-Type: text/plain'
-w 'n'
-d 'shhh!'
- 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/
Run on cluster from local source
2
8
riff function create uppercase
--local-path ./uppercase
--verbose
riff service invoke uppercase --text --
-w 'n'
-d 'shhh!'
- 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/
Demo: Event Driven Functions
- 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 a riff Function with events
3
0
riff channel create numbers
riff channel create squares
riff subscription create
--channel numbers
--subscriber square
--reply squares
riff service create correlator
--image scothis/correlator:s1tour
- 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 a riff Function with events
31
correlator
numbers
squaressquare
riff invoke /numbers
- 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/
Demo: Function Chaining
- 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/
Invoke a riff Function with events
3
3
riff service invoke correlator /s1tour/numbers --json --
-w 'n'
-v
-d 7
- 34. 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
4
correlator
numbers
replies
squaressquaregreet
riff invoke /numbers
- 35. 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
3
5
riff channel create replies
riff subscription create
--channel squares
--subscriber greet
--reply replies
riff subscription create
--channel replies
--subscriber correlator
- 36. 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
3
6
riff service invoke correlator /s1tour/numbers --json --
-H "Knative-Blocking-Request: true"
-w 'n'
-d 7
- 37. 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
7
- 38. 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
8
- 39. 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
9
- 40. 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
4
0
- 41. 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
41
- 42. 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
4
2
- 43. 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
4
3
correlator
numbers
replies
squaressquaregreet
riff invoke /numbers
dead-beef-00
GET /dead-beef-00
- 44. 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...
4
4
• alternate Eventing Channels
• Kafka
• NATSS
• Google Cloud PubSub
• 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://www.knative.dev
- 45. 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/
Free eBook
http://bit.ly/getting-started-with-knative
Hot off the press