如何安装具有传输层安全性和 Azure AD 的 VMware Tanzu Application Platform

时间:2022-12-29 20:00:32

如何安装具有传输层安全性和 Azure AD 的 VMware Tanzu Application Platform

本文将解决VMware Tanzu Application Platform的安装问题,并使用传输层安全性(TLS)和Microsoft Windows Azure Active Directory(Azure AD)保护UI。但首先,什么是Tanzu应用平台?

VMware Tanzu Application Platform 是一个模块化的应用感知平台,可提供一组丰富的开发人员工具和预先铺就的生产路径。此外,它还允许开发人员在任何合规的公共云或本地 Kubernetes 集群上快速安全地构建和部署软件。

下面是一个很好的图表,说明Tanzu应用程序平台的概念是什么。要更深入地了解 Tanzu Application Platform 的工作原理,请阅读 Gowtham Shankar 的这篇文章。

如何安装具有传输层安全性和 Azure AD 的 VMware Tanzu Application Platform

安装 Tanzu 应用程序平台非常简单,但这篇文章仍然会帮助解决一些问题。

  1. 首先,请查看先决条件。
  2. 您还需要有权访问 VMware Tanzu Network。
  3. 从 Tanzu 网络下载适用于您的操作系统的 Tanzu 命令行界面 (CLI),然后将其解压缩。
  4. 接下来,您需要在此处下载 Cluster Essentials for VMware Tanzu。
  5. 确保您已接受所有适用的 EULA。
  6. 您还需要一个域,并专门为Tanzu应用程序平台开辟一个子域。请注意,注册表是必需的 - 对于下面的所有示例,将使用 Harbor。

解决了所有这些问题,让我们开始设置一些有用的导出。

export INSTALL_BUNDLE=registry.tanzu.vmware.com/tanzu-cluster-essentials/cluster-essentials-bundle@sha256:ab0a3539da241a6ea59c75c0743e9058511d7c56312ea3906178ec0f3491f51d
export INSTALL_REGISTRY_HOSTNAME=registry.tanzu.vmware.com
export INSTALL_REGISTRY_USERNAME=TANZU-NET-USER
export INSTALL_REGISTRY_PASSWORD=TANZU-NET-PASSWORD
export TAP_VERSION=1.1.0

请注意,以上内容适用于 Tanzu 应用程序平台 1.1.x。如果您尝试安装比此版本更早的版本,则需要查看 Tanzu 应用程序平台文档以获得正确的 I。​​INSTALL_BUNDLE​​​​NSTALL_BUNDLE​

创建一个命名空间以将 Tanzu 应用程序平台安装到其中。

kubectl create ns tap-install

现在,您需要 cd 到解压缩 Tanzu Cluster Essentials 的目录中。

cd $HOME/tanzu-cluster-essentials ## Or wherever you have cluster-essentials untarred

运行安装程序脚本。

./install.sh --yes

如果一切顺利完成,您可以继续将 kapp 复制到我们的路径。

sudo cp $HOME/tanzu-cluster-essentials/kapp /usr/local/bin/kapp ##Or wherever you have cluster-essentials untarred

接下来,安装 Tanzu CLI。

export TANZU_CLI_NO_INIT=true
cd $HOME/tanzu  # or wherever you downloaded the cli
install cli/core/VERSION/tanzu-core-darwin_amd64 /usr/local/bin/tanzu

请务必检查您的版本。

tanzu version

确认版本后,完成插件的全新安装。

tanzu plugin clean

cd $HOME/tanzu # again wherever you have downloaded this
tanzu plugin install --local cli all # make sure you are not in the cli directory when you do this go one directory above it

检查插件。

tanzu plugin list

需要创建容器注册表机密(即 Docker 注册表机密)。

tanzu secret registry add tap-registry \
--username ${INSTALL_REGISTRY_USERNAME} --password ${INSTALL_REGISTRY_PASSWORD} \
--server ${INSTALL_REGISTRY_HOSTNAME} \
--export-to-all-namespaces --yes --namespace tap-install

通过运行以下命令将 Tanzu 应用程序平台包存储库添加到群集:

tanzu package repository add tanzu-tap-repository \
--url registry.tanzu.vmware.com/tanzu-application-platform/tap-packages:$TAP_VERSION \
--namespace tap-install

获取 Tanzu 应用程序平台包存储库的状态,并通过运行以下命令确保状态更新成功为“协调”:

tanzu package repository get tanzu-tap-repository --namespace tap-install

接下来,需要创建 Tanzu 应用程序平台值文件。下面是一些简单的选项,但同样,我们的最终目标是在最终安装中使用 TLS 和 Azure AD。

您可以​​在此处​​找到值文件的示例。下面是标准 Tanzu 应用程序平台值文件的示例。

profile: full
ceip_policy_disclosed: true # Installation fails if this is set to 'false'
buildservice:
kp_default_repository: myharbor.com/tap/build-service
kp_default_repository_username: YOUR_REGISTRY_USER
kp_default_repository_password: YOUR_REGISTRY_PASSWORD
tanzunet_username: YOUR_TANZU_USERNAME
tanzunet_password: YOUR_TANZU_PASSWORD
descriptor_name: "full"
enable_automatic_dependency_updates: true
supply_chain: basic

