「daily updating」k3s + openfaas serverless bench 踩坑指南持续更新中

OpenFaas从入门到实战 – 踩坑指南 | k3d+OpenFaas | deploy your first python function

https://blog.alexellis.io/first-faas-python-function/

https://docs.openfaas.com/deployment/kubernetes/

搭建环境:第一种方法失败,第二种方法亲测有效嘻嘻嘻,其实我大概知道原因,但先不细究了

1. VM: K3s + OpenFaas on Mac

参考教程:https://midnightprogrammer.net/post/installing-openfaas-on-k3s-single-node/

MacBook Pro

使用 Multipass 来创建一个 VM:需要 4GB 内存和 8GB 磁盘,记得要分配多一点 - 我暂定的

beatles@biantongshusMBP ~ % multipass launch --name k3s --memory 4G --disk 8G 
Launched: k3s

等待 VM 创建,然后为 VM 启动一个 shell

multipass shell k3s

安装 k3s

curl -sfL https://get.k3s.io | sh -

After the installation is completed, you can check if the k3s service is running by executing the below command.

sudo systemctl status k3s

image-20240103190034976

​ 亲测无效,遂脚本自动安装:

curl -SLsf https://dl.get.arkade.dev/ | sudo sh

image-20240104190355723

谁说用着个很简单,总之我还自己凑了两个命名空间

arkade install openfaas

然后就是这样

Release "openfaas" has been upgraded. Happy Helming!
NAME: openfaas
LAST DEPLOYED: Thu Jan  4 19:51:37 2024
NAMESPACE: openfaas
STATUS: deployed
REVISION: 2
TEST SUITE: None
NOTES:
To verify that openfaas has started, run:kubectl -n openfaas get deployments -l "release=openfaas, app=openfaas"To retrieve the admin password, run:echo $(kubectl -n openfaas get secret basic-auth -o jsonpath="{.data.basic-auth-password}" | base64 --decode)
2024/01/04 19:51:42 stderr: WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /home/ubuntu/.kube/config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /home/ubuntu/.kube/config=======================================================================
= OpenFaaS has been installed.                                        =
=======================================================================# Get the faas-cli
curl -SLsf https://cli.openfaas.com | sudo sh# Forward the gateway to your machine
kubectl rollout status -n openfaas deploy/gateway
kubectl port-forward -n openfaas svc/gateway 8080:8080 &# If basic auth is enabled, you can now log into your gateway:
PASSWORD=$(kubectl get secret -n openfaas basic-auth -o jsonpath="{.data.basic-auth-password}" | base64 --decode; echo)
echo -n $PASSWORD | faas-cli login --username admin --password-stdinfaas-cli store deploy figlet
faas-cli list# For Raspberry Pi
faas-cli store list \--platform armhffaas-cli store deploy figlet \--platform armhf# Find out more at:
# https://github.com/openfaas/faas🚀 Speed up GitHub Actions/GitLab CI + reduce costs: https://actuated.dev

check the rollout status of the gateway, After this we can forward the gateway to the machine.

ubuntu@k3s:/etc/rancher/k3s$ kubectl get pod -n openfaas
NAME                            READY   STATUS    RESTARTS      AGE
nats-5c48bc8b46-zksff           1/1     Running   2 (12m ago)   73m
alertmanager-795bbdc56c-6qwpn   1/1     Running   2 (12m ago)   73m
prometheus-78d4c9f748-smjfr     1/1     Running   2 (12m ago)   73m
queue-worker-b9965cc56-bn47b    1/1     Running   6 (12m ago)   73m
gateway-67df8c4d4-jfkbf         2/2     Running   0             73m
ubuntu@k3s:/etc/rancher/k3s$ kubectl rollout status -n openfaas deploy/gateway
deployment "gateway" successfully rolled out
ubuntu@k3s:/etc/rancher/k3s$ kubectl port-forward -n openfaas svc/gateway 8080:8080 &
[1] 4737
ubuntu@k3s:/etc/rancher/k3s$ Forwarding from 127.0.0.1:8080 -> 8080
Forwarding from [::1]:8080 -> 8080
jobs
[1]+  Running                 kubectl port-forward -n openfaas svc/gateway 8080:8080 &
ubuntu@k3s:/etc/rancher/k3s$ 

You can then view the password by printing the value of the PASSWORD variable using the echo command. 反正报错需要等一会儿就好了

ubuntu@k3s:/etc/rancher/k3s$ echo $PASSWORD
oJPdijCZF2Dd

192.168.64.1

http://localhost:31112/ui
http://127.0.0.1:31112/ui

2. Docker: K3d + OpenFaas

参考教程(版本较老,于是我自己做了一些记录):https://mickey.dev/posts/getting-started-with-openfaas/#:~:text=Configure%20faas%2Dcli%20%26%20Login%20to%20the%20OpenFaaS%20Dashboard&text=Open%20a%20browser%20and%20navigate,for%20a%20username%20and%20password.

brew install k3d

Create a cluster named mycluster with just a single server node

k3d cluster create mycluster

You can now use it like this:

kubectl cluster-info

image-20240105215327074

事实上,这句话并没有什么用

export KUBECONFIG="$(k3d kubeconfig get --name='k3s-default')"export KUBECONFIG="$(k3d kubeconfig get --all)"

To install OpenFaaS to your k3d cluster, start by cloning the https://github.com/openfaas/faas-netesrepo:

git clone https://github.com/openfaas/faas-netes.git
cd faas-netes

Install the namespaces:

kubectl apply -f namespaces.yml

This will create two namespaces in your cluster:

openfaas - Which will hold the OpenFaaS cluster services (AKA. ‘Control Plane”).
openfaas-fn - Stores the functions you deploy to OpenFaaS.

Create a password for the OpenFaaS Gateway and add it as a secret into the cluster. The below commands will generate a random password and add the secret:

beatles@biantongshus-MacBook-Pro faas-netes % export PASSWORD=$(head -c 12 /dev/urandom | shasum| cut -d' ' -f1)beatles@biantongshus-MacBook-Pro faas-netes % kubectl -n openfaas create secret generic basic-auth \
--from-literal=basic-auth-user=admin \
--from-literal=basic-auth-password="$PASSWORD"
secret/basic-auth created
beatles@biantongshus-MacBook-Pro faas-netes % 

Now deploy the OpenFaaS stack:

kubectl apply -f ./yaml

Install the faas-cli

The next step is installing the faas-cli. If you’re on MacOS and already have homebrew install then installation is as simple as:

brew install faas-cli

Configure faas-cli & Login to the OpenFaaS Dashboard

Configure the faas-cli to use your local OpenFaaS cluster by using the faas-cli login command. If running k3d you’ll need to forward the gateway service port and set the OPENFAAS_URL environment variable:

kubectl port-forward svc/gateway -n openfaas 31112:8080 &
export OPENFAAS_URL=http://127.0.0.1:31112
echo $PASSWORD | faas-cli login --password-stdin

Open a browser and navigate to http://localhost:31112 to load the UI. The UI will prompt for a username and password. The default username is admin and the password is the one you specified in the deployment instructions above, you can print this to your console using echo $PASSWORD.

echo $PASSWORD
681d0e42c1506c260eba6cc73ad61b3330276302

image-20240106121621039

Cheers!!

再次登陆

http://localhost:31112/

export PASSWORD=681d0e42c1506c260eba6cc73ad61b3330276302

别忘了启动docker engine

kubectl port-forward svc/gateway -n openfaas 31112:8080 &
export OPENFAAS_URL=http://127.0.0.1:31112
echo $PASSWORD | faas-cli login --password-stdin

就好了

3. Deploy New Functions

3.1 bug一览 | 排错完整过程(发疯中)

faas-cli template store list
Error while getting templates info: error while requesting template list: Get "https://raw.githubusercontent.com/openfaas/store/master/templates.json": dial tcp [::]:443: connect: connection refused

祈祷:http://grayblog.cn/2020/07/18/解决Mac中Terminal无法访问github/

IP Lookup : 140.82.113.3 (github.com)
sudo vi /etc/hosts
140.82.113.3 www.github.com 

他的ipaddress有好多,我就放了第一个https://www.ipaddress.com/ip-lookup

185.199.109.133 raw.githubusercontent.com

终于!!!不行的话再来一遍

beatles@biantongshusMBP ~ % faas-cli template store listNAME                     RECOMMENDED DESCRIPTION        SOURCE
bash-streaming           [x]         openfaas-incubator Bash Streaming template
dockerfile               [x]         openfaas           Classic Dockerfile template
golang-middleware        [x]         openfaas           HTTP middleware interface in Go
java11-vert-x            [x]         openfaas           Java 11 Vert.x template
node18                   [x]         openfaas           HTTP-based Node 18 template
php8                     [x]         openfaas           Classic PHP 8 template
python3-http             [x]         openfaas           Python 3 with Flask and HTTP
python3-http-debian      [x]         openfaas           Python 3 with Flask and HTTP based on Debian
ruby-http                [x]         openfaas           Ruby 2.4 HTTP template
cobol                    [ ]         devries            COBOL Template
crystal                  [ ]         tpei               Crystal template
crystal-http             [ ]         koffeinfrei        Crystal HTTP template
csharp-httprequest       [ ]         distantcam         C# HTTP template
csharp-kestrel           [ ]         burtonr            C# Kestrel HTTP template
lua53                    [ ]         affix              Lua 5.3 Template
perl-alpine              [ ]         tmiklas            Perl language template based on Alpine image
quarkus-native           [ ]         pmlopes            Quarkus.io native image template
rust                     [ ]         openfaas-incubator Community Rust template
rust-http                [ ]         openfaas-incubator Community Rust template with HTTP bindings
swift                    [ ]         affix              Swift 4.2 Template
vala                     [ ]         affix              Vala Template
vala-http                [ ]         affix              Non-Forking Vala Template
vertx-native             [ ]         pmlopes            Eclipse Vert.x native image template
bun-express              [ ]         openfaas           HTTP-based template using bun
csharp                   [ ]         openfaas           Classic C# template
go                       [ ]         openfaas           Legacy Golang template
golang-http              [ ]         openfaas           Request/response style HTTP template
java11                   [ ]         openfaas           Java 11 template
node                     [ ]         openfaas           Legacy Node 12 template
node12                   [ ]         openfaas           HTTP-based Node 12 template
node14                   [ ]         openfaas           HTTP-based Node 14 template
node16                   [ ]         openfaas           HTTP-based Node 16 template
node17                   [ ]         openfaas           HTTP-based Node 17 template
php7                     [ ]         openfaas           Classic PHP 7 template
powershell-http-template [ ]         openfaas-incubator Powershell Core HTTP Ubuntu:16.04 template
powershell-template      [ ]         openfaas-incubator Powershell Core Ubuntu:16.04 template
puppeteer-nodelts        [ ]         alexellis          A puppeteer template for headless Chrome
python                   [ ]         openfaas           Classic Python 2.7 template
python27-flask           [ ]         openfaas           Python 2.7 Flask template
python3                  [ ]         openfaas           Classic Python 3 template
python3-debian           [ ]         openfaas           Python 3 Debian template
python3-flask            [ ]         openfaas           Python 3 Flask template
python3-flask-debian     [ ]         openfaas           Python 3 Flask template based on Debian
ruby                     [ ]         openfaas           Classic Ruby 2.5 template
faas-cli up --gateway=http://localhost:31112

faas-cli build -f ./cpu.yml
faas-cli deploy -f ./cpu.yml --gateway=http://localhost:31112

当然了,探索出过程很痛苦,我把我提的github issue挂在这里 https://github.com/openfaas/faas/issues/1831

事到如今,踩坑真得靠自己了

[0] < Building float-operation done in 104.36s.
[0] Worker done.Total build time: 104.36s
Deploying: float-operation.Is OpenFaaS deployed? Do you need to specify the --gateway flag?
Put "http://127.0.0.1:8080/system/functions": dial tcp 127.0.0.1:8080: connect: connection refusedFunction 'float-operation' failed to deploy with status code: 500
beatles@biantongshusMBP openfaas % faas-cli logs float-operation
Cannot connect to OpenFaaS on URL: http://127.0.0.1:8080

排错:

kubectl get service -n openfaas
faas-cli deploy -f ./cpu.yml --gateway=http://localhost:31112

最终成功

