Code Monkey home page Code Monkey logo

fninfo's Introduction

OpenFaaS Kubernetes info function

Create view cluster role binding:

apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: openfaas-fn-view
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: view
subjects:
- apiGroup: rbac.authorization.k8s.io
  kind: User
  name: system:serviceaccount:openfaas-fn:default
kubectl apply -f ./deploy/readonly-role.yaml

Create a secret named fninfo-token:

kubectl -n openfaas-fn create secret generic fninfo-token --from-literal=token=c1d116c6bfb

Deploy (requires OpenFaaS Operator):

apiVersion: o6s.io/v1alpha1
kind: Function
metadata:
  name: fninfo
  namespace: openfaas-fn
spec:
  name: fninfo
  image: stefanprodan/fninfo:latest
  environment:
    secrets_path: "/var/openfaas"
  labels:
    release: "ga"
  secrets:
    - fninfo-token
  limits:
    cpu: "2000m"
    memory: "256Mi"
  requests:
    cpu: "100m"
    memory: "64Mi"
kubectl apply -f ./deploy/fninfo.yaml

Invoke function:

echo "test" | faas invoke fninfo | jq .

{
  "Hostname": "fninfo-6c7bd759cd-pr52v",
  "Namespaces": [
    {
      "Name": "kube-system",
      "Pods": 9,
      "Deployments": 6,
      "Services": 5
    },
    {
      "Name": "openfaas",
      "Pods": 7,
      "Deployments": 4,
      "Services": 3
    },
    {
      "Name": "openfaas-fn",
      "Pods": 4,
      "Deployments": 4,
      "Services": 4
    }
  ],
  "Environment": [
    "Http_X_Forwarded_For=10.56.0.160:35656",
    "Http_X_Envoy_Expected_Rq_Timeout_Ms=15000",
    "Http_Content_Type=text/plain",
    "Http_User_Agent=Go-http-client/2.0",
    "Http_X_Call_Id=baf4758d-cf8a-4f4d-af8e-f2a2c6e055dd",
    "Http_X_Request_Id=a1c2b3f8-85c8-4696-8f47-04487421bbfa",
    "Http_X_Start_Time=1527236562012143249",
    "Http_X_Envoy_Internal=true",
    "Http_X_Forwarded_Proto=https",
    "Http_Accept_Encoding=gzip",
    "Http_Method=POST",
    "Http_ContentLength=-1",
    "Http_Path=/function/fninfo"
  ],
  "Request": "test"
}

Add a random response delay between 1 to 5 seconds:

echo "delay" | faas invoke fninfo

fninfo's People

Contributors

stefanprodan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.