Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use Heml to install and use OpenFaaS in Kubernetes

Shulou Source: shulou.com Published: 2022-06-01 01:38:04 09月22日 Update

This article will explain in detail how to use Heml to install and use OpenFaaS in Kubernetes. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

Introduction to OpenFaaS

OpenFaaS ®- Serverless Functions Made Simple

Download the OpenFaaS driver for Kubernetes, faas-netes:

Git clone https://github.com/openfaas/faas-netes & & cd faas-netesor domestic Code Cloud Image: git clone https://gitee.com/mirrors/faas-netes.git & & cd faas-netes

OpenFaaS (Functions as a Service) [1] is a framework for building serverless functions with Docker and Kubernetes.

In short, OpenFaaS is a framework for building Serverless functionality using Docker, with first-level support for metrics. Any process can be packaged as a function that allows you to use a series of web events without repetitive boilerplate coding.

Helm

Before installing OpenFaaS, we need to install Helm 3 (we no longer need to use tiller).

Combined with the previous article Kubernetes study notes [2], start minikube:

Minikube start-image-mirror-country cneval $(minikube docker-env)

Install Helm:

Brew install kubernetes-helm

Use Helm to manage kubernetes applications [3]

Deploy OpenFaaS

In the minikube environment, first create two namespaces namespaces:

Kubectl apply-f https://raw.githubusercontent.com/openfaas/faas-netes/master/namespaces.yml

Add OpenFaaS helm chart:

Helm repo add openfaas https://openfaas.github.io/faas-netes/

All right, let's try a simple release first:

Helm repo update\ & & helm upgrade openfaas--install openfaas/openfaas\-namespace openfaas\-- set functionNamespace=openfaas-fn\-- set generateBasicAuth=true

Follow the prompts to get the password:

Echo $(kubectl-n openfaas get secret basic-auth- o jsonpath= "{.data.basic-auth-password}" | base64-- decode) / / passwordLnMqQfE5PVva

Port 31112 is provided by default. We use the command $(minikube ip) to obtain the internal ip, access it through ip:31112, and enter the account number and the password provided above:

Hello Function

Let's start with our first serverless function.

Install faas-cli

As recommended in the figure above, we can install faas-cli to create and publish a Function.

$curl-sL cli.openfaas.com | sudo sh

I use mac, so I can also install it directly using brew:

Brew install faas-cli

Create a NodeJS function

Faas-cli new hellofaas-lang node

The whole project structure is as follows:

.├── handler.js └── package.json 's article on "how to install and use OpenFaaS with Heml in Kubernetes" ends here. I hope the above content can be helpful to you so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Articles functions articles more good practical in short above two events content functions commands passwords indicators templates frameworks processes environment knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Apple vpn NVidia OPPO Reno