Skip to content

rteqs/fission-tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fission Tutorial

Table of Contents

  1. Installation & Setup
  2. Usage

Installation & Setup

Requirements:

  1. Kubernetes version > 1.19
  2. Kubectl
  3. Helm v3

Disclaimer: Only for local desktops. A separate process for cloud environments.

Set namespace as fission & install program.

export FISSION_NAMESPACE="fission";
kubectl create namespace $FISSION_NAMESPACE;
kubectl create -k "github.com/fission/fission/crds/v1?ref=v1.17.0";
helm repo add fission-charts <https://fission.github.io/fission-charts/>;
helm repo update;
helm install --version v1.17.0 --namespace $FISSION_NAMESPACE fission \
  --set serviceType=NodePort,routerServiceType=NodePort \
  fission-charts/fission-all;

install.gif

Install CLI:

i. macOS

curl -Lo fission <https://github.com/fission/fission/releases/download/v1.17.0/fission-v1.17.0-darwin-amd64> \
    && chmod +x fission && sudo mv fission /usr/local/bin/

ii. Linux/WSL

curl -Lo fission <https://github.com/fission/fission/releases/download/v1.17.0/fission-v1.17.0-linux-amd64> \
    && chmod +x fission && sudo mv fission /usr/local/bin/

Usage

Initialize spec

fission spec init

Create environment (Python)

You can change name to something else. image must match the language you are using

fission env create --spec --name python --image fission/python-env --builder fission/python-builder

spec.gif

Code

Clone the repo with example code

git clone https://github.com/NauqGnesh/fission-tutorial.git

Your functions should be structured as such:

.
├── room/
│   ├── room.py
│   └── requirements.txt
└── lamp/
    ├── lamp.py 
    └── requirements.txt

Create functions

This will register a function to your fission namespace

  • --env name of environment to execute function
  • --name name of function
  • --src source code
  • --entrypoint entrypoint of your code
fission function create --spec --name room --env python --src "room/*" --entrypoint room.main;
fission function create --spec --name lamp --env python --src "lamp/*" --entrypoint lamp.main;

Trigger

This will create a trigger to invoke your fission functions

  • --method HTTP method
  • --url route endpoint
  • --function name of function to be invoked
fission route create --spec --method GET --url /lamp --function lamp;
fission route create --spec --method GET --url /room --function room;

function&trigger.gif

Addtionally, minikube doesn't support external load balancer, so we need to forward ports. Set <local port> to a free port on your machine. Note: minikube uses 8080 by default

export FISSION_ROUTER=$(minikube ip):$(kubectl -n fission get svc router -o jsonpath='{...nodePort}');
kubectl --namespace fission port-forward $(kubectl --namespace fission get pod -l svc=router -o name) <local port>:8888 &
export FISSION_ROUTER=127.0.0.1:<local port>

Validate

fission spec validate

validate.gif

Deploy

Use --watch to deploy continuously

fission spec apply --wait 

deploy.gif

Test

To invoke a function directly

fission function test --name lamp

test.gif

To invoke a function via trigger

curl http://$FISSION_ROUTER/lamp

trigger.gif

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages