66## Quick search
77
881 . [ Basic Information] ( #templates-for-knative-functions )
9- 2 . [ Prerequisites] ( #prerequisites ) TODO: link to Luke's separate readme
9+ 2 . [ Prerequisites] ( #prerequisites )
10103 . [ How To Use] ( #how-to-use )
1111 1 . [ Build a Function] ( #build-a-function )
1212 2 . [ Deploy a Function] ( #deploy-a-function )
13134 . [ Function Templates Structure] ( #templates-structure )
14146 . [ Contact] ( #contact )
15- 7 . [ F&Q] ( F&Q )
15+ 7 . [ F&Q] ( #fq )
1616
1717## Templates for Knative Functions
1818This repository showcases some use-cases for your Knative Functions!
@@ -23,7 +23,7 @@ Templates in this repository include:
2323- The easiest Hello World (` hello ` )
2424- Simple splash screen with ** referenced .css file** and ** .funcignore** (` splash ` )
2525- Web blog with ** serverside rendering** and ** import statements** (` blog ` )
26- - A "Contact Us" function with a ** secret password** (` contact-us ` )
26+ - upcoming: A "Contact Us" function with a ** secret password** (` contact-us ` )
2727
2828See [ templates structure] ( #templates-structure ) to learn about repository and
2929see how to [ deploy] ( #deploy-a-function ) your function.
@@ -32,7 +32,7 @@ see how to [deploy](#deploy-a-function) your function.
3232In order to use Functions, you will need a few things:
3333
3434### Download the ` func ` binary
35- You can clone our [ GitHub repository] ( https://github.com/knative/func/ ) and
35+ You can clone our [ GitHub repository] ( https://github.com/knative/func/ ) and
3636build your binary from the source or download it straight from the
3737[ release pages] ( https://github.com/knative/func/releases ) under * Assets* .
3838
@@ -55,14 +55,14 @@ curl -L -o /usr/local/bin/func https://github.com/knative/func/releases/latest/d
5555
5656#### PowerShell
5757``` powershell
58- Invoke-WebReqest -Uri "https://github.com/knative/func/releases/latest/download/func_windows_amd64.exe" -OutFile <"C:\path\to\your\destination\func.exe">
58+ Invoke-WebRequest -Uri "https://github.com/knative/func/releases/latest/download/func_windows_amd64.exe" -OutFile <"C:\path\to\your\destination\func.exe">
5959```
6060alternatively if ` curl ` is pre-installed
6161``` powershell
62- curl -L -o <C:\path\to\your\destination\func.exe> "https://github.com/knative/func/releases/latest/download/func_windows_amd64.exe"
62+ curl -L -o <C:\path\to\your\destination\func.exe> "https://github.com/knative/func/releases/latest/download/func_windows_amd64.exe"
6363```
64- * NOTE: You need to change the part in <> to your desired destination*
65- * (don't include the "<>" symbols)*
64+ > [ ! NOTE] You need to change the part in <> to your desired destination
65+ > (don't include the "<>" symbols)
6666### Mac (darwin OS)
6767
6868#### amd64
@@ -77,16 +77,16 @@ curl -L -o /usr/local/bin/func "https://github.com/knative/func/releases/latest/
7777curl -L -o /usr/local/bin/func " https://github.com/knative/func/releases/latest/download/func_darwin_arm64"
7878```
7979
80- * NOTE: After downloading on MacOS and Linux, you might need to make the file
81- executable*
80+ > [ ! NOTE] After downloading on MacOS and Linux, you might need to make the file
81+ > executable
8282
8383``` sh
8484chmod +x /usr/local/bin/func
8585```
8686
8787### Get a containerization technology
8888These are some open-source examples of what you can use with Functions. You will
89- need some tools to atleast build and push your images. This list is not exhaustive.
89+ need some tools to at least build and push your images. This list is not exhaustive.
9090
9191[ Buildah] ( https://github.com/containers/buildah/blob/main/install.md ) - CLI tool
9292to build your images.
@@ -95,7 +95,7 @@ to build your images.
9595to Buildah. Helps you manage and modify your images. Uses Buildah's golang API.
9696Can be installed independently. (* You can get this as a standalone tool* )
9797
98- [ Docker Engine] ( https://docs.docker.com/engine/install/ ) - Helps you build and
98+ [ Docker Engine] ( https://docs.docker.com/engine/install/ ) - Helps you build and
9999containerize your applications. (* You can get this as a standalone tool* )
100100
101101#### Download local cluster runner (kind)
@@ -108,49 +108,75 @@ In order to interact with the objects in k8s, its recommended to get
108108
109109## How To Use
110110You use these templates by creating your function via ` --repository ` flag which
111- means "create my function with this template ".
111+ means "create my function from this repository ".
112112
113113Create your functions directory and ` cd ` into it
114114
115115```
116116mkdir -p ~/testing/myfunc && cd ~/testing/myfunc
117117```
118118
119- - Create a function in ** golang** with ** hello template** within the new (current and empty) directory
119+ Create a function in ** golang** with ** hello template** within the new (current and empty) directory
120120
121121```
122122func create --repository=https://github.com/gauron99/func-templates --language go --template=hello
123123```
124124
125- - TODO add more examples / explanations
125+ Alternatively create the directory with it:
126+
127+ ```
128+ func create myfunc --repository=https://github.com/gauron99/func-templates --language go --template=hello
129+ ```
130+
131+ where ` --language ` conveniently matches the runtime and ` --template ` matches
132+ it's subdirectory containing the Function template, hence:
133+
134+ ```
135+ root
136+ ├── go
137+ | ├── hello
138+ | | ├── README.md
139+ | | ├── function/
140+ | | ├── tests/
141+ | | └── go.mod
142+ | ├── blog
143+ | | ├── ...
144+ | | ...
145+ ├── python
146+ | ├─ ...
147+ | ...
148+ ```
149+
150+ see detailed info in [ Templates structure] ( #templates-structure ) section.
151+
126152### Build a Function
127153
128154#### Using the Host Builder
129- *** NOTE** : Currently, this is under heavy construction and will become the default in the
130- future.*
155+ > [ !NOTE]
156+ > Some languages already have the host builder enabled but not all.
157+ > If available, we recommend using the host builder.
131158
132- In order to use the Host Builder in the mean time, you will need to enable it via a ENV variable
133- and specify some flags in ` func ` via CLI.
159+ In order to use the Host Builder, simply add ` --builder=host ` to build your
160+ Function. If you want to ` func run ` your Function locally first, it's also
161+ recommended to use ` --container=false ` .
134162
135- Alternativelly, run this in your terminal, or put in your config file (* bashrc etc.* )
136163``` bash
137- export FUNC_ENABLE_HOST_BUILDER=1
164+ # deploy to a running cluster (this will also build if needed)
165+ func deploy --builder=host
138166```
139167
140- Then simply add ` --builder=host ` to build your Function with the Host builder.
141- If you want to ` func run ` your Function locally first, make sure to use ` --container=false `
142-
143168#### Using Alternative Builders
144169Alternative built-in builders are ` pack ` and ` s2i ` (for supported languages).
145170The way to use them is simple. Just specify which one you want using the
146171` --builder ` flag (eg. ` --builder=pack ` )
147- ### Deploy a Function
148- * NOTE: In order to deploy anything to a cluster, you will need to have one set up
149- and running along with atleast [ Knative-Serving] ( https://knative.dev/docs/serving/ ) installed.*
150172
173+ ### Deploy a Function
174+ > [ !NOTE]
175+ > In order to deploy anything to a cluster, you will need to have one set up and
176+ > running along with at least [ Knative-Serving] ( https://knative.dev/docs/serving/ ) installed.
151177
152178You can skip the building step entirely and deploy straight after creating your
153- function. (building is included in the ` deploy ` ).
179+ function. (building is included in the ` func deploy` ).
154180
155181#### Local
156182You can deploy your local code (from your machine) to a cluster using a standard
@@ -169,7 +195,7 @@ func deploy --image=registry.com/username/myimage@sha256:xxx
169195```
170196
171197* NOTE: If you know what you want, at any point you can add a ` --build ` flag to
172- your command which will explicitely tell ` func ` if you want to build (or not)
198+ your command which will explicitly tell ` func ` if you want to build (or not)
173199your image. (truthy values will work).*
174200
175201#### Remote
@@ -181,9 +207,9 @@ your cluster).
181207You can simply add ` --remote ` to your ` func deploy ` command.
182208
183209## Templates structure
184- Directory structure is as follows: ** root/[ language] /[ template] ** where * root* is
210+ Directory structure is as follows: ** root/[ language] /[ template] ** where * root* is
185211 the github repository itself, * language* is the programming language used and
186- * template* is the name of the template. Function is created using templates via
212+ * template* is the name of the template. Function is created from Git repo via
187213 ` --repository ` flag when using ` func create ` command. More in [ How-To-Use] ( #how-to-use ) section.
188214
189215```
@@ -192,17 +218,18 @@ github.com/gauron99/func-templates <--[root]
192218│ ├── hello <-----------------------[template]
193219│ │ └── <function source files>
194220│ └── splash-screen
195- │ └── ...
221+ │ └── ...
196222├── node
197223│ ├── hello
198224│ └── splash-screen
199225├── ...
200226```
227+
201228# Contact
202229You can contact us on CNCF Slack [ knative-functions] ( https://cloud-native.slack.com/archives/C04LKEZUXEE ) channel
203230
204- ### F&Q
205- 1 .
231+ ## F&Q
232+ 1 . ** Function signature error **
206233```
207234Error: function may not implement both the static and instanced method signatures simultaneously
208235```
0 commit comments