apiVersion: v1 kind: Service metadata: # Creating a new service to expose the existing one. # This avoids modifying the original service managed by a package manager like Helm. name: prometheus-grafana-external namespace: monitoring labels: app.kubernetes.io/name: grafana-external spec: # Exposes the Service externally using a cloud provider's load balancer. type: LoadBalancer ports: - name: http # The port the service is exposed on externally and internally. # The load balancer will forward traffic from this port. port: 9000 # The port on the pod that the service forwards traffic to. # Based on your original command, this is likely 3000 for Grafana. targetPort: 3000 protocol: TCP # This selector is crucial. It must match the labels of the pods you want to target. # The 'prometheus-grafana' service likely targets pods with a label like this. # Please verify the correct labels for your Grafana pods. selector: app.kubernetes.io/instance: prometheus app.kubernetes.io/name: grafana --- apiVersion: v1 kind: Service metadata: # Creating a new service to avoid modifying the original one. name: prometheus-external namespace: monitoring labels: app.kubernetes.io/name: prometheus-external spec: # This type will provision an external load balancer. type: LoadBalancer ports: - name: http-prometheus protocol: TCP # The external port the load balancer will listen on. port: 9090 # The port on the Prometheus pods to forward traffic to. targetPort: 9090 # This selector is crucial. It tells the service which pods to send traffic to. # For the kube-prometheus stack, the pods are typically labeled like this. # Please verify this matches your setup. selector: app.kubernetes.io/name: prometheus # It's possible an instance label is also required, such as: # app.kubernetes.io/instance: prometheus-kube-prometheus-prometheus # Add it to the selector if your pods have it.