cnrs:
domain_name: tap.alexanderbrash.dev
domain_template: "{{.Name}}-{{.Namespace}}.{{.Domain}}"

ootb_supply_chain_basic:
registry:
server: myharbor.com
repository: "tap/supply-chain"
gitops:
ssh_secret: ""

learningcenter:
ingressDomain: "learningcenter.tap.alexanderbrash.dev"

tap_gui:
service_type: ClusterIP
ingressEnabled: "true"
ingressDomain: "tap.alexanderbrash.dev"
app_config:
app:
baseUrl: http://tap-gui.tap.alexanderbrash.dev #Note this must be called tap-gui I tried tap-ui and it did not work
catalog:
locations:
- type: url
target: https://github.com/badraoul/tap-test/blob/main/blank/catalog-info.yaml
backend:
baseUrl: http://tap-gui.tap.alexanderbrash.dev #Note this must be called tap-gui I tried tap-ui and it did not work
cors:
origin: http://tap-gui.tap.alexanderbrash.dev #Note this must be called tap-gui I tried tap-ui and it did not work

metadata_store:
app_service_type: LoadBalancer # (optional) Defaults to LoadBalancer. Change to NodePort for distributions that don't support LoadBalancer

grype:
namespace: "default" # (optional) Defaults to default namespace.
targetImagePullSecret: "tap-registry"

contour:
envoy:
service:
type: LoadBalancer

以下是使用 亚马逊云科技网络负载均衡器 (AWS NLB) 的示例。

profile: full
ceip_policy_disclosed: true # Installation fails if this is set to 'false'
buildservice:
kp_default_repository: myharbor.com/tap/build-service
kp_default_repository_username: HARBOR_USER
kp_default_repository_password: HARBOR_PASSWORD
tanzunet_username: TANZU_NET_USER
tanzunet_password: TANZU_NET_PASSWORD
descriptor_name: "tap-1.0.0-full"
enable_automatic_dependency_updates: true
supply_chain: basic

cnrs:
domain_name: alexanderbrash.dev

ootb_supply_chain_basic:
registry:
server: myharbor.com
repository: "tap/supply-chain"
gitops:
ssh_secret: ""

learningcenter:
ingressDomain: "lab.alexanderbrash.dev"

tap_gui:
service_type: ClusterIP
ingressEnabled: "true"
ingressDomain: "alexanderbrash.dev"
app_config:
app:
baseUrl: http://tap-gui.alexanderbrash.dev
catalog:
locations:
- type: url
target: https://github.com/badraoul/tap-test/blob/main/blank/catalog-info.yaml
backend:
baseUrl: http://tap-gui.alexanderbrash.dev
cors:
origin: http://tap-gui.alexanderbrash.dev

metadata_store:
app_service_type: LoadBalancer # (optional) Defaults to LoadBalancer. Change to NodePort for distributions that don't support LoadBalancer

grype:
namespace: "default" # (optional) Defaults to default namespace.
targetImagePullSecret: "tap-registry"

contour:
infrastructure_provider: aws
envoy:
service:
aws:
LBType: nlb

Below is the desired outcome and an example of using TLS.

profile: full
ceip_policy_disclosed: true # Installation fails if this is set to 'false'
buildservice:
kp_default_repository: myharbor.com/tap/build-service
kp_default_repository_username: HARBOR_USER
kp_default_repository_password: HARBOR_PASSWORD
tanzunet_username: TANZU_NET_USER
tanzunet_password: TANZU_NET_PASSWORD
descriptor_name: "full"
enable_automatic_dependency_updates: true
supply_chain: basic

cnrs:
domain_name: tap-lab.alexanderbrash.net
domain_template: "{{.Name}}-{{.Namespace}}.{{.Domain}}"
default_tls_secret: tls-certs/tap-lab-alexbrash-net-wldcrd

ootb_supply_chain_basic:
registry:
server: myharbor.com
repository: "tap/supply-chain"
gitops:
ssh_secret: ""

learningcenter:
ingressDomain: "learningcenter.tap-lab.alexanderbrash.net"

tap_gui:
service_type: ClusterIP
ingressEnabled: "true"
ingressDomain: "tap-lab.alexanderbrash.net"
tls:
secretName: tap-lab-alexbrash-net-wldcrd
namespace: tls-certs
app_config:
app:
baseUrl: https://tap-gui.tap-lab.alexanderbrash.net
catalog:
locations:
- type: url
target: https://github.com/badraoul/tap-test/blob/main/blank/catalog-info.yaml
backend:
baseUrl: https://tap-gui.tap-lab.alexanderbrash.net
cors:
origin: https://tap-gui.tap-lab.alexanderbrash.net

metadata_store:
app_service_type: LoadBalancer # (optional) Defaults to LoadBalancer. Change to NodePort for distributions that don't support LoadBalancer