beatles@biantongshusMBP openfaas % faas-cli login --username admin --password=681d0e42c1506c260eba6cc73ad61b3330276302 --gateway=http://localhost:31112WARNING! Using --password is insecure, consider using: cat ~/faas_pass.txt | faas-cli login -u user --password-stdin
Calling the OpenFaaS server to validate the credentials...
credentials saved for admin http://localhost:31112
beatles@biantongshusMBP openfaas % faas-cli deploy -f ./cpu.yml --gateway=http://localhost:31112
Deploying: float-operation.Deployed. 202 Accepted.
URL: http://localhost:31112/function/float-operationbeatles@biantongshusMBP openfaas % 

然而遇到not ready

Not Ready

beatles@biantongshusMBP openfaas % kubectl get deploy -n openfaas-fn
NAME              READY   UP-TO-DATE   AVAILABLE   AGE
float-operation   0/1     1            0           5h36m
beatles@biantongshusMBP openfaas % kubectl describe -n openfaas-fn deploy/float-operation
Name:                   float-operation
Namespace:              openfaas-fn
CreationTimestamp:      Thu, 25 Jan 2024 12:34:41 +0800
Labels:                 faas_function=float-operation
Annotations:            deployment.kubernetes.io/revision: 1prometheus.io.scrape: false
Selector:               faas_function=float-operation
Replicas:               1 desired | 1 updated | 1 total | 0 available | 1 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  0 max unavailable, 1 max surge
Pod Template:Labels:       faas_function=float-operationAnnotations:  prometheus.io.scrape: falseContainers:float-operation:Image:      float-operation:latestPort:       8080/TCPHost Port:  0/TCPLiveness:   http-get http://:8080/_/health delay=2s timeout=1s period=2s #success=1 #failure=3Readiness:  http-get http://:8080/_/health delay=2s timeout=1s period=2s #success=1 #failure=3Environment:fprocess:  python index.pyMounts:      <none>Volumes:       <none>
Conditions:Type           Status  Reason----           ------  ------Available      False   MinimumReplicasUnavailableProgressing    False   ProgressDeadlineExceeded
OldReplicaSets:  <none>
NewReplicaSet:   float-operation-bfd748bd6 (1/1 replicas created)
Events:          <none>
beatles@biantongshusMBP openfaas % 

排错过程:

beatles@biantongshusMBP openfaas % kubectl get deploy -n openfaas-fn
NAME              READY   UP-TO-DATE   AVAILABLE   AGE
float-operation   0/1     1            0           5h36mbeatles@biantongshusMBP openfaas % kubectl logs -n openfaas-fn deploy/float-operation
Error from server (BadRequest): container "float-operation" in pod "float-operation-bfd748bd6-4r67p" is waiting to start: trying and failing to pull imagebeatles@biantongshusMBP openfaas % kubectl get events -n openfaas-fn \--sort-by=.metadata.creationTimestamp
LAST SEEN   TYPE      REASON    OBJECT                                MESSAGE
31m         Normal    Pulling   pod/float-operation-bfd748bd6-p885q   Pulling image "float-operation:latest"
37m         Warning   Failed    pod/float-operation-bfd748bd6-p885q   Failed to pull image "float-operation:latest": rpc error: code = Unknown desc = failed to pull and unpack image "docker.io/library/float-operation:latest": failed to resolve reference "docker.io/library/float-operation:latest": pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
37m         Warning   Failed    pod/float-operation-bfd748bd6-p885q   Error: ErrImagePull
3m28s       Normal    BackOff   pod/float-operation-bfd748bd6-p885q   Back-off pulling image "float-operation:latest"beatles@biantongshusMBP ~ % docker pull float-operation:latest
Error response from daemon: pull access denied for float-operation, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

https://docs.openfaas.com/deployment/kubernetes/

于是我准备先学一下docker: https://www.youtube.com/watch?v=pg19Z8LL06w

现在我学完了,我又来解决问题来了

3.2 First Python Function

faas-cli template store pull python3-http
faas-cli new float-operation --lang python3-http 

部署函数

faas-cli up --gateway=http://localhost:31112

或如下几步

faas-cli build -f ./cpu.yml

build失败可能是网络问题 更换节点可以解决

