kubernetes - Azure Kubernetes - prometheus 作为 ISTIO 的一部分部署,但未显示部署?

标签 kubernetes istio istio-kiali

我使用以下配置来设置 Istio

cat << EOF | kubectl apply -f -
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
metadata:
  namespace: istio-system
  name: istio-control-plane
spec:
  # Use the default profile as the base
  # More details at: https://istio.io/docs/setup/additional-setup/config-profiles/
  profile: default
  # Enable the addons that we will want to use
  addonComponents:
    grafana:
      enabled: true
    prometheus:
      enabled: true
    tracing:
      enabled: true
    kiali:
      enabled: true
  values:
    global:
      # Ensure that the Istio pods are only scheduled to run on Linux nodes
      defaultNodeSelector:
        beta.kubernetes.io/os: linux
    kiali:
      dashboard:
        auth:
          strategy: anonymous
  components:
    egressGateways:
    - name: istio-egressgateway
      enabled: true
EOF
并公开了如下所述的普罗米修斯服务
kubectl expose service prometheus --type=LoadBalancer --name=prometheus-svc --namespace istio-system
kubectl get svc prometheus-svc -n istio-system -o json
export PROMETHEUS_URL=$(kubectl get svc prometheus-svc -n istio-system  -o jsonpath="{.status.loadBalancer.ingress[0]['hostname','ip']}"):$(kubectl get svc prometheus-svc -n istio-system -o 'jsonpath={.spec.ports[0].port}')
echo http://${PROMETHEUS_URL}
curl http://${PROMETHEUS_URL}
我已经部署了一个应用程序,但是在 prometheus 中看不到以下部署
enter image description here

最佳答案

istio 的标准 prometheus 安装不会将您的 pod 配置为向 prometheus 发送指标。它只是从 istio 资源中收集数据。
要将您的 pod 添加到被抓取中,请在您的应用程序的 deployment.yml 中添加以下注释:

apiVersion: apps/v1
kind: Deployment
[...]
spec:
  template:
    metadata:
      annotations:
        prometheus.io/scrape: true   # determines if a pod should be scraped. Set to true to enable scraping.
        prometheus.io/path: /metrics # determines the path to scrape metrics at. Defaults to /metrics.
        prometheus.io/port: 80       # determines the port to scrape metrics at. Defaults to 80.
[...]
顺便说一句:使用 istioctl 安装的 prometheus 实例不应用于生产。从文档:

[...] pass --set values.prometheus.enabled=true during installation. This built-in deployment of Prometheus is intended for new users to help them quickly getting started. However, it does not offer advanced customization, like persistence or authentication and as such should not be considered production ready.


您应该设置自己的 prometheus 并配置 istio 以向它报告。看:
引用:https://istio.io/latest/docs/ops/integrations/prometheus/#option-1-metrics-merging
以下 istio 提供的 yaml 可以作为 prometheus 设置的引用:
https://raw.githubusercontent.com/istio/istio/release-1.7/samples/addons/prometheus.yaml
此外,如果我没记错的话,安装 kiali、prometheus 等附加组件将在 istio 1.8(发布日期 2020 年 12 月)中删除。所以你可能想用 helm 设置你自己的实例。

关于kubernetes - Azure Kubernetes - prometheus 作为 ISTIO 的一部分部署,但未显示部署?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64484444/

相关文章:

kubernetes - status.lastScheduleTime 何时更改?

azure - 如何为 Azure 上的 Kubernetes 集群中运行的 Grafana 安装自定义插件

Istio 和(或与)Nginx 入口 Controller

Azure kubernetes - Azure CNI 和 Istio,sidecar IP 分配?

docker - 如何在多节点集群上的 Kubernetes Pod 中使用 ConfigMap 放置整个目录及其子目录?

docker - 如何使用辅助节点的静态外部IPv4-地址将Kubernetes部署公开为服务?

istio - 禁用向作业 pod 注入(inject) Istio sidecar

elasticsearch - Istio + Elasticsearch

kubernetes - 'istioctl manifest apply' 和 'istioctl install' 和有什么区别?