grype:
namespace: "default" # (optional) Defaults to default namespace.
targetImagePullSecret: "tap-registry"

contour:
envoy:
service:
type: LoadBalancer

要使 TLS 正常工作,您需要为 Envoy 创建一个 TLS 委派和一个命名空间来保存 TLS 机密。

因此,首先,创建命名空间。

kubectl create ns tls-certs

接下来,生成 TLS 委派资源。

cat <<EOF > tls-delegation.yaml
apiVersion: projectcontour.io/v1
kind: TLSCertificateDelegation
metadata:
name: tap-lab-alexbrash-net-wldcrd
namespace: tls-certs
spec:
delegations:
- secretName: tap-lab-alexbrash-net-wldcrd
targetNamespaces:
- "*"

EOF
kubectl apply -f tls-delegation.yaml

现在,在 TLS 证书命名空间中创建证书。

kubectl create secret tls tap-lab-alexbrash-net-wldcrd --key cert-key.pem --cert cert.pem -n tls-certs

之后,添加 Azure AD。默认情况下,Tanzu 应用程序平台 GUI 使用来宾帐户,但 Backstage 支持不同的身份验证提供程序(您可以在此处找到列表)。

将 TLS 添加到 Tanzu 应用程序平台 GUI 的另一个原因是需要启用身份验证。

在Azure门户中,转到“Azure Active Directory”,然后在“应用注册”下单击“新注册”。从这里,只需为其命名,然后在“支持的帐户类型”下为您的组织选择适当的选项。(在此示例中,选择了默认选项。最后,在“重定向URI”下,为平台选择“Web”。

如何安装具有传输层安全性和 Azure AD 的 VMware Tanzu Application Platform

接下来,输入以下统一资源标识符 (URI):

https://tap-gui.yourdomain/api/auth/microsoft/handler/frame

然后,需要创建客户端密码。在“证书和机密”下,选择“新建客户端机密”,然后按照提示操作。请注意,您的客户端密钥是“值”而不是密钥 ID。 (我犯了这个错误,并且正在解决为什么有一段时间不起作用。

对于值文件,您将需要以下三件事:

  1. 客户端标识
  2. 租户标识
  3. 客户端密码

您的值文件现在将如下所示:

profile: full
ceip_policy_disclosed: true # Installation fails if this is set to 'false'
buildservice:
kp_default_repository: HARBOR_REGISTRY_URL/tap/build-service
kp_default_repository_username: HARBOR_USER
kp_default_repository_password: HARBOR_PASSWORD
tanzunet_username: TANZU_NET_USER
tanzunet_password: TANZU_NET_PASSWORD
descriptor_name: "full"
enable_automatic_dependency_updates: true
supply_chain: basic

cnrs:
domain_name: tap.alexanderbrash.dev
domain_template: "{{.Name}}-{{.Namespace}}.{{.Domain}}"
default_tls_secret: tls-certs/tap-alexbrash-dev-wildcard

ootb_supply_chain_basic:
registry:
server: HARBOR_REGISTRY_URL
repository: "tap/supply-chain"
gitops:
ssh_secret: ""

learningcenter:
ingressDomain: "learningcenter.tap.alexanderbrash.dev"

tap_gui:
service_type: ClusterIP
ingressEnabled: "true"
ingressDomain: "tap.alexanderbrash.dev"
tls:
secretName: tap-alexbrash-dev-wildcard
namespace: tls-certs
app_config:
auth:
allowGuestAccess: false
environment: development
providers:
microsoft:
development:
clientId: AZURE_CLIENTID
clientSecret: AZURE_CLIENT_SECRET
tenantId: AZURE_TENANTID
app:
baseUrl: https://tap-gui.tap.alexanderbrash.dev
catalog:
locations:
- type: url
target: https://github.com/badraoul/tap-test/blob/main/blank/catalog-info.yaml
backend:
baseUrl: https://tap-gui.tap.alexanderbrash.dev
cors:
origin: https://tap-gui.tap.alexanderbrash.dev

metadata_store:
app_service_type: LoadBalancer # (optional) Defaults to LoadBalancer. Change to NodePort for distributions that don't support LoadBalancer

grype:
namespace: "default" # (optional) Defaults to default namespace.
targetImagePullSecret: "tap-registry"

contour:
envoy:
service:
type: LoadBalancer

解决了所有这些问题,让我们安装Tanzu应用程序平台。

tanzu package install tap -p tap.tanzu.vmware.com -v $TAP_VERSION --values-file tap-values.yml -n tap-install

您需要确保所有包都成功协调。

tanzu package installed list -n tap-install

请注意:安装时间取决于群集中的可用资源。考虑到这一点,我建议至少四个 m5.x 大节点(即四个节点是 4vCPU 和 16GB RAM,至少 70GB 磁盘空间)。

成功的对帐如下图所示:

如何安装具有传输层安全性和 Azure AD 的 VMware Tanzu Application Platform

就是这样 — 您现在已启动并运行 Tanzu 应用程序平台!