1.3. 订阅报告
订阅报告是来自您的所有受管集群的应用程序状态集合。具体来说,父应用程序资源可以从可扩展的受管集群保存报告。
受管集群的详细应用程序状态可用,而 hub 集群上的 subscriptionReports
则轻便且更具扩展性。请参阅以下三种类型的子状态报告:
-
软件包级的
SubscriptionStatus
:这是受管集群上的应用程序软件包状态,且应用程序在appsub
命名空间中部署的所有资源的详细状态。 -
集群级
SubscriptionReport
:这是与特定集群部署的所有应用程序的整体状态报告。 应用程序级
SubscriptionReport
:这是部署特定应用程序的所有受管集群的总体状态报告。
1.3.1. SubscriptionStatus 软件包级别
软件包级别的受管集群状态位于受管集群上的 <namespace:<your-appsub-namespace>
中,其中包含应用程序部署的所有资源的详细状态。对于部署到受管集群的每个 appsub
,在受管集群的 appsub
命名空间中创建了 SubscriptionStatus
CR。如果存在错误,则会报告每个资源,并带有详细错误。
软件包状态仅指示单个软件包的状态。您可以通过引用字段 .status.subscription
来查看整个订阅状态。
请参阅以下 SubscriptionStatus
示例 YAML 文件:
apiVersion: apps.open-cluster-management.io/v1alpha1 kind: SubscriptionStatus metadata: labels: apps.open-cluster-management.io/cluster: <your-managed-cluster> apps.open-cluster-management.io/hosting-subscription: <your-appsub-namespace>.<your-appsub-name> name: <your-appsub-name> namespace: <your-appsub-namespace> statuses: packages: - apiVersion: v1 kind: Service lastUpdateTime: "2021-09-13T20:12:34Z" Message: <detailed error. visible only if the package fails> name: frontend namespace: test-ns-2 phase: Deployed - apiVersion: apps/v1 kind: Deployment lastUpdateTime: "2021-09-13T20:12:34Z" name: frontend namespace: test-ns-2 phase: Deployed - apiVersion: v1 kind: Service lastUpdateTime: "2021-09-13T20:12:34Z" name: redis-master namespace: test-ns-2 phase: Deployed - apiVersion: apps/v1 kind: Deployment lastUpdateTime: "2021-09-13T20:12:34Z" name: redis-master namespace: test-ns-2 phase: Deployed - apiVersion: v1 kind: Service lastUpdateTime: "2021-09-13T20:12:34Z" name: redis-slave namespace: test-ns-2 phase: Deployed - apiVersion: apps/v1 kind: Deployment lastUpdateTime: "2021-09-13T20:12:34Z" name: redis-slave namespace: test-ns-2 phase: Deployed subscription: lastUpdateTime: "2021-09-13T20:12:34Z" phase: Deployed
apiVersion: apps.open-cluster-management.io/v1alpha1
kind: SubscriptionStatus
metadata:
labels:
apps.open-cluster-management.io/cluster: <your-managed-cluster>
apps.open-cluster-management.io/hosting-subscription: <your-appsub-namespace>.<your-appsub-name>
name: <your-appsub-name>
namespace: <your-appsub-namespace>
statuses:
packages:
- apiVersion: v1
kind: Service
lastUpdateTime: "2021-09-13T20:12:34Z"
Message: <detailed error. visible only if the package fails>
name: frontend
namespace: test-ns-2
phase: Deployed
- apiVersion: apps/v1
kind: Deployment
lastUpdateTime: "2021-09-13T20:12:34Z"
name: frontend
namespace: test-ns-2
phase: Deployed
- apiVersion: v1
kind: Service
lastUpdateTime: "2021-09-13T20:12:34Z"
name: redis-master
namespace: test-ns-2
phase: Deployed
- apiVersion: apps/v1
kind: Deployment
lastUpdateTime: "2021-09-13T20:12:34Z"
name: redis-master
namespace: test-ns-2
phase: Deployed
- apiVersion: v1
kind: Service
lastUpdateTime: "2021-09-13T20:12:34Z"
name: redis-slave
namespace: test-ns-2
phase: Deployed
- apiVersion: apps/v1
kind: Deployment
lastUpdateTime: "2021-09-13T20:12:34Z"
name: redis-slave
namespace: test-ns-2
phase: Deployed
subscription:
lastUpdateTime: "2021-09-13T20:12:34Z"
phase: Deployed
Copy to clipboardCopied1.3.2. SubscriptionReport 集群级别
集群级别状态位于 hub 集群上的 & lt;namespace:<your-managed-cluster-
1>,仅包含该受管集群上每个应用程序的整体状态。hub 集群上的每个集群命名空间中的 subscriptionReport
报告以下状态之一:
-
Deployed
-
Failed
-
propagationFailed
请参阅以下 SubscriptionStatus
示例 YAML 文件:
apiVersion: apps.open-cluster-management.io/v1alpha1 kind: subscriptionReport metadata: labels: apps.open-cluster-management.io/cluster: "true" name: <your-managed-cluster-1> namespace: <your-managed-cluster-1> reportType: Cluster results: - result: deployed source: appsub-1-ns/appsub-1 // appsub 1 to <your-managed-cluster-1> timestamp: nanos: 0 seconds: 1634137362 - result: failed source: appsub-2-ns/appsub-2 // appsub 2 to <your-managed-cluster-1> timestamp: nanos: 0 seconds: 1634137362 - result: propagationFailed source: appsub-3-ns/appsub-3 // appsub 3 to <your-managed-cluster-1> timestamp: nanos: 0 seconds: 1634137362
apiVersion: apps.open-cluster-management.io/v1alpha1
kind: subscriptionReport
metadata:
labels:
apps.open-cluster-management.io/cluster: "true"
name: <your-managed-cluster-1>
namespace: <your-managed-cluster-1>
reportType: Cluster
results:
- result: deployed
source: appsub-1-ns/appsub-1 // appsub 1 to <your-managed-cluster-1>
timestamp:
nanos: 0
seconds: 1634137362
- result: failed
source: appsub-2-ns/appsub-2 // appsub 2 to <your-managed-cluster-1>
timestamp:
nanos: 0
seconds: 1634137362
- result: propagationFailed
source: appsub-3-ns/appsub-3 // appsub 3 to <your-managed-cluster-1>
timestamp:
nanos: 0
seconds: 1634137362
Copy to clipboardCopied1.3.3. SubscriptionReport 应用程序级别
每个应用程序有一个应用程序级 subscriptionReport
,位于 hub 集群的 appsub
命名空间中的 <namespace:<your-appsub-namespace>
,并包含以下信息:
- 每个受管集群的应用程序的整体状态
- 应用程序所有资源的列表
- 带有集群总数的报告概述
-
一个报告摘要,其中包含应用程序处于状态的集群总数:
deployed
,failed
,propagationFailed
, 和inProgress
。
备注: inProcess
状态是总数减 deployed
, 减 failed `, 并减 `propagationFailed
。
请参阅以下 SubscriptionStatus
示例 YAML 文件:
apiVersion: apps.open-cluster-management.io/v1alpha1 kind: subscriptionReport metadata: labels: apps.open-cluster-management.io/hosting-subscription: <your-appsub-namespace>.<your-appsub-name> name: <your-appsub-name> namespace: <your-appsub-namespace> reportType: Application resources: - apiVersion: v1 kind: Service name: redis-master2 namespace: playback-ns-2 - apiVersion: apps/v1 kind: Deployment name: redis-master2 namespace: playback-ns-2 - apiVersion: v1 kind: Service name: redis-slave2 namespace: playback-ns-2 - apiVersion: apps/v1 kind: Deployment name: redis-slave2 namespace: playback-ns-2 - apiVersion: v1 kind: Service name: frontend2 namespace: playback-ns-2 - apiVersion: apps/v1 kind: Deployment name: frontend2 namespace: playback-ns-2 results: - result: deployed source: cluster-1 //cluster 1 status timestamp: nanos: 0 seconds: 0 - result: failed source: cluster-3 //cluster 2 status timestamp: nanos: 0 seconds: 0 - result: propagationFailed source: cluster-4 //cluster 3 status timestamp: nanos: 0 seconds: 0 summary: deployed: 8 failed: 1 inProgress: 0 propagationFailed: 1 clusters: 10
apiVersion: apps.open-cluster-management.io/v1alpha1
kind: subscriptionReport
metadata:
labels:
apps.open-cluster-management.io/hosting-subscription: <your-appsub-namespace>.<your-appsub-name>
name: <your-appsub-name>
namespace: <your-appsub-namespace>
reportType: Application
resources:
- apiVersion: v1
kind: Service
name: redis-master2
namespace: playback-ns-2
- apiVersion: apps/v1
kind: Deployment
name: redis-master2
namespace: playback-ns-2
- apiVersion: v1
kind: Service
name: redis-slave2
namespace: playback-ns-2
- apiVersion: apps/v1
kind: Deployment
name: redis-slave2
namespace: playback-ns-2
- apiVersion: v1
kind: Service
name: frontend2
namespace: playback-ns-2
- apiVersion: apps/v1
kind: Deployment
name: frontend2
namespace: playback-ns-2
results:
- result: deployed
source: cluster-1 //cluster 1 status
timestamp:
nanos: 0
seconds: 0
- result: failed
source: cluster-3 //cluster 2 status
timestamp:
nanos: 0
seconds: 0
- result: propagationFailed
source: cluster-4 //cluster 3 status
timestamp:
nanos: 0
seconds: 0
summary:
deployed: 8
failed: 1
inProgress: 0
propagationFailed: 1
clusters: 10
Copy to clipboardCopied1.3.4. ManagedClusterView
在第一个失败的
集群上报告 ManagedClusterView
CR。如果应用程序在带有资源部署失败的多个集群中部署,则只会为 hub 集群上第一个失败的集群命名空间创建一个 managedClusterView
CR。managedClusterView
CR 从失败集群中检索详细的订阅状态,因此应用程序所有者不需要访问失败的远程集群。
运行以下命令,您可以运行以下命令获取状态:
% oc get managedclusterview -n <failing-clusternamespace> "<app-name>-<app name>"
% oc get managedclusterview -n <failing-clusternamespace> "<app-name>-<app name>"
Copy to clipboardCopied1.3.5. CLI 应用级别状态
如果无法访问受管集群来获取订阅状态,您可以使用 CLI。集群级别或应用程序级别订阅报告提供了整个状态,而不是应用程序的详细错误消息。
- 从 multicloud-operators-subscription 下载 CLI。
-
运行以下命令来创建
managedClusterView
资源来查看受管集群应用程序SubscriptionStatus
,以便您可以识别错误:
% getAppSubStatus.sh -c <your-managed-cluster> -s <your-appsub-namespace> -n <your-appsub-name>
% getAppSubStatus.sh -c <your-managed-cluster> -s <your-appsub-namespace> -n <your-appsub-name>
Copy to clipboardCopied1.3.6. CLI 最后更新时间
当给定受管集群上无法登录到每个受管集群以检索这些信息时,您还可以获得给定受管集群上 AppSub 的 Last Update Time。因此,创建了一个实用程序脚本,以简化受管集群中 AppSub 的 Last Update Time 的检索。这个脚本设计为在 Hub 集群上运行。它会创建一个 managedClusterView 资源,以从受管集群获取 AppSub,并解析数据以获取 Last Update Time。
- 从 multicloud-operators-subscription 下载 CLI。
-
运行以下命令,以检索受管集群中
AppSub
的Last Update Time
。这个脚本设计为在 hub 集群上运行。它会创建一个managedClusterView
资源,以从受管集群获取 AppSub,并解析数据以获取 Last Update Time:
% getLastUpdateTime.sh -c <your-managed-cluster> -s <your-appsub-namespace> -n <your-appsub-name>
% getLastUpdateTime.sh -c <your-managed-cluster> -s <your-appsub-namespace> -n <your-appsub-name>
Copy to clipboardCopied