【问题标题】:Azure Kubernetes - prometheus is deployed as a part of ISTIO not showing the deployments?Azure Kubernetes - prometheus 被部署为 ISTIO 的一部分,没有显示部署?
【发布时间】:2021-02-05 14:24:32
【问题描述】:

我使用以下配置来设置 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

并暴露prometheus服务如下所述

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 中看不到以下部署

【问题讨论】:

  • 部署的应用是否注入了istio?同样根据 istio docs4.用户应用程序(如果它们公开 Prometheus 指标)。您的应用程序是否公开 Prometheus 指标?
  • 应用程序是否应该公开 Prometheus 指标?我以为 ISTIO 会默认处理指标收集?

标签: kubernetes istio istio-kiali istio-prometheus


【解决方案1】:

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 实例不应该用于生产。来自文档:

[...] 在安装期间传递 --set values.prometheus.enabled=true。 Prometheus 的这种内置部署旨在帮助新用户快速入门。但是,它不提供高级定制,如持久性或身份验证,因此不应被视为生产就绪。

您应该设置自己的 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

此外,如果我没记错的话,使用 istioctl 安装 kiali、prometheus 等插件将在 istio 1.8(发布日期 2020 年 12 月)中删除。所以你可能还是想用 helm 设置你自己的实例。

【讨论】:

    猜你喜欢
    • 2021-02-05
    • 1970-01-01
    • 2019-04-28
    • 1970-01-01
    • 2013-04-17
    • 1970-01-01
    • 1970-01-01
    • 2019-01-01
    • 2021-05-28
    相关资源
    最近更新 更多