prometheus-community/helm-charts

[prometheus-pushgateway] PODNAME kubectl command displayed after install is incorrect

tchia04 opened this issue · 1 comments

Describe the bug a clear and concise description of what the bug is.

The kubectl command displayed after helm install for the pushgateway component is incorrect.

What's your helm version?

version.BuildInfo{Version:"v3.15.2", GitCommit:"1a500d5625419a524fdae4b33de351cc4f58ec35", GitTreeState:"clean", GoVersion:"go1.22.4"}

What's your kubectl version?

Client Version: v1.30.2 Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3 Server Version: v1.30.0

Which chart?

prometheus-community/prometheus

What's the chart version?

25.22.0

What happened?

The POD_NAME for the Prometheus server and Prometheus alertmanager are working.
However the POD_NAME for the Prometheus PushGateway could not be parsed from the kubectl command.

What you expected to happen?

The kubectl command should return the pushgateway pod name so it can be used for the "kubectl port-forward" command.

How to reproduce it?

  1. helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
  2. helm repo update
  3. helm install my-prometheus prometheus-community/prometheus --version 25.22.0
  4. helm status my-prometheus | grep pushgateway
  5. copy and paste the output from the previous step and you will get something like this
export POD_NAME=$(kubectl get pods --namespace default -l "app=prometheus-pushgateway,component=pushgateway" -o jsonpath="{.items[0].metadata.name}")
error: error executing jsonpath "{.items[0].metadata.name}": Error executing template: array index out of bounds: index 0, length 0. Printing more information for debugging the template:
	template was:
		{.items[0].metadata.name}
	object given to jsonpath engine was:
		map[string]interface {}{"apiVersion":"v1", "items":[]interface {}{}, "kind":"List", "metadata":map[string]interface {}{"resourceVersion":""}}

Enter the changed values of values.yaml?

values.yaml was not changed

Enter the command that you execute and failing/misfunctioning.

export POD_NAME=$(kubectl get pods --namespace default -l "app=prometheus-pushgateway,component=pushgateway" -o jsonpath="{.items[0].metadata.name}")

Anything else we need to know?

After I replaced it with the following and it worked

export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=prometheus-pushgateway,app.kubernetes.io/instance=my-prometheus" -o jsonpath="{.items[0].metadata.name}")

❯   kubectl --namespace default port-forward $POD_NAME 9091
Forwarding from 127.0.0.1:9091 -> 9091
Forwarding from [::1]:9091 -> 9091
Handling connection for 9091
Handling connection for 9091