Here’s how to upload the function to a remote registry (if needed):

docker login -u beatlesbian -p Bts210717! docker.io
faas-cli push -f ./cpu.yml 
faas-cli deploy -f ./cpu.yml --gateway=http://localhost:31112

出现了这个问题,找到了 https://skemman.is/bitstream/1946/44391/2/OperatingManual.pdf

beatles@biantongshusMBP openfaas % faas-cli push -f ./cpu.yml Unable to push one or more of your functions to Docker Hub:
- float-operationYou must provide a username or registry prefix to the Function's image such as user1/function1

我需要修改yaml文件,啊!我才懂Alex是什么意思image: beatlesbian/float-operation:latest

终于Push成功

latest: digest: sha256:4f6429e67aea67b421804366a4c89ff39be1dc705cd9a58807fcf656399b9cc2 size: 4695
[0] < Pushing float-operation [beatlesbian/float-operation:latest] done.
[0] Worker done.

然而不是200 ok

beatles@biantongshusMBP openfaas % faas-cli deploy -f ./cpu.yml --gateway=http://localhost:31112
Deploying: float-operation.Deployed. 202 Accepted.
URL: http://localhost:31112/function/float-operation

这回终于ready了,然而,我谢谢嘞,我能把所有坑踩遍是吧,我怀疑是 an error in the application,毕竟这也是我第一次来写OpenFaas函数,好吧让我去刷牙洗脸,曙光就在前方,我预感明天我能把所有函数都部署完,然后再考虑auto-scaling的问题,然后上hey插件测试性能,年前就做这些吧,每天保证两小时改论文,画一些简单轻松的小画就可以了

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

这是我修改前的 hanlder.py,这种直接返回估计肯定是不对的

import math
from time import timedef float_operations(n):start = time()for i in range(0, n):sin_i = math.sin(i)cos_i = math.cos(i)sqrt_i = math.sqrt(i)latency = time() - startreturn latencydef handle(event, context):n = int(event['n'])result = float_operations(n)print(result)return result# return {#     "statusCode": 200,#     "body": "Hello from OpenFaaS!"# }

于是我改成了gpt给我写的,还是不行

这当然就要查看日志了!Your function is crashing due to an error in your code, check the logs. 感谢troubleshooting手册,我们可以很轻松的猜测问题定位在最后一个,当然只是猜测

beatles@biantongshusMBP openfaas % kubectl logs -n openfaas-fn deploy/float-operation
2024/02/07 02:23:31 Version: 0.9.15     SHA: bb7b23f61a2251aa158dac6d409f2fdff383f4f9
2024/02/07 02:23:31 Forking: python, arguments: [index.py]
2024/02/07 02:23:31 Started logging: stderr from function.
.....^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024/02/07 02:24:48 stderr:   File "/home/app/index.py", line 66, in call_handler
2024/02/07 02:24:48 stderr:     response_data = handler.handle(event, context)
2024/02/07 02:24:48 stderr:                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024/02/07 02:24:48 stderr:   File "/home/app/function/handler.py", line 16, in handle
2024/02/07 02:24:48 stderr:     n = int(event['n'])
2024/02/07 02:24:48 stderr:             ~~~~~^^^^^
2024/02/07 02:24:48 stderr: TypeError: 'Event' object is not subscriptable
2024/02/07 02:24:48 POST / - 500 INTERNAL SERVER ERROR - ContentLength: 265B (0.0043s)
beatles@biantongshusMBP openfaas % 

The function handler is passed two arguments, event and context.

  • event contains data about the request, including: - body - headers - method - query - path

  • context contains basic information about the function, including: - hostname

问题就出现在event上

n = int(event.body)

I want to test my function without deploying it,尝试一下吧!Then invoke your function via http://127.0.0.1:8081

faas-cli build -f ./cpu.yml
docker run -p 8081:8080 \--rm \--name float-operation \-ti beatlesbian/float-operation:latest

终于成功了!

image-20240207114325042

至此我认为我已经踩完大部分坑了。

3.3 Add Second Function

faas-cli new pyaes --lang python3-http --append cpu.yml
2024/02/07 08:38:07 stderr:     import numpy as np
2024/02/07 08:38:07 stderr: ModuleNotFoundError: No module named 'numpy'

