#!/bin/bash space=`kubectl get pod -A -l app=$1|grep -v "NAMESPACE"|awk '{print $1}'|head -n1` for podname in `kubectl get pod -A -l app=$1|grep -v "NAMESPACE"|grep $1|awk '{print $2}'` do kubectl annotate pod -n $space $podname prometheus.aispeech.com/scrape_scheme=http kubectl annotate pod -n $space $podname prometheus.aispeech.com/scrape_port="$2" kubectl annotate pod -n $space $podname prometheus.aispeech.com/metric_path=$3 kubectl annotate pod -n $space $podname prometheus.aispeech.com/should_be_scraped="true" done