Distributed Cloud connected 支持部署多项 服务 Google Cloud 。这些服务工作负载在 Distributed Cloud connected 集群上的 Kubernetes 容器中运行。
受支持的服务 Google Cloud
Distributed Cloud connected 支持部署以下 Google Cloud 服务:
| 服务类型 | 包含在 GDC connected 费用中 | 单独计费 |
|---|---|---|
| 计算 | 纯软件 Google Distributed Cloud VM Runtime on Google Distributed Cloud |
客机操作系统 (您必须自行获取许可) |
| 存储 | 容器存储接口 (CSI) 混合存储 |
软件定义存储 (SDS), 例如 Symcloud Storage (您必须自行获取许可) |
| 网络 | Edge Network API VLAN 支持 GKE 自定义网络接口 (CNI) 插件 GKE 捆绑式 L4 负载均衡器 |
不适用 |
| AI/ML | 在容器中部署 AutoML 模型 | 不适用 |
| 数据库 | 无 | AlloyDB Omni(预览版) 第三方数据库解决方案,例如 MongoDB (您必须自行获取许可) |
| 可观测性 | Cloud Logging Cloud Monitoring Cloud Logging API GDCc 日志和指标 |
PrometheusPrometheus 应用级自定义日志和指标 |
| 配置管理 | Config Sync 在 Distributed Cloud connected 中使用舰队软件包 舰队软件包(预览版) |
不适用 |
| 管理 | 控制台中的 Google Kubernetes Engine 信息中心 Google Cloud 连接网关 kubectl 本地工具Distributed Cloud connected 软件升级 |
不适用 |
| 安全性 | Cloud Key Management Service 集成 自加密磁盘 (SED) 驱动器 Fleet Workload Identity 审核日志记录 |
不适用 |
前提条件
您必须先完成本部分列出的前提条件,然后才能在 Distributed Cloud connected 上部署 Google Cloud 服务。
获取集群凭据
使用以下命令获取用于访问目标集群的凭据:
gcloud container hub memberships get-credentials CLUSTER_ID \
--project="PROJECT_ID"
替换以下内容:
CLUSTER_ID:目标集群的名称。PROJECT_ID:目标 Google Cloud 项目的 ID。
创建或选择集群
如果您尚未创建 Distributed Cloud connected 集群,请按照创建集群中的说明创建一个。创建集群时,请至少指定 8 个虚拟 IP 地址 (VIP)。这些 VIP 将由运行服务工作负载的 Kubernetes 容器 Google Cloud 使用。
如果您使用的是现有集群,请使用以下命令验证该集群上是否有足够的 VIP:
kubectl get cluster --all-namespaces -o jsonpath="{.items[0].spec.loadBalancer.addressPools}"
该命令会返回类似于以下内容的输出:
[
{
"addresses": [
"10.200.11.188-10.200.11.196"
],
"name": "loadBalancerAddressPool-1"
}
]
如果集群上预配的 VIP 不足,则会显示以下错误,
其中 n 是所需的 VIP 数量,而 m 是在集群上发现的
VIP 数量:
Cluster has less than n external IPs, got m.
如果您收到此错误,则必须删除并重新创建集群,并提供足够数量的 VIP。
配置 Google Cloud 服务子网域
在 Distributed Cloud connected 区域中部署第一个 Google Cloud 服务之前,您可以选择自定义该区域中部署的所有 Google Cloud 服务 将监听连接的子网域。在该 Distributed Cloud 区域中部署至少一项服务后,您将无法修改此子网域。
使用以下命令查看子网域配置:
kubectl -n dns-system get celldns cell-dns -o yaml
该命令会返回类似于以下内容的输出:
apiVersion: system.private.gdc.goog/v1alpha1
kind: CellDNS
metadata:
name: cell-dns
namespace: dns-system
spec:
delegatedSubdomain: private.goog
使用以下命令修改子网域配置:
kubectl -n dns-system edit celldns cell-dns
在 Distributed Cloud connected 上部署 Google Cloud 服务
如需在 Distributed Cloud connected 集群上部署服务,请按照该服务的文档中所述的部署步骤操作。 Google Cloud
配置已部署的 Google Cloud 服务
本部分介绍了您可以根据业务需求选择完成的部署后配置步骤。
将来自内部 DNS 的 DNS 查询转发到集群的 DNS
在 Distributed Cloud connected 集群上部署 Google Cloud 服务时,系统会在集群上为该服务部署专用 DNS 服务器。我们建议您将服务子网域的 DNS 查询转发到集群上新创建的 DNS 服务器。
使用以下命令获取集群子网域:
CLUSTER_SUBDOMAIN=$(kubectl get configmap -n \ $(kubectl get clusters -A -o jsonpath="{.items[0].metadata.namespace}") \ dns-prefix -o jsonpath="{.data.dnsPrefix}") DELEGATED_SUBDOMAIN=$(kubectl get celldns -n dns-system cell-dns -o \ jsonpath="{.spec.delegatedSubdomain}") CLUSTER_FQDN="${CLUSTER_SUBDOMAIN?}.${DELEGATED_SUBDOMAIN?}" echo "${CLUSTER_FQDN?}"最后一个命令会返回类似于以下内容的输出:
my-zone.google.private.goog使用以下命令获取集群内 DNS 服务器的 VIP:
DNS_EXT_IP=$(k -n dns-system get service gpc-coredns-external-tcp -o "jsonpath={.status.loadBalancer.ingress[0].ip}")将内部 DNS 服务器配置为将已部署服务的 DNS 查询转发到您在上一步中获得的 VIP。 Google Cloud 例如:
对于
dnsmasq,请将以下内容添加到/etc/dnsmasq.conf:server=/${CLUSTER_FQDN?}/${DNS_EXT_IP?}对于 CoreDNS,请将以下内容添加到 Corefile:
${CLUSTER_FQDN?}:53 { errors cache 30 forward . ${DNS_EXT_IP?} { max_concurrent 1000 } }
测试 DNS 解析
使用以下 dig 命令测试网域解析是否正确。请特别注意 ANSWER SECTION:
dig "ais-core.${CLUSTER_FQDN?}"
该命令会返回类似于以下内容的输出:
...
;; ANSWER SECTION:
ais-core.my-zone.google.private.goog. 300 IN A 10.200.0.0
...
检索已部署 Google Cloud 服务的自签名证书
在 Distributed Cloud connected 集群上部署 Google Cloud 服务时, Distributed Cloud connected 会颁发自签名证书,然后使用该证书加密 该服务的网络流量。我们建议您检索此证书,并将您的业务环境配置为信任该证书。
如需以 PEM 编码格式获取此证书,请使用以下命令:
kubectl get secret -n cert-manager-cluster-resources web-ca-cert -o jsonpath="{.data.ca\.crt}" | base64 -d
Distributed Cloud connected 会在整个集群中生成多个信任软件包。这些信任软件包以 ConfigMap 的形式存储在集群上的每个命名空间中。它们分别是:
trust-store-internal-only。包含 Distributed Cloud connected 内部服务的证书授权机构 (CA)。trust-store-root-ext。包含trust-store-root-ext中的所有证书授权机构 (CA),以及签署目标 Google Cloud 服务的自签名证书的证书授权机构 (CA)。如果您需要 Pod 访问目标 Google Cloud 服务,请将此信任软件包挂载到 Pod 中。trust-store-user-ext。包含trust-store-root-ext中的所有证书授权机构 (CA),以及您手动添加的所有证书授权机构 (CA)。如果您需要 Pod 访问目标 Google Cloud 服务以及使用您手动添加的 CA 签署的证书的任何内部 资源,请将此软件包挂载到 Pod 中。
使用以下命令查看目标 ConfigMap:
kubectl -n default get configmap trust-store-user-root-ext -o yaml
以下示例输出显示了典型的 trust-store-user-root-ext ConfigMap 资源:
apiVersion: v1
binaryData:
ca.jks: WW91IGFyZSBhd2Vzb21lIQo=
data:
ca.crt: |-
-----BEGIN CERTIFICATE-----
WW91IGFyZSBncmVhdCEK
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
WW91IGFyZSBmYW50YXN0aWMhCg==
-----END CERTIFICATE-----
kind: ConfigMap
metadata:
labels:
trust.cert-manager.io/bundle: trust-store-user-root-ext
name: trust-store-user-root-ext
namespace: default
将已部署的 Google Cloud 服务配置为信任您自己的证书
您可以在 Distributed Cloud connected 集群中创建 TLS Secret,并在 cert-manager-cluster-resources 命名空间中使用 security.private.gdc.goog/bundles=trust-store-user-root-ext 注解对其进行注解。这样,您部署的 Google Cloud
服务就可以信任您的内部第三方服务,从而方便它们之间的数据交换。
将此 Secret 应用到集群后,已部署的 Google Cloud 服务会信任
Secret 中引用的 ca.crt 文件中存储的 CA 证书。例如:
apiVersion: v1
data:
ca.crt: base64EncodedCaCert
tls.crt: base64EncodedCert
tls.key: base64EncodedKey
kind: Secret
metadata:
annotations:
security.private.gdc.goog/bundles: trust-store-user-root-ext
name: my-corporate-cert
namespace: cert-manager-cluster-resources
type: kubernetes.io/tls
配置身份验证提供方
您可以配置身份验证提供方,以便通过已部署 Google Cloud 服务的用户界面轻松登录。以下示例展示了 OpenID Connect 提供方的配置:
apiVersion: authentication.gke.io/v2alpha1
kind: ClientConfig
metadata:
name: default
namespace: kube-public
spec:
authentication:
- name: "google-oidc"
oidc:
clientID: "my-supersecret-client-id.apps.googleusercontent.com"
clientSecret: "my-supersecret-secret"
issuerURI: "https://accounts.google.com"
scopes: "email"
userClaim: "email"
name: "default"
如需了解详情,请参阅 为各个集群设置 GKE 身份认证服务。
使用已部署的 Google Cloud 服务
如需了解如何配置已部署的 Google Cloud 服务以满足您的业务需求,请参阅该服务的 文档。
移除已部署的 Google Cloud 服务
如需从 Distributed Cloud connected 集群中移除已部署的 Google Cloud 服务, 请按照该服务的文档中的步骤操作。如果您完成了本页面上介绍的任何可选部署后步骤,还请执行以下操作:
- 在内部 DNS 中停用向服务子网域的 DNS 转发。
- 在已建立信任的任何位置停用对服务的自签名证书的信任。