缺包可能需要修改dockerfile, 添加RUN ....,再手动build

docker build -t beatlesbian/pyaes:latest ./build/pyaes

然后继续,成功了

faas-cli push -f ./cpu.yml
faas-cli deploy -f ./cpu.yml --gateway=http://localhost:31112

排错常用

kubectl logs -n openfaas-fn deploy/pyaes

对于缺包我做了如下补充:PIL

RUN pip install Pillow
RUN pip install requests

https://blog.csdn.net/qq_28304687/article/details/76551196

根据论文,我现在要把这些都添加完,明天测试openFaas可扩展性,并安装插件

pyaes

RUN pip install pyaes# test
{'length_of_message': 4,'num_of_iterations': 5
}event_body = json.loads(event.body.decode("utf-8"))
length_of_message = event_body['length_of_message']
num_of_iterations = event_body['num_of_iterations']{'message': '69wc', 'ciphertext': b'\xb6 \xbf"', 'latency': 0.0022983551025390625}
  • TypeError: Object of type bytes is not JSON serializable OpenFaas简单的事例,并没有演示出来event.body是字节码类型,还要靠自己反复摸索,解决方案最终如上,好在可以举一反三了

FunctionBench workloads

1. CPU & Memory
  • ⭐️Float Operations(sin, cos, sqrt) done

  • ⭐️MatMul(square matrix multiplication) done

  • ⭐️Linpack(solve linear equations Ax = b) done

  • ⭐️Image Processing

  • ⭐️Video Processing

  • MapReduce

  • Chameleon

  • ⭐️pyaes done

  • Feature Generation

  • ⭐️Model Training

  • Model Serving

    • Video Face Detection - Cascade Classifier
    • Classification Image - CNN
    • Generating Names- RNN
    • Prediction Reviews - LR
2. Disk
  • ⭐️dd
  • ⭐️gzip-compression
3. Network
  • iPerf3
  • Cloud storage service download-upload
  • json serialization deserialization
# from google.cloud import storage
from PIL import Image, ImageFilter
from time import time
import json
import osTMP = "/tmp/"
#输入的image, file_name, 输出的filename需要斟酌# left-right + top-bottom
def flip(image, file_name):path_list = []path = TMP + "flip-left-right-" + file_nameimg = image.transpose(Image.FLIP_LEFT_RIGHT)img.save(path)path_list.append(path)path = TMP + "flip-top-bottom-" + file_nameimg = image.transpose(Image.FLIP_TOP_BOTTOM)img.save(path)path_list.append(path)return path_list# rotate 90 180 270
def rotate(image, file_name):path_list = []path = TMP + "rotate-90-" + file_nameimg = image.transpose(Image.ROTATE_90)img.save(path)path_list.append(path)path = TMP + "rotate-180-" + file_nameimg = image.transpose(Image.ROTATE_180)img.save(path)path_list.append(path)path = TMP + "rotate-270-" + file_nameimg = image.transpose(Image.ROTATE_270)img.save(path)path_list.append(path)return path_list# filter
def filter(image, file_name):path_list = []path = TMP + "blur-" + file_nameimg = image.filter(ImageFilter.BLUR)img.save(path)path_list.append(path)path = TMP + "contour-" + file_nameimg = image.filter(ImageFilter.CONTOUR)img.save(path)path_list.append(path)path = TMP + "sharpen-" + file_nameimg = image.filter(ImageFilter.SHARPEN)img.save(path)path_list.append(path)return path_listdef gray_scale(image, file_name):path = TMP + "gray-scale-" + file_nameimg = image.convert('L')img.save(path)return [path]def resize(image, file_name):path = TMP + "resized-" + file_nameimage.thumbnail((128, 128))image.save(path)return [path]# upon 5 image processing actions
def image_processing(file_name, image_path):path_list = []start = time()with Image.open(image_path) as image:tmp = imagepath_list += flip(image, file_name)path_list += rotate(image, file_name)path_list += filter(image, file_name)path_list += gray_scale(image, file_name)path_list += resize(image, file_name)latency = time() - startresult = {'path_list': path_list,'latency': latency}return result# file_name, image_path
def handle(event, context):image_path = str(event.body)file_name = os.path.basename(image_path)result = image_processing(file_name,image_path)return {"statusCode": 200,"body": json.dumps(result)}

