環境版本 https://github.com/coreos/kube-prometheus/archive/v0.1.0.tar.gznode
1. 默認設定安裝完成後, 幾個主服務的端口,未對外暴露, 只能在localhost訪問。 多是從安全上考慮,纔有此策略。 在測試系統中,可酌情使用NodePort設定git
# 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/github
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. 步驟二、3也可使用下述命令,在默認部署後修改(保存後立刻生效)
kubectl edit -n monitoring service alertmanager-mainbash
5. 這樣就能夠愉快的從外部訪問了:
grafana http://10.247.15.75:30300
prometheus http://10.247.15.75:30090
alertmanager http://10.247.15.75:30093測試