本文介绍了如何上传自己的二进制文件(Python模块)作为Kubernetes应用程序的资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我自己的Python模块(可以在本地导入的".so"文件),我希望将其提供给在Kubernetes中运行的应用程序.我完全不熟悉Kubernetes和Helm,到目前为止,我所做的文档和尝试还没有使我明白.

I have my own Python module (an '.so' file that I'm able to import locally) that I want to make available to my application running in Kubernetes. I am wholly unfamiliar with Kubernetes and Helm, and the documentation and attempts I've made so far haven't gotten me anywhere.

我查看了 ConfigMaps kubectl.exe create configmap mymodule --from-file=MyModule.so,但kubectl说请求实体太大:限制为3145728". (我的二进制文件约为6mb.)我不知道这是否是将文件保存到那里的适当方法.我还查看了 Helm Charts ,但对于如何打包文件上传. Helm Charts更像是一种配置现有服务部署的方法.

I looked into ConfigMaps, trying kubectl.exe create configmap mymodule --from-file=MyModule.so, but kubectl says "Request entity too large: limit is 3145728". (My binary file is ~6mb.) I don't know if this is even the appropriate way to get my file there. I've also looked at Helm Charts, but I see nothing about how to package up a file to upload. Helm Charts look more like a way to configure deployment of existing services.

打包,上传文件并在我的应用程序中使用它的合适方法是什么(确保在我的AKS集群中运行Python时可以成功import MyModule)?

What's the appropriate way to package up my file, upload it, and use it within my application (ensuring that Python will be able to import MyModule successfully when running in my AKS cluster)?

推荐答案

应该将python模块添加到容器映像,它在Kubernetes中运行,而不是Kubernetes本身.

The python module should be added to the container image that runs in Kubernetes, not to Kubernetes itself.

在Kubernetes中运行的当前容器映像具有构建过程,通常由Dockerfile控制.然后,该容器映像将发布到映像存储库,Kubernetes中的容器运行时可以从中提取图像并运行该容器.

The current container image running in Kubernetes has a build process, usually controlled by a Dockerfile. That container image is then published to an image repository where the container runtime in Kubernetes can pull the image in from and run the container.

如果您当前不构建此容器,则可能需要创建自己的构建过程以将python模块添加到现有容器中.在Dockerfile中,您使用FROM old/image:1.7.1,然后添加您的内容.

If you don't currently build this container, you may need to create your own build process to add the python module to the existing container. In a Dockerfile you use the FROM old/image:1.7.1 and then add your content.

FROM old/image:1.7.1
COPY MyModule.so /app/

将新的容器映像发布到ECR( Elastic Container Registry ),因此可以在您的AKS集群中使用.

Publish the new container image to an ECR (Elastic Container Registry) so it is available for use in your AKS cluster.

然后,您可能需要在Kubernetes中进行的唯一更改是将部署的image设置为新发布的映像.

The only change you might need to make in Kubernetes then is to set the image for the deployment to the newly published image.

这是简单的端到端指南 python应用程序.

Here is a simple end to end guide for a python application.

这篇关于如何上传自己的二进制文件(Python模块)作为Kubernetes应用程序的资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 14:38