Kubeedge

multipass launch --name kubeedge1 --memory 4G --disk 8G 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/677594.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【SpringBootStarter】自定义全局加解密组件

【SpringBootStarter】 目的 了解SpringBoot Starter相关概念以及开发流程实现自定义SpringBoot Starter(全局加解密)了解测试流程优化 最终引用的效果&#xff1a; <dependency><groupId>com.xbhog</groupId><artifactId>globalValidation-spring…

[职场] 大厂群面的基本题型 #学习方法#其他

大厂群面的基本题型 大厂群面的基本题型 群面&#xff0c;又叫做“无领导小组面试”。历年来是企业校招时&#xff0c;进行大批量刷人的有效方法。流行于互联网、快消、银行、四大等多个行业。因为难度大、情况复杂、淘汰率高&#xff0c;又被称为“死亡面试”。 无领导小组…

CSP-202012-2-期末预测之最佳阈值

CSP-202012-2-期末预测之最佳阈值 【70分思路】 本题的难点还是时间复杂度&#xff0c;暴力枚举会导致时间超限。对于每一个可能的阈值theta&#xff0c;代码都重新计算了整个predict数组&#xff0c;统计预测正确的数目&#xff0c;因为有两个嵌套的循环&#xff0c;使得时间…

计算机网络之一

目录 1.因特网概述 1.1网络、互连网&#xff08;互联网&#xff09;和因特网 1.2.因特网发展的三个阶段 1.3基于ISP的三层架构的因特网 1.4.因特网的组成 2.三种交换方式 2.1电路交换 2.2分组交换 1.因特网概述 1.1网络、互连网&#xff08;互联网&#xff09;和因特网…

Git分支常用指令

目录 1 git branch 2 git branch xx 3 git checkout xx 4 git checkout -b xx 5 git branch -d xx 6 git branch -D xx 7 git merge xx(含快进模式和冲突解决的讲解) 注意git-log: 1 git branch 作用&#xff1a;查看分支 示例&#xff1a; 2 git branch xx 作用&a…

数据结构——5.5 树与二叉树的应用

5.5 树与二叉树的应用 概念 结点的权&#xff1a;大小可以表示结点的重要性 结点的带权路径长度&#xff1a;从树的根到该结&#xff0c;的路径长度&#xff08;经过的边数&#xff09;与该结点权的乘积 树的带权路径长度&#xff1a;树中所有叶结点的带权路径长度之和(WPL) …

蜂鸣器播放提示音音乐(天空之城)

目录 蜂鸣器播放提示音 蜂鸣器播放音乐&#xff08;天空之城&#xff09; 准备工作 主程序 中断函数 上一节讲了蜂鸣器驱动原理和乐理基础知识&#xff0c;这一节开始代码演示&#xff01; 蜂鸣器播放提示音 先创建工程&#xff1a;蜂鸣器播放提示音 把我们之前模块化的…

python 爬虫篇(3)---->Beautiful Soup 网页解析库的使用(包含实例代码)

