惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
Google DeepMind News
Google DeepMind News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
P
Proofpoint News Feed
Recent Announcements
Recent Announcements
MongoDB | Blog
MongoDB | Blog
U
Unit 42
云风的 BLOG
云风的 BLOG
Recorded Future
Recorded Future
G
Google Developers Blog
I
InfoQ
Blog — PlanetScale
Blog — PlanetScale
A
About on SuperTechFans
Jina AI
Jina AI
量子位
宝玉的分享
宝玉的分享
The Cloudflare Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 聂微东
Last Week in AI
Last Week in AI
WordPress大学
WordPress大学
美团技术团队
The Hacker News
The Hacker News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Tailwind CSS Blog
博客园 - 司徒正美
博客园 - 叶小钗
Hugging Face - Blog
Hugging Face - Blog
P
Palo Alto Networks Blog
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
博客园 - 【当耐特】
Spread Privacy
Spread Privacy
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
Vercel News
Vercel News
Martin Fowler
Martin Fowler
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Forbes - Security
Forbes - Security
Attack and Defense Labs
Attack and Defense Labs
Google DeepMind News
Google DeepMind News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Azure Blog
Microsoft Azure Blog
P
Privacy International News Feed
G
GRAHAM CLULEY
The Last Watchdog
The Last Watchdog
C
Cyber Attacks, Cyber Crime and Cyber Security
AI
AI
V2EX - 技术
V2EX - 技术

Learn Cloud Native

Agentgateway rate limiting for agents | Learn Cloud Native Local development with coding agents on Kubernetes using Signadot | Learn Cloud Native cuenv: one typed file for your whole project | Learn Cloud Native Preflight: AI Code Review Before You Push Anatomy of AI Agents Accessing Google Drive from Next.js Deploying to Fly.io using Dagger and Github Top Cloud-Native & Kubernetes Certifications [2026 Guide] Rapid microservices development with Signadot How to prepare for Istio certified associate exam (ICA) Global Rate Limiting in Istio with Envoy Rate Limit Service My Journey with Istio: From Incubation to Graduation Cilium Network Policy Tutorial: Secure Kubernetes Step by Step Kubernetes Networking: How kube-proxy and iptables Work Istio ServiceEntry: DNS vs. STATIC Resolution & Endpoints Explained Istio Rate Limiting: Configure a Local Rate Limiter in Envoy How to expose custom ports on Istio ingress gateway Portainer Tutorial: A Web UI for Kubernetes & Containers Traefik Proxy 2.x and TLS 101 Kubernetes CLI (kubectl) tips you didn't know about Setting up SSL certificates with Istio Gateway ArgoCD Best Practices You Should Know 在 OCI Ampere A1 计算实例上运行 AI Running AI On OCI Ampere A1 Instance How to Deploy Traefik Proxy Using Flux and GitOps Principles Firebase Emulators with Next.js: Local Setup Guide Running Hugo on free Ampere VM (Oracle Cloud Infrastructure) How to use kwatch to detect crashes in Kubernetes clusters Continuous profiling in Kubernetes using Pyroscope Monitoring containers with cAdvisor Creating a Kubernetes cluster in Google Cloud (LAB) Your first Kubernetes Pod and ReplicaSet (LABS) Container Lifecycle Hooks Maybe Convert Wasm Extension Config? GetIstio - CLI, training, and community Attach multiple VirtualServices to Istio Gateway Kubernetes Volumes Explained: Keep Data Beyond the Pod Send a Slack message when Docker images are updated Kubernetes Network Policy Ambassador Container Pattern Start Kubernetes Release Sidecar Container Pattern Kubernetes Init Containers Deploying multiple Istio Ingress Gateways Branch by Abstraction Pattern The Strangler Pattern Kubernetes Development Environment with Skaffold Securing Kubernetes Ingress with Ambassador and Let's Encrypt All About the Ingress Resource How to quarantine Kubernetes pods? Getting started with Kubernetes Horizontal partitioning in MongoDB Docker image tagging scheme Six things to keep in mind when working with Dockerfiles Beginners guide to Docker Beginners guide to gateways and proxies Deploy and Operate Multiple Istio Meshes in one Kubernetes Cluster Managing service meshes with Meshery Circuit Breaking in Istio Explained Build and push your Docker images using Github Actions Kubernetes and Istio service mesh workshop materials Build Netlify-like deployment for React app using Kubernetes pods Six exciting enhancements in Istio 1.4.0 Fallacies of Distributed Systems CAP Theorem Explained Master the Kubernetes CLI (kubectl) - Cheatsheet Minikube Basics and How to Get Started with Kubernetes 5 Tips to Be More Productive with Kubernetes What are sticky sessions and how to configure them with Istio? Debugging Kubernetes applications using Istio Kubernetes Ingress and Istio Gateway Resource Zero Downtime Releases using Kubernetes and Istio Traffic Mirroring with Istio Service Mesh Expose a Kubernetes service on your own custom domain
Apply an Istio DestinationRule Globally (Mesh-Wide)
Peter Jausovec · 2023-02-03 · via Learn Cloud Native

