您可以使用 Tanzu CLI 在 主管 上的 TKG 2 集群中安装 Tanzu 软件包。

Tanzu 软件包安装要求

您可以使用 Tanzu CLI 在 主管 上的 TKG 2 集群中安装 Tanzu 软件包。您可以通过调用命令 tanzu package install 来执行此操作。有关完整的用法详情,请参阅 Tanzu CLI 参考指南

要在 主管 上的 TKG 2 集群中安装 Tanzu 软件包,请满足以下必备条件。

安装并验证 Tanzu 软件包存储库

要使用 Tanzu CLI 安装 Tanzu 软件包,您需要使用 kubectl 安装 Tanzu 软件包存储库。要执行此操作,请参见安装软件包存储库

安装 Tanzu 软件包存储库后,使用 Tanzu CLI 验证配置了默认软件包存储库,且存储库状态为 Reconcile succeeded
tanzu package repository list -n tanzu-package-repo-global
NAME            REPOSITORY                                               TAG     STATUS
tanzu-standard  projects.registry.vmware.com/tkg/packages/standard/repo  v1.6.0  Reconcile succeeded

安装证书管理器

获取可用的 cert-manager 版本。
tanzu package available list cert-manager.tanzu.vmware.com -n tanzu-package-repo-global
安装 cert-manager 软件包。使用最新的可用版本。相应地更新此命令。
tanzu package install cert-manager --package-name cert-manager.tanzu.vmware.com --version 1.7.2+vmware.1-tkg.1 --namespace tanzu-package-repo-global
验证 cert-manager 的安装。
tanzu package installed get cert-manager -n cert-manager-package
 
NAME:                    cert-manager
PACKAGE-NAME:            cert-manager.tanzu.vmware.com
PACKAGE-VERSION:         1.7.2+vmware.1-tkg.1
STATUS:                  Reconcile succeeded

安装 Contour

创建 contour-data-values.yaml 文件。有关配置选项,请参见 Contour 软件包配置
---
infrastructure_provider: vsphere
namespace: tanzu-system-ingress
contour:
 configFileContents: {}
 useProxyProtocol: false
 replicas: 2
 pspNames: "vmware-system-restricted"
 logLevel: info
envoy:
 service:
   type: LoadBalancer
   annotations: {}
   nodePorts:
     http: null
     https: null
   externalTrafficPolicy: Cluster
   disableWait: false
 hostPorts:
   enable: true
   http: 80
   https: 443
 hostNetwork: false
 terminationGracePeriodSeconds: 300
 logLevel: info
 pspNames: null
certificates:
 duration: 8760h
 renewBefore: 360h
获取可用的 Contour 软件包版本。
tanzu package available list contour.tanzu.vmware.com -n tanzu-package-repo-global
安装 Contour。使用最新的可用版本。相应地更新此命令。
tanzu package install contour --package-name contour.tanzu.vmware.com --version 1.20.2+vmware.1-tkg.1 --values-file ./contour-data-values.yaml --namespace tanzu-system-ingress --create-namespace
验证 Contour 安装。
tanzu package installed get contour --namespace tanzu-system-ingress
 
NAME:                    contour
PACKAGE-NAME:            contour.tanzu.vmware.com
PACKAGE-VERSION:         1.20.2+vmware.1-tkg.1
STATUS:                  Reconcile succeeded

安装 Harbor

获取可用的 Harbor 软件包版本。
tanzu package available list harbor.tanzu.vmware.com -A
创建 harbor-data-values.yaml 文件。
image_url=$(kubectl -n tanzu-package-repo-global get packages harbor.tanzu.vmware.com.2.5.3+vmware.1-tkg.1 -o jsonpath='{.spec.template.spec.fetch[0].imgpkgBundle.image}')
 
imgpkg pull -b $image_url -o /tmp/harbor-package
 
cp /tmp/harbor-package/config/values.yaml harbor-data-values.yaml
harbor-data-values.yaml 文件中设置必需的密码和密钥。
bash /tmp/harbor-package/config/scripts/generate-passwords.sh harbor-data-values.yaml
编辑 harbor-data-values.yaml 文件并配置以下必需参数的值。有关详细信息,请参见《 使用 Kubectl 安装用于 Harbor 注册表的 Tanzu 软件包》。
  • hostname - 用于访问 Harbor 管理控制台和注册表服务的 FQDN。
  • namespace - 输入要部署 Harbor 的命名空间
  • port - 输入用于运行 Harbor 的端口
  • harborAdminPassword - 输入 Harbor 的管理员密码
  • secretKey – 提供包含 16 个字符的字母数字字符串密钥;请注意,“generate-passwords.sh”脚本将为您生成值。

移除 harbor-data-values.yaml 文件中任何不必要的注释。

