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'
0 commit comments