An interesting question came up today in Istio Slack where someone asked if and how to apply DestinationRules globally to all workloads inside the cluster. The short answer is yes, you can do that, and this article will explain how to do it.

The DestinationRule resource allows us to configure policies that get applied to traffic once routing has occurred. Under the hood, the Istio translates this config to the Envoy config's clusters section.

Typically you use DestinationRule to configure different subsets (e.g., v1, v2 or prod, dev, and so on) and traffic policy settings, such as the load balancing policy, connection pool sizes, and outlier detection.

If you're using only subsets, you'll probably have one DestinationRule per host, as those typically don't make sense to apply globally across multiple workloads.

On the other hand, settings such as outlier detection or load balancer policies might make sense to apply globally.

For example:

apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: ?
  namespace: ?
spec:
  host: ?
  trafficPolicy:
    loadBalancer:
      simple: LEAST_REQUEST
    outlierDetection:
      consecutive5xxErrors: 10
      interval: 2m
      baseEjectionTime: 10m

It would be best if you looked first at the Istio's global mesh options. The global mesh options are the place for any settings and configurations Istio applies globally across the whole mesh. However, in the case of the outlier detection, load balancer policy, or other configuration that can be set in the DestinationRule, we can't define those through the global options.

Looking at the above YAML, we know we need to answer two questions -- where to create the DestinationRule (name and namespace), and what do we set the host field to?

Istio has a concept of a root namespace (rootNamespace field in the global mesh options). So let's say we're running a workload in ns1; when processing the configuration, Istio looks in ns1 first, and if there's no configuration there, it will look in the root namespace. If not explicitly set, the root namespace defaults to istio-system. The answer to the first question is that we must deploy the resource to the istio-system namespace.

But how can we target multiple hosts? The host field in the DestinationRule expects the name of a service that exists in the service registry - for example, product-page or product-page.svc.cluster.local. Note that using a fully qualified name is the preferred way to address the service, so you can avoid misinterpretation and know precisely which service the rule applies to.

The "feature" that will allow us to apply the rule globally is the support for wildcards (*) in the service name. Therefore, to apply a destination rule globally, we could use the notation *.cluster.local or just leave the host field off all together.

Note

If you're using a different trust domain (configurable through trustDomain field in the global mesh settings), replace the cluster.local with your trust domain.

This notation, coupled with the resource being in the root namespace, will apply the configuration across all services in the mesh:

apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: global-dr
  namespace: istio-system
spec:
  # Note we don't specify the `host` field at all.
  trafficPolicy:
    loadBalancer:
      simple: LEAST_REQUEST
    outlierDetection:
      consecutive5xxErrors: 15
      interval: 2m
      baseEjectionTime: 10m

