宝剑锋从磨砺出,梅花香自苦寒来。这篇文章主要讲述kubernetes port-forward相关的知识,希望能为你提供帮助。
在上一篇文章中(??https://blog.51cto.com/luosea/4769771??)我们配置了本地kubectl config, 现在我们来配置port-forward.
tips:
当我们使用helm upgrade 更新后,最后会有句类似下面的提示:
helm upgrade prometheus /opt/prometheus-monitoring-qa/prometheus --namespace monitoring
NOTES:
The Prometheus server can be accessed via port 80 on the following DNS name from within your cluster:
prometheus-server.monitoring.svc.cluster.local
Get the Prometheus server URL by running these commands in the same shell:
export POD_NAME=$(kubectl get pods --namespace monitoring -l "app=prometheus,component=server" -o jsonpath="{.items[0].metadata.name}")
kubectl --namespace monitoring port-forward $POD_NAME 9090
现在我们来设置端口转发:
直接将这两行命令在本地执行
export POD_NAME=$(kubectl get pods --namespace monitoring -l "app=prometheus,component=server" -o jsonpath="{.items[0].metadata.name}")
kubectl --namespace monitoring port-forward $POD_NAME 9090
然后在浏览器上打开 ??http://localhost:9090/?? 应该就可以看到对应的内容了
【kubernetes port-forward】
如果我们得到的提示如下:
?~kubectl --namespace monitoring port-forward $POD_NAME 9090
error: error upgrading connection:
那就估计是pod name的问题
使用kubectl get pods -n monitoring 查看对应的pods名字
?~ kubectl get pods -n monitoring
NAMEREADYSTATUSRESTARTSAGE
alertmanager-kube-prometheus-stack-alertmanager-02/2Running0177d
kube-prometheus-stack-grafana-dfb76888d-mrlhg2/2Running053d
kube-prometheus-stack-kube-state-metrics-66789f8885-5c5jt1/1Running653d
kube-prometheus-stack-operator-866999d799-5658g1/1Running0177d
kube-prometheus-stack-prometheus-node-exporter-4qnm71/1Running3180d
kube-prometheus-stack-prometheus-node-exporter-99zvf1/1Running7180d
kube-prometheus-stack-prometheus-node-exporter-c8xg21/1Running3180d
kube-prometheus-stack-prometheus-node-exporter-v9f9f1/1Running4180d
kube-prometheus-stack-prometheus-node-exporter-zgq8t1/1Running0180d
prometheus-blackbox-exporter-9fd56958c-xqlkw1/1Running56418d
prometheus-kube-prometheus-stack-prometheus-02/2Running139h
prometheus-kube-state-metrics-c65b87574-fgq751/1Running1177d
prometheus-mysql-exporter-msqa-666c944bbc-zlmjb1/1Running053d
prometheus-mysql-exporter-qa-664d8d7fb6-22rpt1/1Running0356d
prometheus-server-786497558b-lg49q0/2Terminating053d
prometheus-server-786497558b-wpzfd2/2Running024h
victoria-metrics-single-server-01/1Running039h
?~
然后输入正确的pods
kubectl --namespace monitoring port-forward prometheus-server-786497558b-wpzfd 9090
推荐阅读
- Intellij IDEA 神级插件!效率提升 10 倍!
- #yyds干货盘点#--k8s-存储
- #yyds干货盘点# MySQL数据库语句进阶--随手笔记
- 面试官(手撕LRU缓存了解一下#2021年底大盘点#)
- MySQL性能测试之insert&deleteFunTester框架#yyds干货盘点#
- Python包管理 pip教程 | 解决用pip更新pip失败 #yyds干货盘点#
- #私藏项目实操分享#Maven实战技巧「插件使用专题」Maven-Archetype插件创建自定义maven项目骨架
- Go 语言入门很简单 -- 12. Go 方法 #私藏项目实操分享#
- #私藏项目实操分享# SAP 软件的精髓之一(各种各样的决定机制 - Determination Logic)