[zh-cn] sync blog 2025-05-28-gateway-api-v1.3

pull/51110/head
Eason1118 2025-05-30 10:08:37 +07:00
parent 04d1bb452b
commit 57566781f3
2 changed files with 729 additions and 0 deletions

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="900px" height="250px" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd" xmlns:xlink="http://www.w3.org/1999/xlink">
<g><path style="opacity:0.908" fill="#fbfcfe" d="M 134.5,17.5 C 137.85,17.335 141.183,17.5017 144.5,18C 170.5,30.3333 196.5,42.6667 222.5,55C 226.894,58.0684 229.728,62.235 231,67.5C 236.872,93.8622 242.872,120.196 249,146.5C 249.61,150.236 249.277,153.903 248,157.5C 230.333,179.833 212.667,202.167 195,224.5C 192.441,227.531 189.274,229.698 185.5,231C 154.5,231.667 123.5,231.667 92.5,231C 88.7257,229.698 85.559,227.531 83,224.5C 66.9068,203.984 50.5734,183.651 34,163.5C 27.7798,155.497 26.7798,146.83 31,137.5C 36.6667,113.167 42.3333,88.8333 48,64.5C 49.7735,59.7271 52.9402,56.2271 57.5,54C 83.2576,41.7854 108.924,29.6188 134.5,17.5 Z"/></g>
<g><path style="opacity:1" fill="#346de5" d="M 134.5,24.5 C 139.08,24.1134 143.414,24.9468 147.5,27C 171.045,38.606 194.712,49.9393 218.5,61C 222.491,63.7785 224.658,67.6119 225,72.5C 229.528,94.2768 234.528,115.943 240,137.5C 241.168,142.482 241.835,147.482 242,152.5C 241.439,154.725 240.439,156.725 239,158.5C 222.427,178.651 206.093,198.984 190,219.5C 188.269,221.617 186.102,223.117 183.5,224C 153.5,224.667 123.5,224.667 93.5,224C 73.0249,201.215 53.8582,177.382 36,152.5C 41.3608,123.356 47.6941,94.3556 55,65.5C 56.5,64 58,62.5 59.5,61C 84.8363,49.3308 109.836,37.1641 134.5,24.5 Z"/></g>
<g><path style="opacity:1" fill="#fafbfe" d="M 133.5,45.5 C 137.167,45.5 140.833,45.5 144.5,45.5C 144.5,52.8333 144.5,60.1667 144.5,67.5C 158.146,68.9079 169.979,74.2412 180,83.5C 186.083,79.5376 191.917,75.2043 197.5,70.5C 199.493,72.6655 201.327,74.9989 203,77.5C 203.749,78.635 203.583,79.635 202.5,80.5C 197.179,84.489 192.179,88.8223 187.5,93.5C 194.894,105.411 198.061,118.411 197,132.5C 198.785,133.24 200.618,133.907 202.5,134.5C 203.471,131.879 204.804,129.546 206.5,127.5C 212.363,132.529 217.697,138.029 222.5,144C 222.355,144.772 222.022,145.439 221.5,146C 214.573,148.476 207.573,150.643 200.5,152.5C 200.5,149.833 200.5,147.167 200.5,144.5C 198.208,144.756 196.041,144.423 194,143.5C 188.976,155.86 180.976,165.86 170,173.5C 170.384,176.309 171.384,178.975 173,181.5C 174.897,179.984 177.064,179.317 179.5,179.5C 178.903,187.153 178.403,194.82 178,202.5C 177.439,203.022 176.772,203.355 176,203.5C 169.677,199.182 163.344,194.848 157,190.5C 156.312,189.668 156.479,189.002 157.5,188.5C 159.332,187.752 160.999,186.752 162.5,185.5C 161.42,183.004 160.086,180.67 158.5,178.5C 145.627,183.814 132.794,183.814 120,178.5C 118.833,180.833 117.667,183.167 116.5,185.5C 117.912,186.806 119.579,187.64 121.5,188C 122.451,188.718 122.617,189.551 122,190.5C 115.505,195.521 108.671,199.854 101.5,203.5C 100.745,195.178 100.078,186.845 99.5,178.5C 101.816,179.36 104.149,179.86 106.5,180C 107.627,178.247 108.627,176.413 109.5,174.5C 97.8509,166.691 89.3509,156.358 84,143.5C 81.9592,144.423 79.7925,144.756 77.5,144.5C 77.8333,147.167 78.1667,149.833 78.5,152.5C 71.0621,150.856 63.7288,148.689 56.5,146C 55.9781,145.439 55.6448,144.772 55.5,144C 60.3409,138.232 65.6742,132.899 71.5,128C 72.3317,127.312 72.9984,127.479 73.5,128.5C 74.3094,130.071 74.6427,131.738 74.5,133.5C 76.7925,133.756 78.9592,133.423 81,132.5C 80.115,118.45 83.2817,105.45 90.5,93.5C 85.5084,88.6769 80.3418,84.0102 75,79.5C 75.7298,75.4517 77.8965,72.6183 81.5,71C 87.0109,75.1809 92.5109,79.3475 98,83.5C 108.046,74.2274 119.879,68.8941 133.5,67.5C 133.5,60.1667 133.5,52.8333 133.5,45.5 Z"/></g>
<g><path style="opacity:0.882" fill="#000000" d="M 858.5,74.5 C 867.424,74.3534 871.257,78.6868 870,87.5C 867.185,93.1691 862.685,95.0024 856.5,93C 850.261,88.7034 849.261,83.3701 853.5,77C 855.315,76.2432 856.981,75.4098 858.5,74.5 Z"/></g>
<g><path style="opacity:1" fill="#356ee5" d="M 127.5,79.5 C 129.5,79.5 131.5,79.5 133.5,79.5C 133.666,89.1724 133.5,98.8391 133,108.5C 132.275,109.059 131.442,109.392 130.5,109.5C 122.292,104.225 114.625,98.2248 107.5,91.5C 113.265,85.9526 119.932,81.9526 127.5,79.5 Z"/></g>
<g><path style="opacity:1" fill="#356de5" d="M 144.5,79.5 C 154.716,80.2764 163.382,84.2764 170.5,91.5C 163.172,97.9916 155.672,104.325 148,110.5C 147,109.833 146,109.167 145,108.5C 144.5,98.8391 144.334,89.1724 144.5,79.5 Z"/></g>
<g><path style="opacity:0.928" fill="#000000" d="M 423.5,83.5 C 424.833,83.5 426.167,83.5 427.5,83.5C 427.5,88.8333 427.5,94.1667 427.5,99.5C 433.833,99.5 440.167,99.5 446.5,99.5C 446.5,104.167 446.5,108.833 446.5,113.5C 440.167,113.5 433.833,113.5 427.5,113.5C 427.13,121.903 427.63,130.236 429,138.5C 430.779,140.764 433.113,142.097 436,142.5C 439.478,141.671 442.978,141.004 446.5,140.5C 446.896,144.375 447.562,148.208 448.5,152C 448.095,152.945 447.428,153.612 446.5,154C 438.116,156.922 429.782,156.922 421.5,154C 415.996,151.16 412.829,146.66 412,140.5C 411.5,122.17 411.333,103.836 411.5,85.5C 415.733,85.4613 419.733,84.7947 423.5,83.5 Z"/></g>
<g><path style="opacity:0.918" fill="#000000" d="M 311.5,98.5 C 321.347,97.9802 331.014,98.9802 340.5,101.5C 341.921,120.529 341.754,139.529 340,158.5C 337.742,166.389 332.575,171.222 324.5,173C 314.057,175.006 303.724,174.506 293.5,171.5C 294.111,166.892 295.111,162.392 296.5,158C 303.028,159.529 309.694,160.196 316.5,160C 322.554,158.957 325.054,155.457 324,149.5C 303.472,154.648 292.305,146.648 290.5,125.5C 291.084,111.263 298.084,102.263 311.5,98.5 Z M 316.5,111.5 C 319.119,111.232 321.619,111.565 324,112.5C 324.167,116.5 324.333,120.5 324.5,124.5C 327.333,136.731 323,140.564 311.5,136C 307.355,130.681 306.522,124.848 309,118.5C 310.767,115.228 313.267,112.895 316.5,111.5 Z"/></g>
<g><path style="opacity:0.94" fill="#000000" d="M 364.5,98.5 C 371.175,98.3337 377.842,98.5004 384.5,99C 391.702,100.869 396.202,105.369 398,112.5C 398.5,126.163 398.667,139.829 398.5,153.5C 387.249,155.423 375.916,155.923 364.5,155C 353.152,151.144 348.985,143.31 352,131.5C 354.443,125.394 358.943,121.894 365.5,121C 371.528,120.83 377.528,120.33 383.5,119.5C 382.625,115.126 379.958,112.626 375.5,112C 369.805,111.623 364.305,112.456 359,114.5C 357.414,109.983 356.58,105.316 356.5,100.5C 359.373,100.198 362.039,99.531 364.5,98.5 Z M 372.5,131.5 C 376.167,131.5 379.833,131.5 383.5,131.5C 383.5,135.167 383.5,138.833 383.5,142.5C 378.728,143.929 374.061,143.595 369.5,141.5C 366.482,136.899 367.482,133.565 372.5,131.5 Z"/></g>
<g><path style="opacity:0.928" fill="#000000" d="M 472.5,98.5 C 497.203,96.5548 507.87,107.888 504.5,132.5C 493.167,132.5 481.833,132.5 470.5,132.5C 470.79,136.961 473.123,139.795 477.5,141C 479.847,141.436 482.181,141.936 484.5,142.5C 489.581,141.61 494.581,140.776 499.5,140C 500.861,144.362 501.528,148.862 501.5,153.5C 491.612,156.456 481.612,156.956 471.5,155C 458.543,150.518 452.543,141.352 453.5,127.5C 453.103,113.266 459.436,103.599 472.5,98.5 Z M 477.5,111.5 C 483.988,111.484 487.988,114.651 489.5,121C 483.175,121.5 476.842,121.666 470.5,121.5C 470.873,116.742 473.206,113.409 477.5,111.5 Z"/></g>
<g><path style="opacity:0.926" fill="#000000" d="M 605.5,98.5 C 612.175,98.3337 618.842,98.5004 625.5,99C 635.288,101.791 640.122,108.291 640,118.5C 640.5,130.162 640.667,141.829 640.5,153.5C 628.91,155.397 617.243,155.897 605.5,155C 594.473,151.455 590.306,143.955 593,132.5C 595.154,125.994 599.654,122.161 606.5,121C 612.491,120.501 618.491,120.334 624.5,120.5C 624.064,115.564 621.397,112.731 616.5,112C 610.805,111.623 605.305,112.456 600,114.5C 598.627,109.928 597.794,105.261 597.5,100.5C 600.373,100.198 603.039,99.531 605.5,98.5 Z M 613.5,131.5 C 617.167,131.5 620.833,131.5 624.5,131.5C 624.5,135.167 624.5,138.833 624.5,142.5C 619.728,143.929 615.061,143.595 610.5,141.5C 607.462,136.989 608.462,133.656 613.5,131.5 Z"/></g>
<g><path style="opacity:0.925" fill="#000000" d="M 742.5,98.5 C 749.175,98.3337 755.842,98.5004 762.5,99C 771.815,101.649 776.649,107.816 777,117.5C 777.5,129.495 777.667,141.495 777.5,153.5C 766.244,155.386 754.911,155.886 743.5,155C 731.751,152.02 727.251,144.52 730,132.5C 732.154,125.994 736.654,122.161 743.5,121C 749.491,120.501 755.491,120.334 761.5,120.5C 761.064,115.564 758.397,112.731 753.5,112C 747.826,111.696 742.326,112.529 737,114.5C 735.627,109.928 734.794,105.261 734.5,100.5C 737.373,100.198 740.039,99.531 742.5,98.5 Z M 750.5,131.5 C 754.167,131.5 757.833,131.5 761.5,131.5C 761.5,135.167 761.5,138.833 761.5,142.5C 757.128,143.885 752.795,143.718 748.5,142C 744.299,137.629 744.966,134.129 750.5,131.5 Z"/></g>
<g><path style="opacity:0.945" fill="#000000" d="M 802.5,98.5 C 832.848,95.8694 845.348,109.536 840,139.5C 837.5,147.333 832.333,152.5 824.5,155C 818.472,155.641 812.472,155.474 806.5,154.5C 806.5,160.833 806.5,167.167 806.5,173.5C 801.167,173.5 795.833,173.5 790.5,173.5C 790.333,149.498 790.5,125.498 791,101.5C 794.917,100.439 798.751,99.4392 802.5,98.5 Z M 806.5,112.5 C 818.841,110.485 824.841,115.652 824.5,128C 824.34,140.262 818.34,144.429 806.5,140.5C 806.5,131.167 806.5,121.833 806.5,112.5 Z"/></g>
<g><path style="opacity:0.919" fill="#000000" d="M 509.5,99.5 C 515.5,99.5 521.5,99.5 527.5,99.5C 529.363,110.955 531.863,122.288 535,133.5C 538.352,122.28 541.186,110.947 543.5,99.5C 547.833,99.5 552.167,99.5 556.5,99.5C 558.225,110.401 560.892,121.068 564.5,131.5C 567.793,120.994 570.46,110.328 572.5,99.5C 578.167,99.5 583.833,99.5 589.5,99.5C 584.799,118.104 578.799,136.271 571.5,154C 567.129,154.828 562.795,154.661 558.5,153.5C 555.493,144.813 552.493,136.146 549.5,127.5C 546.671,136.14 543.838,144.806 541,153.5C 536.55,154.8 532.05,154.8 527.5,153.5C 520.497,135.824 514.497,117.824 509.5,99.5 Z"/></g>
<g><path style="opacity:0.917" fill="#000000" d="M 645.5,99.5 C 651.425,99.1918 657.259,99.5251 663,100.5C 665.869,111.773 669.536,122.773 674,133.5C 677.886,122.345 681.053,111.011 683.5,99.5C 689.167,99.5 694.833,99.5 700.5,99.5C 694.611,121.996 686.445,143.663 676,164.5C 669.118,173.048 660.284,175.881 649.5,173C 647.616,172.784 645.949,172.117 644.5,171C 645.942,166.959 646.942,162.792 647.5,158.5C 651.796,159.463 656.129,159.629 660.5,159C 662.958,157.213 664.624,154.879 665.5,152C 657.154,135.128 650.488,117.628 645.5,99.5 Z"/></g>
<g><path style="opacity:0.95" fill="#000000" d="M 852.5,99.5 C 857.833,99.5 863.167,99.5 868.5,99.5C 868.5,117.833 868.5,136.167 868.5,154.5C 863.167,154.5 857.833,154.5 852.5,154.5C 852.5,136.167 852.5,117.833 852.5,99.5 Z"/></g>
<g><path style="opacity:1" fill="#386ee5" d="M 99.5,100.5 C 107.134,105.665 114.468,111.332 121.5,117.5C 122.833,119.167 122.833,120.833 121.5,122.5C 112.581,125.153 103.581,127.486 94.5,129.5C 92.1812,119.117 93.8478,109.45 99.5,100.5 Z"/></g>
<g><path style="opacity:1" fill="#386fe5" d="M 177.5,100.5 C 184.058,109.086 186.058,118.752 183.5,129.5C 174.476,127.494 165.476,125.328 156.5,123C 155.24,121.186 155.24,119.353 156.5,117.5C 163.753,112.054 170.753,106.387 177.5,100.5 Z"/></g>
<g><path style="opacity:1" fill="#4173e6" d="M 135.5,116.5 C 141.755,115.261 145.422,117.761 146.5,124C 144.602,131.278 140.269,133.111 133.5,129.5C 130.544,124.611 131.211,120.278 135.5,116.5 Z"/></g>
<g><path style="opacity:1" fill="#386fe5" d="M 120.5,134.5 C 122.5,134.5 124.5,134.5 126.5,134.5C 123.684,144.464 119.517,153.797 114,162.5C 105.956,157.595 100.123,150.762 96.5,142C 96.9054,141.055 97.572,140.388 98.5,140C 105.962,138.134 113.295,136.301 120.5,134.5 Z"/></g>
<g><path style="opacity:1" fill="#386ee5" d="M 152.5,133.5 C 161.379,136.092 170.379,138.259 179.5,140C 180.428,140.388 181.095,141.055 181.5,142C 178.209,150.792 172.542,157.626 164.5,162.5C 159.86,154.421 155.693,146.087 152,137.5C 151.421,136.072 151.588,134.738 152.5,133.5 Z"/></g>
<g><path style="opacity:1" fill="#376ee5" d="M 136.5,141.5 C 138.604,141.201 140.604,141.534 142.5,142.5C 146.737,150.968 150.403,159.635 153.5,168.5C 148.384,169.489 143.218,170.156 138,170.5C 133.215,170.678 128.715,169.678 124.5,167.5C 129.059,159.051 133.059,150.384 136.5,141.5 Z"/></g>
</svg>

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -0,0 +1,703 @@
---
layout: blog
title: "Gateway API v1.3.0流量复制、CORS、Gateway 合并和重试预算的改进"
date: 2025-06-02T09:00:00-08:00
draft: false
slug: gateway-api-v1-3
author: >
[Candace Holman](https://github.com/candita) (Red Hat)
translator: >
[Wenjun Lou](https://github.com/Eason1118)
---
<!--
layout: blog
title: "Gateway API v1.3.0: Advancements in Request Mirroring, CORS, Gateway Merging, and Retry Budgets"
date: 2025-06-02T09:00:00-08:00
draft: false
slug: gateway-api-v1-3
author: >
[Candace Holman](https://github.com/candita) (Red Hat)
-->
![Gateway API logo](gateway-api-logo.svg)
<!--
Join us in the Kubernetes SIG Network community in celebrating the general
availability of [Gateway API](https://gateway-api.sigs.k8s.io/) v1.3.0! We are
also pleased to announce that there are already a number of conformant
implementations to try, made possible by postponing this blog
announcement. Version 1.3.0 of the API was released about a month ago on
April 24, 2025.
-->
加入 Kubernetes SIG Network 社区,共同庆祝 [Gateway API](https://gateway-api.sigs.k8s.io/) v1.3.0 正式发布!
我们很高兴地宣布,通过推迟这篇博客的发布,现在已经有了多个符合规范的实现可供试用。
API 1.3.0 版本已于 2025 年 4 月 24 日发布。
<!--
Gateway API v1.3.0 brings a new feature to the _Standard_ channel
(Gateway API's GA release channel): _percentage-based request mirroring_, and
introduces three new experimental features: cross-origin resource sharing (CORS)
filters, a standardized mechanism for listener and gateway merging, and retry
budgets.
-->
Gateway API v1.3.0 为 **Standard** 渠道Gateway API 的正式发布渠道)带来了一个新功能:**基于百分比的流量复制**
并引入了三个新的实验性功能:
- 跨源资源共享CORS过滤器
- Listener 和 Gateway 合并的标准化机制
- 重试预算Retry Budgets
<!--
Also see the full
[release notes](https://github.com/kubernetes-sigs/gateway-api/blob/54df0a899c1c5c845dd3a80f05dcfdf65576f03c/CHANGELOG/1.3-CHANGELOG.md)
and applaud the
[v1.3.0 release team](https://github.com/kubernetes-sigs/gateway-api/blob/54df0a899c1c5c845dd3a80f05dcfdf65576f03c/CHANGELOG/1.3-TEAM.md)
next time you see them.
-->
另请查看完整的[发布说明](https://github.com/kubernetes-sigs/gateway-api/blob/54df0a899c1c5c845dd3a80f05dcfdf65576f03c/CHANGELOG/1.3-CHANGELOG.md)
下次见到 [v1.3.0 发布团队](https://github.com/kubernetes-sigs/gateway-api/blob/54df0a899c1c5c845dd3a80f05dcfdf65576f03c/CHANGELOG/1.3-TEAM.md) 时请为他们鼓掌。
<!--
## Graduation to Standard channel
-->
## 升级至 Standard 渠道 {#graduation-to-standard-channel}
<!--
Graduation to the Standard channel is a notable achievement for Gateway API
features, as inclusion in the Standard release channel denotes a high level of
confidence in the API surface and provides guarantees of backward compatibility.
Of course, as with any other Kubernetes API, Standard channel features can continue
to evolve with backward-compatible additions over time, and we (SIG Network)
certainly expect
further refinements and improvements in the future. For more information on how
all of this works, refer to the [Gateway API Versioning Policy](https://gateway-api.sigs.k8s.io/concepts/versioning/).
-->
对于 Gateway API 的功能来说,升级到 Standard 渠道是一个重要的里程碑。
被纳入 Standard 发布渠道表明我们对该 API 接口的稳定性具有高度信心,并且承诺向后兼容。
当然,与任何其他 Kubernetes API 一样, Standard 渠道中的功能仍可通过向后兼容的方式不断演进。
我们SIG Network也确实预计未来会有进一步的优化和改进。
有关这一切如何运作的更多信息,请参阅 [Gateway API 版本控制策略](https://gateway-api.sigs.k8s.io/concepts/versioning/)。
<!--
### Percentage-based request mirroring
Leads: [Lior Lieberman](https://github.com/LiorLieberman),[Jake Bennert](https://github.com/jakebennert)
GEP-3171: [Percentage-Based Request Mirroring](https://github.com/kubernetes-sigs/gateway-api/blob/main/geps/gep-3171/index.md)
-->
### 基于百分比的流量复制 {#percentage-based-request-mirroring}
负责人:[Lior Lieberman](https://github.com/LiorLieberman)、[Jake Bennert](https://github.com/jakebennert)
GEP-3171[基于百分比的流量复制](https://github.com/kubernetes-sigs/gateway-api/blob/main/geps/gep-3171/index.md)
<!--
_Percentage-based request mirroring_ is an enhancement to the
existing support for [HTTP request mirroring](https://gateway-api.sigs.k8s.io/guides/http-request-mirroring/), which allows HTTP requests to be duplicated to another backend using the
RequestMirror filter type. Request mirroring is particularly useful in
blue-green deployment. It can be used to assess the impact of request scaling on
application performance without impacting responses to clients.
-->
**基于百分比的流量复制**是对现有 [HTTP 流量复制](https://gateway-api.sigs.k8s.io/guides/http-request-mirroring/) 支持的增强,
它允许使用 RequestMirror 过滤器类型将 HTTP 请求复制到另一个后端。流量复制在蓝绿部署中特别有用。
它可用于评估流量波动对应用程序性能的影响,而不会影响对客户端的响应。
<!--
The previous mirroring capability worked on all the requests to a `backendRef`.
Percentage-based request mirroring allows users to specify a subset of requests
they want to be mirrored, either by percentage or fraction. This can be
particularly useful when services are receiving a large volume of requests.
Instead of mirroring all of those requests, this new feature can be used to
mirror a smaller subset of them.
-->
之前的流量复制功能适用于对 `backendRef` 的所有请求。基于百分比的流量复制允许用户指定他们想要复制的请求子集,
可以通过百分比或分数来指定。当服务接收大量请求时,这特别有用。这个新功能可以用来复制这些请求中的一小部分,
而不是复制所有请求。
<!--
Here's an example with 42% of the requests to "foo-v1" being mirrored to "foo-v2":
-->
以下是一个示例,将发送到 "foo-v1" 的流量的 42% 复制到 "foo-v2"
<!--
```yaml
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: http-filter-mirror
labels:
gateway: mirror-gateway
spec:
parentRefs:
- name: mirror-gateway
hostnames:
- mirror.example
rules:
- backendRefs:
- name: foo-v1
port: 8080
filters:
- type: RequestMirror
requestMirror:
backendRef:
name: foo-v2
port: 8080
percent: 42 # This value must be an integer.
```
-->
```yaml
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: http-filter-mirror
labels:
gateway: mirror-gateway
spec:
parentRefs:
- name: mirror-gateway
hostnames:
- mirror.example
rules:
- backendRefs:
- name: foo-v1
port: 8080
filters:
- type: RequestMirror
requestMirror:
backendRef:
name: foo-v2
port: 8080
percent: 42 # 此值必须为整数。
```
<!--
You can also configure the partial mirroring using a fraction. Here is an example
with 5 out of every 1000 requests to "foo-v1" being mirrored to "foo-v2".
-->
你也可以通过调整分数来实现部分流量复制。
以下是一个示例,在发送到 "foo-v1" 的请求中,将每 1000 个中的 5 个复制到 "foo-v2"。
```yaml
rules:
- backendRefs:
- name: foo-v1
port: 8080
filters:
- type: RequestMirror
requestMirror:
backendRef:
name: foo-v2
port: 8080
fraction:
numerator: 5
denominator: 1000
```
<!--
## Additions to Experimental channel
-->
## 实验渠道的新特性 {#additions-to-Experimental-channel}
<!--
The Experimental channel is Gateway API's channel for experimenting with new
features and gaining confidence with them before allowing them to graduate to
standard. Please note: the experimental channel may include features that are
changed or removed later.
-->
实验渠道Experimental channel是 Gateway API 用于试验新功能的渠道,以便在功能成熟之前积累足够信心,
再将其升级为 Standard 渠道功能。
请注意:实验渠道可能包含后续会被更改或移除的功能。
<!--
Starting in release v1.3.0, in an effort to distinguish Experimental channel
resources from Standard channel resources, any new experimental API kinds have the
prefix "**X**". For the same reason, experimental resources are now added to the
API group `gateway.networking.x-k8s.io` instead of `gateway.networking.k8s.io`.
Bear in mind that using new experimental channel resources means they can coexist
with standard channel resources, but migrating these resources to the standard
channel will require recreating them with the standard channel names and API
group (both of which lack the "x-k8s" designator or "X" prefix).
-->
从 v1.3.0 版本开始,为了区分实验渠道资源和 Standard 渠道资源,
所有新的实验性 API 类型都带有 "**X**" 前缀。
出于同样的原因,实验性资源现在被添加到 API 组 `gateway.networking.x-k8s.io`
而不是 `gateway.networking.k8s.io`
请注意,使用新的实验渠道资源意味着它们可以与 Standard 渠道资源共存,
若要将这些资源迁移到 Standard 渠道,则需要使用 Standard 渠道的名称和 API 组
(两者都不包含 "x-k8s" 标识或 "X" 前缀)来重新创建它们。
<!--
The v1.3 release introduces two new experimental API kinds: XBackendTrafficPolicy
and XListenerSet. To be able to use experimental API kinds, you need to install
the Experimental channel Gateway API YAMLs from the locations listed below.
-->
v1.3 版本引入了两个新的实验性 API 类型XBackendTrafficPolicy 和 XListenerSet。
要使用实验性 API 类型,你需要从下面列出的位置安装实验渠道 Gateway API YAML 文件。
<!--
### CORS filtering
-->
### CORS 过滤 {#cors-filtering}
<!--
Leads: [Liang Li](https://github.com/liangli), [Eyal Pazz](https://github.com/EyalPazz), [Rob Scott](https://github.com/robscott)
GEP-1767: [CORS Filter](https://github.com/kubernetes-sigs/gateway-api/blob/main/geps/gep-1767/index.md)
-->
负责人:[Liang Li](https://github.com/liangli)、[Eyal Pazz](https://github.com/EyalPazz)、[Rob Scott](https://github.com/robscott)
GEP-1767[CORS 过滤器](https://github.com/kubernetes-sigs/gateway-api/blob/main/geps/gep-1767/index.md)
<!--
Cross-origin resource sharing (CORS) is an HTTP-header based mechanism that allows
a web page to access restricted resources from a server on an origin (domain,
scheme, or port) different from the domain that served the web page. This feature
adds a new HTTPRoute `filter` type, called "CORS", to configure the handling of
cross-origin requests before the response is sent back to the client.
-->
跨源资源共享CORS是一种基于 HTTP Header 的机制,
允许网页从与提供网页的域不同的源(域名、协议或端口)访问受限资源。
此功能添加了一个新的 HTTPRoute `filter` 类型,
称为 "CORS",用于在响应发送回客户端之前配置跨源请求的处理。
<!--
To be able to use experimental CORS filtering, you need to install the
[Experimental channel Gateway API HTTPRoute yaml](https://github.com/kubernetes-sigs/gateway-api/blob/main/config/crd/experimental/gateway.networking.k8s.io_httproutes.yaml).
-->
要使用实验性 CORS 过滤,你需要安装[实验渠道 Gateway API HTTPRoute yaml](https://github.com/kubernetes-sigs/gateway-api/blob/main/config/crd/experimental/gateway.networking.k8s.io_httproutes.yaml)。
<!--
Here's an example of a simple cross-origin configuration:
-->
以下是一个简单的跨源配置示例:
```yaml
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: http-route-cors
spec:
parentRefs:
- name: http-gateway
rules:
- matches:
- path:
type: PathPrefix
value: /resource/foo
filters:
- cors:
- type: CORS
allowOrigins:
- *
allowMethods:
- GET
- HEAD
- POST
allowHeaders:
- Accept
- Accept-Language
- Content-Language
- Content-Type
- Range
backendRefs:
- kind: Service
name: http-route-cors
port: 80
```
<!--
In this case, the Gateway returns an _origin header_ of "*", which means that the
requested resource can be referenced from any origin, a _methods header_
(`Access-Control-Allow-Methods`) that permits the `GET`, `HEAD`, and `POST`
verbs, and a _headers header_ allowing `Accept`, `Accept-Language`,
`Content-Language`, `Content-Type`, and `Range`.
-->
在这种情况下Gateway 返回一个 **origin header** 为 "*",这意味着请求的资源可以从任何源引用;
一个 **methods header** `Access-Control-Allow-Methods`)允许 `GET`、`HEAD` 和 `POST` 方法;
此外,还会返回一个 **headers header** ,允许的字段包括 `Accept`、`Accept-Language`、
`Content-Language`、`Content-Type` 和 `Range`
```text
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, HEAD, POST
Access-Control-Allow-Headers: Accept,Accept-Language,Content-Language,Content-Type,Range
```
<!--
The complete list of fields in the new CORS filter:
* `allowOrigins`
* `allowMethods`
* `allowHeaders`
* `allowCredentials`
* `exposeHeaders`
* `maxAge`
See [CORS protocol](https://fetch.spec.whatwg.org/#http-cors-protocol) for details.
-->
新的 CORS 过滤器中的完整字段列表如下:
* `allowOrigins`:允许的请求来源列表。
* `allowMethods`:允许的 HTTP 方法(如 `GET`、`POST` 等)。
* `allowHeaders`:允许携带的请求头字段。
* `allowCredentials`:是否允许携带凭据(如 Cookie、Authorization 头等)。
* `exposeHeaders`:允许客户端访问的响应头字段。
* `maxAge`:预检请求的缓存持续时间(单位:秒)。
有关详细信息,请参阅 [CORS 协议](https://fetch.spec.whatwg.org/#http-cors-protocol)。
<!--
### XListenerSets (standardized mechanism for Listener and Gateway merging){#XListenerSet}
-->
### XListenerSetsListener 和 Gateway 合并的标准化机制){#XListenerSet}
<!--
Lead: [Dave Protasowski](https://github.com/dprotaso)
-->
负责人:[Dave Protasowski](https://github.com/dprotaso)
<!--
GEP-1713: [ListenerSets - Standard Mechanism to Merge Multiple Gateways](https://github.com/kubernetes-sigs/gateway-api/pull/3213)
-->
GEP-1713[ListenerSets - 合并多个 Gateway 的标准机制](https://github.com/kubernetes-sigs/gateway-api/pull/3213)
<!--
This release adds a new experimental API kind, XListenerSet, that allows a
shared list of _listeners_ to be attached to one or more parent Gateway(s). In
addition, it expands upon the existing suggestion that Gateway API implementations
may merge configuration from multiple Gateway objects. It also:
-->
此版本添加了一个新的实验性 API 类型 XListenerSet它允许将 **listeners** 的共享列表附加到一个或多个父 Gateway。
此外,它还扩展了现有的建议,即 Gateway API 实现可以合并来自多个 Gateway 对象的配置。它还包括:
<!--
- adds a new field `allowedListeners` to the `.spec` of a Gateway. The
`allowedListeners` field defines from which Namespaces to select XListenerSets
that are allowed to attach to that Gateway: Same, All, None, or Selector based.
-->
- 向 Gateway 的 `.spec` 添加了一个新字段 `allowedListeners`
`allowedListeners` 字段定义了从哪些命名空间选择允许附加到该 Gateway 的 XListenerSets
Same同一命名空间、All所有命名空间、None不允许、或基于选择器Selector的方式。
<!--
- increases the previous maximum number (64) of listeners with the addition of
XListenerSets.
-->
- 通过添加 XListenerSets 增加了之前的监听器最大数量64
<!--
- allows the delegation of listener configuration, such as TLS, to applications in
other namespaces.
-->
- 允许将监听器配置(如 TLS委托给其他命名空间中的应用程序。
<!--
To be able to use experimental XListenerSet, you need to install the
[Experimental channel Gateway API XListenerSet yaml](https://github.com/kubernetes-sigs/gateway-api/blob/main/config/crd/experimental/gateway.networking.x-k8s.io_xlistenersets.yaml).
-->
要使用实验性 XListenerSet你需要安装[实验渠道 Gateway API XListenerSet yaml](https://github.com/kubernetes-sigs/gateway-api/blob/main/config/crd/experimental/gateway.networking.x-k8s.io_xlistenersets.yaml)。
<!--
The following example shows a Gateway with an HTTP listener and two child HTTPS
XListenerSets with unique hostnames and certificates. The combined set of listeners
attached to the Gateway includes the two additional HTTPS listeners in the
XListenerSets that attach to the Gateway. This example illustrates the
delegation of listener TLS config to application owners in different namespaces
("store" and "app"). The HTTPRoute has both the Gateway listener named "foo" and
one XListenerSet listener named "second" as `parentRefs`.
-->
以下示例展示了一个带有 HTTP 监听器和两个子 HTTPS XListenerSets 的 Gateway
每个 XListenerSet 都有唯一的主机名和证书。
最终附加到该 Gateway 的监听器集合包含这两个附加的 HTTPS `XListenerSet` 监听器。
此示例说明了将监听器 TLS 配置委托给不同命名空间("store" 和 "app")中的应用程序所有者。
HTTPRoute 同时将名为 `"foo"` 的 Gateway 监听器和一个名为 `"second"``XListenerSet`
监听器设置为其 `parentRefs`
```yaml
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: prod-external
namespace: infra
spec:
gatewayClassName: example
allowedListeners:
- from: All
listeners:
- name: foo
hostname: foo.com
protocol: HTTP
port: 80
---
apiVersion: gateway.networking.x-k8s.io/v1alpha1
kind: XListenerSet
metadata:
name: store
namespace: store
spec:
parentRef:
name: prod-external
listeners:
- name: first
hostname: first.foo.com
protocol: HTTPS
port: 443
tls:
mode: Terminate
certificateRefs:
- kind: Secret
group: ""
name: first-workload-cert
---
apiVersion: gateway.networking.x-k8s.io/v1alpha1
kind: XListenerSet
metadata:
name: app
namespace: app
spec:
parentRef:
name: prod-external
listeners:
- name: second
hostname: second.foo.com
protocol: HTTPS
port: 443
tls:
mode: Terminate
certificateRefs:
- kind: Secret
group: ""
name: second-workload-cert
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: httproute-example
spec:
parentRefs:
- name: app
kind: XListenerSet
sectionName: second
- name: parent-gateway
kind: Gateway
sectionName: foo
...
```
<!--
Each listener in a Gateway must have a unique combination of `port`, `protocol`,
(and `hostname` if supported by the protocol) in order for all listeners to be
**compatible** and not conflicted over which traffic they should receive.
-->
Gateway 中的每个监听器必须具有唯一的 `port`、`protocol` 组合
(如果协议支持,还包括 `hostname`
以便所有监听器都**兼容**,并且不会在它们应该接收的流量上发生冲突。
<!--
Furthermore, implementations can _merge_ separate Gateways into a single set of
listener addresses if all listeners across those Gateways are compatible. The
management of merged listeners was under-specified in releases prior to v1.3.0.
-->
此外,如果这些 Gateway 上的所有监听器都兼容,实现可以将单独的 Gateway **合并**为单个监听器地址集。
在 v1.3.0 之前的版本中,合并监听器的管理规范不足。
<!--
With the new feature, the specification on merging is expanded. Implementations
must treat the parent Gateways as having the merged list of all listeners from
itself and from attached XListenerSets, and validation of this list of listeners
must behave the same as if the list were part of a single Gateway. Within a single
Gateway, listeners are ordered using the following precedence:
-->
通过新功能,合并规范得到了扩展。实现必须将父 Gateway 视为具有来自自身和附加的 XListenerSets
的所有监听器的合并列表,
并且对该监听器列表的验证行为应与其作为单个 Gateway 的一部分。
在单个 Gateway 内,监听器使用以下优先级排序:
<!--
1. Single Listeners (not a part of an XListenerSet) first,
-->
1. 首先是单个监听器(而不是 XListenerSet 的一部分),
<!--
2. Remaining listeners ordered by:
- object creation time (oldest first), and if two listeners are defined in
objects that have the same timestamp, then
- alphabetically based on "{namespace}/{name of listener}"
-->
2. 其余监听器按以下顺序排序:
- 按对象创建时间排序(最早创建的优先);如果两个监听器所在的对象具有相同的时间戳,
则按照 `{namespace}/{监听器名称}` 的字母顺序排序
<!--
### Retry budgets (XBackendTrafficPolicy) {#XBackendTrafficPolicy}
-->
### 重试预算Retry budgetsXBackendTrafficPolicy{#XBackendTrafficPolicy}
<!--
Leads: [Eric Bishop](https://github.com/ericdbishop), [Mike Morris](https://github.com/mikemorris)
-->
负责人:[Eric Bishop](https://github.com/ericdbishop)、[Mike Morris](https://github.com/mikemorris)
<!--
GEP-3388: [Retry Budgets](https://gateway-api.sigs.k8s.io/geps/gep-3388)
-->
GEP-3388[重试预算Retry budgets](https://gateway-api.sigs.k8s.io/geps/gep-3388)
<!--
This feature allows you to configure a _retry budget_ across all endpoints
of a destination Service. This is used to limit additional client-side retries
after reaching a configured threshold. When configuring the budget, the maximum
percentage of active requests that may consist of retries may be specified, as well as
the interval over which requests will be considered when calculating the threshold
for retries. The development of this specification changed the existing
experimental API kind BackendLBPolicy into a new experimental API kind,
XBackendTrafficPolicy, in the interest of reducing the proliferation of policy
resources that had commonalities.
-->
此功能允许你为目标服务的所有端点配置**重试预算Retry budgets**。
用于在达到配置的阈值后限制额外的客户端重试。
配置预算时,可以指定可能包含重试在内的活动请求的最大百分比,
以及在计算重试阈值时考虑请求的时间间隔。
此规范的开发将现有的实验性 API 类型 BackendLBPolicy 更改为新的实验性 API 类型 XBackendTrafficPolicy
以减少具有共同点的策略资源的扩散。
<!--
To be able to use experimental retry budgets, you need to install the
[Experimental channel Gateway API XBackendTrafficPolicy yaml](https://github.com/kubernetes-sigs/gateway-api/blob/main/config/crd/experimental/gateway.networking.x-k8s.io_xbackendtrafficpolicies.yaml).
-->
要使用实验性重试预算Retry budgets你需要安装[实验渠道 Gateway API XBackendTrafficPolicy yaml](https://github.com/kubernetes-sigs/gateway-api/blob/main/config/crd/experimental/gateway.networking.x-k8s.io_xbackendtrafficpolicies.yaml)。
<!--
The following example shows an XBackendTrafficPolicy that applies a
`retryConstraint` that represents a budget that limits the retries to a maximum
of 20% of requests, over a duration of 10 seconds, and to a minimum of 3 retries
over 1 second.
-->
以下示例显示了一个 XBackendTrafficPolicy它应用了一个 `retryConstraint` (重试约束),
表示一个 重试预算Retry budgets ,将重试限制为最多 20% 的请求,持续时间为 10 秒,
并且在 1 秒内最少重试 3 次。
```yaml
apiVersion: gateway.networking.x-k8s.io/v1alpha1
kind: XBackendTrafficPolicy
metadata:
name: traffic-policy-example
spec:
retryConstraint:
budget:
percent: 20
interval: 10s
minRetryRate:
count: 3
interval: 1s
...
```
<!--
## Try it out
-->
## 试用
<!--
Unlike other Kubernetes APIs, you don't need to upgrade to the latest version of
Kubernetes to get the latest version of Gateway API. As long as you're running
Kubernetes 1.26 or later, you'll be able to get up and running with this version
of Gateway API.
-->
与其他 Kubernetes API 不同,你不需要升级到最新版本的 Kubernetes 来获取最新版本的 Gateway API。
只要你运行的是 Kubernetes 1.26 或更高版本,你就可以使用此版本的 Gateway API 启动和运行。
<!--
To try out the API, follow the [Getting Started Guide](https://gateway-api.sigs.k8s.io/guides/).
As of this writing, four implementations are already conformant with Gateway API
v1.3 experimental channel features. In alphabetical order:
-->
要试用 API请按照[入门指南](https://gateway-api.sigs.k8s.io/guides/)操作。
截至本文撰写时,已有四个实现符合 Gateway API v1.3 实验渠道功能。按字母顺序排列:
<!--
- [Airlock Microgateway 4.6](https://github.com/airlock/microgateway/releases/tag/4.6.0)
-->
- [Airlock Microgateway 4.6](https://github.com/airlock/microgateway/releases/tag/4.6.0)
<!--
- [Cilium main](https://github.com/cilium/cilium)
-->
- [Cilium main](https://github.com/cilium/cilium)
<!--
- [Envoy Gateway v1.4.0](https://github.com/envoyproxy/gateway/releases/tag/v1.4.0)
-->
- [Envoy Gateway v1.4.0](https://github.com/envoyproxy/gateway/releases/tag/v1.4.0)
<!--
- [Istio 1.27-dev](https://istio.io)
-->
- [Istio 1.27-dev](https://istio.io)
<!--
## Get involved
-->
## 参与其中
<!--
Wondering when a feature will be added? There are lots of opportunities to get
involved and help define the future of Kubernetes routing APIs for both ingress
and service mesh.
-->
想知道何时会添加功能?有很多机会参与并帮助定义 Kubernetes API 路由的未来,包括 Ingress 和服务网格。
<!--
* Check out the [user guides](https://gateway-api.sigs.k8s.io/guides) to see what use-cases can be addressed.
-->
* 查看[用户指南](https://gateway-api.sigs.k8s.io/guides)了解可以解决哪些用例。
<!--
* Try out one of the [existing Gateway controllers](https://gateway-api.sigs.k8s.io/implementations/).
-->
* 试用[现有的 Gateway 控制器](https://gateway-api.sigs.k8s.io/implementations/)之一。
<!--
* Or [join us in the community](https://gateway-api.sigs.k8s.io/contributing/)
and help us build the future of Gateway API together!
-->
* 或者[加入我们的社区](https://gateway-api.sigs.k8s.io/contributing/)
帮助我们共同构建 Gateway API 的未来!
<!--
The maintainers would like to thank _everyone_ who's contributed to Gateway
API, whether in the form of commits to the repo, discussion, ideas, or general
support. We could never have made this kind of progress without the support of
this dedicated and active community.
-->
维护者衷心感谢**所有**为 Gateway API 做出贡献的人,无论是通过提交代码、讨论、想法还是提供其他支持。
没有这个充满热情和活力的社区,我们永远无法取得如此进展。
<!--
## Related Kubernetes blog articles
-->
## 相关 Kubernetes 博客文章
<!--
* [Gateway API v1.2: WebSockets, Timeouts, Retries, and More](/blog/2024/11/21/gateway-api-v1-2/)
(November 2024)
-->
* [Gateway API v1.2WebSockets、超时、重试等](/blog/2024/11/21/gateway-api-v1-2/)
2024 年 11 月)
<!--
* [Gateway API v1.1: Service mesh, GRPCRoute, and a whole lot more](/blog/2024/05/09/gateway-api-v1-1/)
(May 2024)
-->
* [Gateway API v1.1服务网格、GRPCRoute 和更多变化](/zh-cn/blog/2024/05/09/gateway-api-v1-1/)
2024 年 5 月)
<!--
* [New Experimental Features in Gateway API v1.0](/blog/2023/11/28/gateway-api-ga/)
(November 2023)
-->
* [Gateway API v1.0 中的新实验功能](/blog/2023/11/28/gateway-api-ga/)
2023 年 11 月)
<!--
* [Gateway API v1.0: GA Release](/blog/2023/10/31/gateway-api-ga/)
(October 2023)
-->
* [Gateway API v1.0正式发布GA](/zh-cn/blog/2023/10/31/gateway-api-ga/)
2023 年 10 月)