Beautiful Soup 网页解析库的使用 文章目录 Beautiful Soup 网页解析库的使用前言一、安装Beautiful Soup 和 lxml二、Beautiful Soup基本使用方法标签选择器1 .string --获取文本内容2 .name --获取标签本身名称3 .attrs[] --通过属性拿属性的值标准选择器find_all( name , at…

Sentinel 源码分析

Sentinel源码分析 项目源码 1.Sentinel的基本概念 Sentinel实现限流、隔离、降级、熔断等功能&#xff0c;本质要做的就是两件事情&#xff1a; 统计数据&#xff1a;统计某个资源的访问数据&#xff08;QPS、RT等信息&#xff09;规则判断&#xff1a;判断限流规则、隔离规…

20240210使用剪映识别字幕的时候的GPU占比RX580-RTX4090

20240210使用剪映识别字幕的时候的GPU占比RX580-RTX4090 2024/2/10 17:54 【使用剪映识别不同的封装格式&#xff0c;不同的音视频编码&#xff0c;对GPU的占用率可能会有比较大的不同&#xff01;】 很容易发现在在WIN10下使用剪映的时候&#xff0c;X99RX550组合。 GPU部分&…

【Spring】Bean 的生命周期

一、Bean 的生命周期 Spring 其实就是一个管理 Bean 对象的工厂&#xff0c;它负责对象的创建&#xff0c;对象的销毁等 所谓的生命周期就是&#xff1a;对象从创建开始到最终销毁的整个过程 什么时候创建 Bean 对象&#xff1f;创建 Bean 对象的前后会调用什么方法&#xf…

【Go】三、Go并发编程

并发编程 我们主流的并发编程思路一般有&#xff1a;多进程、多线程 但这两种方式都需要操作系统介入&#xff0c;进入内核态&#xff0c;是十分大的时间开销 由此而来&#xff0c;一个解决该需求的技术出现了&#xff1a;用户级线程&#xff0c;也叫做 绿程、轻量级线程、协…

大厂的供应链域数据中台设计

关注我&#xff0c;紧跟本系列专栏文章&#xff0c;咱们下篇再续&#xff01; 作者简介&#xff1a;魔都技术专家兼架构&#xff0c;多家大厂后端一线研发经验&#xff0c;各大技术社区头部专家博主&#xff0c;编程严选网创始人。具有丰富的引领团队经验&#xff0c;深厚业务架…

庆除夕,比特币两日大涨10%

号外&#xff1a;教链内参2024年1月合订本 今日除夕。昨日今日两天&#xff0c;比特币从43k发力上攻&#xff0c;一度涨超10%至47.7k&#xff0c;以独特的方式给全世界的bitcoiners送去了新春的祝福。 一个新鲜的知识&#xff1a;2023年12月22日&#xff0c;第78届联合国大会协…

JVM 执行引擎

概念 执行class文件中的指令&#xff0c;由解释器编译器组成 补充——Java为什么是半编译半解释型语言 因为Java即有编译器也有解释器&#xff0c;可以用其中一种来运行。 程序执行步骤 解释器与编译器区别 编译器 概念 JIT&#xff08;Just In Time Compiler&#xff09;…

深入探索Java IO:从基础到高级操作全览

深入探索Java IO&#xff1a;从基础到高级操作全览 Java IO一、概览二、磁盘操作三、字节操作实现文件复制装饰者模式 四、字符操作编码与解码String 的编码方式Reader 与 Writer实现逐行输出文本文件的内容 五、对象操作序列化Serializabletransient 六、网络操作InetAddressU…

机器学习系列——(十三)多项式回归

引言 在机器学习领域&#xff0c;线性回归是一种常见且简单的模型。然而&#xff0c;在某些情况下&#xff0c;变量之间的关系并不是线性的&#xff0c;这时候我们就需要使用多项式回归来建模非线性关系。多项式回归通过引入高次项来扩展线性回归模型&#xff0c;从而更好地拟…

【前端】Vue实现网站导航 以卡片形式显示(附Demo)

目录 前言1. html版本2. Vue2.1 Demo12.2 Demo2 前言 单独做一个跳转页面推荐阅读&#xff1a;【前端】实现Vue组件页面跳转的多种方式 但是如果网站多了&#xff0c;推荐卡片式导航&#xff0c;具体可看下文&#xff1a;&#xff08;以图片显示显示各个网站&#xff0c;图片…

MySQL-视图(VIEW)

文章目录 1. 什么是视图&#xff1f;2. 视图 VS 数据表3. 视图的优点4. 视图相关语法4.1 创建视图4.2 查看视图4.3 修改视图4.4 删除视图4.5 检查选项 5. 案例6. 注意事项 1. 什么是视图&#xff1f; MySQL 视图&#xff08; View&#xff09;是一种虚拟存在的表&#xff0c;同…

七、滚动条操作——调整图像对比度

对比度调整&#xff1a;是在原来图像基础上进行相应的公式调整&#xff0c;是类似乘法操作&#xff0c;本身像数值越大&#xff0c;对比度增加之后其与低像素点值差距越大&#xff0c;导致对比增强 项目最终效果&#xff1a;通过滚动条trackbar来实现调整图片亮度的功能 我这里…