kube-prometheus NodePort config

环境版本 https://github.com/coreos/kube-prometheus/archive/v0.1.0.tar.gz

1. 默认设定安装完成后, 几个主服务的端口,未对外暴露, 只能在localhost访问。 可能是从安全上考虑,才有此策略。  在测试系统中,可酌情使用NodePort设定

# kubectl -n monitoring get svc
NAME                    TYPE        CLUSTER-IP        EXTERNAL-IP   PORT(S)             AGE
alertmanager-main       ClusterIP   192.168.74.123    <none>        9093/TCP            8h
alertmanager-operated   ClusterIP   None              <none>        9093/TCP,6783/TCP   8h
grafana                 ClusterIP   192.168.228.214   <none>        3000/TCP            8h
kube-state-metrics      ClusterIP   None              <none>        8443/TCP,9443/TCP   8h
node-exporter           ClusterIP   None              <none>        9100/TCP            8h
prometheus-adapter      ClusterIP   192.168.216.149   <none>        443/TCP             8h
prometheus-k8s          ClusterIP   192.168.109.239   <none>        9090/TCP            8h
prometheus-operated     ClusterIP   None              <none>        9090/TCP            8h
prometheus-operator     ClusterIP   None              <none>        8080/TCP            8h

2. 修改设定
配置文件路径 kube-prometheus-0.1.0/manifests/

sed -i "12a \ \ \ \ nodePort: 30300" grafana-service.yaml
sed -i "13a \ \ type:\ NodePort"     grafana-service.yaml
sed -i "12a \ \ \ \ nodePort: 30090" prometheus-service.yaml
sed -i "13a \ \ type:\ NodePort"     prometheus-service.yaml
sed -i "12a \ \ \ \ nodePort: 30093" alertmanager-service.yaml
sed -i "13a \ \ type:\ NodePort"     alertmanager-service.yaml


3. 重新套用后,服务端口输出如下:

# kubectl -n monitoring get svc
NAME                    TYPE        CLUSTER-IP        EXTERNAL-IP   PORT(S)             AGE
alertmanager-main       NodePort    192.168.10.137    <none>        9093:30093/TCP      12s        <---
alertmanager-operated   ClusterIP   None              <none>        9093/TCP,6783/TCP   12s
grafana                 NodePort    192.168.34.147    <none>        3000:30300/TCP      12s        <---
kube-state-metrics      ClusterIP   None              <none>        8443/TCP,9443/TCP   12s
node-exporter           ClusterIP   None              <none>        9100/TCP            12s
prometheus-adapter      ClusterIP   192.168.158.90    <none>        443/TCP             12s
prometheus-k8s          NodePort    192.168.116.201   <none>        9090:30090/TCP      11s        <---
prometheus-operated     ClusterIP   None              <none>        9090/TCP            11s
prometheus-operator     ClusterIP   None              <none>        8080/TCP            8h

4. 步骤2、3也可以使用下述命令,在默认部署后修改(保存后马上生效)
kubectl edit -n monitoring service alertmanager-main

5. 这样就可以愉快的从外部访问了:
grafana          http://10.247.15.75:30300
prometheus   http://10.247.15.75:30090
alertmanager http://10.247.15.75:30093

转载于:https://my.oschina.net/u/3362827/blog/3064590

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值