本文共 1493 字,大约阅读时间需要 4 分钟。
Isitio目前自带Prometheus和Grafana,但无法从外部访问,使用port forward只能从本地访问。运行下面的命令:
kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=prometheus -o jsonpath='{.items[0].metadata.name}') 9090:9090 &
可以从本地curl到Prometheus的UI(curl localost:9090/graph):
# Source: istio/charts/prometheus/templates/service.yamlapiVersion: v1kind: Servicemetadata: name: prometheus namespace: istio-system annotations: prometheus.io/scrape: 'true' labels: name: prometheusspec: type: NodePort #原来是ClusterIP,改成NodePort selector: app: prometheus ports: - name: http-prometheus protocol: TCP port: 9090 nodePort: 32339 #外部访问端口---# Source: istio/charts/grafana/templates/service.yamlapiVersion: v1kind: Servicemetadata: name: grafana namespace: istio-system annotations: auth.istio.io/3000: NONE labels: app: grafana chart: grafana-0.1.0 release: RELEASE-NAME heritage: Tillerspec: type: NodePort #原来是没有type的,加上 ports: - port: 3000 targetPort: 3000 protocol: TCP name: http nodePort: 32333 #加上外部访问端口 selector: app: grafana
* nodePort要在30000到32767之间!!!!否则会报错:
The Service "grafana" is invalid: spec.ports[0].nodePort: Invalid value: 33333: provided port is not in the valid range. The range of valid ports is 30000-32767
重新部署istio-demo.yaml文件后、访问对应url,就会出现Prometheus(IP:32339/graph)和Grafana(IP:32333)的UI了。
转载地址:http://aokvb.baihongyu.com/