You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将自定义Service资源添加到Helmfile中?

如何将自定义Service资源添加到Helmfile中部署?

有三种常见方式可以将你的clickhouse-svc.yaml资源集成到现有Helmfile中:

方式一:直接引用外部YAML文件

在现有ClickHouse release配置中添加manifests字段,指向你的Service文件,Helmfile会在部署Chart的同时应用该资源。

修改后的helmfile.yaml:

---
repositories:
  - name: bitnami
    url: https://charts.bitnami.com/bitnami

releases:
  - name: clickhouse
    namespace: clickhouse
    chart: bitnami/clickhouse
    version: 5.0.1
    values:
      - values.common.yaml
    # 引用外部Service资源文件
    manifests:
      - clickhouse-svc.yaml

environments:
  data-ehp:
    values:
  data-prod:
    values:

注意:确保clickhouse-svc.yaml与helmfile.yaml在同一目录,或者使用相对/绝对路径指定文件位置。

方式二:将Service内容嵌入Helmfile

如果不想单独维护Service文件,可以直接把YAML内容嵌入到manifests字段中:

修改后的helmfile.yaml:

---
repositories:
  - name: bitnami
    url: https://charts.bitnami.com/bitnami

releases:
  - name: clickhouse
    namespace: clickhouse
    chart: bitnami/clickhouse
    version: 5.0.1
    values:
      - values.common.yaml
    # 嵌入Service资源内容
    manifests:
      - |
        apiVersion: v1
        kind: Service
        metadata:
          name: clickhouse-svc
          annotations:
            networking.gke.io/load-balancer-type: "Internal"
        spec:
          type: LoadBalancer
          externalTrafficPolicy: Cluster
          selector:
            statefulset.kubernetes.io/pod-name: clickhouse-shard0-0
          ports:
          - name: http-port
            protocol: TCP
            port: 8123
            targetPort: 8123
          - name: tcp-port
            protocol: TCP
            port: 9000
            targetPort: 9000
          - name: mysql-port
            protocol: TCP
            port: 9004
            targetPort: 9004
          - name: postgresql-port
            protocol: TCP
            port: 9005
            targetPort: 9005

environments:
  data-ehp:
    values:
  data-prod:
    values:

方式三:利用Chart的extraDeploy字段(推荐)

Bitnami官方Chart大多支持extraDeploy字段,可将额外资源作为Helm Release的一部分管理,删除Release时资源会一并清理。

修改你的values.common.yaml,添加Service配置:

# values.common.yaml
extraDeploy:
  - apiVersion: v1
    kind: Service
    metadata:
      name: clickhouse-svc
      annotations:
        networking.gke.io/load-balancer-type: "Internal"
    spec:
      type: LoadBalancer
      externalTrafficPolicy: Cluster
      selector:
        statefulset.kubernetes.io/pod-name: clickhouse-shard0-0
      ports:
      - name: http-port
        protocol: TCP
        port: 8123
        targetPort: 8123
      - name: tcp-port
        protocol: TCP
        port: 9000
        targetPort: 9000
      - name: mysql-port
        protocol: TCP
        port: 9004
        targetPort: 9004
      - name: postgresql-port
        protocol: TCP
        port: 9005
        targetPort: 9005

部署验证

完成配置后,执行以下命令部署所有资源:

helmfile sync
# 或者使用 apply 命令
helmfile apply

内容的提问来源于stack exchange,提问作者Dimitri Kopriwa

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 10:02:31