【问题标题】:Kubernetes cannot access grafana and prometheus fron Google cloud platformKubernetes无法从谷歌云平台访问grafana和prometheus
【发布时间】:2018-05-01 10:20:58
【问题描述】:

我已经按照link 在谷歌云 kubernetes 中安装 Grafana/Prometheus。我希望它部署成功请找到以下响应以供参考,

服务创建成功:

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

命名空间创建成功:

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

现在我正在尝试为 Grafana 公开外部 Ip,但我无法继续收到以下异常“来自服务器的错误 (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.

【问题讨论】:

    标签: docker kubernetes google-cloud-platform grafana prometheus


    【解决方案1】:

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

    您的问题的解决方案

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

    kubectl -n monitoring edit service prometheus 
    

    然后你最喜欢的文本编辑器会弹出,你只需要更新 类型:负载均衡器

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

    已编辑

    如果您无法使用上述命令,请执行以下步骤: 您需要编辑 Prometheus 服务清单文件并使用 type: LoadBalancer 进行更新。

    现在你需要申请 kubectl apply -f prometheus-service.yaml

    【讨论】:

    • 我使用上述评论并编辑了文件,但它显示“编辑已取消”。另外编辑文件后我需要重新启动服务吗?负载均衡器会暴露外部 IP 吗?
    • 基本上,如果您可以更新 type : LoadBalancer 它将在网络负载平衡器上创建一个外部 IP(例如亚马逊上的 ELB 等)。我也编辑了答案
    • 但我无法保存此文件...我正在使用谷歌云
    • 您需要编辑服务清单文件。检查更新的答案
    猜你喜欢
    • 1970-01-01
    • 2020-07-18
    • 1970-01-01
    • 2020-03-03
    • 1970-01-01
    • 2018-06-22
    • 1970-01-01
    • 2020-12-11
    • 1970-01-01
    相关资源
    最近更新 更多