@@ -207,75 +207,29 @@ load_image() {
207207 log_success " Image '$WVA_IMAGE_REPO :$WVA_IMAGE_TAG ' loaded into KIND cluster '$CLUSTER_NAME '"
208208}
209209
210+ materialize_namespace () {
211+ kubectl create namespace " $1 "
212+ }
213+
210214# ### REQUIRED FUNCTION used by deploy/install.sh ####
211215create_namespaces () {
212- log_info " Creating namespaces..."
213-
214- for ns in $WVA_NS $MONITORING_NAMESPACE $LLMD_NS ; do
215- if kubectl get namespace $ns & > /dev/null; then
216- log_warning " Namespace $ns already exists"
217- else
218- kubectl create namespace $ns
219- log_success " Namespace $ns created"
220- fi
221- done
216+ local _deploy_lib_dir
217+ _deploy_lib_dir=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) /../lib"
218+ # shellcheck source=create_namespaces.sh
219+ source " ${_deploy_lib_dir} /create_namespaces.sh"
220+ create_namespaces_shared_loop
222221}
223222
223+ _wva_deploy_lib=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) /../lib"
224+ # shellcheck source=deploy_prometheus_kube_stack.sh
225+ source " ${_wva_deploy_lib} /deploy_prometheus_kube_stack.sh"
226+ # shellcheck source=delete_namespaces_kube_like.sh
227+ source " ${_wva_deploy_lib} /delete_namespaces_kube_like.sh"
228+
224229# ### REQUIRED FUNCTION used by deploy/install.sh ####
225- # Deploy Prometheus stack with TLS for Kubernetes
230+ # Deploy Prometheus stack with TLS (shared with deploy/kubernetes/install.sh)
226231deploy_prometheus_stack () {
227- log_info " Deploying kube-prometheus-stack with TLS..."
228-
229- # Add helm repo
230- helm repo add prometheus-community https://prometheus-community.github.io/helm-charts || true
231- if [ " ${SKIP_HELM_REPO_UPDATE:- } " = " true" ]; then
232- log_info " Skipping helm repo update (SKIP_HELM_REPO_UPDATE=true)"
233- else
234- helm repo update
235- fi
236-
237- # Create self-signed TLS certificate for Prometheus
238- log_info " Creating self-signed TLS certificate for Prometheus"
239- openssl req -x509 -newkey rsa:2048 -nodes \
240- -keyout /tmp/prometheus-tls.key \
241- -out /tmp/prometheus-tls.crt \
242- -days 365 \
243- -subj " /CN=prometheus" \
244- -addext " subjectAltName=DNS:kube-prometheus-stack-prometheus.${MONITORING_NAMESPACE} .svc.cluster.local,DNS:kube-prometheus-stack-prometheus.${MONITORING_NAMESPACE} .svc,DNS:prometheus,DNS:localhost" \
245- & > /dev/null
246-
247- # Create Kubernetes secret with TLS certificate
248- log_info " Creating Kubernetes secret for Prometheus TLS"
249- kubectl create secret tls $PROMETHEUS_SECRET_NAME \
250- --cert=/tmp/prometheus-tls.crt \
251- --key=/tmp/prometheus-tls.key \
252- -n $MONITORING_NAMESPACE \
253- --dry-run=client -o yaml | kubectl apply -f - & > /dev/null
254-
255- # Clean up temp files
256- rm -f /tmp/prometheus-tls.{key,crt}
257-
258- # Install kube-prometheus-stack with TLS enabled
259- # Disable Grafana and Alertmanager — WVA only needs Prometheus for metrics collection.
260- # Use a 10m timeout — 5m is insufficient on busy clusters (e.g. CKS with preemption).
261- log_info " Installing kube-prometheus-stack with TLS configuration"
262- helm upgrade --install kube-prometheus-stack prometheus-community/kube-prometheus-stack \
263- -n $MONITORING_NAMESPACE \
264- --set prometheus.prometheusSpec.serviceMonitorSelectorNilUsesHelmValues=false \
265- --set prometheus.prometheusSpec.podMonitorSelectorNilUsesHelmValues=false \
266- --set prometheus.service.type=ClusterIP \
267- --set prometheus.service.port=$PROMETHEUS_PORT \
268- --set prometheus.prometheusSpec.web.tlsConfig.cert.secret.name=$PROMETHEUS_SECRET_NAME \
269- --set prometheus.prometheusSpec.web.tlsConfig.cert.secret.key=tls.crt \
270- --set prometheus.prometheusSpec.web.tlsConfig.keySecret.name=$PROMETHEUS_SECRET_NAME \
271- --set prometheus.prometheusSpec.web.tlsConfig.keySecret.key=tls.key \
272- --set grafana.enabled=false \
273- --set alertmanager.enabled=false \
274- --timeout=10m \
275- --wait
276-
277- log_success " kube-prometheus-stack deployed with TLS"
278- log_info " Prometheus URL: $PROMETHEUS_URL "
232+ deploy_prometheus_kube_stack
279233}
280234
281235# REQUIRED FUNCTION - only for emulated environments ####
@@ -317,36 +271,13 @@ apply_llm_d_infrastructure_fixes() {
317271 fi
318272}
319273
320- # Kubernetes-specific Undeployment functions
321274undeploy_prometheus_stack () {
322- log_info " Uninstalling kube-prometheus-stack..."
323-
324- helm uninstall kube-prometheus-stack -n $MONITORING_NAMESPACE 2> /dev/null || \
325- log_warning " Prometheus stack not found or already uninstalled"
326-
327- kubectl delete secret $PROMETHEUS_SECRET_NAME -n $MONITORING_NAMESPACE --ignore-not-found
328-
329- log_success " Prometheus stack uninstalled"
275+ undeploy_prometheus_kube_stack
330276}
331277
332278# ### REQUIRED FUNCTION used by deploy/install.sh ####
333279delete_namespaces () {
334- log_info " Deleting namespaces..."
335-
336- for ns in $LLMD_NS $WVA_NS $MONITORING_NAMESPACE ; do
337- if kubectl get namespace $ns & > /dev/null; then
338- if [[ " $ns " == " $LLMD_NS " && " $DEPLOY_LLM_D " == " false" ]] || [[ " $ns " == " $WVA_NS " && " $DEPLOY_WVA " == " false" ]] || [[ " $ns " == " $MONITORING_NAMESPACE " && " $DEPLOY_PROMETHEUS " == " false" ]] ; then
339- log_info " Skipping deletion of namespace $ns as it was not deployed"
340- else
341- log_info " Deleting namespace $ns ..."
342- kubectl delete namespace $ns 2> /dev/null || \
343- log_warning " Failed to delete namespace $ns "
344- fi
345- fi
346- done
347-
348- log_success " Namespaces deleted"
349-
280+ delete_namespaces_kube_like
350281 if [ " $DELETE_CLUSTER " = true ]; then
351282 delete_kind_cluster
352283 fi
0 commit comments