Access Resources in Kubernetes cluster ClusterIP -> NodePort
Quote from Moshe Sharon on 24/01/2021, 7:53 amProblem
User working with Prometheus installed in kubernetes in a cluster environment cannot see the metrics / alerts /graphs / status management page.
Solution
Need to Change the type of the service from ClusterIP to NodePort in order to expose the service on the cluster IP
List all your Kubernetes services in monitoring namespace
kubectl get service -n monitoring
edit the service
kubectl edit service prom-operator-prom-prometheus -n monitoring
Under Spec section in the YAML structure change the value for
type: ClusterIP
to
type: NodePortExample
spec:
clusterIP: 10.233.8.194
externalTrafficPolicy: Cluster
ports:
– name: web
nodePort: 31531
port: 9090
protocol: TCP
targetPort: 9090
selector:
app: prometheus
prometheus:prom-operator-prom-prometheus
sessionAffinity: None
type: NodePort
status:
loadBalancer: {}Check the assigned nodePort value and in your browser type
http://<CLUSTER IP ADDRESS>:31531
Problem
User working with Prometheus installed in kubernetes in a cluster environment cannot see the metrics / alerts /graphs / status management page.
Solution
Need to Change the type of the service from ClusterIP to NodePort in order to expose the service on the cluster IP
List all your Kubernetes services in monitoring namespace
kubectl get service -n monitoring
edit the service
kubectl edit service prom-operator-prom-prometheus -n monitoring
Under Spec section in the YAML structure change the value for
type: ClusterIP
to
type: NodePort
Example
spec:
clusterIP: 10.233.8.194
externalTrafficPolicy: Cluster
ports:
– name: web
nodePort: 31531
port: 9090
protocol: TCP
targetPort: 9090
selector:
app: prometheus
prometheus:prom-operator-prom-prometheus
sessionAffinity: None
type: NodePort
status:
loadBalancer: {}
Check the assigned nodePort value and in your browser type
http://<CLUSTER IP ADDRESS>:31531