Skip to content

Commit

Permalink
Add prometheus_shard and prometheus_path to Pod spec
Browse files Browse the repository at this point in the history
  • Loading branch information
davent committed Oct 9, 2020
1 parent 70772d3 commit 04b6c71
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
39 changes: 22 additions & 17 deletions paasta_tools/kubernetes_tools.py
Expand Up @@ -1285,12 +1285,6 @@ def format_kubernetes_app(self) -> Union[V1Deployment, V1StatefulSet]:
"paasta.yelp.com/prometheus_shard"
] = prometheus_shard

prometheus_path = self.get_prometheus_path()
if prometheus_path:
complete_config.metadata.labels[
"paasta.yelp.com/prometheus_path"
] = prometheus_path

# DO NOT ADD LABELS AFTER THIS LINE
config_hash = get_config_hash(
self.sanitize_for_config_hash(complete_config),
Expand Down Expand Up @@ -1407,18 +1401,29 @@ def get_pod_template_spec(
else:
annotations["iam.amazonaws.com/role"] = self.get_iam_role()

# prometheus_path is used to override the default scrape path in Prometheus
prometheus_path = self.get_prometheus_path()
if prometheus_path:
annotations["paasta.yelp.com/prometheus_path"] = prometheus_path

# Default Pod labels
labels: Dict[str, Any] = {
"yelp.com/paasta_service": self.get_service(),
"yelp.com/paasta_instance": self.get_instance(),
"yelp.com/paasta_git_sha": git_sha,
"paasta.yelp.com/service": self.get_service(),
"paasta.yelp.com/instance": self.get_instance(),
"paasta.yelp.com/git_sha": git_sha,
}

# Allow the Prometheus Operator's Pod Service Monitor for specified
# shard to find this pod
prometheus_shard = self.get_prometheus_shard()
if prometheus_shard:
labels["paasta.yelp.com/prometheus_shard"] = prometheus_shard

return V1PodTemplateSpec(
metadata=V1ObjectMeta(
labels={
"yelp.com/paasta_service": self.get_service(),
"yelp.com/paasta_instance": self.get_instance(),
"yelp.com/paasta_git_sha": git_sha,
"paasta.yelp.com/service": self.get_service(),
"paasta.yelp.com/instance": self.get_instance(),
"paasta.yelp.com/git_sha": git_sha,
},
annotations=annotations,
),
metadata=V1ObjectMeta(labels=labels, annotations=annotations,),
spec=V1PodSpec(**pod_spec_kwargs),
)

Expand Down
2 changes: 1 addition & 1 deletion yelp_package/Makefile
Expand Up @@ -24,7 +24,7 @@ DOCKER_RUN=docker run -t -v $(CURDIR)/../:/work:rw -e PIP_INDEX_URL=$(PIP_INDEX_
NOOP = true
ifeq ($(PAASTA_ENV),YELP)
ADD_MISSING_DEPS_MAYBE:=-diff --unchanged-line-format= --old-line-format= --new-line-format='%L' ../requirements.txt ./extra_requirements_yelp.txt >> ../requirements.txt
ACTUAL_PACKAGE_VERSION=$(RELEASE)-yelp1
ACTUAL_PACKAGE_VERSION=$(RELEASE)-yelp2
ADD_VERSION_SUFFIX=dch -v $(ACTUAL_PACKAGE_VERSION) --force-distribution --distribution $* --changelog ../debian/changelog 'Build for yelp: add scribereader to virtualenv'
else
ADD_MISSING_DEPS_MAYBE:=$(NOOP)
Expand Down

0 comments on commit 04b6c71

Please sign in to comment.