27. Create a new function in Go
$ faas-cli new --lang go generate-pdf
.
|—- generate-pdf/
|—- generate-pdf/handler.go
└—- generate-pdf.yml
package function
func Handle(req []byte) string {
return "Enjoy your PDF”
}
version: 1.0
provider:
name: openfaas
gateway: http://127.0.0.1:8080
functions:
generate-pdf:
lang: go
handler: ./generate-pdf
image: generate-pdf:latest
$ faas-cli build/push/deploy
# Or:
$ faas-cli up
28. Function CRD - from stack.yml
$ faas-cli generate -f generate-pdf apiVersion: openfaas.com/v1alpha2
kind: Function
metadata:
name: generate-pdf
spec:
name: generate-pdf
image: generate-pdf:latest
29. Function CRD - from store
$ faas-cli generate --from-store
colorise
apiVersion: openfaas.com/v1alpha2
kind: Function
metadata:
name: colorise
spec:
name: colorise
image: alexellis2/openfaas-colorization:0.4.1
environment:
read_timeout: 60s
url_mode: "true"
write_debug: "false"
write_timeout: 60s
labels:
com.openfaas.ui.ext: jpg
30. Function CRD
apiVersion: openfaas.com/v1alpha2
kind: Function
metadata:
name: generate-pdf
spec:
name: generate-pdf
image: alexellis2/generate-pdf:latest
environment:
write_timeout: "10s"
# Create a new Function
$ faas-cli new --lang go
generate-pdf
$ faas-cli generate
-f generate-pdf.yml
# Or from Function Store
$ faas-cli generate
--from-store colorise
34. GitOps conclusion ⚖
• FluxCD
• Pull-based (polling)
• Repo for config/code
• Flux per repo
• Limited GitHub/
GitLab integration (no
statuses)
• No ARM support
• Alternative
• Push-based (webhooks)
• Harder to recover
• 1 repo for config/code
• Tools can be shared
• Statuses and checks
• ARM support
35. In summary 💻
• Serverless 2.0 (w/Kubernetes)
• anything, anywhere, any scale
• Template Store
• reduce duplication, maintenance
• OpenFaaS Cloud (push)
• Serverless PaaS with GitOps
• FluxCD & HelmOperator (pull)
• CD for OpenFaaS & Functions with CRD
36. Connect & Learn 👋
• Docs & workshop
• Blog posts & tutorials
• Join the community on
Slack
https://openfaas.com/