全部產品
Search
文件中心

Compute Nest:Helm Chart部署物

更新時間:May 26, 2026

本文為您介紹Helm Chart部署物使用情境與原理,以及如何建立和使用。

使用情境

  • 當使用Helm Chart部署服務時,如果您的Chart包需要保持私密性不公開,則推薦使用計算巢的Helm Chart部署物。這些部署物儲存於計算巢Acr鏡像倉庫中,並通過臨時密鑰實現安全拉取。

    重要

    對於那些可公開訪問的Helm Chart包,直接在服務ROS模板中指定其公開連結即可完成部署,無需額外配置。

  • Helm Chart一般用於服務結構比較複雜,對應的部署資源YAML檔案比較多的情境,用來對部署資源YAML檔案做結構化管理。Helm Chart部署物在計算巢中是託管到Acr倉庫中,具體上傳和拉取原理,請參見容器鏡像部署物

應用原理

Helm Chart部署物在服務範本中怎麼使用呢,主要需要在服務範本中定義以下兩個標識,在部署時進行替換:

  • {{computenest::helmchart::test}}部署物預留位置,替換成Helm Chart的完整地址,如oci://compute-nest-chart-registry.cn-hangzhou.cr.aliyuncs.com/${aliUid}/wordpress:15.4.1

  • {{computenest::helm::dockerconfigjson}}倉庫拉取密鑰,用來拉取託管在計算巢ACR倉庫中的Chart包。

Helm Chart部署使用計算巢定義的公用模組MODULE::ACS::ComputeNest::FluxOciHelmDeploy,裡面使用了開源組件FluxCD,目前僅支援Oci格式的Chart倉庫,計算巢Helm Chart部署物倉庫對應的格式為Oci格式。使用MODULE::ACS::ComputeNest::FluxOciHelmDeploy部署Helm Chart部署物樣本模板如下:

Resources:
  FluxHelmDeploy:
    Type: MODULE::ACS::ComputeNest::FluxOciHelmDeploy
    Version: v1
    Properties:
      ClusterId:
        Ref: ClusterId
      ReleaseName: wordpress
      Namespace: wordpress
      HelmChartUrl: '{{ computenest::helmchart::test }}'
      DockerConfigJson: '{{ computenest::helm::dockerconfigjson }}'
      ChartValues:
        mariadb:
          primary:
            persistence:
              enabled: true
              storageClass: alicloud-disk-essd
              size: 20Gi
        persistence:
          enabled: false
...

建立和使用

前提條件

已安裝Helm Chart並已有鏡像。如果您沒有,請參見推送和拉取Helm Chart

建立Helm Chart部署物

  1. 配置部署物的基本資料。

    1. 登入計算巢控制台,在左側導覽列選擇服務部署物,並在部署物地區中單擊建立部署物

    2. 部署物資訊地區,完成部署物資訊填寫。

      配置項

      說明

      部署物名稱

      由中文、數字、英文及底線組成,長度在 3~128 個字元之間,一個中文字等於 2 個字元,部署物名稱建立後不可修改。

      部署物版本名稱

      由中文、數字、英文及底線組成,長度在 3~50 個字元之間,一個中文字等於 2 個字元。

      部署物描述

      簡介長度在10-500個字元之間,一個中文字等於2個字元。

      資源群組

      選擇建立的部署所歸屬的資源群組名稱。

      資源群組對您擁有的雲資源從用途、許可權、歸屬等維度進行分組,實現企業內部多使用者、多專案的資源分級管理。更多資訊,請參見資源群組

      標籤配置

      選擇或填寫完整的標籤鍵和標籤值,為部署物定標籤。每個資源最多可綁定20列標籤。若無可選的標籤鍵和標籤值,可建立自訂標籤。建立自訂標籤的詳細操作,請參見建立並綁定自訂標籤

  2. 配置Helm Chart部署物。

    1. 部署物內容區塊,選擇部署物類型Helm Chart

    2. 單擊擷取訪問憑證,可以擷取對應命名空間的臨時密鑰,在命令列中按順序執行擷取的命令。

      部署物類型中選擇Helm Chart頁簽。頁面分三步操作:Step 1 登入鏡像倉庫,執行 helm registry login 命令;Step 2 將鏡像打標推送到鏡像倉庫;Step 3 在輸入框中填寫 Chart 名稱(如 chart-name),執行 helm push chart-name.tgz oci://xxx 命令完成推送。

    3. Helm Chart包上傳到計算巢ACR倉庫後,選擇剛上傳的Chart包,並單擊發布部署物

  3. 查看部署物。

    1. 返回服務部署物頁面,單擊部署物名稱,進入部署物詳情介面查看部署進度。

    2. 當狀態為可用時,表示建立完成。

