使用 helm 部署 Python 应用

community_674 2022-03-25 16:15:24

回归下示例Python应用 cloud_native_hello_py 的目录结构:

.
├── Dockerfile
├── README.md
├── k8s.deployment.yaml
├── k8s.service.yaml
└── src
    ├── main.py
    └── requirements.txt

我们使用 kubectl 命令部署过该 Python 服务,现在,我们用 helm 来部署。

首先,在项目命令下通过 helm 命令创建一个chart 配置文件夹

makedir chart
cd chart
helm create hello-py

此时,目录结构如下:

.
├── Dockerfile
├── README.md
├── chart
│   └── hello-py
│       ├── Chart.yaml
│       ├── charts
│       ├── templates
│       │   ├── NOTES.txt
│       │   ├── _helpers.tpl
│       │   ├── deployment.yaml
│       │   ├── hpa.yaml
│       │   ├── ingress.yaml
│       │   ├── service.yaml
│       │   ├── serviceaccount.yaml
│       │   └── tests
│       │       └── test-connection.yaml
│       └── values.yaml
├── k8s.deployment.yaml
├── k8s.service.yaml
└── src
    ├── main.py
    └── requirements.txt

其中:

  • Chart.yaml: 基本描述
  • values.yaml: 配置镜像名称等
  • charts: 用于存放依赖的其他 chart
  • templates: 用于存放需要的配置模板

修改 values.yaml: ```bash replicaCount: 1

image: image: fanfeilong/cloud_native_hello_py pullPolicy: IfNotPresent ```

现在,使用 heml 安装

helm install ./chart/hello-py/ --generate-name

检测下 k8s 的 deployment 和 sevice:


端口转发:


访问服务:


以下说法错误的是?

返回练习题答题页面

...全文
76 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

3

社区成员

发帖
与我相关
我的任务
社区管理员
  • community_674
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