Kubernetes cannot access grafana and prometheus fron Google cloud platform

11/17/2017

I have followed this link to install Grafana/Prometheus in Google cloud kubernetes. I hope it is deployed successfully please find the following response for reference,

Service Created successfully :

kubectl --namespace=monitoring get services
NAME         TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
grafana      NodePort   10.27.249.8     <none>        3000:32703/TCP   1h
prometheus   NodePort   10.27.249.233   <none>        9090:31939/TCP   1h

Namespace created successfully :

kubectl get namespaces
NAME          STATUS    AGE
default       Active    19h
kube-public   Active    19h
kube-system   Active    19h
monitoring    Active    1h

PODS response :

kubectl --namespace=monitoring get pods
NAME                          READY     STATUS             RESTARTS   AGE
grafana-1323121529-8614m      1/1       Running            0          1h
node-exporter-lw8cr           0/1       CrashLoopBackOff   17         1h
node-exporter-nv85s           0/1       CrashLoopBackOff   17         1h
node-exporter-r2rfl           0/1       CrashLoopBackOff   17         1h
prometheus-3259208887-x2zjc   1/1       Running            0          1h

Now i am trying to expose the external-Ip for Grafana but i couldn't keep on getting following exception "Error from server (AlreadyExists): services "prometheus" already exists"

kubectl --namespace=monitoring expose deployment/prometheus --type=LoadBalancer

Error from server (AlreadyExists): services "prometheus" already exists

Edited

kubectl -n monitoring edit service prometheus

Edit cancelled, no changes made.
-- VelNaga
docker
google-cloud-platform
grafana
kubernetes
prometheus

1 Answer

11/17/2017

As you have already deployed the Prometheus service manifest file in the monitoring namespace. However, you are trying to deploy a service with the same name at the same namespace.That's not acceptable As Two Service cannot co-exist in the same namespace with same name.

Solutions for your problem

I would use the following command to edit the already deployed Service.

kubectl -n monitoring edit service prometheus 

Then your favourite text editor would pop up, you just need to update type: LoadBalancer

Basically, your service will be edited.

Edited

If you are not able to use the above command, then you do following steps : you need to edit the Prometheus service manifest file and update it with type: LoadBalancer.

Now you need to apply kubectl apply -f prometheus-service.yaml

-- Suresh Vishnoi
Source: StackOverflow