1. 背景介绍
- kubeless-v1.0.7
- kubeless runtime: python3.7
在向kubeless无服务计算框架发送http请求时,如果http的请求实体过大,kubeless会报’413 Request Entity Too Large’的错误。
使用的kubeless runtime为python3.7,主要原因runtime是基于bottle web框架进行构建的,而python bottle模块对请求体的大小进行了限制,解决方案也很简单:基于现有的python3.7 runtime进行修改,并重新制作成镜像,替换掉原来的python3.7 runtime.
2. Python3.7 Runtime修改
- 向kubeless python3.7 runtime文件——kubeless.py中添加如下内容:
1 2
| bottle.BaseRequest.MEMFILE_MAX = 1024 * 1024
|
3. 制作镜像
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| FROM bitnami/minideb-runtimes:stretch
RUN install_packages build-essential ca-certificates curl git libbz2-1.0 libc6 libffi6 libncurses5 libreadline7 libsqlite3-0 libssl1.1 libtinfo5 pkg-config unzip wget zlib1g RUN wget -nc -P /tmp/bitnami/pkg/cache/ https://downloads.bitnami.com/files/stacksmith/python-3.7.1-0-linux-amd64-debian-9.tar.gz && \ echo "4f1a47dc398b6942d328662b5a7719358fb7788afc746b0e4935ffb165140596 /tmp/bitnami/pkg/cache/python-3.7.1-0-linux-amd64-debian-9.tar.gz" | sha256sum -c - && \ tar -zxf /tmp/bitnami/pkg/cache/python-3.7.1-0-linux-amd64-debian-9.tar.gz -P --transform 's|^[^/]*/files|/opt/bitnami|' --wildcards '*/files' && \ rm -rf /tmp/bitnami/pkg/cache/python-3.7.1-0-linux-amd64-debian-9.tar.gz
ENV BITNAMI_APP_NAME="python" \ BITNAMI_IMAGE_VERSION="3.7.1-r0" \ PATH="/opt/bitnami/python/bin:$PATH"
RUN curl https://bootstrap.pypa.io/get-pip.py --output get-pip.py RUN python ./get-pip.py
RUN pip install bottle==0.12.13 cherrypy==8.9.1 wsgi-request-logger prometheus_client requests
WORKDIR /
ADD kubeless.py .
USER 1000
ENV PYTHONUNBUFFERED 1 CMD ["python", "/kubeless.py"]
|
1
| $ docker build -t mykubeless/python37:debug .
|
4. 替换镜像
修改kubeless的安装文件,将python3.7的runtime镜像替换为自己的runtime镜像。文件地址为:
https://github.com/kubeless/kubeless/releases/download/v1.0.7/kubeless-v1.0.7.yaml
Reference