-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathgather_spoke_logs
More file actions
executable file
·115 lines (94 loc) · 5.19 KB
/
gather_spoke_logs
File metadata and controls
executable file
·115 lines (94 loc) · 5.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#! /bin/bash
# Copyright (c) 2023 Red Hat, Inc.
# Copyright Contributors to the Open Cluster Management project
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
source ${SCRIPT_DIR}/gather_utils
HC_NAME=${HC_NAME:-""}
HC_NAMESPACE=${HC_NAMESPACE:-"clusters"}
gather_spoke() {
# collect CRDs to aid automated must-gather readers
log "Gathering spoke information for MCE"
run_inspect customresourcedefinition.apiextensions.k8s.io
run_inspect klusterlets.operator.open-cluster-management.io --all-namespaces
run_inspect clusterclaims.cluster.open-cluster-management.io --all-namespaces
run_inspect appliedmanifestworks.work.open-cluster-management.io --all-namespaces
KLUSTERLETS_NAMES=$(oc get klusterlets.operator.open-cluster-management.io -o name)
for name in ${KLUSTERLETS_NAMES}; do
local agent_namespace
local mode
mode=$(oc get "$name" -o jsonpath='{.spec.deployOption.mode}')
log "klusterlet $name is deployed in $mode mode"
if [ "$mode" = 'Hosted' ] || [ "$mode" = 'SingletonHosted' ]; then
agent_namespace=$name
else
agent_namespace=$(oc get "$name" -o jsonpath='{.spec.namespace}')
fi
log "klusterlet name: $name, agent namespace: $agent_namespace"
run_inspect ns/"$agent_namespace"
done
# gather all the customized addon namespaces
run_inspect ns/"open-cluster-management-agent-addon"
CUSTOMIZED_ADDON_NAMESPACES=$(oc get ns -l addon.open-cluster-management.io/namespace=true --no-headers=true -o custom-columns="NAME:.metadata.name")
for addon_namespace in ${CUSTOMIZED_ADDON_NAMESPACES}; do
run_inspect ns/"$addon_namespace"
done
run_inspect ns/openshift-operators # gatekeeper and volsync operator will be installed in this ns in production
}
log "Starting Managed cluster must-gather"
gather_spoke
parse_args "$@"
dump_hostedcluster
if oc get crd policies.policy.open-cluster-management.io &>/dev/null; then
log "Gathering spoke information for ACM"
# application resources on managed cluster
run_inspect subscriptions.apps.open-cluster-management.io --all-namespaces
run_inspect helmreleases.apps.open-cluster-management.io --all-namespaces
run_inspect subscriptionstatus.apps.open-cluster-management.io --all-namespaces
run_inspect workmanagers.agent.open-cluster-management.io --all-namespaces
run_inspect applicationmanagers.agent.open-cluster-management.io --all-namespaces
run_inspect certpolicycontrollers.agent.open-cluster-management.io --all-namespaces
run_inspect iampolicycontrollers.agent.open-cluster-management.io --all-namespaces
run_inspect policycontrollers.agent.open-cluster-management.io --all-namespaces
run_inspect searchcollectors.agent.open-cluster-management.io --all-namespaces
run_inspect policies.policy.open-cluster-management.io --all-namespaces
run_inspect certificatepolicies.policy.open-cluster-management.io --all-namespaces
run_inspect iampolicies.policy.open-cluster-management.io --all-namespaces
# ref: https://github.com/openshift/oc/pull/1550/files#diff-6f6b5698b5c7ebfc01c64967180a4d2e5f2f248509dae99f7d0d07e13018c366
log "ConfigurationPolicies throw error 'the server doesn't have a resource type ', which can be ignored."
run_inspect configurationpolicies.policy.open-cluster-management.io --all-namespaces
run_inspect operatorpolicies.policy.open-cluster-management.io --all-namespaces
log "Starting Gatekeeper must-gather"
for i in $(oc get crds -o custom-columns=NAME:.metadata.name | grep '\.gatekeeper\.sh$'); do
run_inspect "$i" --all-namespaces
done
# Observability CRs
run_inspect ns/open-cluster-management-addon-observability
# user workload metrics config - collect observability-metrics-custom-allowlist across all namespaces
OBSERVABILITY_NAMESPACES=$(oc get configmap --all-namespaces --field-selector=metadata.name=observability-metrics-custom-allowlist -o jsonpath='{.items[*].metadata.namespace}')
for namespace in ${OBSERVABILITY_NAMESPACES}; do
run_inspect configmap/observability-metrics-custom-allowlist -n "${namespace}"
done
# MCOA resources
for addon_namespace in ${CUSTOMIZED_ADDON_NAMESPACES}; do
run_inspect prometheusagents.monitoring.rhobs -n "$addon_namespace"
run_inspect prometheusrules.monitoring.coreos.com -n "$addon_namespace"
done
run_inspect scrapeconfigs.monitoring.rhobs --all-namespaces
run_inspect ns/openshift-cluster-observability-operator
# Cluster and user workload monitoring config for alert forwarding
run_inspect configmap/cluster-monitoring-config -n openshift-monitoring
run_inspect configmap/user-workload-monitoring-config -n openshift-user-workload-monitoring
# VolSync CRs
run_inspect replicationdestinations.volsync.backube --all-namespaces
run_inspect replicationsources.volsync.backube --all-namespaces
run_inspect ns/openshift-operators # gatekeeper and volsync operator will be installed in this ns in production
run_inspect ns/openshift-gatekeeper-system
run_inspect ns/openshift-gatekeeper-operator
run_inspect ns/open-cluster-management-policies
# Submariner logs
run_inspect ns/submariner-operator
# Get disconnected information
run_inspect imagecontentsourcepolicies.operator.openshift.io --all-namespaces
# Version info
run_inspect clusterversions
fi