Skip to content

Commit 1dbe62a

Browse files
nthomas91Nivin Thomas
andauthored
INFRA-42750: Filter out GrafanaDashboard CRs from non-monitoring clusters
Co-authored-by: Nivin Thomas <nthomas@mintel.com>
1 parent 88c974b commit 1dbe62a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

modules/k8s/tanka/generate.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,18 @@ fi
8787
TMP_RENDERED="$(mktemp -d)"
8888
echo "Rendering manifests to $TMP_RENDERED..."
8989
tk export "$TMP_RENDERED/" "$TANKA_REPO_DIR/environments" -r -l "$(join_arr , "${SELECTOR[@]}")" --format="$TANKA_EXPORT_FMT" --merge-strategy=fail-on-conflicts
90+
91+
# Filter out GrafanaDashboard CRs from non-monitoring clusters
92+
# Dashboards should only be deployed to aws.dev.monitoring and aws.logs
93+
echo "Filtering GrafanaDashboard manifests from non-monitoring clusters..."
94+
while IFS= read -r -d '' manifest; do
95+
# Extract the environment name (e.g., aws.dev, aws.prod) from the path
96+
# Path format: $TMP_RENDERED/environments/<app>/<env>/manifests/<file>.yaml
97+
env_name=$(echo "$manifest" | sed -E 's|.*/environments/[^/]+/([^/]+)/manifests/.*|\1|')
98+
if [[ "$env_name" != "aws.dev.monitoring" && "$env_name" != "aws.logs" ]]; then
99+
rm -f "$manifest"
100+
fi
101+
done < <(find "$TMP_RENDERED" -name "*GrafanaDashboard*.yaml" -print0 2>/dev/null)
90102
function finish {
91103
rm -rf "$TMP_RENDERED"
92104
}

0 commit comments

Comments
 (0)