安装 Harbor。使用最新的可用版本。相应地更新此命令。
tanzu package install harbor --package harbor.tanzu.vmware.com --version 2.5.3+vmware.1-tkg.1 --values-file ./harbor-data-values.yaml --namespace tanzu-system-registry
验证 Harbor 安装。
tanzu package installed get harbor --namespace tanzu-system-registry
 
NAME:                    harbor
PACKAGE-NAME:            harbor.tanzu.vmware.com
PACKAGE-VERSION:         2.5.3+vmware.1-tkg.1
STATUS:                  Reconcile succeeded

要访问 Harbor 接口,请创建 Contour 配置的 Envoy 外部 IP 的 DNS 记录。有关其他指导,请参见使用 LoadBalancer 类型的 Envoy 服务为 Harbor 配置 DNS(NSX-T 网络连接)

安装 Prometheus

获取可用的 Prometheus 软件包版本。
tanzu package available list prometheus.tanzu.vmware.com -n tanzu-package-repo-global
创建 prometheus-data-values.yaml 文件。
image_url=$(kubectl -n tanzu-package-repo-global get packages prometheus.tanzu.vmware.com.2.36.2+vmware.1-tkg.1 -o jsonpath='{.spec.template.spec.fetch[0].imgpkgBundle.image}')
 
imgpkg pull -b $image_url -o /tmp/prometheus-package-2.36.2+vmware.1-tkg.1
 
cp /tmp/prometheus-package-2.36.2+vmware.1-tkg.1/config/values.yaml prometheus-data-values.yaml
编辑 prometheus-data-values.yaml 文件,并配置以下值。有关所有可用参数的完整列表,请参见 Prometheus 配置参数
  • Ingress.tlsCertificate.tls.crt - 为输入生成自签名 TLS 证书。(可选)您可以覆盖此证书并提供您自己的证书。
  • ingress.tlsCertificate.tls.key - 为输入生成自签名 TLS 私钥。(可选)您可以覆盖此证书并提供您自己的证书。
  • ingress.enabled - 将值设置为 true
  • ingress.virtual_host_fqdn - 将值设置为 prometheus.<your-domain>

移除 prometheus-data-values.yaml 文件中任何不必要的注释。

安装 Prometheus 软件包。使用最新的可用版本。相应地更新此命令。
tanzu package install prometheus --package-name prometheus.tanzu.vmware.com --version 2.36.2+vmware.1-tkg.1 --values-file ./prometheus-data-values.yaml --namespace tanzu-system-monitoring --create-namespace
验证 Prometheus 安装。
tanzu package installed get prometheus -n tanzu-system-monitoring
 
NAME:                    prometheus
PACKAGE-NAME:            prometheus.tanzu.vmware.com
PACKAGE-VERSION:         2.36.2+vmware.1-tkg.1
STATUS:                  Reconcile succeeded

安装 Grafana

获取可用的 Grafana 软件包版本。
tanzu package available list grafana.tanzu.vmware.com -A
创建 gafana-data-values.yaml 文件。
image_url=$(kubectl -n tanzu-package-repo-global get packages grafana.tanzu.vmware.com.7.5.16+vmware.1-tkg.1 -o jsonpath='{.spec.template.spec.fetch[0].imgpkgBundle.image}')
 
imgpkg pull -b $image_url -o /tmp/grafana-package-7.5.16+vmware.1-tkg.1
 
cp /tmp/grafana-package-7.5.16+vmware.1-tkg.1/config/values.yaml grafana-data-values.yaml
编辑 gafana-data-values.yaml 文件并配置值。有关所有可用参数的完整列表,请参见 Grafana 配置参数
  • grafana.service.type - 可以根据需要从 LoadBalancer 更改为 NodePort。
  • grafana.secret.admin_password - 密码必须采用 Base64 编码格式。
  • ingress.virtual_host_fqdn - 将值设置为 grafana.<your-domain>
  • Ingress.tlsCertificate.tls.crt - 为输入生成自签名 TLS 证书。(可选)您可以覆盖此证书并提供您自己的证书。
  • ingress.tlsCertificate.tls.key - 为输入生成自签名 TLS 私钥。(可选)您可以覆盖此证书并提供您自己的证书。

移除 gafana-data-values.yaml 文件中任何不必要的注释。

安装 Grafana 软件包。使用最新的可用版本。相应地更新此命令。
tanzu package install grafana --package-name grafana.tanzu.vmware.com --version 7.5.16+vmware.1-tkg.1 --values-file grafana-data-values.yaml --namespace tanzu-system-dashboards --create-namespace
验证 Grafana 安装。
tanzu package installed get grafana -n tanzu-system-dashboards
 
NAME:                    grafana
PACKAGE-NAME:            grafana.tanzu.vmware.com
PACKAGE-VERSION:         7.5.16+vmware.1-tkg.1
STATUS:                  Reconcile succeeded