We can try this out quickly by deploying workloads into two separate namespaces and then applying this global DestinationRule.

Then, we can use the istioctl pc cluster command to check the settings are applied globally to all Envoy clusters in the mesh:

istioctl pc cluster deploy/httpbin.httpbin -o yaml | grep -B3 consecutive5xx
 name: outbound|8000||httpbin.httpbin.svc.cluster.local
  outlierDetection:
    baseEjectionTime: 900s
    consecutive5xx: 15
--
  name: outbound|80||istio-ingressgateway.istio-system.svc.cluster.local
  outlierDetection:
    baseEjectionTime: 900s
    consecutive5xx: 15
--
  name: outbound|443||istio-ingressgateway.istio-system.svc.cluster.local
  outlierDetection:
    baseEjectionTime: 900s
    consecutive5xx: 15
...

Another option we have for targeting workloads is by using the workloadSelector and specifying the labels. Note that having a mesh or namespace destination rule together with the workloadSelector isn't going to work. You'll have to specify the exact host name.

Note

I've tried setting the host to *.cluster.local, exporting the destination rule to the current namespace only (default and exportTo set to .), however, the outlier detection (for example) was still applied to workloads outside of the default namespace and the workload selector labels were also ignored. Make sure you check the configuration is applied correctly or per your expectations.

Here's how you can apply a destination rule for v1 versions of the workloads:

apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: sleep-dr
  namespace: default
spec:
  host: "sleep.default.svc.cluster.local"
  workloadSelector:
    matchLabels:
      version: v1
  trafficPolicy:
    loadBalancer:
      simple: LEAST_REQUEST
    outlierDetection:
      consecutive5xxErrors: 15
      interval: 2m
      baseEjectionTime: 10m

How about merging multiple DestinationRules?

Another interesting scenario is having a global DestinationRule and having workload or host specific DestinationRules. In this case we'd expect Istio to merge the two DestinationRules.

However, that only happens if you set the PILOT_ENABLE_DESTINATION_RULE_INHERITANCE environment variable to true when installing Istio. By default, the destination rule inheritance is turned off.

Note

You can pass the environment variables in when installing Istio: istioctl install --set values.pilot.env.PILOT_ENABLE_DESTINATION_RULE_INHERITANCE=true

So let's apply a global destination rule (without a host set) to the istio-system namespace:

apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: global-dr
  namespace: istio-system
spec:
  # Note we don't specify the `host` field at all.
  trafficPolicy:
    loadBalancer:
      simple: LEAST_REQUEST
    outlierDetection:
      consecutive5xxErrors: 15
      interval: 2m
      baseEjectionTime: 10m

Just like before, these settings will be applied to all services in the mesh. If we want to customize the settings per namespace, we can deploy another DestinationRule and only modify the specific values we want to change.

For example, let's say we want to increase the consecutive5xxErrors to 25, for the sleep host:

apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: sleep-dr
  namespace: default
spec:
  host: "sleep.default.svc.cluster.local"
  trafficPolicy:
    outlierDetection:
      consecutive5xxErrors: 25

If we run the istioctl pc cluster command, we'll see that the sleep workload inherited the settings from the global DestinationRule that got merged with the local DestinationRule where we changed the consecutive5xxErrors value:

...
         name: httpbin
          namespace: default
  name: outbound|8000||httpbin.default.svc.cluster.local
  outlierDetection:
    baseEjectionTime: 600s
    consecutive5xx: 15
    enforcingConsecutive5xx: 100
    enforcingSuccessRate: 0
    interval: 120s
  transportSocketMatches:
  - match:
--
...
          name: sleep
          namespace: default
  name: outbound|80||sleep.default.svc.cluster.local
  outlierDetection:
    baseEjectionTime: 600s
    consecutive5xx: 25
    enforcingConsecutive5xx: 100
    enforcingSuccessRate: 0
    interval: 120s
  transportSocketMatches:
  - match:
...