Kubernetes无法访问谷歌云平台上的Grafana和Prometheus

我跟着这个链接在Google云端安装Grafana / Prometheus。 希望能够成功部署请参考以下回复,

服务成功创build:

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 

命名空间已成功创build:

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

PODS回应:

 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 

现在,我正在尝试公开外部Ip格拉法纳,但我不能继续得到以下exception“从服务器(AlreadyExists)错误:服务”prometheus“已经存在”

 kubectl --namespace=monitoring expose deployment/prometheus --type=LoadBalancer Error from server (AlreadyExists): services "prometheus" already exists 

编辑

 kubectl -n monitoring edit service prometheus Edit cancelled, no changes made. 

因为您已经在监控命名空间中部署了Prometheus服务清单文件。 但是,您正在尝试在相同的名称空间中部署具有相同名称的服务。这是不可接受的由于两个服务不能共同存在于具有相同名称的同一名称空间中。

解决您的问题

我将使用以下命令来编辑已经部署的服务。

 kubectl -n monitoring edit service prometheus 

然后你最喜欢的文本编辑器会popup,你只需要更新types:LoadBalancer

基本上,您的服务将被编辑。

编辑

如果您不能使用上述命令,那么您需要执行以下步骤:您需要编辑Prometheus服务清单文件并使用types:LoadBalancer进行更新。

现在你需要应用 kubectl apply -f prometheus-service.yaml