使用Helm Chart部署物

本節以建立私人化部署服務為例,重點介紹在建立服務時使用Helm Chart部署物相關配置。

  1. 登入計算巢控制台

  2. 在左側導覽列中選擇我的服務,在我建立的服務地區下單擊建立新服務

  3. 在建立新服務頁面,建立服務的方式選擇為自訂建立服務,服務類型選擇為私有部署服務,單擊下一步:佈建服務

  4. 根據提示填入服務基本資料,根據實際情況進行選擇並輸入ROS模板。

    在服務ROS模板資源中填入Helm Chart部署物標識 {{ computenest::helmchart::test}} 和部署物拉取密鑰標識 {{ computenest::helm::dockerconfigjson}}

    樣本模板

    說明

    本樣本模板僅可用於測試。

    ROSTemplateFormatVersion: '2015-09-01'
    Description:
      en: 建立ack部署
      zh-cn: new ack
    Parameters:
      PayType:
        Type: String
        Label:
          en: ECS Instance Charge Type
          zh-cn: 付費類型
        Default: PostPaid
        AllowedValues:
          - PostPaid
          - PrePaid
        AssociationProperty: ChargeType
        AssociationPropertyMetadata:
          LocaleKey: InstanceChargeType
      PayPeriodUnit:
        Type: String
        Label:
          en: Pay Period Unit
          zh-cn: 購買資源時間長度周期
        Default: Month
        AllowedValues:
          - Month
          - Year
        AssociationProperty: PayPeriodUnit
        AssociationPropertyMetadata:
          Visible:
            Condition:
              Fn::Not:
                Fn::Equals:
                  - ${PayType}
                  - PostPaid
      PayPeriod:
        Type: Number
        Description:
          en: When the resource purchase duration is Month, the value of Period ranges from 1 to 9, 12, 24, 36, 48, or 60. <br><b><font color='red'> When ECS instance types are PrePaid valid </b></font>
          zh-cn: 當購買資源時間長度為Month時,Period取值:1~9 <br><b><font color='red'>當ECS執行個體類型為PrePaid有效</b></font>
        Label:
          en: Period
          zh-cn: 購買資源時間長度
        Default: 1
        AllowedValues:
          - 1
          - 2
          - 3
          - 4
          - 5
          - 6
          - 7
          - 8
          - 9
        AssociationProperty: PayPeriod
        AssociationPropertyMetadata:
          Visible:
            Condition:
              Fn::Not:
                Fn::Equals:
                  - ${PayType}
                  - PostPaid
      ZoneId:
        Type: String
        AssociationProperty: ALIYUN::ECS::Instance:ZoneId
        Label:
          en: Zone ID
          zh-cn: 可用性區域
      EcsInstanceType:
        Type: String
        Label:
          en: Instance Type
          zh-cn: 執行個體類型
        AssociationProperty: ALIYUN::ECS::Instance::InstanceType
        AssociationPropertyMetadata:
          ZoneId: ${ZoneId}
          InstanceChargeType: ${InstanceChargeType}
      EcsInstancePassword:
        NoEcho: true
        Type: String
        AllowedPattern: '[0-9A-Za-z\_\-\&:;''<>,=%`~!@#\(\)\$\^\*\+\|\{\}\[\]\.\?\/]+$'
        Label:
          en: Instance Password
          zh-cn: 執行個體密碼
        ConstraintDescription:
          en: Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)
          zh-cn: 長度8-30,必須包含三項(大寫字母、小寫字母、數字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符號)
        MinLength: 8
        MaxLength: 30
        AssociationProperty: ALIYUN::ECS::Instance::Password
      ServerSystemDiskCategory:
        Type: String
        AllowedValues:
          - cloud_efficiency
          - cloud_ssd
          - cloud_essd
        AssociationPropertyMetadata:
          LocaleKey: DiskCategory
          InstanceType: ${EcsInstanceType}
        Label:
          en: Server System Disk Category
          zh-cn: Server系統硬碟磁碟類型
        Default: cloud_essd
      ServerSystemDiskSize:
        Type: Number
        Label:
          en: Server System Disk Size(GB)
          zh-cn: Server節點系統硬碟大小(GB)
        MinValue: 1
        Default: 500
      VpcCidrBlock:
        Type: String
        Label:
          en: VPC CIDR IPv4 Block
          zh-cn: 專用網路IPv4網段
        Description:
          zh-cn: VPC的ip位址區段範圍,<br>您可以使用以下的ip位址區段或其子網:<br><font color='green'>[10.0.0.0/8]</font><br><font color='green'>[172.16.0.0/12]</font><br><font color='green'>[192.168.0.0/16]</font>
          en: 'The ip address range of the VPC in the CidrBlock form; <br>You can use the following ip address ranges and their subnets: <br><font color=''green''>[10.0.0.0/8]</font><br><font color=''green''>[172.16.0.0/12]</font><br><font color=''green''>[192.168.0.0/16]</font>'
        Default: 192.168.0.0/16
        AssociationProperty: ALIYUN::VPC::VPC::CidrBlock
      VSwitchCidrBlock:
        Type: String
        Label:
          en: VSwitch CIDR Block
          zh-cn: 交換器子網網段
        Description:
          zh-cn: 必須屬於VPC的子網段。
          en: Must belong to the subnet segment of VPC.
        Default: 192.168.1.0/24
        AssociationProperty: ALIYUN::VPC::VSwitch::CidrBlock
        AssociationPropertyMetadata:
          VpcCidrBlock: VpcCidrBlock
      PodCidr:
        Type: String
        Description:
          zh-cn: 請填寫有效私人網段,即以下網段及其子網:10.0.0.0/8,172.16-31.0.0/12-16,192.168.0.0/16<br>不能與 VPC 及 VPC 內已有 Kubernetes 叢集使用的網段重複。<font color='blue'><b>建立成功後不能修改</b></font>
          en: 'Please fill in a valid private segment, i.e. the following segments and their subnets: 10.0.0.0/8, 172.16-31.0.0/12-16, 192.168.0.0/16<br> which cannot duplicate the network segments already used by clusters in VPC and VPC Kunetberes. <font color=''blue''><b>Cannot be modified after successful creation</b></font>'
        Label:
          zh-cn: Pod 網路 CIDR
          en: Pod Network CIDR
        AssociationProperty: ALIYUN::CS::ManagedKubernetesCluster::PodCidr
        Default: 10.0.0.0/16
      ServiceCidr:
        Type: String
        Description:
          zh-cn: 可選範圍:10.0.0.0/16-24,172.16-31.0.0/16-24,192.168.0.0/16-24<br>不能與 VPC 及 VPC 內已有 Kubernetes 叢集使用的網段重複。<font color='blue'><b>建立成功後不能修改</b></font>
          en: 'Optional range: 10.0.0.0/16-24, 172.16-31.0.0/16-24, 192.168.0.0/16-24<br> cannot duplicate segments already used by existing Kubernetes clusters in VPC and VPC.<font color=''blue''><b>Cannot be modified after successful creation</b></font>'
        Label:
          zh-cn: Service CIDR
          en: Service CIDR
        AssociationProperty: ALIYUN::CS::ManagedKubernetesCluster::ServiceCidr
        Default: 172.16.0.0/16
    Resources:
      EcsVpc:
        Type: ALIYUN::ECS::VPC
        Properties:
          VpcName:
            Ref: ALIYUN::StackName
          CidrBlock:
            Ref: VpcCidrBlock
      EcsVSwitch:
        Type: ALIYUN::ECS::VSwitch
        Properties:
          VSwitchName:
            Ref: ALIYUN::StackName
          VpcId:
            Ref: EcsVpc
          ZoneId:
            Ref: ZoneId
          CidrBlock:
            Ref: VSwitchCidrBlock
      EcsSecurityGroup:
        Type: ALIYUN::ECS::SecurityGroup
        Properties:
          SecurityGroupName:
            Ref: ALIYUN::StackName
          VpcId:
            Ref: EcsVpc
          SecurityGroupEgress:
            - PortRange: '-1/-1'
              Priority: 1
              IpProtocol: all
              DestCidrIp: 0.0.0.0/0
              NicType: intranet
          SecurityGroupIngress:
            - PortRange: '-1/-1'
              Priority: 1
              IpProtocol: all
              SourceCidrIp:
                Ref: PodCidr
              Description: pod網路訪問開放
              NicType: intranet
            - PortRange: '-1/-1'
              Priority: 1
              IpProtocol: all
              SourceCidrIp:
                Ref: VpcCidrBlock
              Description: vpc網路訪問開放
              NicType: intranet
            - PortRange: '-1/-1'
              Priority: 1
              IpProtocol: icmp
              SourceCidrIp: 0.0.0.0/0
              Description: icmp協議連接埠放開
              NicType: intranet
            - Priority: 1
              PortRange: 22/22
              SourceCidrIp: 0.0.0.0/0
              IpProtocol: tcp
            - Priority: 1
              PortRange: 443/443
              SourceCidrIp: 0.0.0.0/0
              IpProtocol: tcp
            - Priority: 1
              PortRange: 3001/3001
              SourceCidrIp: 0.0.0.0/0
              IpProtocol: tcp
            - Priority: 1
              PortRange: 31001/31001
              SourceCidrIp: 0.0.0.0/0
              IpProtocol: tcp
            - Priority: 1
              PortRange: 9000/9000
              SourceCidrIp: 0.0.0.0/0
              IpProtocol: tcp
            - Priority: 1
              PortRange: 3389/3389
              SourceCidrIp: 0.0.0.0/0
              IpProtocol: tcp
            - Priority: 1
              PortRange: 80/80
              SourceCidrIp: 0.0.0.0/0
              IpProtocol: tcp
      CsghubServerInstance:
        Type: ALIYUN::ECS::InstanceGroup
        Properties:
          ZoneId:
            Ref: ZoneId
          IoOptimized: optimized
          InstanceChargeType:
            Ref: PayType
          PeriodUnit:
            Ref: PayPeriodUnit
          Period:
            Ref: PayPeriod
          VpcId:
            Ref: EcsVpc
          VSwitchId:
            Ref: EcsVSwitch
          SecurityGroupId:
            Ref: EcsSecurityGroup
          SystemDiskCategory:
            Ref: ServerSystemDiskCategory
          SystemDiskSize:
            Ref: ServerSystemDiskSize
          MaxAmount: 1
          ImageId: centos_7
          InstanceType:
            Ref: EcsInstanceType
          Password:
            Ref: EcsInstancePassword
          InternetMaxBandwidthOut: 50
          InstanceName:
            Fn::Join:
              - '-'
              - - Ref: ALIYUN::StackName
                - '[1,4]'
      InstanceRunCommand:
        Type: ALIYUN::ECS::RunCommand
        Properties:
          Type: RunShellScript
          Sync: true
          CommandContent:
            Fn::Sub:
              - |
                #!/bin/bash
                yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
                yum makecache fast
                yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin jq
                mkdir -p /etc/docker
                tee /etc/docker/daemon.json <<-'EOF'
                {
                    "registry-mirrors": [
                        "https://docker.m.daocloud.io",
                        "https://mirror.baidubce.com",
                        "https://dockerproxy.com",
                        "https://mirror.iscas.ac.cn",
                        "https://huecker.io",
                        "https://dockerhub.timeweb.cloud",
                        "https://noohub.ru",
                        "https://vlgh0kqj.mirror.aliyuncs.com"
                    ]
                }
                EOF
                systemctl enable docker
                systemctl start docker
                sleep 10
                # 安裝Server
                wget '{{ computenest::file::csgserver }}' -O csghub-main.tar.gz
                tar -xvf csghub-main.tar.gz
                cd /root/csghub-main/deploy/all_in_one
                sed -i 's/SERVER_DOMAIN=[^,)]*/SERVER_DOMAIN=${PublicAddress}/' .env
                sleep 10
                chmod 777 startup.sh
                ./startup.sh
                sleep 10
                docker compose restart user_server
                sleep 10
                docker compose restart nginx
                docker compose restart user_server
                # 執行成功回調WaitCondition結束waitCondition的等待     
              - PublicAddress: 
                  Fn::Select:
                    - 0
                    - Fn::GetAtt:
                        - CsghubServerInstance
                        - PublicIps
          InstanceIds:
            Fn::GetAtt:
              - CsghubServerInstance
              - InstanceIds
          Timeout: 3600
  5. 部署物關聯區塊中可設定Helm關聯。單擊選擇部署物,在彈框中選擇部署物和版本,單擊確定完成Helm Chart部署物替換。

    彈框中關聯標誌符顯示為 {{ computenest::helmchart::wordpress }} 格式,僅可選擇HelmChart類型的部署物。完成關聯後,頁面底部設定Helm關聯地區顯示關聯標誌符與關聯部署物的對應結果。

  6. 完成服務的建立,並測試通過後, 請根據計算巢服務的發布審核標準進行自檢,並提交審核。發布審核標準的詳細資料,請參見發布審核標準

  7. 服務建立完成後,可以在服務詳情頁查看部署物關聯關係。

    在服務詳情頁單擊部署關聯頁簽,再單擊helm關聯子頁簽,可查看關聯標誌符(如 {{ computenest::helmchart::wordpress }})及其對應的部署物資訊和版本號碼。

相關文檔

  • 關於建立計算巢服務的詳細內容,請參見建立服務

  • 當您不再需要部署物或部署物版本時,可刪除該部署物或部署物版本,請參見刪除部署物

  • 當您需要變更部署物內容等資訊時,可通過建立新版本來實現,請參見建立新版本

  • 設定部署物的升級配置,請參見服務升級配置