Skip to content

Commit 8d58161

Browse files
committed
install & remove acm operator and multiCluster observability
1 parent d0fb011 commit 8d58161

5 files changed

Lines changed: 323 additions & 0 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// 02.acm_alerting_ui.cy.ts
2+
// E2E test for validating ACM Alerting UI integration with Cluster Observability Operator (COO)
3+
import { commonPages } from '../../views/common';
4+
import { nav } from '../../views/nav';
5+
6+
const MCP = {
7+
namespace: 'openshift-cluster-observability-operator',
8+
packageName: 'cluster-observability-operator',
9+
operatorName: 'Cluster Observability Operator',
10+
config: {
11+
kind: 'UIPlugin',
12+
name: 'monitoring',
13+
},
14+
};
15+
16+
const MP = {
17+
namespace: 'openshift-monitoring',
18+
operatorName: 'Cluster Monitoring Operator',
19+
};
20+
21+
describe('ACM Alerting UI', () => {
22+
before(() => {
23+
cy.beforeBlockCOO(MCP, MP);
24+
cy.log('=== [Setup] Installing ACM operator and MultiCluster Observability ===');
25+
// install acm through shell script
26+
cy.exec('bash ./cypress/fixtures/coo/acm-install.sh', {
27+
env: { KUBECONFIG: Cypress.env('KUBECONFIG_PATH'), },
28+
failOnNonZeroExit: false,
29+
timeout: 600000, // long time script
30+
});
31+
// update UIPlugin with the acm related content, (OCP enabled since installed from operatorHub)
32+
cy.exec(`oc apply -f ./cypress/fixtures/coo/acm-uiplugin.yaml --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
33+
// add thanos-ruler-custom-rules
34+
cy.exec(`oc apply -f ./cypress/fixtures/coo/acm-alerrule-test.yaml --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
35+
});
36+
37+
it('Admin perspective - Observe Menu', () => {
38+
//cy.visit('/');
39+
nav.sidenav.clickNavLink(['Observe', 'Alerting']);
40+
commonPages.titleShouldHaveText('Alerting');
41+
42+
// TO DO:
43+
// Fleet Management => local-cluster => Observe => Alerting
44+
45+
cy.log('✅ ACM Alerting UI test completed successfully');
46+
});
47+
48+
after(() => {
49+
cy.log('=== [Teardown] Uninstalling ACM operator and cleaning up ===');
50+
cy.exec('bash ./cypress/fixtures/coo/acm-uninstall.sh', {
51+
env: { KUBECONFIG: Cypress.env('KUBECONFIG_PATH') },
52+
failOnNonZeroExit: false,
53+
timeout: 600000,
54+
});
55+
});
56+
});
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: thanos-ruler-custom-rules
5+
namespace: open-cluster-management-observability
6+
data:
7+
custom_rules.yaml: |
8+
groups:
9+
- name: alertrule-testing
10+
rules:
11+
- alert: Watchdog
12+
annotations:
13+
summary: An alert that should always be firing to certify that Alertmanager is working properly.
14+
description: This is an alert meant to ensure that the entire alerting pipeline is functional.
15+
expr: vector(1)
16+
labels:
17+
instance: "local"
18+
cluster: "local"
19+
clusterID: "111111111"
20+
severity: info
21+
- alert: Watchdog-spoke
22+
annotations:
23+
summary: An alert that should always be firing to certify that Alertmanager is working properly.
24+
description: This is an alert meant to ensure that the entire alerting pipeline is functional.
25+
expr: vector(1)
26+
labels:
27+
instance: "spoke"
28+
cluster: "spoke"
29+
clusterID: "22222222"
30+
severity: warn
31+
- name: cluster-health
32+
rules:
33+
- alert: ClusterCPUHealth-jb
34+
annotations:
35+
summary: Notify when CPU utilization on a cluster is greater than the defined utilization limit
36+
description: "The cluster has a high CPU usage: core for"
37+
expr: |
38+
max(cluster:cpu_usage_cores:sum) by (clusterID, cluster, prometheus) > 0
39+
labels:
40+
cluster: "{{ $labels.cluster }}"
41+
prometheus: "{{ $labels.prometheus }}"
42+
severity: critical
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
#!/bin/bash
2+
set -eux
3+
oc patch Scheduler cluster --type='json' -p '[{ "op": "replace", "path": "/spec/mastersSchedulable", "value": true }]'
4+
5+
oc apply -f - <<EOF
6+
apiVersion: v1
7+
kind: Namespace
8+
metadata:
9+
name: open-cluster-management
10+
---
11+
apiVersion: operators.coreos.com/v1
12+
kind: OperatorGroup
13+
metadata:
14+
namespace: open-cluster-management
15+
name: og-global
16+
labels:
17+
og_label: open-cluster-management
18+
spec:
19+
targetNamespaces:
20+
- open-cluster-management
21+
upgradeStrategy: Default
22+
EOF
23+
oc apply -f - <<EOF
24+
---
25+
apiVersion: operators.coreos.com/v1alpha1
26+
kind: Subscription
27+
metadata:
28+
labels:
29+
operators.coreos.com/advanced-cluster-management.open-cluster-management: ""
30+
name: advanced-cluster-management
31+
namespace: open-cluster-management
32+
spec:
33+
installPlanApproval: Automatic
34+
name: advanced-cluster-management
35+
source: redhat-operators
36+
sourceNamespace: openshift-marketplace
37+
---
38+
EOF
39+
tries=30
40+
while [[ $tries -gt 0 ]] &&
41+
! oc -n open-cluster-management rollout status deploy/multiclusterhub-operator; do
42+
sleep 10
43+
((tries--))
44+
done
45+
oc wait -n open-cluster-management --for=condition=Available deploy/multiclusterhub-operator --timeout=300s
46+
oc apply -f - <<EOF
47+
apiVersion: operator.open-cluster-management.io/v1
48+
kind: MultiClusterHub
49+
metadata:
50+
name: multiclusterhub
51+
namespace: open-cluster-management
52+
spec: {}
53+
EOF
54+
sleep 5m
55+
oc wait -n open-cluster-management --for=condition=Available deploy/search-api --timeout=300s
56+
oc wait -n open-cluster-management --for=condition=Available deploy/search-collector --timeout=300s
57+
oc wait -n open-cluster-management --for=condition=Available deploy/search-indexer --timeout=300s
58+
oc -n open-cluster-management get pod
59+
#create multi-cluster
60+
oc create ns open-cluster-management-observability || true
61+
oc apply -f -<<EOF
62+
apiVersion: apps/v1
63+
kind: Deployment
64+
metadata:
65+
name: minio
66+
namespace: open-cluster-management-observability
67+
labels:
68+
app.kubernetes.io/name: minio
69+
spec:
70+
replicas: 1
71+
selector:
72+
matchLabels:
73+
app.kubernetes.io/name: minio
74+
strategy:
75+
type: Recreate
76+
template:
77+
metadata:
78+
labels:
79+
app.kubernetes.io/name: minio
80+
spec:
81+
containers:
82+
- command:
83+
- /bin/sh
84+
- -c
85+
- mkdir -p /storage/thanos && /usr/bin/minio server /storage
86+
env:
87+
- name: MINIO_ACCESS_KEY
88+
value: minio
89+
- name: MINIO_SECRET_KEY
90+
value: minio123
91+
image: quay.io/minio/minio:RELEASE.2021-08-25T00-41-18Z
92+
name: minio
93+
ports:
94+
- containerPort: 9000
95+
protocol: TCP
96+
volumeMounts:
97+
- mountPath: /storage
98+
name: storage
99+
volumes:
100+
- name: storage
101+
persistentVolumeClaim:
102+
claimName: minio
103+
EOF
104+
oc apply -f - <<EOF
105+
apiVersion: v1
106+
kind: PersistentVolumeClaim
107+
metadata:
108+
labels:
109+
app.kubernetes.io/name: minio
110+
name: minio
111+
namespace: open-cluster-management-observability
112+
spec:
113+
storageClassName: gp3-csi
114+
accessModes:
115+
- ReadWriteOnce
116+
resources:
117+
requests:
118+
storage: "1Gi"
119+
EOF
120+
oc apply -f - <<EOF
121+
apiVersion: v1
122+
stringData:
123+
thanos.yaml: |
124+
type: s3
125+
config:
126+
bucket: "thanos"
127+
endpoint: "minio:9000"
128+
insecure: true
129+
access_key: "minio"
130+
secret_key: "minio123"
131+
kind: Secret
132+
metadata:
133+
name: thanos-object-storage
134+
namespace: open-cluster-management-observability
135+
type: Opaque
136+
EOF
137+
oc apply -f -<<EOF
138+
apiVersion: v1
139+
kind: Service
140+
metadata:
141+
name: minio
142+
namespace: open-cluster-management-observability
143+
spec:
144+
ports:
145+
- port: 9000
146+
protocol: TCP
147+
targetPort: 9000
148+
selector:
149+
app.kubernetes.io/name: minio
150+
type: ClusterIP
151+
EOF
152+
oc wait -n open-cluster-management-observability --for=condition=Available deploy/minio --timeout=300s
153+
oc apply -f - <<EOF
154+
apiVersion: observability.open-cluster-management.io/v1beta2
155+
kind: MultiClusterObservability
156+
metadata:
157+
name: observability
158+
spec:
159+
observabilityAddonSpec: {}
160+
storageConfig:
161+
metricObjectStorage:
162+
name: thanos-object-storage
163+
key: thanos.yaml
164+
EOF
165+
sleep 1m
166+
oc wait --for=condition=Ready pod -l alertmanager=observability,app=multicluster-observability-alertmanager -n open-cluster-management-observability --timeout=300s
167+
oc -n open-cluster-management-observability get pod
168+
oc -n open-cluster-management-observability get svc | grep -E 'alertmanager|rbac-query'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: observability.openshift.io/v1alpha1
2+
kind: UIPlugin
3+
metadata:
4+
name: monitoring
5+
spec:
6+
monitoring:
7+
acm:
8+
enabled: true
9+
alertmanager:
10+
url: 'https://alertmanager.open-cluster-management-observability.svc:9095'
11+
thanosQuerier:
12+
url: 'https://rbac-query-proxy.open-cluster-management-observability.svc:8443'
13+
type: Monitoring
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
set -eux
3+
echo "[ACM Uninstall] Using KUBECONFIG=${KUBECONFIG:-~/.kube/config}"
4+
5+
# --- Step 1: delete MultiClusterObservability ---
6+
echo "[ACM Uninstall] Deleting MultiClusterObservability (MCO)..."
7+
oc delete MultiClusterObservability observability -n open-cluster-management-observability --ignore-not-found=true
8+
9+
# --- Step 2: delete MinIO、PVC、Secret、Service ---
10+
echo "[ACM Uninstall] Cleaning up MinIO and related resources..."
11+
oc delete deploy minio -n open-cluster-management-observability --ignore-not-found=true
12+
oc delete pvc minio -n open-cluster-management-observability --ignore-not-found=true
13+
oc delete secret thanos-object-storage -n open-cluster-management-observability --ignore-not-found=true
14+
oc delete svc minio -n open-cluster-management-observability --ignore-not-found=true
15+
16+
# --- Step 3: delete MultiClusterHub ---
17+
echo "[ACM Uninstall] Deleting MultiClusterHub..."
18+
oc delete MultiClusterHub multiclusterhub -n open-cluster-management --ignore-not-found=true
19+
20+
# wait for MultiClusterHub deleted
21+
echo "[ACM Uninstall] Waiting for MultiClusterHub cleanup..."
22+
oc wait MultiClusterHub multiclusterhub -n open-cluster-management --for=delete --timeout=180s || true
23+
24+
# --- Step 4: delete Subscription and OperatorGroup ---
25+
echo "[ACM Uninstall] Deleting ACM Operator Subscription & OperatorGroup..."
26+
oc delete sub advanced-cluster-management -n open-cluster-management --ignore-not-found=true
27+
oc delete og og-global -n open-cluster-management --ignore-not-found=true
28+
29+
# --- Step 5: delete namespace ---
30+
echo "[ACM Uninstall] Deleting ACM-related namespaces..."
31+
oc delete ns open-cluster-management-observability --ignore-not-found=true
32+
oc delete ns open-cluster-management --ignore-not-found=true
33+
34+
# # --- Step 6: clean up CRDs(optional)---
35+
# echo "[ACM Uninstall] Cleaning up CRDs (optional cleanup)..."
36+
# oc delete crd multiclusterhubs.operator.open-cluster-management.io --ignore-not-found=true
37+
# oc delete crd multiclusterobservabilities.observability.open-cluster-management.io --ignore-not-found=true
38+
39+
# --- Step 7: Pod / Finalizer ---
40+
# echo "[ACM Uninstall] Removing potential finalizers..."
41+
# oc get ns open-cluster-management-observability -o json | jq '.spec.finalizers=[]' | oc replace --raw "/api/v1/namespaces/open-cluster-management-observability/finalize" -f - || true
42+
# oc get ns open-cluster-management -o json | jq '.spec.finalizers=[]' | oc replace --raw "/api/v1/namespaces/open-cluster-management/finalize" -f - || true
43+
44+
echo "[ACM Uninstall] ✅ Completed cleanup."

0 commit comments

Comments
 (0)