skip to Main Content

I installed Prometheus using helm into Kubernets cluster (CentOS 8 VM) and want to access to dashboard from outside of cluster using VM IP

kubectl get svc -n monitoring
NAME                                      TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                      AGE
alertmanager-operated                     ClusterIP   None             <none>        9093/TCP,9094/TCP,9094/UDP   27m
prometheus-grafana                        ClusterIP   10.98.154.200    <none>        80/TCP                       27m
prometheus-kube-state-metrics             ClusterIP   10.109.183.131   <none>        8080/TCP                     27m
prometheus-operated                       ClusterIP   None             <none>        9090/TCP                     27m
prometheus-prometheus-node-exporter       ClusterIP   10.101.171.235   <none>        30206/TCP                    27m
prometheus-prometheus-oper-alertmanager   ClusterIP   10.109.205.136   <none>        9093/TCP                     27m
prometheus-prometheus-oper-operator       ClusterIP   10.111.243.35    <none>        8080/TCP,443/TCP             27m
prometheus-prometheus-oper-prometheus     ClusterIP   10.106.76.22     <none>        9090/TCP                     27m

i need to expose prometheus-prometheus-oper-prometheus service which works on port 9090 to be accessible from the outside on port 30000 using NodePort

http://Kubernetes_VM_IP:30000

so i created another service: but it fails services.yaml:

apiVersion: v1
kind: Service
metadata:
  name: prometheus-service
  namespace: monitoring
  annotations:
      prometheus.io/scrape: 'true'
      prometheus.io/port:   '9090'
spec:
  selector:
    app: prometheus-operator-prometheus
  type: NodePort
  ports:
    - port: 9090
      nodePort: 30000
      protocol: TCP


kubectl describe svc prometheus-prometheus-oper-prometheus -n monitoring
Name:              prometheus-prometheus-oper-prometheus
Namespace:         monitoring
Labels:            app=prometheus-operator-prometheus
                   chart=prometheus-operator-8.12.2
                   heritage=Helm
                   release=prometheus
                   self-monitor=true
Annotations:       <none>
Selector:          app=prometheus,prometheus=prometheus-prometheus-oper-prometheus
Type:              ClusterIP
IP:                10.106.76.22
Port:              web  9090/TCP
TargetPort:        9090/TCP
Endpoints:         10.32.0.7:9090
Session Affinity:  None
Events:            <none>

2

Answers


  1. Chosen as BEST ANSWER

    Recreated prometheus and specified nodeport during installation:

    helm install prometheus stable/prometheus-operator --namespace monitoring --set prometheus.service.nodePort=30000 --set prometheus.service.type=NodePort
    

  2. For those using a values.yaml file, this is the correct structure :

    prometheus:
      service:
        nodePort: 30000
        type: NodePort
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search