일단 프로메테우스를 한번 올려서 확인을 해보려고한다.
curl -O https://raw.githubusercontent.com/istio/istio/release-1.8/samples/addons/prometheus.yaml
kubectl apply -f prometheus.yaml
이렇게 화면을 잘 볼수있는 것 확인...!
prometheus-values.yaml의 additionalScrapeConfigs: 아래와 같이 Scrape config 추가!
- job_name: 'istiod'
kubernetes_sd_configs:
- role: endpoints
namespaces:
names:
- istio-system
relabel_configs:
- source_labels: [__meta_kubernetes_service_name, __meta_kubernetes_endpoint_port_name]
action: keep
regex: istiod;http-monitoring
- job_name: 'istio-mesh'
kubernetes_sd_configs:
- role: endpoints
namespaces:
names:
- istio-system
scrape_interval: 15s
relabel_configs:
- source_labels: [__meta_kubernetes_service_name, __meta_kubernetes_endpoint_port_name]
action: keep
regex: istio-telemetry;prometheus
# Scrape config for envoy stats
- job_name: 'envoy-stats'
metrics_path: /stats/prometheus
kubernetes_sd_configs:
- role: pod
scrape_interval: 15s
relabel_configs:
- source_labels: [__meta_kubernetes_pod_container_port_name]
action: keep
regex: '.*-envoy-prom'
- source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
action: replace
regex: ([^:]+)(?::\d+)?;(\d+)
replacement: $1:15090
target_label: __address__
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
- source_labels: [__meta_kubernetes_namespace]
action: replace
target_label: namespace
- source_labels: [__meta_kubernetes_pod_name]
action: replace
target_label: pod_name
- job_name: 'istio-policy'
kubernetes_sd_configs:
- role: endpoints
namespaces:
names:
- istio-system
scrape_interval: 15s
relabel_configs:
- source_labels: [__meta_kubernetes_service_name, __meta_kubernetes_endpoint_port_name]
action: keep
regex: istio-policy;http-monitoring
- job_name: 'istio-telemetry'
kubernetes_sd_configs:
- role: endpoints
namespaces:
names:
- istio-system
scrape_interval: 15s
relabel_configs:
- source_labels: [__meta_kubernetes_service_name, __meta_kubernetes_endpoint_port_name]
action: keep
regex: istio-telemetry;http-monitoring
- job_name: 'pilot'
kubernetes_sd_configs:
- role: endpoints
namespaces:
names:
- istio-system
scrape_interval: 15s
relabel_configs:
- source_labels: [__meta_kubernetes_service_name, __meta_kubernetes_endpoint_port_name]
action: keep
regex: istio-pilot;http-monitoring
- job_name: 'galley'
kubernetes_sd_configs:
- role: endpoints
namespaces:
names:
- istio-system
scrape_interval: 15s
relabel_configs:
- source_labels: [__meta_kubernetes_service_name, __meta_kubernetes_endpoint_port_name]
action: keep
regex: istio-galley;http-monitoring
- job_name: 'citadel'
kubernetes_sd_configs:
- role: endpoints
namespaces:
names:
- istio-system
scrape_interval: 15s
relabel_configs:
- source_labels: [__meta_kubernetes_service_name, __meta_kubernetes_endpoint_port_name]
action: keep
regex: istio-citadel;http-monitoring
기존의 prometheus로 변경해줘야됨.
istio external prometheus 사용 스택오버플로우 참고글 0
kubectl edit cm kiali -n istio-system
external_services:
custom_dashboards:
enabled: true
istio:
root_namespace: istio-system
prometheus:
auth:
ca_file: ''
insecure_skip_verify: false
password: ''
token: ''
type: none
use_kiali_token: false
username: ''
custom_metric_url: http://kube-prometheus-stack-prometheus.prometheus:9090/
url: http://kube-prometheus-stack-prometheus.prometheus:9090/
아래와 같이 나오는 것 확인!
cat gw.yaml
apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
name: gw-test
namespace: test
spec:
selector:
istio: ingressgateway
servers:
- hosts:
- '*'
port:
name: http
number: 80
protocol: HTTP
cat vs-external.yaml
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: test-external
namespace: test
spec:
gateways:
- test
hosts:
- ''www.test.com''
http:
- route:
- destination:
host: test.test.svc.cluster.local
port:
number: 80
cat vs-internal.yaml
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: test-internal
namespace: test
spec:
hosts:
- ''test.test.svc.cluster.local''
http:
- route:
- destination:
host: test.test.svc.cluster.local
port:
number: 80
cat dr.yaml
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
name: test
namespace: test
spec:
host: test
kubectl apply -f .