Kubernetes Helm 构建无端口 Chart 实践
介绍
使用 helm create 创建 Chart 后,默认生成的是 Web 类型应用,并配置了 Service 和端口探测。如果直接将其更改为无端口的 Worker 类型应用,部署时会报错。因此需要调整 Helm Chart 文件,移除无端口和 Service 相关配置,然后再打包部署。
本文以 busybox 为例,演示如何打包一个无端口的 Helm Chart 并部署到 Kubernetes 中。
无端口 Chart 构建步骤
1. 创建 Chart
helm create xg-busybox
2. 清理无用配置项
- values.yaml:设置
ingress为false。 - deployment.yaml:去掉端口相关的配置
containers.ports。 - service.yaml:删除该配置文件。
修改后的 values.yaml 示例:
replicaCount: 1
image:
repository: registry-vpc.cn-shanghai.aliyuncs.com/yourNamespace/busybox
pullPolicy: IfNotPresent
tag: busybox_1.31
imagePullSecrets:
- name: regcred
nameOverride: ""
fullnameOverride: ""
serviceAccount:
create: true
annotations: {}
name: ""
podAnnotations: {}
podSecurityContext: {}
securityContext: {}
service:
type: ClusterIP
port: 80
ingress:
enabled:
{}
[]
{}
{}
[]
{}

