@@ -4,7 +4,7 @@ export TERM=xterm-256color
4
4
# Configuration
5
5
NAMESPACE=" ${1:- openobserve} " # Use first argument as namespace, default to 'openobserve' if not provided
6
6
RELEASE_NAME=" ${2:- o2} " # Use second argument as release name, default to 'o2' if not provided
7
- NAMESPACE=" o2 "
7
+ NAMESPACE=" o3 "
8
8
RELEASE_NAME=" o2"
9
9
# Function to check pod status
10
10
check_pods () {
@@ -53,6 +53,19 @@ check_pods() {
53
53
fi
54
54
}
55
55
56
+ uninstall () {
57
+ local namespace=$1
58
+ local release_name=$2
59
+
60
+ echo " Uninstalling OpenObserve..."
61
+ helm --namespace " $namespace " uninstall " $release_name "
62
+ if [ $? -ne 0 ]; then
63
+ echo " Failed to uninstall OpenObserve"
64
+ return 1
65
+ fi
66
+ echo " OpenObserve uninstalled successfully"
67
+ }
68
+
56
69
# Function to cleanup resources
57
70
cleanup () {
58
71
local namespace=$1
@@ -61,10 +74,6 @@ cleanup() {
61
74
62
75
echo -e " \nStarting cleanup..."
63
76
64
- # Uninstall helm release
65
- echo " Uninstalling OpenObserve helm release: ${release_name} ..."
66
- helm --namespace " $namespace " uninstall " $release_name "
67
-
68
77
# Delete namespace
69
78
echo " Deleting namespace: ${namespace} "
70
79
kubectl delete namespace " $namespace "
@@ -79,40 +88,111 @@ cleanup() {
79
88
exit $exit_code
80
89
}
81
90
91
+ setup () {
92
+
93
+ # Check if CloudNative PostgreSQL Operator is already installed
94
+ if kubectl get deployment -n cnpg-system cloudnative-pg-controller-manager & > /dev/null; then
95
+ echo " CloudNative PostgreSQL Operator is already installed."
96
+ else
97
+ # Install CloudNative PostgreSQL Operator (prerequisite)
98
+ echo " Installing CloudNative PostgreSQL Operator..."
99
+ kubectl apply -f https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/release-1.22/releases/cnpg-1.22.1.yaml
100
+ fi
101
+
102
+ # wait for the operator to get ready
103
+ echo " Waiting for PostgreSQL Operator to be ready..."
104
+ while true ; do
105
+ if kubectl get pods -n cnpg-system | grep -q " Running" ; then
106
+ echo " PostgreSQL Operator is ready!"
107
+ break
108
+ else
109
+ echo " Waiting for PostgreSQL Operator to be ready..."
110
+ sleep 5
111
+ fi
112
+ done
113
+
114
+ local namespace=$1
115
+ local release_name=$2
116
+
117
+ # Check if the namespace already exists
118
+ if kubectl get namespace " $namespace " > /dev/null 2>&1 ; then
119
+ echo " Namespace '${namespace} ' already exists. Skipping creation."
120
+ else
121
+ echo " Creating namespace '${namespace} '..."
122
+ kubectl create namespace " $namespace "
123
+ fi
124
+
125
+ # Check if OpenObserve is already installed
126
+ if helm --namespace " $namespace " list | grep -q " $release_name " ; then
127
+ echo " OpenObserve is already installed. Skipping installation."
128
+ return 0
129
+ fi
130
+ }
131
+
132
+ # Function to install OpenObserve and its dependencies
133
+ test_basic () {
134
+ local namespace=$1
135
+ local release_name=$2
136
+
137
+ # Create namespace
138
+ echo " Creating namespace: ${namespace} "
139
+ kubectl create namespace " $namespace "
140
+
141
+ # Install OpenObserve helm chart
142
+ echo " Installing OpenObserve helm chart (Release: ${release_name} ) in namespace: ${namespace} "
143
+ helm --namespace " $namespace " upgrade --install " $release_name " . -f values.yaml
144
+
145
+ return $?
146
+ }
147
+
148
+ # Function to install OpenObserve external_secret
149
+ test_with_external_secret () {
150
+ local namespace=$1
151
+ local release_name=$2
152
+
153
+ # Create namespace
154
+ echo " Creating namespace: ${namespace} "
155
+ kubectl create namespace " $namespace "
156
+
157
+ kubectl -n " $namespace " apply -f test_secret.yaml
158
+
159
+ # Install OpenObserve helm chart
160
+ echo " Installing OpenObserve helm chart (Release: ${release_name} ) in namespace: ${namespace} "
161
+ helm --namespace " $namespace " upgrade --install " $release_name " . -f test_values_external_secret.yaml
162
+
163
+ return $?
164
+ }
165
+
82
166
# Print configuration
83
167
echo " Using configuration:"
84
168
echo " Namespace: ${NAMESPACE} "
85
169
echo " Release Name: ${RELEASE_NAME} "
86
170
echo -e " -------------------\n"
87
171
88
- # Start minikube
89
- echo " Starting minikube cluster..."
90
- # minikube start
91
- # if [ $? -ne 0 ]; then
92
- # echo "Failed to start minikube cluster"
93
- # exit 1
94
- # fi
95
-
96
- # Install CloudNative PostgreSQL Operator (prerequisite)
97
- echo " Installing CloudNative PostgreSQL Operator..."
98
- kubectl apply -f https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/release-1.22/releases/cnpg-1.22.1.yaml
172
+ # Setup basic prerequisites
173
+ setup " $namespace " " $release_name "
174
+ if [ $? -ne 0 ]; then
175
+ echo " Failed to setup prerequisites. Exiting."
176
+ return 1
177
+ fi
99
178
100
- # wait for the operator to get ready by sleeping
101
- sleep 60
179
+ # Test 1 - Install basic installation of OpenObserve and dependencies
180
+ # test_basic "$NAMESPACE" "$RELEASE_NAME"
181
+ # # Check pod status
182
+ # check_pods "$NAMESPACE"
183
+ # exit_status=$?
102
184
103
- # Add OpenObserve helm repository
104
- # echo "Adding OpenObserve helm repository..."
105
- # helm repo add openobserve https://charts.openobserve.ai
106
- # helm repo update
185
+ # if [ $exit_status -eq 0 ]; then
186
+ # echo -e "\033[1;92m OpenObserve deployment completed successfully in namespace: ${NAMESPACE} \033[0m"
187
+ # else
188
+ # echo -e "\033[1;31m OpenObserve deployment encountered issues in namespace: ${NAMESPACE} . Please check the pod status above. \033[0m"
189
+ # fi
107
190
108
- # Create namespace
109
- echo " Creating namespace: ${NAMESPACE} "
110
- kubectl create namespace " $NAMESPACE "
191
+ # uninstall "$namespace" "$release_name"
111
192
112
- # Install OpenObserve helm chart
113
- echo " Installing OpenObserve helm chart (Release: ${RELEASE_NAME} ) in namespace: ${NAMESPACE} "
114
- helm --namespace " $NAMESPACE " upgrade --install " $RELEASE_NAME " . -f values.yaml
115
193
194
+ # Test #2 - Install OpenObserve with external secret
195
+ test_with_external_secret " $NAMESPACE " " $RELEASE_NAME "
116
196
# Check pod status
117
197
check_pods " $NAMESPACE "
118
198
exit_status=$?
@@ -123,12 +203,14 @@ else
123
203
echo -e " \033[1;31m OpenObserve deployment encountered issues in namespace: ${NAMESPACE} . Please check the pod status above. \033[0m"
124
204
fi
125
205
206
+ # uninstall "$namespace" "$release_name"
207
+
126
208
# Setup trap for Ctrl+C
127
- trap ' cleanup "$NAMESPACE" "$RELEASE_NAME" $exit_status' INT
209
+ # trap 'cleanup "$NAMESPACE" "$RELEASE_NAME" $exit_status' INT
128
210
129
211
# Pause to show results before cleanup
130
212
# echo -e "\nTest completed. Press Enter to cleanup or Ctrl+C to keep the deployment..."
131
213
# read -r
132
214
133
215
# Perform cleanup
134
- cleanup " $NAMESPACE " " $RELEASE_NAME " $exit_status
216
+ # cleanup "$NAMESPACE" "$RELEASE_NAME" $exit_status
0 commit comments