Add prometheus-monitoring namespace
When using 'prometheus_monitoring=true' in the label option, 'kube-enable-monitoring.service' in the master node has stuck in 'Wait for Grafana pod and then inject data source'. It caused the 'prometheus-monitoring' namespace doesn't exist, so scripts don't create pods about Prometheus and Grafana. To fix the error, I added codes in 'magnum/drivers/common/templates/ kubernetes/fragments/enable-prometheus-monitoring.sh' to make 'prometheus-monitoring' namespace. We could put codes in a new file like 'magnum/magnum/drivers/ k8s_coreos_v1/templates/fragments/create-kube-namespace.yaml', but I think it's ok. Change-Id: I23395b41919c6f39cfcc2b4480bcd4b040cae031 Task: 26347 Story: 2003697
This commit is contained in:
parent
d9a43d87d0
commit
bc36ef8fb6
|
@ -280,6 +280,19 @@ EOF
|
|||
)
|
||||
writeFile $prometheusService_file "$prometheusService_content"
|
||||
|
||||
# Write the file for prometheus-monitoring namespace
|
||||
prometheusNamespace_file=/srv/magnum/kubernetes/monitoring/prometheusNamespace.yaml
|
||||
prometheusNamespace_content=$(cat <<EOF
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
labels:
|
||||
name: prometheus-monitoring
|
||||
name: prometheus-monitoring
|
||||
EOF
|
||||
)
|
||||
writeFile $prometheusNamespace_file "$prometheusNamespace_content"
|
||||
|
||||
grafanaService_file=/srv/magnum/kubernetes/monitoring/grafanaService.yaml
|
||||
grafanaService_content=$(cat <<EOF
|
||||
apiVersion: v1
|
||||
|
@ -375,6 +388,13 @@ do
|
|||
sleep 5
|
||||
done
|
||||
|
||||
# Check if prometheus-monitoring namespace exist already before creating the namespace
|
||||
kubectl get namespace prometheus-monitoring
|
||||
if [ "$?" != "0" ] && \
|
||||
[ -f "'''${PROMETHEUS_MON_BASE_DIR}'''/prometheusNamespace.yaml" ]; then
|
||||
kubectl create -f '''${PROMETHEUS_MON_BASE_DIR}'''/prometheusNamespace.yaml
|
||||
fi
|
||||
|
||||
# Check if all resources exist already before creating them
|
||||
# Check if configmap Prometheus exists
|
||||
kubectl get configmap prometheus -n prometheus-monitoring
|
||||
|
|
Loading…
Reference in New Issue