Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Kubernetes - prometheus is deployed as a part of ISTIO not showing the deployments?

I have used the following configuration to setup the 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

and exposed the prometheus service as mentioned below

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}

I have deployed an application however couldn't see the below deployments in prometheus

enter image description here

like image 901
Karthikeyan Vijayakumar Avatar asked Oct 22 '20 14:10

Karthikeyan Vijayakumar


People also ask

How does Prometheus work with Istio?

In an Istio mesh, each component exposes an endpoint that emits metrics. Prometheus works by scraping these endpoints and collecting the results. This is configured through the Prometheus configuration file which controls settings for which endpoints to query, the port and path to query, TLS settings, and more.

How do I check if Istio is installed?

The istioctl command saves the IstioOperator CR that was used to install Istio in a copy of the CR named installed-state. You can inspect this CR if you lose track of what is installed in a cluster. The installed-state CR is also used to perform checks in some istioctl commands and should therefore not be removed.

What is the Kube-Prometheus-exporter-node service?

The kube-prometheus-exporter-node service has these labels so it’s metrics port will be monitored by Prometheus: This allows Prometheus server to scrape metrics from each node: To access Prometheus we have to connect to the pod that is running the Prometheus server in our cluster.

What is the use of Prometheus in Kubernetes?

The prometheus operator will generate and apply the required configuration for the prometheus server. When you install the kubernetes operator in your cluster you will get the operator and the above mentioned CRD’s but you will not get any prometheus server or any service monitor instances by default.

What are the different types of Prometheus deployment?

These 3 types are: Prometheus, which defines a desired Prometheus deployment. The Operator ensures at all times that a deployment matching the resource definition is running. ServiceMonitor, which declaratively specifies how groups of services should be monitored.

Is a Prometheus server required to integrate with azure monitor?

By integrating with Azure Monitor, a Prometheus server is not required. You just need to expose the Prometheus metrics endpoint through your exporters or pods (application), and the containerized agent for Container insights can scrape the metrics for you.


1 Answers

The standard prometheus installation by istio does not configure your pods to send metrics to prometheus. It just collects data from the istio resouces.

To add your pods to being scraped add the following annotations in the deployment.yml of your application:

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.
[...]

By the way: The prometheus instance installed with istioctl should not be used for production. From docs:

[...] 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.

You should setup your own prometheus and configure istio to report to it. See: Reference: https://istio.io/latest/docs/ops/integrations/prometheus/#option-1-metrics-merging

The following yaml provided by istio can be used as reference for setup of prometheus: https://raw.githubusercontent.com/istio/istio/release-1.7/samples/addons/prometheus.yaml

Furthermore, if I remember correctly, installation of addons like kiali, prometheus, ... with istioctl will be removed with istio 1.8 (release date december 2020). So you might want to setup your own instances with helm anyway.

like image 178
Chris Avatar answered Oct 17 '22 08:10

Chris