Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
comp90024
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Atefeh
comp90024
Commits
63f3c3e8
Commit
63f3c3e8
authored
3 years ago
by
Luca Morandini
Browse files
Options
Downloads
Patches
Plain Diff
- Refreshed fn example
parent
b2c829bd
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+3
-1
3 additions, 1 deletion
.gitignore
fn/README.md
+34
-18
34 additions, 18 deletions
fn/README.md
spark/README.md
+6
-0
6 additions, 0 deletions
spark/README.md
with
43 additions
and
19 deletions
.gitignore
+
3
−
1
View file @
63f3c3e8
...
...
@@ -58,5 +58,7 @@ typings/
.env
/couchdb/twitter/spacetime/
/openfaas/faas/
/couchdb/macos/data
/fn/wcmp
/fn/pywcmp
This diff is collapsed.
Click to expand it.
fn/README.md
+
34
−
18
View file @
63f3c3e8
...
...
@@ -6,8 +6,11 @@ These are the steps to follow in order to deploy an Fn instance running on a sin
## Install and start Fn
```
shell script
curl -LSs https://raw.githubusercontent.com/fnproject/cli/master/install | sh
fn start --log-level DEBUG
(
cd fn
curl -LSs https://raw.githubusercontent.com/fnproject/cli/master/install | sh
fn start --log-level DEBUG
)
```
(For instructions on operating systems othe than Linux, see
[
Quickstart
](
https://github.com/fnproject/fn#quickstart
)
.
...
...
@@ -25,13 +28,16 @@ docker ps
Sample function creaation:
```
shell script
fn init --runtime node --trigger http wcmp
(
cd fn
fn init --runtime node --trigger http wcmp
)
```
A new directory name
`wcmp`
should have been added; a few editings has to be done to its contents:
Suppose we aant to fine-tune the Docker image that Fn builds by default, we then have to add a Dockerfile and change the function runtime.
Create a
`Dockerfile`
file with the contents:
Create a
`Dockerfile`
file
under the
`fn/wcmp`
directory,
with the contents:
```
dockerfile
FROM
fnproject/node:dev
as
build-stage
WORKDIR
/function
...
...
@@ -47,7 +53,7 @@ ENTRYPOINT ["node", "func.js"]
In the
`func.yaml`
file, change
`runtime: node`
to
`runtime: docker`
.
To have our functions counts the in
o
ut words, we have to replace
`func.js`
with:
To have our functions counts the in
p
ut words, we have to replace
`func.js`
with:
```
javascript
const
fdk
=
require
(
'
@fnproject/fdk
'
);
...
...
@@ -65,22 +71,25 @@ fdk.handle (function (input) {
})
```
Create an Fn
`app`
(these commands have to be run from the directory containing the
`wmcp`
func
i
ton directory):
Create an Fn
`app`
(these commands have to be run from the directory containing the
`wmcp`
funct
i
on directory):
```
shell script
fn create app wcapp
(
cd fn/wcmp
fn create app wcapp
)
```
Function build and deployment on the l
c
oal Fn server:
Function build and deployment on the lo
c
al Fn server:
```
shell script
fn deploy --app wcapp --local wcmp
fn list functions wcapp
(
cd fn
fn deploy --app wcapp --verbose --local wcmp
fn list functions wcapp
)
```
Function invokation:
```
shell scriptimport urllib2 # the lib that handles the url stuff
data = urllib2.urlopen(target_url) # it's a file like object and works just like a file
```
shell script
curl -XPOST 'http://localhost:8080/t/wcapp/wcmp' --data 'lorem ipsum'
```
...
...
@@ -89,7 +98,8 @@ curl -XPOST 'http://localhost:8080/t/wcapp/wcmp' --data 'lorem ipsum'
Start the Fn webadmin user interface:
```
shell
docker run
--rm
-it
--link
fnserver:api
-p
4000:4000
-e
FN_API_URL
=
http://api:8080
-e
FN_LISTENER
=
unix:/iofs/lsnr.sock fnproject/ui
docker run
--rm
-it
--link
fnserver:api
-p
4000:4000
-e
FN_API_URL
=
http://api:8080
\
-e
FN_LISTENER
=
unix:/iofs/lsnr.sock fnproject/ui
```
Point your browser to
`http://0.0.0.0:4000`
.
...
...
@@ -125,7 +135,10 @@ On the UI window, the number of replicas can be observed to raise, and then fall
Sample function creaation:
```
shell script
fn init --runtime python --trigger http pywcmp
(
cd fn
fn init --runtime python --trigger http pywcmp
)
```
A new directory name
`pywcmp`
should have been added; a few editings has to be done to its contensts:
...
...
@@ -156,8 +169,11 @@ def handler(ctx, data: io.BytesIO = None):
Function build and deployment on the lcoal Fn server (these commands have to be run from the directory containing the
`wmcp`
funciton directory):
```
shell script
fn deploy --app wcapp --local pywcmp
fn list functions wcapp
(
cd fn
fn deploy --app wcapp --local pywcmp
fn list functions wcapp
)
```
Function invokation:
...
...
This diff is collapsed.
Click to expand it.
spark/README.md
+
6
−
0
View file @
63f3c3e8
...
...
@@ -57,6 +57,12 @@ To have a look at the cluster workers, point your browser to: `http://173.17.2.2
(
cd spark
docker-compose stop
)
```
```shell script
(
cd spark
docker-compose start
)
```
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment