fix setup_prometheus_endpoints in configure (#790)

The kubeControllerManager endpoints were being cleared on each iteration of the loop over control nodes leading to only the last control node being added. Instead the array has been cleared outside of the loop.
This commit is contained in:
Adam Petrovic authored and GitHub committed 2023-06-15 06:58:18 -04:00
1 parent be1b7029f0
commit 8c30a120da
1 file changed
+2 -2
Vendored
+2 -2
View File
@@ -475,14 +475,14 @@ generate_ansible_hosts() {
} }
setup_prometheus_endpoints() { setup_prometheus_endpoints() {
yq --inplace 'del(.spec.values.kubeControllerManager.endpoints[])' \
"${PROJECT_DIR}/kubernetes/apps/monitoring/kube-prometheus-stack/app/helmrelease.yaml"
for var in "${!BOOTSTRAP_ANSIBLE_HOST_ADDR_@}"; do for var in "${!BOOTSTRAP_ANSIBLE_HOST_ADDR_@}"; do
node_id=$(echo "${var}" | awk -F"_" '{print $5}') node_id=$(echo "${var}" | awk -F"_" '{print $5}')
node_control="BOOTSTRAP_ANSIBLE_CONTROL_NODE_${node_id}" node_control="BOOTSTRAP_ANSIBLE_CONTROL_NODE_${node_id}"
if [[ "${!node_control}" == "true" ]]; then if [[ "${!node_control}" == "true" ]]; then
node_addr="BOOTSTRAP_ANSIBLE_HOST_ADDR_${node_id}" node_addr="BOOTSTRAP_ANSIBLE_HOST_ADDR_${node_id}"
_log "INFO(${FUNCNAME[0]})" "Setting up Prometheus endpoint for '${!node_addr}'" _log "INFO(${FUNCNAME[0]})" "Setting up Prometheus endpoint for '${!node_addr}'"
yq --inplace 'del(.spec.values.kubeControllerManager.endpoints[])' \
"${PROJECT_DIR}/kubernetes/apps/monitoring/kube-prometheus-stack/app/helmrelease.yaml"
yq --inplace ".spec.values.kubeControllerManager.endpoints += \"${!node_addr}\"" \ yq --inplace ".spec.values.kubeControllerManager.endpoints += \"${!node_addr}\"" \
"${PROJECT_DIR}/kubernetes/apps/monitoring/kube-prometheus-stack/app/helmrelease.yaml" "${PROJECT_DIR}/kubernetes/apps/monitoring/kube-prometheus-stack/app/helmrelease.yaml"
fi fi