In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
In this issue, the editor will bring you what to do if you encounter problems in the deployment of Kubeless functions. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.
So how do you Debug a function in Kubeless? The following describes the possible errors in the function deployment process function and how to Debug to locate and resolve the problem.
Environment description
Operating system: macOS
Kubernetes version: v1.15.5
Kubeless version: v1.0.7
Understand the process of function deployment
There may be many reasons for deployment errors. To learn how to debug a function successfully, the most important thing is to understand the process of deploying the Kubeless function.
In this article, we assume that you use the kubeless CLI tool to deploy the function. In this case, the deployment process of the function is as follows:
Kubeless CLI reads the parameters you give it, generates a function object, and submits it to the Kubernetes API server.
The Kubeless function controller detects that a new Function is created and reads its contents. It generates these from functions: a ConfigMap with function code and dependencies, a Service so that the function can be accessed through HTTP, a Deployment with a base image, and all the necessary steps to install and run the function. It's important to know this order, because if the controller cannot create a ConfigMap or Service, then the Deployment will never be created. Failure of any step terminates the process.
Once Deployment has created a Pod,Pod generated by your function, it will dynamically read the contents of the function (in the case of a parsed language) when it starts.
After you have done all the above, you can call the function. Let's look at some common mistakes and how to solve them.
"kubeless function deploy" failed
The first error that may occur is the parameter error we gave to the kubeless function deploy command. These errors are easy to debug:
$kubeless function deploy-runtime python2-from-file test.py-handler test.hello helloFATA [0000] Invalid runtime: python2. Supported runtimes are: ballerina0.981.0, dotnetcore2.0, dotnetcore2.1, dotnetcore2.2, dotnetcore3.1, go1.13, go1.14, java1.8, java11, nodejs6, nodejs8, nodejs10, nodejs12, php7.2, php7.3, python2.7, python3.4, python3.6, python3.7, ruby2.3, ruby2.4, ruby2.5, ruby2.6, jvm1.8, nodejs_distroless8, nodejsCE8, vertx1.8
From the error log above, we can see that the runtime parameter is wrong and python2 should be changed to python2.7.
"kubeless function ls" returns "MISSING: Check controller logs"
In some cases, validation in CLI is not sufficient to find problems in a given parameter. If this is the case, the function Deployment will never appear. To debug this type of problem, you must check what the error is in the controller log. To retrieve these logs, execute:
$kubeless function deploy hello-runtime python2.7-from-file test.py-handler test,helloINFO [0000] Deploying function... INFO [0000] Function hello submitted for deployment INFO [0000] Check the deployment status executing 'kubeless function ls hello'donghuideMBP:kubeless_demo donghui$ kubeless function ls helloNAME NAMESPACE HANDLER RUNTIME DEPENDENCIES STATUS hello default test,hello python2.7 MISSING: Check controller logs$ kubectl logs-n kubeless- l kubeless=controllerError from server (BadRequest): a container name must be specified for pod kubeless-controller-manager-cd68f56c4-cjbnz Choose one of: [kubeless-function-controller http-trigger-controller cronjob-trigger-controller] $kubectl logs-n kubeless- l kubeless=controller-c kubeless-function-controllertime= "2020-10-01T01:38:42Z" level=info msg= "Processing change to Function default/hello" pkg=function-controllertime= "2020-10-01T01:38:42Z" level=error msg= "Function can not be created/updated: failed: incorrect handler format. It should be module_name.handler_name "pkg=function-controller
We can see from the log that there is a problem with the handler parameter: we should change test,hello to test.hello.
Function pod crash
The most common error is to find that the Deployment is generated successfully, but the function still maintains the state 0 Not ready 1. This is usually caused by syntax errors in functions or dependencies we specify.
If our function does not start, we should check the status of pod as follows:
$kubectl get pods-l function=hello
Init:CrashLoopBackOff of function pod crash
If our function fails because of an Init error, it may mean:
It cannot retrieve the contents of the function
It cannot install dependencies
It cannot compile our function (using compiled language)
For either of these cases, we should first determine which container failed (because each step is performed in a different container):
$kubectl get pods-l function=helloNAME READY STATUS RESTARTS AGEhello-b46455654-v2bs9 0bind 1 Init:CrashLoopBackOff 5 5m2s $kubectl get pods-l function=hello-o yaml... Name: install ready: false restartCount: 5...
As we can see from above, the container install is the container with the problem. Depending on the run time, the container log will also be displayed, so we can find the problem directly. Unfortunately, this is not the case, so let's manually retrieve the log of the install container:
$kubectl logs hello-b46455654-v2bs9-c install-- previous/kubeless/requirements.txt: OKDEPRECATION: Python 2.7reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-supportWARNING: The directory'/ .cache / pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's-H flag.ERROR: Could not find a version that satisfies the requirement jenkinsapi-2020 (from-r / kubeless/requirements.txt (line 1)) (from versions: none) ERROR: No matching distribution found for jenkinsapi-2020 (from-r / kubeless/requirements.txt (line 1)) WARNING: You are using pip version 20.0.2; however, version 20.2.3 is available.You should consider upgrading via the'/ usr/local/bin/python-m pip install-upgrade pip' command.
Now we can find that the problem is that we have the wrong module block name in requirements.txt. We should change jenkinsapi-2020 to jenkinsapi.
CrashLoopBackOff of function pod crash
With Pod in this state, we should retrieve the log of the runtime container:
$kubectl logs-l function=helloTraceback (most recent call last): File "/ kubeless.py", line 17, in'/ kubeless/%s.py'% os.getenv ('MOD_NAME') File "/ kubeless/test.py", line 1 import requests123 ^ SyntaxError: invalid syntax
We can see that we have a syntax error: import requests123, which should be changed to: import requests.
The function returns "Internal Server Error"
In some cases, pod does not crash, but the function returns an error:
$kubectl get pods-l function=helloNAME READY STATUS RESTARTS AGEhello-c6946586b-thb8b 1 an error on the server 1 Running 0 29s $kubeless function call hello--data'{"username": "test"} 'ERRO [0000] FATA [0000] an error on the server ("Error: 500 Internal Server Error Html {background-color: # eee Font-family: sans;} body {background-color: # fff; border: 1px solid # ddd; padding: 15px; margin: 15px;} pre {background-color: # eee; border: 1px solid # ddd; padding: 5px;} Error: 500Internal Server Error
Sorry, the requested URL & # 039; http://kubernetes.docker.internal:6443/' caused an error:
Internal Server Error ") has prevented the request from succeeding
This usually means that the function is syntactically correct, but there are errors. To check the problem again, we should check the function log:
$kubectl logs-l function=hello File "/ usr/local/lib/python2.7/dist-packages/bottle.py", line 862, in _ handle return route.call (* * args) File "/ usr/local/lib/python2.7/dist-packages/bottle.py", line 1740, in wrapper rv = callback (* a, * * ka) File "/ kubeless.py", line 91, in handler raise resKeyError: 'user' {' event-time': '2020-10-01T03Fran 04ve27Z' 'extensions': {' request':}, 'event-type':' application/json', 'event-namespace':' cli.kubeless.io', 'data': {upright username: upright test'} 'event-id':' fltxfHu2hF5M2TQ'} 10.1.0.1-- [01/Oct/2020:03:04:27 + 0000] "POST / HTTP/1.1" 500758 "" kubeless/v0.0.0 (darwin/amd64) kubernetes/$Format "0GET 2372310.1.0.1-- [01/Oct/2020:03:04:57 + 0000]" GET / healthz HTTP/1.1 "2002"kube-probe/1.15" 0142
Look at the function code that caused the error:
Def hello (event, context): print event return event ['data'] [' user'] ['name']
Here, change event ['data'] [' user'] ['name'] to event [' data'] ['username'].
This is what happened to the deployment of the Kubeless function shared by the editor. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.