Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

[WIP] Added example of accessing API of Fission #196

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/content/en/docs/usage/functions.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ draft: false
weight: 2
---

This section walks through working with functions, for controlling execution of functions please refer to [Controlling Function Execution]({{% relref "executor.en.md" %}})
This section walks through working with functions, for controlling execution of functions please refer to [Controlling Function Execution]({{% ref "executor.en.md" %}})

### Create a function

Before creating a function, you'll need an environment; read
[environments]({{% relref "environments.en.md" %}}) if you
[environments]({{% ref "environments.en.md" %}}) if you
haven't already.

Let's create an environment for our function.
Expand Down Expand Up @@ -43,7 +43,7 @@ $ fission route create --function hello --url /hello
trigger '5327e9a7-6d87-4533-a4fb-c67f55b1e492' created
```

Setup [FISSION_ROUTER]({{% relref "../installation/env_vars.en.md" %}}) environment variable if you haven't already.
Setup [FISSION_ROUTER]({{% ref "../installation/env_vars.en.md" %}}) environment variable if you haven't already.

When you hit this function's URL, you get the expected response:

Expand Down Expand Up @@ -138,7 +138,7 @@ $ fission fn logs --name hello

Most real world functions will require more than one source files. It is also easier to simply provide source files and let Fission take care of building from source files. Fission provides first class support for building from source as well as using compiled artifacts to create functions.

You can attach the source/deployment packages to a function or explicitly create packages and use them across functions. Check documentation for [package]({{% relref "package.en.md" %}}) for more information.
You can attach the source/deployment packages to a function or explicitly create packages and use them across functions. Check documentation for [package]({{% ref "package.en.md" %}}) for more information.

#### Building functions from source

Expand Down Expand Up @@ -229,7 +229,7 @@ b: {c: 3, d: 4}
```

If you're using Fission with source code, be sure to read about the
recommended [development workflow]({{%relref "../spec/_index.md" %}}).
recommended [development workflow]({{%ref "../spec/_index.md" %}}).

#### Using compiled artifacts with Fission

Expand Down
43 changes: 43 additions & 0 deletions docs/content/en/docs/usage/using-fission-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
title: "Using Fission API"
date: 2020-04-18T14:56:20+05:30
draft: false
---

# Introduction

The Fission API can be accessed from Kubernetes API as well as from the Fission controller directly.

# With Kubernetes API

Fission is built using Kubernetes CRDs and the Fission API follows the standard Kubernetes API model. If you are not aware of Kubernetes API or never used it before, it would be a good idea to have a [Kubernetes API documentation](https://kubernetes.io/docs/concepts/overview/kubernetes-api). Kubernetes also supports the OpenAPI standard and provides Swagger definitions as you can notice in the [Kubernetes API documentation page](https://kubernetes.io/docs/concepts/overview/kubernetes-api/#openapi-and-swagger-definitions). For more details on authentication and authorization with the API you can check the documentation on [Controlling Access to Kubernetes API](https://kubernetes.io/docs/reference/access-authn-authz/controlling-access/)

You can download the entire the Kubernetes API documentation from a cluster which has Fission installed - so you also get Fission API calls built in the definition.

- To download the entire Kubernetes API Swagger definition, assuming you are proxying the API server on localhost use the URL: [http://localhost:8001/openapi/v2](http://localhost:8001/openapi/v2). The Kubernetes API document is huge and generally consumes a lot of resources when you are trying to load it in browser. You can use https://editor.swagger.io/ to load the doc in browser or sign up at http://app.swaggerhub.com/ and then create APIs by importing the document.

- We have also hosted a Swagger DOC created in April 2020 here for a Kubernetes cluster with Fission installed: https://app.swaggerhub.com/apis/Infracloud/kubernetes/v1.15.9#/fissionIo_v1


![Kubernetes API](/images/fission-k8s.png)


# With Fission Controller

To download only the Fission Swagger API doc, assuming you are proxying the API server on localhost use the URL: [http://localhost:8001/api/v1/namespaces/fission/services/controller:80/proxy/v2/apidocs.json](http://localhost:8001/api/v1/namespaces/fission/services/controller:80/proxy/v2/apidocs.json)

For accessing this API, you will have to proxy the controller pod locally and then access the API. For programmatic access this means you should be able to access controller pod from outside the cluster.

```
$ kubectl port-forward controller-548c5d8988-fgqxt 8888:8888
Forwarding from 127.0.0.1:8888 -> 8888
Forwarding from [::1]:8888 -> 8888
Handling connection for 8888

```

![Fission Controller API](/images/fission-controller-api.png)

# Reccomended Approach


Binary file added docs/static/images/fission-controller-api.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/static/images/fission-k8s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.