Compare commits
292 Commits
copilot/re
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34871c59e3 | ||
|
|
0d4b0a9f90 | ||
|
|
b7bb1a5a7c | ||
|
|
39c98f335b | ||
|
|
edbb343c98 | ||
|
|
a9491f891a | ||
|
|
ee83b193f7 | ||
|
|
0b1cb95c9d | ||
|
|
ac0005fb0d | ||
|
|
ead514fffd | ||
|
|
70042851d6 | ||
|
|
4cf848a9e9 | ||
|
|
0418247e7e | ||
|
|
28ead632fe | ||
|
|
ccc31c040b | ||
|
|
3bf346eb6b | ||
|
|
c1d05ae952 | ||
|
|
4e9a4bdc4f | ||
|
|
661c1b0d99 | ||
|
|
d3db9106b8 | ||
|
|
8b96e4da5c | ||
|
|
143ee77d86 | ||
|
|
ebed6743b7 | ||
|
|
b35cc7d561 | ||
|
|
5c6c7f10e2 | ||
|
|
6deb9d38ae | ||
|
|
cf5ade8a49 | ||
|
|
076fa978a1 | ||
|
|
fff0ec3e85 | ||
|
|
a0cdfbeeb6 | ||
|
|
4d04dea960 | ||
|
|
badc180a79 | ||
|
|
9e726dbd69 | ||
|
|
be0c3128ac | ||
|
|
eeb246b9fd | ||
|
|
8f0e00850d | ||
|
|
304e2c3073 | ||
|
|
8a08a7e431 | ||
|
|
570f9b18b3 | ||
|
|
225ca63127 | ||
|
|
88d3ac4e45 | ||
|
|
d95d555d5b | ||
|
|
e5eea3ebd8 | ||
|
|
a1b70fa595 | ||
|
|
db5e9598b7 | ||
|
|
85d5e1ade5 | ||
|
|
2fd260be35 | ||
|
|
54e18b2b30 | ||
|
|
f35f0f8f35 | ||
|
|
0b3c8c68bb | ||
|
|
61e49fb507 | ||
|
|
6081e848f3 | ||
|
|
e0bd15ceef | ||
|
|
04695a4f30 | ||
|
|
a67cd7b5c9 | ||
|
|
60ebe19a78 | ||
|
|
76b725627e | ||
|
|
b440fb4d5e | ||
|
|
0b901fcf59 | ||
|
|
758de777bb | ||
|
|
379b23d9b8 | ||
|
|
9ce893eddb | ||
|
|
878d9a0f78 | ||
|
|
d5104c40ec | ||
|
|
4b673f7072 | ||
|
|
b066230bd0 | ||
|
|
390719a08b | ||
|
|
242ececfb2 | ||
|
|
3180560484 | ||
|
|
81fb149c1b | ||
|
|
9990c57208 | ||
|
|
dde32322dd | ||
|
|
e583eb5eba | ||
|
|
08b9aa04ab | ||
|
|
eb560f3142 | ||
|
|
74f7f33f41 | ||
|
|
36c8677bf2 | ||
|
|
c48ebfd6da | ||
|
|
36742d9207 | ||
|
|
7d49605816 | ||
|
|
91868fb70b | ||
|
|
f9a7fbe5cf | ||
|
|
a536a5d18c | ||
|
|
8f6c538890 | ||
|
|
be0d630dd2 | ||
|
|
a10e46a8f5 | ||
|
|
24166a1075 | ||
|
|
c3da9a38d3 | ||
|
|
3d246e21b2 | ||
|
|
229f50294e | ||
|
|
5ecb337374 | ||
|
|
187abe26cf | ||
|
|
e24c1aaf21 | ||
|
|
aa196aa940 | ||
|
|
d7604e9aa0 | ||
|
|
75906e35b8 | ||
|
|
cab1f2b8af | ||
|
|
1ddcb20785 | ||
|
|
bc4d3104ec | ||
|
|
e1be6afa65 | ||
|
|
63ddb7123f | ||
|
|
59fc168e86 | ||
|
|
7e12290560 | ||
|
|
426995f513 | ||
|
|
594bf5aac3 | ||
|
|
b505b09ea5 | ||
|
|
f0f27ad440 | ||
|
|
715299dac4 | ||
|
|
dab1d0492a | ||
|
|
49f6cadb3d | ||
|
|
8b217ffc4c | ||
|
|
27aca3c2aa | ||
|
|
f39623667f | ||
|
|
62ebad4092 | ||
|
|
454bf45026 | ||
|
|
409e962136 | ||
|
|
829362b36a | ||
|
|
907b335de5 | ||
|
|
880d8fb61f | ||
|
|
4757715b70 | ||
|
|
21a9f7334a | ||
|
|
b65b65a4fa | ||
|
|
9f735ed5b4 | ||
|
|
d8a3996074 | ||
|
|
d9b88d820b | ||
|
|
aec87fc7e1 | ||
|
|
2efacb8010 | ||
|
|
b658ec994c | ||
|
|
9c29c1a4c4 | ||
|
|
4e5710de83 | ||
|
|
4c281ebbc3 | ||
|
|
c90990f210 | ||
|
|
9a390bd2bf | ||
|
|
13a04ddee7 | ||
|
|
99d1f208ec | ||
|
|
4c481a3ce6 | ||
|
|
d7ec01d42b | ||
|
|
2b4f64eb03 | ||
|
|
f6b2b51710 | ||
|
|
f1d3cbad14 | ||
|
|
a72d8bf5ef | ||
|
|
772c618820 | ||
|
|
4da7b76372 | ||
|
|
5798b5acaf | ||
|
|
27bde2ea0a | ||
|
|
50e5fb6534 | ||
|
|
f09112bd0f | ||
|
|
1198e0a283 | ||
|
|
a6ec2025a0 | ||
|
|
31bb042978 | ||
|
|
9dc73c0267 | ||
|
|
93be096804 | ||
|
|
dc4742a461 | ||
|
|
592f1bfd40 | ||
|
|
6ebc8a8132 | ||
|
|
52e01ac3e3 | ||
|
|
c3a8b95208 | ||
|
|
ab95c0233d | ||
|
|
e4c0a373a5 | ||
|
|
2732caf701 | ||
|
|
1712c72d8f | ||
|
|
b1bf8e1705 | ||
|
|
8e80e29438 | ||
|
|
04d6fee28e | ||
|
|
fa9f72cbec | ||
|
|
06c517c3c4 | ||
|
|
b091165dd9 | ||
|
|
d60c7885ac | ||
|
|
9da8e84547 | ||
|
|
fb6c9ccbf8 | ||
|
|
6942c6dffc | ||
|
|
a752a177f2 | ||
|
|
6ceadc60b6 | ||
|
|
e2ff9421ef | ||
|
|
bdf1a2764a | ||
|
|
f4f39b0013 | ||
|
|
1d5613f939 | ||
|
|
e88dfb4468 | ||
|
|
b7f257de07 | ||
|
|
af18183cf3 | ||
|
|
a2fa5061d4 | ||
|
|
b18db6facb | ||
|
|
76e7e51442 | ||
|
|
799c5f5c33 | ||
|
|
044fa0932f | ||
|
|
0aa1130a23 | ||
|
|
e9284e9c5e | ||
|
|
4b3cb25988 | ||
|
|
8ffa38af6b | ||
|
|
f2bb6c704a | ||
|
|
f0268d6827 | ||
|
|
5f73f6be39 | ||
|
|
f565cd37e6 | ||
|
|
abab6cd7f1 | ||
|
|
39fa545663 | ||
|
|
666a7d8927 | ||
|
|
408a09c860 | ||
|
|
c76d0d4d99 | ||
|
|
eab29a77aa | ||
|
|
69c2b9684e | ||
|
|
ada67a32ca | ||
|
|
323c3d6619 | ||
|
|
15a2749a2a | ||
|
|
2f4df9842b | ||
|
|
10db2279ef | ||
|
|
0b326aa24b | ||
|
|
d39ed07e73 | ||
|
|
39df259a08 | ||
|
|
72febeed94 | ||
|
|
0f71c997a4 | ||
|
|
5ec4c751cc | ||
|
|
606db06656 | ||
|
|
e9496ade0a | ||
|
|
c8b96c9761 | ||
|
|
f4fc21f7cb | ||
|
|
607d4399c8 | ||
|
|
2f9ffa89c2 | ||
|
|
c737b72c10 | ||
|
|
8ce54340c2 | ||
|
|
cde3b1b3fb | ||
|
|
fd2c96ea02 | ||
|
|
69e597fe1f | ||
|
|
48057b1c42 | ||
|
|
657bcfeb18 | ||
|
|
dd7ed663b1 | ||
|
|
7da75b0d38 | ||
|
|
b2f5ab6d52 | ||
|
|
e78016b8fc | ||
|
|
f763710085 | ||
|
|
dd3a4f7481 | ||
|
|
76da48d45d | ||
|
|
99f1212d8c | ||
|
|
c61f266b60 | ||
|
|
004f1daab1 | ||
|
|
5c4dca6633 | ||
|
|
a189ec8b96 | ||
|
|
30d20a0cb8 | ||
|
|
dabab1f08c | ||
|
|
172ffdae56 | ||
|
|
36378fbc04 | ||
|
|
1f0b18763c | ||
|
|
c596e17603 | ||
|
|
bba31020df | ||
|
|
5b3f8e44ca | ||
|
|
189d9acfc0 | ||
|
|
224bfac8ae | ||
|
|
25b051d739 | ||
|
|
60702e2130 | ||
|
|
37b388abcc | ||
|
|
1ea8efd7f2 | ||
|
|
0c5208cf24 | ||
|
|
245d2ae69b | ||
|
|
dc05567c54 | ||
|
|
3333d3236d | ||
|
|
44b3037d8f | ||
|
|
b99731a12b | ||
|
|
b281f5b142 | ||
|
|
2ac141f36d | ||
|
|
4310dc4cba | ||
|
|
27b9928b14 | ||
|
|
cf8513880f | ||
|
|
2db42ed787 | ||
|
|
6ec8e22b66 | ||
|
|
2c054da3cb | ||
|
|
75e1f3755f | ||
|
|
486ccc7aa7 | ||
|
|
0af69b3b79 | ||
|
|
2458905e86 | ||
|
|
60cc68877d | ||
|
|
ded7204e90 | ||
|
|
188830263e | ||
|
|
30b9b5963f | ||
|
|
73c7e29604 | ||
|
|
ce53c91a83 | ||
|
|
7cd8176bcc | ||
|
|
3e839bc5e3 | ||
|
|
5e75a9b574 | ||
|
|
02b8450099 | ||
|
|
f6b89cf55c | ||
|
|
fcc8d5c6fe | ||
|
|
88f645e5d4 | ||
|
|
c94b0cab38 | ||
|
|
5abfe4bad9 | ||
|
|
bd8dcba1d8 | ||
|
|
b3d8aa91d6 | ||
|
|
e31f594c41 | ||
|
|
6f49b80921 | ||
|
|
0dc9ee72b9 | ||
|
|
1367e0bf9d | ||
|
|
8338484546 | ||
|
|
35b29146e8 | ||
|
|
f1b238e8d4 |
8
.gitattributes
vendored
8
.gitattributes
vendored
@ -1,3 +1,5 @@
|
||||
api/applyconfiguration/** linguist-generated=true
|
||||
pkg/client/** linguist-generated=true
|
||||
pkg/generated/** linguist-generated=true
|
||||
controller/api/applyconfiguration/** linguist-generated=true
|
||||
controller/pkg/client/** linguist-generated=true
|
||||
controller/pkg/generated/** linguist-generated=true
|
||||
crates/agentgateway/src/llm/tests/** text eol=lf
|
||||
crates/agentgateway/src/llm/tests/**/*.bin -text
|
||||
|
||||
83
.github/dependabot.yml
vendored
Normal file
83
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
version: 2
|
||||
|
||||
updates:
|
||||
- package-ecosystem: "cargo"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
day: "monday"
|
||||
time: "05:00"
|
||||
timezone: "America/Los_Angeles"
|
||||
groups:
|
||||
cargo-weekly:
|
||||
patterns:
|
||||
- "*"
|
||||
ignore:
|
||||
- dependency-name: "nom"
|
||||
- dependency-name: "criterion"
|
||||
open-pull-requests-limit: 1
|
||||
|
||||
# Disable regular version updates while still allowing Dependabot security PRs.
|
||||
- package-ecosystem: "gomod"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
time: "09:00"
|
||||
timezone: "America/Los_Angeles"
|
||||
open-pull-requests-limit: 0
|
||||
|
||||
- package-ecosystem: "gomod"
|
||||
directory: "/api"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
time: "09:00"
|
||||
timezone: "America/Los_Angeles"
|
||||
open-pull-requests-limit: 0
|
||||
|
||||
- package-ecosystem: "gomod"
|
||||
directory: "/tools"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
time: "09:00"
|
||||
timezone: "America/Los_Angeles"
|
||||
open-pull-requests-limit: 0
|
||||
|
||||
- package-ecosystem: "npm"
|
||||
directory: "/ui"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
time: "09:00"
|
||||
timezone: "America/Los_Angeles"
|
||||
open-pull-requests-limit: 0
|
||||
|
||||
- package-ecosystem: "docker"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
time: "09:00"
|
||||
timezone: "America/Los_Angeles"
|
||||
open-pull-requests-limit: 0
|
||||
|
||||
- package-ecosystem: "docker"
|
||||
directory: "/controller/hack/testbox"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
time: "09:00"
|
||||
timezone: "America/Los_Angeles"
|
||||
open-pull-requests-limit: 0
|
||||
|
||||
- package-ecosystem: "uv"
|
||||
directory: "/examples/a2a/strands-agents"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
time: "09:00"
|
||||
timezone: "America/Los_Angeles"
|
||||
open-pull-requests-limit: 0
|
||||
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
time: "09:00"
|
||||
timezone: "America/Los_Angeles"
|
||||
open-pull-requests-limit: 0
|
||||
6
.github/workflows/debug_cache.yml
vendored
6
.github/workflows/debug_cache.yml
vendored
@ -15,10 +15,10 @@ on:
|
||||
type: string
|
||||
jobs:
|
||||
cache-upload:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
|
||||
- name: Restore cache
|
||||
uses: Andrej730/cache/restore@e294f7d180f76c94062d0251c60fe7362ce6667d
|
||||
@ -28,7 +28,7 @@ jobs:
|
||||
key: ${{ github.event.inputs.cache_key }}
|
||||
|
||||
- name: Upload cached folder as artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
|
||||
with:
|
||||
name: cache-artifact
|
||||
path: |
|
||||
|
||||
56
.github/workflows/nightly.yml
vendored
Normal file
56
.github/workflows/nightly.yml
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
name: Nightly Release
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 2 * * *'
|
||||
workflow_dispatch: {}
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
id-token: write
|
||||
|
||||
jobs:
|
||||
prepare:
|
||||
if: github.repository == 'agentgateway/agentgateway'
|
||||
runs-on: ubuntu-24.04
|
||||
outputs:
|
||||
has_commits: ${{ steps.check.outputs.has_commits }}
|
||||
version: ${{ steps.version.outputs.version }}
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Check for commits in the last 24 hours
|
||||
id: check
|
||||
run: |
|
||||
LAST_COMMIT=$(git log -1 --format="%ct")
|
||||
NOW=$(date +%s)
|
||||
DIFF=$((NOW - LAST_COMMIT))
|
||||
# 86400 = seconds in one day
|
||||
if [ "$DIFF" -lt 86400 ]; then
|
||||
echo "has_commits=true" >> $GITHUB_OUTPUT
|
||||
echo "Recent commit found (${DIFF}s ago)"
|
||||
else
|
||||
echo "has_commits=false" >> $GITHUB_OUTPUT
|
||||
echo "No recent commits (last commit was ${DIFF}s ago), skipping nightly release"
|
||||
fi
|
||||
|
||||
- name: Compute nightly version
|
||||
id: version
|
||||
run: |
|
||||
SHORT_SHA=$(git rev-parse --short HEAD)
|
||||
echo "version=0.0.0-alpha.${SHORT_SHA}" >> $GITHUB_OUTPUT
|
||||
echo "Nightly version: 0.0.0-alpha.${SHORT_SHA}"
|
||||
|
||||
release:
|
||||
needs: prepare
|
||||
if: ${{ needs.prepare.outputs.has_commits == 'true' || github.event_name == 'workflow_dispatch' }}
|
||||
uses: ./.github/workflows/release.yml
|
||||
with:
|
||||
version: ${{ needs.prepare.outputs.version }}
|
||||
extra_tag: latest-dev
|
||||
# Helm is special and requires a semver.
|
||||
extra_helm_tag: 0.0.0-latest-dev
|
||||
secrets: inherit
|
||||
119
.github/workflows/pull_request.yml
vendored
119
.github/workflows/pull_request.yml
vendored
@ -2,9 +2,11 @@ name: Branch
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
branches:
|
||||
- "main"
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
branches:
|
||||
- "main"
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref_name }}
|
||||
@ -14,54 +16,61 @@ env:
|
||||
CARGO_TERM_COLOR: always
|
||||
CI: true
|
||||
RUST_VERSION: "1.93.1"
|
||||
GO_VERSION: "1.25.7"
|
||||
GO_VERSION: "1.26.2"
|
||||
|
||||
jobs:
|
||||
#### Proxy jobs ####
|
||||
test:
|
||||
proxy-test:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
include:
|
||||
- os: blacksmith-4vcpu-ubuntu-2404
|
||||
name: "Proxy Test"
|
||||
- os: windows-2025
|
||||
name: "Proxy Test (Windows)"
|
||||
- os: macos-15
|
||||
name: "Proxy Test (Mac)"
|
||||
runs-on: ${{ matrix.os }}
|
||||
name: ${{ matrix.name }}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
- name: Install Rust
|
||||
uses: dtolnay/rust-toolchain@master
|
||||
uses: dtolnay/rust-toolchain@efa25f7f19611383d5b0ccf2d1c8914531636bf9 # master
|
||||
with:
|
||||
toolchain: "${{ env.RUST_VERSION }}"
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
|
||||
# Github cache is too tiny to handle the full matrix :-(
|
||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||
if: ${{ startsWith(matrix.os, 'blacksmith-') }}
|
||||
with:
|
||||
# Github cache will restore from 'main' OR the current branch.
|
||||
# If we cache PR branches, we may evict the 'main' cache and end up with no cache hits at all.
|
||||
# Ideally, we would have main be 'high priority' and not be evicted but I don't think thats possible.
|
||||
save-if: ${{ github.ref == 'refs/heads/main' }}
|
||||
- name: Start validation dependencies
|
||||
if: ${{ startsWith(matrix.os, 'blacksmith-') }}
|
||||
run: tools/manage-validation-deps.sh start
|
||||
- name: Test
|
||||
run: make test
|
||||
- name: Validate
|
||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||
run: make validate
|
||||
env:
|
||||
KEYCLOAK_AVAILABLE: ${{ startsWith(matrix.os, 'blacksmith-') && '1' || '' }}
|
||||
- name: Stop validation dependencies
|
||||
if: ${{ always() && startsWith(matrix.os, 'blacksmith-') }}
|
||||
run: tools/manage-validation-deps.sh stop
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
proxy-lint:
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 23
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
- name: Install Rust
|
||||
uses: dtolnay/rust-toolchain@master
|
||||
uses: dtolnay/rust-toolchain@efa25f7f19611383d5b0ccf2d1c8914531636bf9 # master
|
||||
with:
|
||||
toolchain: "${{ env.RUST_VERSION }}"
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
|
||||
with:
|
||||
# Github cache will restore from 'main' OR the current branch.
|
||||
# If we cache PR branches, we may evict the 'main' cache and end up with no cache hits at all.
|
||||
# Ideally, we would have main be 'high priority' and not be evicted but I don't think thats possible.
|
||||
save-if: ${{ github.ref == 'refs/heads/main' }}
|
||||
- name: Add Go bin to PATH
|
||||
run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
|
||||
- name: Generation
|
||||
run: make generate-schema check-clean-repo
|
||||
- name: Lint
|
||||
@ -69,15 +78,15 @@ jobs:
|
||||
|
||||
#### UI jobs ####
|
||||
ui-lint:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ui
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
with:
|
||||
node-version: 23
|
||||
node-version: 24
|
||||
- name: Lint
|
||||
run: |
|
||||
npm ci
|
||||
@ -85,10 +94,10 @@ jobs:
|
||||
|
||||
#### Controller jobs ####
|
||||
controller-test:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/setup-go@v6
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6
|
||||
with:
|
||||
go-version: "${{ env.GO_VERSION }}"
|
||||
cache-dependency-path: |
|
||||
@ -98,10 +107,10 @@ jobs:
|
||||
run: go test -race ./...
|
||||
|
||||
controller-lint:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/setup-go@v6
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6
|
||||
with:
|
||||
go-version: "${{ env.GO_VERSION }}"
|
||||
cache-dependency-path: |
|
||||
@ -109,25 +118,35 @@ jobs:
|
||||
.github/workflows/cache-test
|
||||
- name: Lint
|
||||
run: make -C controller analyze
|
||||
- name: go mod tidy
|
||||
run: |
|
||||
go mod tidy
|
||||
git diff --exit-code go.mod go.sum
|
||||
- name: Gen
|
||||
# TODO: the rest of codegen
|
||||
run: make generate-apis check-clean-repo
|
||||
|
||||
controller-e2e:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
- name: Check Runner Info
|
||||
run: |
|
||||
cat /sys/fs/cgroup/cpu.stat || true
|
||||
cat /proc/pressure/cpu || true
|
||||
lscpu || true
|
||||
openssl speed -seconds 1 -bytes 256 sha256 || rtue
|
||||
- name: Install Rust
|
||||
uses: dtolnay/rust-toolchain@master
|
||||
uses: dtolnay/rust-toolchain@efa25f7f19611383d5b0ccf2d1c8914531636bf9 # master
|
||||
with:
|
||||
toolchain: "${{ env.RUST_VERSION }}"
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
|
||||
with:
|
||||
# Github cache will restore from 'main' OR the current branch.
|
||||
# If we cache PR branches, we may evict the 'main' cache and end up with no cache hits at all.
|
||||
# Ideally, we would have main be 'high priority' and not be evicted but I don't think thats possible.
|
||||
save-if: ${{ github.ref == 'refs/heads/main' }}
|
||||
- uses: actions/setup-go@v6
|
||||
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6
|
||||
with:
|
||||
go-version: "${{ env.GO_VERSION }}"
|
||||
cache-dependency-path: |
|
||||
@ -143,13 +162,13 @@ jobs:
|
||||
CGO_ENABLED=0 PERSIST_INSTALL=true go test -tags=e2e -v ./controller/test/e2e/tests -run '^TestAgentgatewayIntegration'
|
||||
- name: Archive bug report directory on failure
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
|
||||
with:
|
||||
name: bug-report
|
||||
path: ./controller/_test/bug_report/kind
|
||||
retention-days: 2
|
||||
- name: Upload cargo timings
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
|
||||
with:
|
||||
name: cargo-timings-e2e
|
||||
path: target/cargo-timings/cargo-timing*.html
|
||||
@ -160,19 +179,19 @@ jobs:
|
||||
cat controller/_test/ci-step-timings.log >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
controller-conformance:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
- name: Install Rust
|
||||
uses: dtolnay/rust-toolchain@master
|
||||
uses: dtolnay/rust-toolchain@efa25f7f19611383d5b0ccf2d1c8914531636bf9 # master
|
||||
with:
|
||||
toolchain: "${{ env.RUST_VERSION }}"
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
|
||||
with:
|
||||
# We only read the cache from 'E2E' job, since they should have identical cache.
|
||||
save-if: "false"
|
||||
shared-key: "controller-e2e" # Pull E2E job's cache
|
||||
- uses: actions/setup-go@v6
|
||||
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6
|
||||
with:
|
||||
go-version: "${{ env.GO_VERSION }}"
|
||||
cache-dependency-path: |
|
||||
@ -186,8 +205,14 @@ jobs:
|
||||
- name: Conformance
|
||||
run: |
|
||||
make -C controller all-conformance
|
||||
- name: Debug Info
|
||||
if: ${{ failure() }}
|
||||
run: |
|
||||
kubectl describe deployment -n agentgateway-system
|
||||
kubectl get pods -n agentgateway-system
|
||||
kubectl logs -n agentgateway-system -l app.kubernetes.io/name=agentgateway
|
||||
- name: Upload cargo timings
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
|
||||
with:
|
||||
name: cargo-timings-conformance
|
||||
path: target/cargo-timings/cargo-timing*.html
|
||||
@ -197,12 +222,12 @@ jobs:
|
||||
cat-yamls () {
|
||||
local files=("$@")
|
||||
local count=$#
|
||||
|
||||
|
||||
for ((i=0; i<count-1; i++)); do
|
||||
cat "${files[i]}"
|
||||
echo -e "\n---"
|
||||
done
|
||||
|
||||
|
||||
if [ $count -gt 0 ]; then
|
||||
cat "${files[count-1]}"
|
||||
fi
|
||||
|
||||
264
.github/workflows/release.yml
vendored
264
.github/workflows/release.yml
vendored
@ -13,23 +13,53 @@ on:
|
||||
required: false
|
||||
default: false
|
||||
type: boolean
|
||||
extra_helm_tag:
|
||||
description: 'Additional Helm chart version to push (e.g. 0.0.0-latest-dev)'
|
||||
required: false
|
||||
default: ''
|
||||
type: string
|
||||
workflow_call:
|
||||
inputs:
|
||||
version:
|
||||
description: 'Version number (without v prefix)'
|
||||
required: true
|
||||
type: string
|
||||
extra_tag:
|
||||
description: 'Additional Docker image tag to push (e.g. latest-dev)'
|
||||
required: false
|
||||
default: ''
|
||||
type: string
|
||||
extra_helm_tag:
|
||||
description: 'Additional Helm chart version to push (e.g. 0.0.0-latest-dev)'
|
||||
required: false
|
||||
default: ''
|
||||
type: string
|
||||
|
||||
env:
|
||||
REGISTRY_IMAGE: ghcr.io/${{ github.repository }}
|
||||
CONTROLLER_REGISTRY_IMAGE: ghcr.io/${{ github.repository }}-controller
|
||||
CARGO_TERM_COLOR: always
|
||||
CI: true
|
||||
RUST_VERSION: "1.93.1"
|
||||
GO_VERSION: "1.26.2"
|
||||
REGISTRY_IMAGE: ghcr.io/${{ github.repository_owner }}/agentgateway
|
||||
CONTROLLER_REGISTRY_IMAGE: ghcr.io/${{ github.repository_owner }}/controller
|
||||
# Note: /charts is added to this
|
||||
CHART_REGISTRY_IMAGE_BASE: ghcr.io/${{ github.repository_owner }}
|
||||
|
||||
jobs:
|
||||
setup:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
outputs:
|
||||
version: ${{ steps.version.outputs.version }}
|
||||
steps:
|
||||
# Help debug what exact was input for this since Github doesn't expose it.
|
||||
- name: Output Inputs
|
||||
run: echo "${{ toJSON(github.event.inputs) }}"
|
||||
- name: Set canonical VERSION
|
||||
id: version
|
||||
run: |
|
||||
# Determine version source
|
||||
if [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ -n "${{ github.event.inputs.version }}" ]; then
|
||||
VERSION="${{ github.event.inputs.version }}"
|
||||
if [ -n "${{ inputs.version }}" ]; then
|
||||
VERSION="${{ inputs.version }}"
|
||||
else
|
||||
VERSION="${{ github.ref_name }}"
|
||||
fi
|
||||
@ -50,9 +80,9 @@ jobs:
|
||||
matrix:
|
||||
include:
|
||||
- platform: linux/amd64
|
||||
os: ubuntu-latest
|
||||
os: blacksmith-4vcpu-ubuntu-2404
|
||||
- platform: linux/arm64
|
||||
os: ubuntu-22.04-arm
|
||||
os: blacksmith-4vcpu-ubuntu-2404-arm
|
||||
env:
|
||||
VERSION: ${{ needs.setup.outputs.version }}
|
||||
steps:
|
||||
@ -63,23 +93,23 @@ jobs:
|
||||
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY_IMAGE }}
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
|
||||
|
||||
- name: Build and push by digest
|
||||
id: build
|
||||
uses: docker/build-push-action@v6
|
||||
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
|
||||
with:
|
||||
build-args: |
|
||||
VERSION=${{ env.VERSION }}
|
||||
@ -98,7 +128,7 @@ jobs:
|
||||
touch "${{ runner.temp }}/digests/${digest#sha256:}"
|
||||
|
||||
- name: Upload digest
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
|
||||
with:
|
||||
name: digests-${{ env.PLATFORM_PAIR }}
|
||||
path: ${{ runner.temp }}/digests/*
|
||||
@ -106,7 +136,7 @@ jobs:
|
||||
retention-days: 1
|
||||
|
||||
push-image:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
@ -118,32 +148,33 @@ jobs:
|
||||
VERSION: ${{ needs.setup.outputs.version }}
|
||||
steps:
|
||||
- name: Install cosign
|
||||
uses: sigstore/cosign-installer@v3.9.2
|
||||
uses: sigstore/cosign-installer@398d4b0eeef1380460a10c8013a76f728fb906ac # v3
|
||||
|
||||
- name: Download digests
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
|
||||
with:
|
||||
path: ${{ runner.temp }}/digests
|
||||
pattern: digests-linux-*
|
||||
merge-multiple: true
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
|
||||
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY_IMAGE }}
|
||||
tags: |
|
||||
type=semver,pattern={{version}},value=${{ env.VERSION }}
|
||||
type=raw,value=v${{ env.VERSION }}
|
||||
type=raw,value=${{ inputs.extra_tag }},enable=${{ inputs.extra_tag != '' }}
|
||||
|
||||
- name: Create manifest list and push
|
||||
working-directory: ${{ runner.temp }}/digests
|
||||
@ -152,11 +183,15 @@ jobs:
|
||||
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
|
||||
|
||||
- name: Sign the container image
|
||||
run: cosign sign --yes ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
|
||||
run: cosign sign --yes ${{ env.REGISTRY_IMAGE }}:v${{ env.VERSION }}
|
||||
|
||||
- name: Sign the extra tag
|
||||
if: ${{ inputs.extra_tag != '' }}
|
||||
run: cosign sign --yes ${{ env.REGISTRY_IMAGE }}:${{ inputs.extra_tag }}
|
||||
|
||||
- name: Inspect image
|
||||
run: |
|
||||
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
|
||||
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:v${{ env.VERSION }}
|
||||
|
||||
musl-build-image:
|
||||
runs-on: ${{ matrix.os }}
|
||||
@ -170,9 +205,9 @@ jobs:
|
||||
matrix:
|
||||
include:
|
||||
- platform: linux/amd64
|
||||
os: ubuntu-latest
|
||||
os: blacksmith-4vcpu-ubuntu-2404
|
||||
- platform: linux/arm64
|
||||
os: ubuntu-22.04-arm
|
||||
os: blacksmith-4vcpu-ubuntu-2404-arm
|
||||
env:
|
||||
VERSION: ${{ needs.setup.outputs.version }}
|
||||
steps:
|
||||
@ -183,24 +218,24 @@ jobs:
|
||||
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY_IMAGE }}-musl
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
|
||||
|
||||
- name: Build and push by digest
|
||||
id: build
|
||||
uses: docker/build-push-action@v6
|
||||
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
|
||||
with:
|
||||
platforms: ${{ matrix.platform }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
@ -220,7 +255,7 @@ jobs:
|
||||
touch "${{ runner.temp }}/digests-musl/${digest#sha256:}"
|
||||
|
||||
- name: Upload digest
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
|
||||
with:
|
||||
name: digests-musl-${{ env.PLATFORM_PAIR }}
|
||||
path: ${{ runner.temp }}/digests-musl/*
|
||||
@ -228,7 +263,7 @@ jobs:
|
||||
retention-days: 1
|
||||
|
||||
musl-push-image:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
@ -240,32 +275,33 @@ jobs:
|
||||
VERSION: ${{ needs.setup.outputs.version }}
|
||||
steps:
|
||||
- name: Install cosign
|
||||
uses: sigstore/cosign-installer@v3.9.2
|
||||
uses: sigstore/cosign-installer@398d4b0eeef1380460a10c8013a76f728fb906ac # v3
|
||||
|
||||
- name: Download digests
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
|
||||
with:
|
||||
path: ${{ runner.temp }}/digests-musl
|
||||
pattern: digests-musl*
|
||||
merge-multiple: true
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
|
||||
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY_IMAGE }}
|
||||
tags: |
|
||||
type=semver,pattern={{version}},value=${{ env.VERSION }}
|
||||
type=raw,value=v${{ env.VERSION }}
|
||||
type=raw,value=${{ inputs.extra_tag }},enable=${{ inputs.extra_tag != '' }}
|
||||
|
||||
- name: Create manifest list and push
|
||||
working-directory: ${{ runner.temp }}/digests-musl
|
||||
@ -274,11 +310,15 @@ jobs:
|
||||
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
|
||||
|
||||
- name: Sign the container image
|
||||
run: cosign sign --yes ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}-musl
|
||||
run: cosign sign --yes ${{ env.REGISTRY_IMAGE }}:v${{ env.VERSION }}-musl
|
||||
|
||||
- name: Sign the extra tag
|
||||
if: ${{ inputs.extra_tag != '' }}
|
||||
run: cosign sign --yes ${{ env.REGISTRY_IMAGE }}:${{ inputs.extra_tag }}-musl
|
||||
|
||||
- name: Inspect image
|
||||
run: |
|
||||
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}-musl
|
||||
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:v${{ env.VERSION }}-musl
|
||||
|
||||
build-controller-image:
|
||||
runs-on: ${{ matrix.os }}
|
||||
@ -292,10 +332,10 @@ jobs:
|
||||
matrix:
|
||||
include:
|
||||
- platform: linux/amd64
|
||||
os: ubuntu-latest
|
||||
os: ubuntu-24.04
|
||||
goarch: amd64
|
||||
- platform: linux/arm64
|
||||
os: ubuntu-22.04-arm
|
||||
os: blacksmith-4vcpu-ubuntu-2404-arm
|
||||
goarch: arm64
|
||||
defaults:
|
||||
run:
|
||||
@ -309,19 +349,19 @@ jobs:
|
||||
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
||||
working-directory: .
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6
|
||||
with:
|
||||
go-version: '1.25.7'
|
||||
go-version: "${{ env.GO_VERSION }}"
|
||||
cache-dependency-path: |
|
||||
**/*.sum
|
||||
|
||||
@ -337,16 +377,16 @@ jobs:
|
||||
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
|
||||
with:
|
||||
images: ${{ env.CONTROLLER_REGISTRY_IMAGE }}
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
|
||||
|
||||
- name: Build and push by digest
|
||||
id: build
|
||||
uses: docker/build-push-action@v6
|
||||
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
|
||||
with:
|
||||
context: controller/_output/pkg/agentgateway
|
||||
file: controller/_output/pkg/agentgateway/Dockerfile.agentgateway
|
||||
@ -366,7 +406,7 @@ jobs:
|
||||
touch "${{ runner.temp }}/controller-digests/${digest#sha256:}"
|
||||
|
||||
- name: Upload digest
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
|
||||
with:
|
||||
name: controller-digests-${{ env.PLATFORM_PAIR }}
|
||||
path: ${{ runner.temp }}/controller-digests/*
|
||||
@ -374,7 +414,7 @@ jobs:
|
||||
retention-days: 1
|
||||
|
||||
push-controller-image:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
@ -386,10 +426,10 @@ jobs:
|
||||
VERSION: ${{ needs.setup.outputs.version }}
|
||||
steps:
|
||||
- name: Install cosign
|
||||
uses: sigstore/cosign-installer@v3.9.2
|
||||
uses: sigstore/cosign-installer@398d4b0eeef1380460a10c8013a76f728fb906ac # v3
|
||||
|
||||
- name: Download digests
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
|
||||
with:
|
||||
path: ${{ runner.temp }}/controller-digests
|
||||
pattern: controller-digests-*
|
||||
@ -403,22 +443,23 @@ jobs:
|
||||
find . -type f
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
|
||||
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
|
||||
with:
|
||||
images: ${{ env.CONTROLLER_REGISTRY_IMAGE }}
|
||||
tags: |
|
||||
type=semver,pattern={{version}},value=${{ env.VERSION }}
|
||||
type=raw,value=v${{ env.VERSION }}
|
||||
type=raw,value=${{ inputs.extra_tag }},enable=${{ inputs.extra_tag != '' }}
|
||||
|
||||
- name: Create manifest list and push
|
||||
working-directory: ${{ runner.temp }}/controller-digests
|
||||
@ -427,48 +468,79 @@ jobs:
|
||||
$(find . -type f -exec sh -c 'printf "${{ env.CONTROLLER_REGISTRY_IMAGE }}@sha256:%s " "$(basename "$1")"' _ {} \;)
|
||||
|
||||
- name: Sign the container image
|
||||
run: cosign sign --yes ${{ env.CONTROLLER_REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
|
||||
run: cosign sign --yes ${{ env.CONTROLLER_REGISTRY_IMAGE }}:v${{ env.VERSION }}
|
||||
|
||||
- name: Sign the extra tag
|
||||
if: ${{ inputs.extra_tag != '' }}
|
||||
run: cosign sign --yes ${{ env.CONTROLLER_REGISTRY_IMAGE }}:${{ inputs.extra_tag }}
|
||||
|
||||
- name: Inspect image
|
||||
run: |
|
||||
docker buildx imagetools inspect ${{ env.CONTROLLER_REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
|
||||
docker buildx imagetools inspect ${{ env.CONTROLLER_REGISTRY_IMAGE }}:v${{ env.VERSION }}
|
||||
|
||||
push-helm-charts:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
id-token: write
|
||||
needs:
|
||||
- setup
|
||||
- push-controller-image
|
||||
env:
|
||||
VERSION: ${{ needs.setup.outputs.version }}
|
||||
steps:
|
||||
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||
|
||||
- name: Helm login to ${{ env.CHART_REGISTRY_IMAGE_BASE }}
|
||||
run: echo "${{ secrets.GITHUB_TOKEN }}" | ./tools/helm registry login ghcr.io -u ${{ github.repository_owner }} --password-stdin
|
||||
|
||||
- name: Push helm charts
|
||||
run: make -C controller release-charts
|
||||
env:
|
||||
IMAGE_REGISTRY: ${{ env.CHART_REGISTRY_IMAGE_BASE }}
|
||||
EXTRA_HELM_TAG: ${{ inputs.extra_helm_tag }}
|
||||
|
||||
build:
|
||||
if: ${{ github.event_name == 'push' || ! github.event.inputs.skip_gh_release }}
|
||||
if: ${{ github.event_name != 'workflow_call' && (github.event_name == 'push' || ! github.event.inputs.skip_gh_release) }}
|
||||
needs:
|
||||
- setup
|
||||
runs-on: ${{ matrix.os }}
|
||||
permissions:
|
||||
contents: read
|
||||
env:
|
||||
VERSION: ${{ needs.setup.outputs.version }}
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
- os: blacksmith-4vcpu-ubuntu-2404
|
||||
target: x86_64-unknown-linux-musl
|
||||
# Performance is horrendous on musl without jemalloc
|
||||
features: jemalloc
|
||||
- os: ubuntu-22.04-arm
|
||||
name: linux
|
||||
- os: blacksmith-4vcpu-ubuntu-2404-arm
|
||||
target: aarch64-unknown-linux-musl
|
||||
# TODO: arm64 build fails with jemalloc for some reason?
|
||||
# TODO: arm64 build fails with jemalloc for some reason? https://github.com/tikv/jemallocator/issues/146
|
||||
features: default
|
||||
- os: macos-latest
|
||||
name: linux-arm
|
||||
- os: macos-26
|
||||
target: aarch64-apple-darwin
|
||||
features: default
|
||||
- os: macos-15-intel
|
||||
target: x86_64-apple-darwin
|
||||
features: default
|
||||
- os: windows-latest
|
||||
name: mac
|
||||
- os: windows-2025
|
||||
target: x86_64-pc-windows-msvc
|
||||
features: default
|
||||
name: windows
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
with:
|
||||
node-version: 23
|
||||
node-version: 24
|
||||
- name: Install Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
uses: dtolnay/rust-toolchain@efa25f7f19611383d5b0ccf2d1c8914531636bf9 # master
|
||||
with:
|
||||
toolchain: "${{ env.RUST_VERSION }}"
|
||||
targets: ${{ matrix.target }}
|
||||
# TODO: build this in a separate job and just copy it over
|
||||
- name: Build UI
|
||||
@ -476,8 +548,8 @@ jobs:
|
||||
cd ui
|
||||
npm install
|
||||
npm run build
|
||||
- name: Install musl-tools
|
||||
if: ${{ matrix.os == 'ubuntu-22.04-arm' || matrix.os == 'ubuntu-latest' }}
|
||||
- name: Prepare Linux target
|
||||
if: ${{ matrix.target == 'x86_64-unknown-linux-musl' || matrix.target == 'aarch64-unknown-linux-musl' }}
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y musl-tools
|
||||
@ -490,26 +562,30 @@ jobs:
|
||||
run: |
|
||||
git status
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
|
||||
with:
|
||||
name: release-binary-${{ matrix.os }}
|
||||
name: release-binary-${{ matrix.name }}
|
||||
path: |
|
||||
target/${{ matrix.target }}/release/agentgateway
|
||||
target/${{ matrix.target }}/release/agentgateway.exe
|
||||
|
||||
release:
|
||||
if: ${{ github.event_name == 'push' || ! github.event.inputs.skip_gh_release }}
|
||||
if: ${{ github.event_name != 'workflow_call' && (github.event_name == 'push' || ! github.event.inputs.skip_gh_release) }}
|
||||
needs:
|
||||
- setup
|
||||
- push-image
|
||||
- musl-push-image
|
||||
- push-controller-image
|
||||
- push-helm-charts
|
||||
- build
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
permissions:
|
||||
contents: write
|
||||
env:
|
||||
VERSION: ${{ needs.setup.outputs.version }}
|
||||
steps:
|
||||
- name: Download Artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
|
||||
with:
|
||||
pattern: release-binary-*
|
||||
|
||||
@ -517,22 +593,38 @@ jobs:
|
||||
run: |
|
||||
ls -R
|
||||
mkdir outputs
|
||||
mv release-binary-macos-latest/agentgateway outputs/agentgateway-darwin-arm64
|
||||
mv release-binary-mac/agentgateway outputs/agentgateway-darwin-arm64
|
||||
sha256sum outputs/agentgateway-darwin-arm64 > outputs/agentgateway-darwin-arm64.sha256
|
||||
mv release-binary-macos-15-intel/agentgateway outputs/agentgateway-darwin-amd64
|
||||
sha256sum outputs/agentgateway-darwin-amd64 > outputs/agentgateway-darwin-amd64.sha256
|
||||
mv release-binary-ubuntu-latest/agentgateway outputs/agentgateway-linux-amd64
|
||||
mv release-binary-linux/agentgateway outputs/agentgateway-linux-amd64
|
||||
sha256sum outputs/agentgateway-linux-amd64 > outputs/agentgateway-linux-amd64.sha256
|
||||
mv release-binary-ubuntu-22.04-arm/agentgateway outputs/agentgateway-linux-arm64
|
||||
mv release-binary-linux-arm/agentgateway outputs/agentgateway-linux-arm64
|
||||
sha256sum outputs/agentgateway-linux-arm64 > outputs/agentgateway-linux-arm64.sha256
|
||||
mv release-binary-windows-latest/agentgateway.exe outputs/agentgateway-windows-amd64.exe
|
||||
mv release-binary-windows/agentgateway.exe outputs/agentgateway-windows-amd64.exe
|
||||
sha256sum outputs/agentgateway-windows-amd64.exe > outputs/agentgateway-windows-amd64.exe.sha256
|
||||
- name: Create GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
uses: softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe # v2
|
||||
with:
|
||||
files: outputs/agentgateway-*
|
||||
tag_name: ${{ github.ref_name }}
|
||||
body: "Automated release of ${{ github.ref_name }}."
|
||||
generate_release_notes: true
|
||||
body: |
|
||||
🎉 Welcome to the ${{ env.VERSION }} release of the agentgateway project!
|
||||
|
||||
## Artifacts
|
||||
|
||||
**Docker images** are available:
|
||||
* `cr.agentgateway.dev/agentgateway:v${{ env.VERSION }}`
|
||||
* `cr.agentgateway.dev/controller:v${{ env.VERSION }}`
|
||||
|
||||
**Helm charts** are available:
|
||||
* `cr.agentgateway.dev/charts/agentgateway:v${{ env.VERSION }}`
|
||||
* `cr.agentgateway.dev/charts/agentgateway-crds:v${{ env.VERSION }}`
|
||||
|
||||
**Binaries** are available below.
|
||||
|
||||
## Quick Start
|
||||
|
||||
Follow the [Kubernetes](https://agentgateway.dev/docs/kubernetes/latest/quickstart/) or [Standalone](https://agentgateway.dev/docs/standalone/latest/quickstart/) quick start guide to get started!
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,6 +1,8 @@
|
||||
.cursor
|
||||
/target
|
||||
.vscode
|
||||
.idea
|
||||
.run
|
||||
.DS_Store
|
||||
.venv
|
||||
*.local
|
||||
|
||||
222
.goreleaser.yaml
222
.goreleaser.yaml
@ -1,222 +0,0 @@
|
||||
version: 2
|
||||
before:
|
||||
hooks:
|
||||
- go mod tidy
|
||||
- go mod download
|
||||
builds:
|
||||
- id: controller
|
||||
main: ./cmd/agentgateway
|
||||
binary: agentgateway-linux-{{ .Arch }}
|
||||
gcflags: "{{ .Env.GCFLAGS }}"
|
||||
ldflags: "{{ .Env.LDFLAGS }}"
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
- GO111MODULE=on
|
||||
- GOARCH={{ .Arch }}
|
||||
- GOOS={{ .Os }}
|
||||
mod_timestamp: "{{ .CommitTimestamp }}"
|
||||
goos:
|
||||
- linux
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
- id: sds
|
||||
main: ./cmd/sds
|
||||
binary: sds-linux-{{ .Arch }}
|
||||
gcflags: "{{ .Env.GCFLAGS }}"
|
||||
ldflags: "{{ .Env.LDFLAGS }}"
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
- GO111MODULE=on
|
||||
- GOARCH={{ .Arch }}
|
||||
- GOOS={{ .Os }}
|
||||
goos:
|
||||
- linux
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
- id: envoyinit
|
||||
main: ./cmd/envoyinit
|
||||
binary: envoyinit-linux-{{ .Arch }}
|
||||
gcflags: "{{ .Env.GCFLAGS }}"
|
||||
ldflags: "{{ .Env.LDFLAGS }}"
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
- GO111MODULE=on
|
||||
- GOARCH={{ .Arch }}
|
||||
- GOOS={{ .Os }}
|
||||
goos:
|
||||
- linux
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
dockers:
|
||||
- image_templates:
|
||||
- &controller_arm_image "{{ .Env.IMAGE_REGISTRY }}/{{ .Env.CONTROLLER_IMAGE_REPO }}:{{ .Env.VERSION }}-arm64"
|
||||
use: buildx
|
||||
dockerfile: &controller_dockerfile cmd/agentgateway/Dockerfile
|
||||
goos: linux
|
||||
goarch: arm64
|
||||
build_flag_templates:
|
||||
- "--pull"
|
||||
- "--platform=linux/arm64"
|
||||
- "--build-arg=GOARCH=arm64"
|
||||
- "--build-arg=ENVOY_IMAGE={{ .Env.ENVOY_IMAGE_ARM64 }}"
|
||||
- image_templates:
|
||||
- &controller_amd_image "{{ .Env.IMAGE_REGISTRY }}/{{ .Env.CONTROLLER_IMAGE_REPO }}:{{ .Env.VERSION }}-amd64"
|
||||
use: buildx
|
||||
dockerfile: *controller_dockerfile
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
build_flag_templates:
|
||||
- "--pull"
|
||||
- "--platform=linux/amd64"
|
||||
- "--build-arg=GOARCH=amd64"
|
||||
- "--build-arg=ENVOY_IMAGE={{ .Env.ENVOY_IMAGE_AMD64 }}"
|
||||
- image_templates:
|
||||
- &agentgateway_arm_image "{{ .Env.IMAGE_REGISTRY }}/{{ .Env.AGENTGATEWAY_IMAGE_REPO }}:{{ .Env.VERSION }}-arm64"
|
||||
use: buildx
|
||||
dockerfile: &agentgateway_dockerfile cmd/agentgateway/Dockerfile.agentgateway
|
||||
goos: linux
|
||||
goarch: arm64
|
||||
build_flag_templates:
|
||||
- "--pull"
|
||||
- "--platform=linux/arm64"
|
||||
- "--build-arg=GOARCH=arm64"
|
||||
- image_templates:
|
||||
- &agentgateway_amd_image "{{ .Env.IMAGE_REGISTRY }}/{{ .Env.AGENTGATEWAY_IMAGE_REPO }}:{{ .Env.VERSION }}-amd64"
|
||||
use: buildx
|
||||
dockerfile: *agentgateway_dockerfile
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
build_flag_templates:
|
||||
- "--pull"
|
||||
- "--platform=linux/amd64"
|
||||
- "--build-arg=GOARCH=amd64"
|
||||
- image_templates:
|
||||
- &sds_arm_image "{{ .Env.IMAGE_REGISTRY }}/{{ .Env.SDS_IMAGE_REPO }}:{{ .Env.VERSION }}-arm64"
|
||||
use: buildx
|
||||
dockerfile: &sds_dockerfile cmd/sds/Dockerfile
|
||||
goos: linux
|
||||
goarch: arm64
|
||||
build_flag_templates:
|
||||
- "--pull"
|
||||
- "--platform=linux/arm64"
|
||||
- "--build-arg=GOARCH=arm64"
|
||||
- "--build-arg=BASE_IMAGE={{ .Env.ALPINE_BASE_IMAGE }}"
|
||||
- image_templates:
|
||||
- &sds_amd_image "{{ .Env.IMAGE_REGISTRY }}/{{ .Env.SDS_IMAGE_REPO }}:{{ .Env.VERSION }}-amd64"
|
||||
use: buildx
|
||||
dockerfile: *sds_dockerfile
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
build_flag_templates:
|
||||
- "--pull"
|
||||
- "--platform=linux/amd64"
|
||||
- "--build-arg=GOARCH=amd64"
|
||||
- "--build-arg=BASE_IMAGE={{ .Env.ALPINE_BASE_IMAGE }}"
|
||||
- image_templates:
|
||||
- &envoyinit_arm_image "{{ .Env.IMAGE_REGISTRY }}/{{ .Env.ENVOYINIT_IMAGE_REPO }}:{{ .Env.VERSION }}-arm64"
|
||||
use: buildx
|
||||
dockerfile: &envoyinit_dockerfile cmd/envoyinit/Dockerfile
|
||||
goos: linux
|
||||
goarch: arm64
|
||||
build_flag_templates:
|
||||
- "--pull"
|
||||
- "--platform=linux/arm64"
|
||||
- "--build-arg=GOARCH=arm64"
|
||||
- "--build-arg=ENTRYPOINT_SCRIPT=/cmd/envoyinit/docker-entrypoint.sh"
|
||||
- "--build-arg=ENVOY_IMAGE={{ .Env.ENVOY_IMAGE_ARM64 }}"
|
||||
- "--build-arg=RUST_BUILD_ARCH=aarch64"
|
||||
- "--build-arg=RUSTFORMATIONS_DIR=/internal/envoyinit"
|
||||
- "--cache-from=type=registry,ref={{ .Env.IMAGE_REGISTRY }}/envoy-wrapper-cache:arm64"
|
||||
- "--cache-to=type=registry,ref={{ .Env.IMAGE_REGISTRY }}/envoy-wrapper-cache:arm64,mode=max,ignore-error=true"
|
||||
extra_files:
|
||||
- cmd/envoyinit/docker-entrypoint.sh
|
||||
- internal/envoyinit
|
||||
- image_templates:
|
||||
- &envoyinit_amd_image "{{ .Env.IMAGE_REGISTRY }}/{{ .Env.ENVOYINIT_IMAGE_REPO }}:{{ .Env.VERSION }}-amd64"
|
||||
use: buildx
|
||||
dockerfile: *envoyinit_dockerfile
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
build_flag_templates:
|
||||
- "--pull"
|
||||
- "--platform=linux/amd64"
|
||||
- "--build-arg=GOARCH=amd64"
|
||||
- "--build-arg=ENTRYPOINT_SCRIPT=/cmd/envoyinit/docker-entrypoint.sh"
|
||||
- "--build-arg=ENVOY_IMAGE={{ .Env.ENVOY_IMAGE_AMD64 }}"
|
||||
- "--build-arg=RUSTFORMATIONS_DIR=/internal/envoyinit"
|
||||
- "--cache-from=type=registry,ref={{ .Env.IMAGE_REGISTRY }}/envoy-wrapper-cache:amd64"
|
||||
- "--cache-to=type=registry,ref={{ .Env.IMAGE_REGISTRY }}/envoy-wrapper-cache:amd64,mode=max,ignore-error=true"
|
||||
extra_files:
|
||||
- cmd/envoyinit/docker-entrypoint.sh
|
||||
- internal/envoyinit
|
||||
docker_manifests:
|
||||
- name_template: "{{ .Env.IMAGE_REGISTRY }}/{{ .Env.CONTROLLER_IMAGE_REPO }}:{{ .Env.VERSION }}"
|
||||
image_templates:
|
||||
- *controller_arm_image
|
||||
- *controller_amd_image
|
||||
- name_template: "{{ .Env.IMAGE_REGISTRY }}/{{ .Env.AGENTGATEWAY_IMAGE_REPO }}:{{ .Env.VERSION }}"
|
||||
image_templates:
|
||||
- *agentgateway_arm_image
|
||||
- *agentgateway_amd_image
|
||||
- name_template: "{{ .Env.IMAGE_REGISTRY }}/{{ .Env.SDS_IMAGE_REPO }}:{{ .Env.VERSION }}"
|
||||
image_templates:
|
||||
- *sds_arm_image
|
||||
- *sds_amd_image
|
||||
- name_template: "{{ .Env.IMAGE_REGISTRY }}/{{ .Env.ENVOYINIT_IMAGE_REPO }}:{{ .Env.VERSION }}"
|
||||
image_templates:
|
||||
- *envoyinit_arm_image
|
||||
- *envoyinit_amd_image
|
||||
changelog:
|
||||
# Disable auto-generated changelog from git commits.
|
||||
# For real releases, we use --release-notes flag with our custom script output.
|
||||
# For main branch builds, we skip changelog entirely (same as release).
|
||||
disable: '{{ if isEnvSet "GORELEASER_DISABLE_RELEASE" }}{{ .Env.GORELEASER_DISABLE_RELEASE }}{{ else }}false{{ end }}'
|
||||
release:
|
||||
disable: '{{ if isEnvSet "GORELEASER_DISABLE_RELEASE" }}{{ .Env.GORELEASER_DISABLE_RELEASE }}{{ else }}false{{ end }}'
|
||||
prerelease: "auto"
|
||||
mode: "replace"
|
||||
replace_existing_artifacts: true
|
||||
target_commitish: "{{ .FullCommit }}"
|
||||
header: |
|
||||
{{ if eq .Env.VERSION "v2.3.0-main" }}
|
||||
🚀 Rolling main build of kgateway!
|
||||
---
|
||||
It includes the latest changes but may be unstable. Use it for testing and providing feedback.
|
||||
{{ else }}
|
||||
🎉 Welcome to the {{ .Env.VERSION }} release of the kgateway project!
|
||||
---
|
||||
{{ end }}
|
||||
footer: |
|
||||
## Installation
|
||||
|
||||
The kgateway project is available as a Helm chart and docker images.
|
||||
|
||||
### Helm Charts
|
||||
|
||||
The Helm charts are available at:
|
||||
* [{{ .Env.VANITY_REGISTRY }}/charts/kgateway]({{ .Env.VANITY_REGISTRY }}/charts/kgateway).
|
||||
* [{{ .Env.AGW_VANITY_REGISTRY }}/charts/agentgateway]({{ .Env.AGW_VANITY_REGISTRY }}/charts/agentgateway).
|
||||
|
||||
### Docker Images
|
||||
|
||||
The docker images are available at:
|
||||
|
||||
- {{ .Env.VANITY_REGISTRY }}/{{ .Env.CONTROLLER_IMAGE_REPO }}:{{ .Env.VERSION }}
|
||||
- {{ .Env.VANITY_REGISTRY }}/{{ .Env.SDS_IMAGE_REPO }}:{{ .Env.VERSION }}
|
||||
- {{ .Env.VANITY_REGISTRY }}/{{ .Env.ENVOYINIT_IMAGE_REPO }}:{{ .Env.VERSION }}
|
||||
- {{ .Env.AGW_VANITY_REGISTRY }}/{{ .Env.AGENTGATEWAY_IMAGE_REPO }}:{{ .Env.VERSION }}
|
||||
|
||||
## Quickstart
|
||||
|
||||
Try installing this release:
|
||||
```
|
||||
helm install kgateway-crds oci://{{ .Env.VANITY_REGISTRY }}/charts/kgateway-crds --version {{ .Env.VERSION }} --namespace kgateway-system --create-namespace
|
||||
helm install kgateway oci://{{ .Env.VANITY_REGISTRY }}/charts/kgateway --version {{ .Env.VERSION }} --namespace kgateway-system --create-namespace
|
||||
helm install agentgateway-crds oci://{{ .Env.AGW_VANITY_REGISTRY }}/charts/agentgateway-crds --version {{ .Env.VERSION }} --namespace agentgateway-system --create-namespace
|
||||
helm install agentgateway oci://{{ .Env.AGW_VANITY_REGISTRY }}/charts/agentgateway --version {{ .Env.VERSION }} --namespace agentgateway-system --create-namespace
|
||||
```
|
||||
|
||||
For detailed installation instructions and next steps, please visit our [quickstart guide](https://kgateway.dev/docs/quickstart/).
|
||||
@ -104,7 +104,7 @@ Only project maintainers can create releases. The process is:
|
||||
### Community
|
||||
|
||||
- Join our [Discord server](https://discord.gg/y9efgEmppm) for discussions
|
||||
- Participate in [our All Things AI Agents community calls](https://github.com/kagent-dev/community?tab=readme-ov-file#community-meetings)
|
||||
- Participate in our [agentgateway community calls](https://calendar.google.com/calendar/u/0?cid=Y18zZTAzNGE0OTFiMGUyYzU2OWI1Y2ZlOWNmOWM4NjYyZTljNTNjYzVlOTdmMjdkY2I5ZTZmNmM5ZDZhYzRkM2ZmQGdyb3VwLmNhbGVuZGFyLmdvb2dsZS5jb20)
|
||||
- Help answer questions in GitHub issues
|
||||
- Review pull requests from other contributors
|
||||
|
||||
@ -114,4 +114,4 @@ By contributing to this project, you agree that your contributions will be licen
|
||||
|
||||
## Questions?
|
||||
|
||||
If you have any questions about contributing, please open an issue or reach out to the maintainers.
|
||||
If you have any questions about contributing, please open an issue or reach out to the maintainers.
|
||||
|
||||
1565
Cargo.lock
generated
1565
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
107
Cargo.toml
107
Cargo.toml
@ -6,7 +6,6 @@ wiremock = { git = "https://github.com/howardjohn/wiremock-rs", rev = "e55f5b960
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
members = [
|
||||
"crates/a2a-sdk",
|
||||
"crates/agentgateway",
|
||||
"crates/agentgateway-app",
|
||||
"crates/cel-fork/cel",
|
||||
@ -14,11 +13,11 @@ members = [
|
||||
"crates/celx",
|
||||
"crates/core",
|
||||
"crates/hbone",
|
||||
"crates/protos",
|
||||
"crates/xds",
|
||||
"crates/xtask",
|
||||
]
|
||||
default-members = [
|
||||
"crates/a2a-sdk",
|
||||
"crates/agentgateway",
|
||||
"crates/agentgateway-app",
|
||||
"crates/cel-fork/cel",
|
||||
@ -26,18 +25,18 @@ default-members = [
|
||||
"crates/celx",
|
||||
"crates/core",
|
||||
"crates/hbone",
|
||||
"crates/protos",
|
||||
"crates/xds",
|
||||
]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.7.0"
|
||||
version = "0.0.0" # We do not use this version
|
||||
edition = "2024"
|
||||
rust-version = "1.90"
|
||||
license = "Apache-2.0"
|
||||
publish = false
|
||||
|
||||
[workspace.dependencies]
|
||||
a2a-sdk = { version = "0.7.0", path = "crates/a2a-sdk" }
|
||||
agent-core = { path = "crates/core" }
|
||||
agent-celx = { path = "crates/celx" }
|
||||
agent-hbone = { path = "crates/hbone" }
|
||||
@ -45,45 +44,52 @@ agent-xds = { path = "crates/xds" }
|
||||
agentgateway = { path = "crates/agentgateway" }
|
||||
cel = { path = "crates/cel-fork/cel" }
|
||||
cel-derive = { path = "crates/cel-fork/cel-derive" }
|
||||
protos = { path = "crates/protos" }
|
||||
atomic_float = { version = "1.1.0", features = ["serde"] }
|
||||
anyhow = "1.0"
|
||||
arc-swap = "1.7.1"
|
||||
arc-swap = "1.9"
|
||||
arcstr = { version = "1.2", features = ["serde"] }
|
||||
assert_matches = "1.5.0"
|
||||
async-openai = { version = "0.32.2", default-features = false, features = ["chat-completion-types", "embedding-types", "moderation-types", "response-types", "realtime-types"] }
|
||||
async-openai = { version = "0.34", default-features = false, features = ["chat-completion-types", "moderation-types", "response-types", "realtime-types"] }
|
||||
async-stream = "0.3"
|
||||
async-trait = "0.1"
|
||||
aws-config = "1.8"
|
||||
aws-config = { version = "1.8", default-features = false, features = ["default-https-client", "rt-tokio"] }
|
||||
aws-credential-types = "1.2"
|
||||
aws-sigv4 = "1.3"
|
||||
aws-smithy-eventstream = "0.60"
|
||||
aws-smithy-types = "1.3"
|
||||
aws-lc-rs = "1.15"
|
||||
aws-lc-rs = "1.16"
|
||||
axum = { version = "0.8", features = ["macros"] }
|
||||
axum-core = "0.5"
|
||||
axum-extra = { version = "0.12", features = ["json-lines", "typed-header"] }
|
||||
# Disable default features to avoid pulling in native-tls and requiring openssl
|
||||
# TODO: allow default features if we ever add an openssl feature
|
||||
azure_identity = { version = "0.31", default-features = false }
|
||||
azure_core = { version = "0.31", default-features = false }
|
||||
typespec_client_core = { default-features = false, version = "0.10" }
|
||||
azure_identity = { version = "0.33", default-features = false }
|
||||
azure_core = { version = "0.33", default-features = false }
|
||||
typespec_client_core = { default-features = false, version = "0.12" }
|
||||
base64 = "0.22"
|
||||
bcrypt = "0.18"
|
||||
bytes = { version = "1.10", features = ["serde"] }
|
||||
cookie = { version = "0.18", default-features = false }
|
||||
bcrypt = "0.19"
|
||||
bytes = { version = "1.11", features = ["serde"] }
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
clap = { version = "4.5", features = ["derive"] }
|
||||
clocksource = "0.8"
|
||||
clap = { version = "4.6", features = ["derive"] }
|
||||
clocksource = "1.0"
|
||||
crossbeam = "0.8"
|
||||
divan = "0.1"
|
||||
durationfmt = "0.1"
|
||||
go-parse-duration = "0.1"
|
||||
flurry = "0.5.2"
|
||||
fs-err = { version = "3.1", features = ["tokio"] }
|
||||
fs-err = { version = "3.3", features = ["tokio"] }
|
||||
futures = "0.3"
|
||||
futures-channel = "0.3"
|
||||
futures-core = "0.3"
|
||||
futures-util = "0.3"
|
||||
google-cloud-auth = { git = "https://github.com/googleapis/google-cloud-rust", rev = "18f8434cb598ae9f9835b7d77b2a8774fec1d2ea", default-features = false, features = ["idtoken"] }
|
||||
google-cloud-auth = { version = "1.8", default-features = false, features = [
|
||||
"idtoken",
|
||||
# They use AWS-LC which is what we want so its fine. If they changed we would need to switch
|
||||
# To installing a global default which is annoying so prefer to do it this way.
|
||||
"default-rustls-provider",
|
||||
] }
|
||||
hashbrown = "0.16"
|
||||
h2 = "0.4"
|
||||
headers = "0.4"
|
||||
@ -91,37 +97,37 @@ hex = "0.4"
|
||||
hickory-resolver = { version = "0.25", features = ["serde"] }
|
||||
htpasswd-verify-fork = { path = "crates/htpasswd-verify-fork" }
|
||||
httpdate = "1.0"
|
||||
http = "1.3"
|
||||
http = "1.4"
|
||||
http-body = "1"
|
||||
http-body-util = "0.1.3"
|
||||
hyper = { version = "1.6", features = ["full"] }
|
||||
hyper = { version = "1.8", features = ["full"] }
|
||||
hyper-rustls = "0.27"
|
||||
hyper-util = { version = "0.1", features = ["full"] }
|
||||
hyper-util-fork = { path = "crates/hyper-util-fork", features = ["full"] }
|
||||
hyper-util-fork = { path = "crates/hyper-util-fork" }
|
||||
include_dir = "0.7"
|
||||
indexmap = { version = "2.9", features = ["serde"] }
|
||||
insta = { version = "1.38", features = ["json", "redactions", "filters"] }
|
||||
ipnet = { version = "2.11", features = ["serde"] }
|
||||
indexmap = { version = "2.13", features = ["serde"] }
|
||||
insta = { version = "1.47", features = ["json", "redactions", "filters", "yaml"] }
|
||||
ipnet = { version = "2.12", features = ["serde"] }
|
||||
itertools = "0.14"
|
||||
jsonwebtoken = { version = "10.3", features = ["aws_lc_rs"] }
|
||||
lazy_static = "1.4"
|
||||
lazy_static = "1.5"
|
||||
libc = "0.2"
|
||||
notify = "8.0"
|
||||
notify = "8.2"
|
||||
notify-debouncer-full = "0.7"
|
||||
md-5 = "0.10"
|
||||
md-5 = "0.11"
|
||||
num_cpus = "1.17"
|
||||
once_cell = "1.21"
|
||||
openapiv3 = "2.2"
|
||||
opentelemetry = "0.31"
|
||||
opentelemetry-http = "0.31"
|
||||
opentelemetry-otlp = { version = "0.31", features = ["grpc-tonic"] }
|
||||
opentelemetry-proto = { version = "0.31", features = ["gen-tonic"] }
|
||||
opentelemetry_sdk = { version = "0.31", features = ["rt-tokio"] }
|
||||
opentelemetry-otlp = { version = "0.31", default-features = false, features = ["http-proto", "internal-logs", "trace", "grpc-tonic", "logs"] }
|
||||
opentelemetry-proto = { version = "0.31", features = ["gen-tonic", "logs"] }
|
||||
opentelemetry_sdk = { version = "0.31", features = ["rt-tokio", "logs"] }
|
||||
parking_lot = "0.12"
|
||||
percent-encoding = "2.3"
|
||||
phonenumber = "0.3"
|
||||
pin-project-lite = "0.2"
|
||||
pingora-pool = "0.7"
|
||||
pingora-pool = "0.8"
|
||||
ppp = "2.3"
|
||||
pprof = { version = "0.15", features = [
|
||||
"protobuf",
|
||||
@ -133,24 +139,22 @@ prometheus-client = "0.24"
|
||||
prost = "0.14"
|
||||
prost-build = "0.14"
|
||||
prost-types = "0.14"
|
||||
prost-wkt-types = { version = "0.7.0", features = ["vendored-protox"] }
|
||||
prost-wkt-build = "0.7.0"
|
||||
prost-wkt-types = { version = "0.7", features = ["vendored-protox"] }
|
||||
prost-wkt-build = "0.7"
|
||||
pwhash = "1"
|
||||
rand = "0.10"
|
||||
rcgen = { version = "0.14", features = ["pem", "x509-parser"] }
|
||||
regex = "1.11"
|
||||
reqwest = { version = "0.12", default-features = false, features = [
|
||||
rcgen = { version = "0.14", default-features = false, features = ["pem", "x509-parser", "aws_lc_rs"] }
|
||||
regex = "1.12"
|
||||
reqwest = { version = "0.13", default-features = false, features = [
|
||||
"http2",
|
||||
"charset",
|
||||
"macos-system-configuration",
|
||||
"rustls-tls",
|
||||
"rustls",
|
||||
] }
|
||||
rstest = "0.26"
|
||||
rustc_version = "0.4"
|
||||
rustls = { version = "0.23", features = ["tls12", "ring"] }
|
||||
rustls = { version = "0.23", default-features = false, features = ["tls12", "aws_lc_rs"] }
|
||||
rustls-native-certs = "0.8"
|
||||
rustls-pemfile = "2.2"
|
||||
rustls-pki-types = "1.12"
|
||||
rustls-pki-types = "1.14"
|
||||
schemars = { version = "=1.0.4", git = "https://github.com/howardjohn/schemars", rev = "4364354fa41897a0c2001d891c0a9a38eafedb82", features = [
|
||||
#schemars = { version = "1.0", features = [
|
||||
"bytes1",
|
||||
@ -166,17 +170,18 @@ serde-untagged = "0.1"
|
||||
serde_json_path_to_error = "0.1"
|
||||
serde_regex = "1.1"
|
||||
serde_yaml = "0.9"
|
||||
sha1 = "0.10"
|
||||
sha1 = "0.11"
|
||||
sha2 = "0.11"
|
||||
shellexpand = "3.1"
|
||||
socket2 = "0.6"
|
||||
split-iter = "0.1"
|
||||
sse-stream = "0.2"
|
||||
stacker = "0.1"
|
||||
tempfile = "3.20"
|
||||
tempfile = "3.27"
|
||||
thiserror = "2.0"
|
||||
tiktoken-rs = "0.9"
|
||||
tokio = { version = "1.48", features = ["full", "macros", "sync"] }
|
||||
tokio-rustls = { version = "0.26", default-features = false }
|
||||
tokio = { version = "1.50", features = ["full", "macros", "sync"] }
|
||||
tokio-rustls = { version = "0.26", default-features = false, features = ["aws_lc_rs"] }
|
||||
tokio-stream = { version = "0.1", features = ["net", "sync"] }
|
||||
tokio-test = "0.4"
|
||||
tokio-util = { version = "0.7", features = ["codec", "io"] }
|
||||
@ -199,7 +204,7 @@ tracing-subscriber = { version = "0.3", features = [
|
||||
"json",
|
||||
] }
|
||||
url = "2.5"
|
||||
uuid = { version = "1.11", features = ["v4"] }
|
||||
uuid = { version = "1.23", features = ["v4"] }
|
||||
wiremock = { version = "0.6", features = ["tls"] }
|
||||
x509-parser = { version = "0.18", default-features = false, features = ["verify-aws"] }
|
||||
which = "8.0"
|
||||
@ -210,12 +215,12 @@ crossbeam-channel = "0.5"
|
||||
http-serde = "2.1"
|
||||
itoa = "1.0"
|
||||
serde_urlencoded = "0.7"
|
||||
serde_with = { version = "3.14", features = [
|
||||
serde_with = { version = "3.17", features = [
|
||||
"schemars_1",
|
||||
"macros",
|
||||
"alloc",
|
||||
], default-features = false }
|
||||
value-bag = { version = "1.11", features = ["serde", "value-bag-serde1"] }
|
||||
value-bag = { version = "1.12", features = ["serde", "value-bag-serde1"] }
|
||||
time = "0.3"
|
||||
tikv-jemallocator = { version = "0.6", features = [
|
||||
"profiling",
|
||||
@ -223,17 +228,17 @@ tikv-jemallocator = { version = "0.6", features = [
|
||||
] }
|
||||
jemalloc_pprof = { version = "0.8", features = ["symbolize"] }
|
||||
protox = "0.9"
|
||||
async-compression = { version = "0.4.27", features = [
|
||||
async-compression = { version = "0.4", features = [
|
||||
"brotli",
|
||||
"zlib",
|
||||
"gzip",
|
||||
"zstd",
|
||||
"tokio",
|
||||
] }
|
||||
core_affinity = "0.8.3"
|
||||
frozen-collections = "0.8.0"
|
||||
core_affinity = "0.8"
|
||||
frozen-collections = "0.9"
|
||||
heck = "0.5"
|
||||
macro_rules_attribute = "0.2.2"
|
||||
macro_rules_attribute = "0.2"
|
||||
|
||||
# Release optimized but without as many dependencies, suitable for incremental development
|
||||
[profile.quick-release]
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
# syntax=docker/dockerfile:1.11
|
||||
ARG BUILDER=base
|
||||
|
||||
FROM docker.io/library/node:23.11.0-bookworm AS node
|
||||
|
||||
10
Makefile
10
Makefile
@ -19,6 +19,14 @@ else
|
||||
$(DOCKER_BUILDER) build $(DOCKER_BUILD_ARGS) -t $(IMAGE_FULL_NAME) . --progress=plain
|
||||
endif
|
||||
|
||||
.PHONY: docker-ci
|
||||
docker-ci:
|
||||
ifeq ($(OS),Windows_NT)
|
||||
$(DOCKER_BUILDER) build $(DOCKER_BUILD_ARGS) --build-arg PROFILE=ci -f Dockerfile.windows -t $(IMAGE_FULL_NAME) .
|
||||
else
|
||||
$(DOCKER_BUILDER) build $(DOCKER_BUILD_ARGS) --build-arg PROFILE=ci -t $(IMAGE_FULL_NAME) . --progress=plain
|
||||
endif
|
||||
|
||||
.PHONY: docker-musl
|
||||
docker-musl:
|
||||
$(DOCKER_BUILDER) build $(DOCKER_BUILD_ARGS) -t $(IMAGE_FULL_NAME)-musl --build-arg=BUILDER=musl . --progress=plain
|
||||
@ -74,7 +82,7 @@ generate-schema:
|
||||
# Code generation for xds apis
|
||||
.PHONY: generate-apis
|
||||
generate-apis:
|
||||
@PATH="./common/tools:$(PATH)" buf generate --path crates/agentgateway/proto/resource.proto
|
||||
@PATH="./common/tools:$(PATH)" buf generate --path crates/protos/proto/resource.proto
|
||||
|
||||
.PHONY: run-validation-deps
|
||||
run-validation-deps:
|
||||
|
||||
56
README.md
56
README.md
@ -29,7 +29,7 @@
|
||||
|
||||
---
|
||||
|
||||
**Agentgateway** is an open source data plane optimized for agentic AI connectivity within or across any agent framework or environment. Agentgateway provides drop-in security, observability, and governance for agent-to-agent and agent-to-tool communication and supports leading interoperable protocols, including [Agent2Agent (A2A)](https://developers.googleblog.com/en/a2a-a-new-era-of-agent-interoperability/) and [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction).
|
||||
**Agentgateway** is an open source proxy built on AI-native protocols ([MCP](https://modelcontextprotocol.io/introduction) & [A2A](https://developers.googleblog.com/en/a2a-a-new-era-of-agent-interoperability/)) that provides drop-in security, observability, and governance for agent-to-LLM, agent-to-tool, and agent-to-agent communication across any framework and environment.
|
||||
|
||||
<br>
|
||||
<div align="center">
|
||||
@ -37,33 +37,42 @@
|
||||
</div>
|
||||
<br>
|
||||
|
||||
> [!TIP]
|
||||
> Want to use agentgateway in Kubernetes? Check out the [kgateway.dev/docs/agentgateway](https://kgateway.dev/docs/agentgateway/) docs. Agentgateway is a supported data plane for the kgateway project, which provides a control plane to dynamically provision and manage agentgateway with the Kubernetes Gateway API.
|
||||
|
||||
## Intro to Agentgateway Video
|
||||
|
||||
[](https://youtu.be/SomP92JWPmE)
|
||||
|
||||
## Key Features:
|
||||
## Key Features
|
||||
|
||||
- [x] **Highly performant:** agentgateway is written in rust, and is designed from the ground up to handle any scale you can throw at it.
|
||||
- [x] **Security First:** agentgateway includes a robust MCP/A2A focused RBAC system.
|
||||
- [x] **Multi Tenant:** agentgateway supports multiple tenants, each with their own set of resources and users.
|
||||
- [x] **Dynamic:** agentgateway supports dynamic configuration updates via xDS, without any downtime.
|
||||
- [x] **Run Anywhere:** agentgateway can run anywhere with any agent framework, from a single machine to a large scale multi-tenant deployment.
|
||||
- [x] **Legacy API Support:** agentgateway can transform legacy APIs into MCP resources. Currently supports OpenAPI. (gRPC coming soon)
|
||||
- **LLM Gateway**<br>
|
||||
Route traffic to major LLM providers (OpenAI, Anthropic, Gemini, Bedrock, and more) through a unified OpenAI-compatible API with budget and spend controls, prompt enrichment, load balancing, and failover.
|
||||
|
||||
- **MCP Gateway**<br>
|
||||
Connect LLMs to tools and external data sources via MCP with tool federation, stdio/HTTP/SSE/Streamable HTTP transports, OpenAPI integration, and OAuth authentication.
|
||||
|
||||
- **A2A Gateway**<br>
|
||||
Enable secure agent-to-agent communication using A2A, with capability discovery, modality negotiation, and task collaboration.
|
||||
|
||||
- **Inference Routing**<br>
|
||||
Intelligent routing to self-hosted models using Kubernetes Inference Gateway extensions, with decisions based on GPU utilization, KV cache, LoRA adapters, and queue depth.
|
||||
|
||||
- **Guardrails**<br>
|
||||
Multi-layered content filtering with regex, OpenAI moderation, AWS Bedrock Guardrails, Google Model Armor, and custom webhooks.
|
||||
|
||||
- **Security & Observability**<br>
|
||||
Auth (JWT, API keys, OAuth), fine-grained RBAC with CEL policy engine, rate limiting, TLS, and OpenTelemetry metrics/logs/tracing.
|
||||
<br>
|
||||
|
||||
## Getting Started
|
||||
## Getting Started
|
||||
|
||||
To get started with agentgateway, please check out the [Getting Started Guide](https://agentgateway.dev/docs/quickstart).
|
||||
- [Standalone Quickstart](https://agentgateway.dev/docs/quickstart) — Get started with agentgateway in minutes.
|
||||
- [Kubernetes Quickstart](https://agentgateway.dev/docs/kubernetes/latest) — Deploy on Kubernetes using the built-in controller and Gateway API.
|
||||
|
||||
## Documentation
|
||||
|
||||
Depending on your deployment environment, check out the following docs:
|
||||
|
||||
- [agentgateway.dev/docs](https://agentgateway.dev/docs/): For standalone deployments such as local or on-prem. These docs are for this upstream `agentgateway/agentgateway` GitHub project.
|
||||
- [kgateway.dev/docs/agentgateway](https://kgateway.dev/docs/agentgateway/): For Kubernetes-based deployments. These docs are for the agentgateway data plane that is supported by the [`kgateway-dev/kgateway` GitHub project](https://github.com/kgateway-dev/kgateway). Kgateway provides a control plane to dynamically provision and manage agentgateway with the Kubernetes Gateway API.
|
||||
- [agentgateway.dev/docs/kubernetes/latest](https://agentgateway.dev/docs/kubernetes/latest): For Kubernetes-based deployments using the built-in Kubernetes controller and Gateway API support.
|
||||
|
||||
Agentgateway has a built-in UI for you to explore agentgateway connecting agent-to-agent or agent-to-tool:
|
||||
|
||||
@ -71,6 +80,23 @@ Agentgateway has a built-in UI for you to explore agentgateway connecting agent-
|
||||
<img alt="agentgateway UI" src="img/UI-homepage.png">
|
||||
</div>
|
||||
|
||||
## Sponsors
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center" width="33.3%">
|
||||
<a href="https://blacksmith.sh/">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/agentgateway/agentgateway/main/img/blacksmith-light.svg">
|
||||
<img src="https://raw.githubusercontent.com/agentgateway/agentgateway/main/img/blacksmith.svg" alt="Blacksmith" height="48">
|
||||
</picture>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
Thank you to our sponsors for helping to fund the development of agentgateway!
|
||||
|
||||
## Contributing
|
||||
|
||||
For instructions on how to contribute to the agentgateway project, see the [CONTRIBUTION.md](CONTRIBUTION.md) file.
|
||||
@ -82,7 +108,7 @@ Recordings of the community meetings will be published on our [google drive](htt
|
||||
|
||||
## Roadmap
|
||||
|
||||
`agentgateway` is currently in active development. If you want a feature missing, open an issue in our [Github repo](https://github.com/agentgateway/agentgateway/issues).
|
||||
`agentgateway` is currently in active development. If you'd like a feature that's missing, open an issue in our [GitHub repo](https://github.com/agentgateway/agentgateway/issues).
|
||||
|
||||
## Contributors
|
||||
|
||||
|
||||
177
Tiltfile
Normal file
177
Tiltfile
Normal file
@ -0,0 +1,177 @@
|
||||
# Tiltfile for AgentGateway development
|
||||
# This deploys both control plane (Go) and data plane (Rust) to Kind with live updates
|
||||
load('ext://restart_process', 'docker_build_with_restart')
|
||||
load('ext://helm_resource', 'helm_resource', 'helm_repo')
|
||||
|
||||
# Configuration
|
||||
version = 'v1.0.1-dev'
|
||||
cluster_name = 'kind'
|
||||
install_namespace = k8s_namespace()
|
||||
image_registry = 'localhost:5000'
|
||||
|
||||
# Ensure Kind cluster exists
|
||||
allow_k8s_contexts('kind-' + cluster_name)
|
||||
|
||||
# Helper to run Make targets
|
||||
def run_make(target, cwd='.'):
|
||||
return local('make -C ' + cwd + ' ' + target)
|
||||
|
||||
def run_controller_make(target):
|
||||
return run_make(target, cwd='./controller')
|
||||
# =============================================================================
|
||||
# Setup: Ensure cluster is ready
|
||||
# =============================================================================
|
||||
|
||||
# Check if kind cluster exists, create if not
|
||||
if str(local('kind get clusters 2>/dev/null | grep -c "^' + cluster_name + '$" || true')).strip() == '0':
|
||||
print('No kind cluster! create one and restart tilt after doing so. You can use this command:')
|
||||
print('ctlptl create cluster kind --name kind-' + cluster_name + ' --registry=ctlptl-registry')
|
||||
fail("started kind cluster. Create one and run tilt again")
|
||||
|
||||
print('Installing Gateway API CRDs...')
|
||||
run_controller_make('gw-api-crds')
|
||||
run_controller_make('gie-crds')
|
||||
|
||||
# Install CRDs
|
||||
print('Installing AgentGateway CRDs...')
|
||||
helm_resource(
|
||||
'agentgateway-crds',
|
||||
'controller/install/helm/agentgateway-crds',
|
||||
namespace=install_namespace,
|
||||
flags=['--set=version=' + version],
|
||||
)
|
||||
|
||||
# =============================================================================
|
||||
# Control Plane (Go-based controller)
|
||||
# =============================================================================
|
||||
|
||||
local_resource(
|
||||
'go-compile-controller',
|
||||
'make -C ./controller VERSION=' + version + ' GCFLAGS=all="-N -l" agentgateway-controller && mv ./controller/_output/pkg/agentgateway/agentgateway-linux-$(go env GOARCH) ./tools/tilt/agentgateway-controller',
|
||||
deps=['./controller/'],
|
||||
ignore=['./controller/_output/'],
|
||||
)
|
||||
|
||||
# Build control plane Docker image
|
||||
docker_build_with_restart(
|
||||
image_registry + '/agentgateway-controller',
|
||||
context='./tools/tilt/',
|
||||
entrypoint='/usr/local/bin/agentgateway-controller',
|
||||
dockerfile_contents="""
|
||||
FROM ubuntu:24.04
|
||||
COPY agentgateway-controller /usr/local/bin/agentgateway-controller
|
||||
ENTRYPOINT /usr/local/bin/agentgateway-controller
|
||||
""",
|
||||
# Live update: sync Go binaries
|
||||
live_update=[
|
||||
# Sync Go code changes
|
||||
sync('./tools/tilt/agentgateway-controller', '/usr/local/bin/agentgateway-controller'),
|
||||
],
|
||||
only=[
|
||||
'./agentgateway-controller',
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# Deploy via Helm
|
||||
# =============================================================================
|
||||
|
||||
# Deploy AgentGateway via Helm
|
||||
k8s_yaml(helm(
|
||||
'controller/install/helm/agentgateway',
|
||||
name='agentgateway',
|
||||
namespace=install_namespace,
|
||||
set=[
|
||||
'image.registry=' + image_registry,
|
||||
'image.tag=' + version,
|
||||
'image.pullPolicy=IfNotPresent',
|
||||
'controller.image.repository=agentgateway-controller',
|
||||
'controller.image.tag=' + version,
|
||||
'controller.replicaCount=1',
|
||||
'controller.logLevel=debug',
|
||||
'proxy.image.repository=agentgateway',
|
||||
'proxy.image.tag=' + version,
|
||||
],
|
||||
values=[config.main_dir + '/controller/hack/helm/dev.yaml'] if os.path.exists(config.main_dir + '/controller/hack/helm/dev.yaml') else [],
|
||||
))
|
||||
|
||||
k8s_resource('agentgateway',
|
||||
resource_deps=['go-compile-controller'])
|
||||
|
||||
# =============================================================================
|
||||
# Data Plane (Rust-based proxy)
|
||||
# =============================================================================
|
||||
|
||||
local_resource(
|
||||
'rust-compile-dataplane',
|
||||
'cargo build && if [ -f "./tools/tilt/agentgateway" ]; then rm "./tools/tilt/agentgateway"; fi && mv ./target/debug/agentgateway ./tools/tilt/agentgateway',
|
||||
deps=['./crates',
|
||||
'./Cargo.toml',
|
||||
'./Cargo.lock',
|
||||
'./.cargo'])
|
||||
#
|
||||
# Build data plane Docker image
|
||||
docker_build(
|
||||
'agentgateway',
|
||||
context='./tools/tilt/',
|
||||
dockerfile_contents="""
|
||||
FROM ubuntu:24.04
|
||||
COPY start.sh /scripts/start.sh
|
||||
COPY restart.sh /scripts/restart.sh
|
||||
COPY agentgateway /usr/local/bin/
|
||||
ENTRYPOINT ["/scripts/start.sh", "/usr/local/bin/agentgateway"]
|
||||
""",
|
||||
live_update=[
|
||||
sync('./tools/tilt/agentgateway', '/usr/local/bin/agentgateway'),
|
||||
run('/scripts/restart.sh'),
|
||||
],
|
||||
only=[
|
||||
'./agentgateway',
|
||||
'./start.sh',
|
||||
'./restart.sh',
|
||||
],
|
||||
)
|
||||
|
||||
k8s_kind('AgentgatewayParameters', image_object={'json_path': '{.spec.image}', 'repo_field': 'repository', 'tag_field': 'tag'})
|
||||
k8s_kind('Gateway', pod_readiness='wait')
|
||||
|
||||
k8s_yaml(blob("""
|
||||
apiVersion: agentgateway.dev/v1alpha1
|
||||
kind: AgentgatewayParameters
|
||||
metadata:
|
||||
name: dataplane-dev-gwparams
|
||||
spec:
|
||||
image:
|
||||
registry: "" # tilt will fill in the registry in the repository field, so leave it blank here (othewise it will be duplicated)
|
||||
repository: agentgateway
|
||||
tag: """ + version + """
|
||||
deployment:
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
# Delete container-level securityContext so that Tilt can apply live updates
|
||||
# (need root user, and file system to be writable for live updates)
|
||||
- name: agentgateway
|
||||
securityContext:
|
||||
$patch: delete
|
||||
---
|
||||
kind: Gateway
|
||||
apiVersion: gateway.networking.k8s.io/v1
|
||||
metadata:
|
||||
name: tilt-gw
|
||||
spec:
|
||||
gatewayClassName: agentgateway
|
||||
infrastructure:
|
||||
parametersRef:
|
||||
group: agentgateway.dev
|
||||
kind: AgentgatewayParameters
|
||||
name: dataplane-dev-gwparams
|
||||
listeners:
|
||||
- name: http
|
||||
protocol: HTTP
|
||||
port: 8080
|
||||
"""))
|
||||
k8s_resource(workload='dataplane-dev-gwparams', extra_pod_selectors={"gateway.networking.k8s.io/gateway-name":"tilt-gw"},
|
||||
resource_deps=['rust-compile-dataplane'])
|
||||
2828
api/resource.pb.go
2828
api/resource.pb.go
File diff suppressed because it is too large
Load Diff
@ -336,6 +336,17 @@ func (this *AzureDeveloperImplicit) UnmarshalJSON(b []byte) error {
|
||||
return ResourceUnmarshaler.Unmarshal(bytes.NewReader(b), this)
|
||||
}
|
||||
|
||||
// MarshalJSON is a custom marshaler for AzureImplicit
|
||||
func (this *AzureImplicit) MarshalJSON() ([]byte, error) {
|
||||
str, err := ResourceMarshaler.MarshalToString(this)
|
||||
return []byte(str), err
|
||||
}
|
||||
|
||||
// UnmarshalJSON is a custom unmarshaler for AzureImplicit
|
||||
func (this *AzureImplicit) UnmarshalJSON(b []byte) error {
|
||||
return ResourceUnmarshaler.Unmarshal(bytes.NewReader(b), this)
|
||||
}
|
||||
|
||||
// MarshalJSON is a custom marshaler for RouteMatch
|
||||
func (this *RouteMatch) MarshalJSON() ([]byte, error) {
|
||||
str, err := ResourceMarshaler.MarshalToString(this)
|
||||
@ -600,6 +611,17 @@ func (this *FrontendPolicySpec_TCP) UnmarshalJSON(b []byte) error {
|
||||
return ResourceUnmarshaler.Unmarshal(bytes.NewReader(b), this)
|
||||
}
|
||||
|
||||
// MarshalJSON is a custom marshaler for FrontendPolicySpec_NetworkAuthorization
|
||||
func (this *FrontendPolicySpec_NetworkAuthorization) MarshalJSON() ([]byte, error) {
|
||||
str, err := ResourceMarshaler.MarshalToString(this)
|
||||
return []byte(str), err
|
||||
}
|
||||
|
||||
// UnmarshalJSON is a custom unmarshaler for FrontendPolicySpec_NetworkAuthorization
|
||||
func (this *FrontendPolicySpec_NetworkAuthorization) UnmarshalJSON(b []byte) error {
|
||||
return ResourceUnmarshaler.Unmarshal(bytes.NewReader(b), this)
|
||||
}
|
||||
|
||||
// MarshalJSON is a custom marshaler for FrontendPolicySpec_Logging
|
||||
func (this *FrontendPolicySpec_Logging) MarshalJSON() ([]byte, error) {
|
||||
str, err := ResourceMarshaler.MarshalToString(this)
|
||||
@ -633,6 +655,17 @@ func (this *FrontendPolicySpec_Logging_Fields) UnmarshalJSON(b []byte) error {
|
||||
return ResourceUnmarshaler.Unmarshal(bytes.NewReader(b), this)
|
||||
}
|
||||
|
||||
// MarshalJSON is a custom marshaler for FrontendPolicySpec_Logging_OtlpAccessLog
|
||||
func (this *FrontendPolicySpec_Logging_OtlpAccessLog) MarshalJSON() ([]byte, error) {
|
||||
str, err := ResourceMarshaler.MarshalToString(this)
|
||||
return []byte(str), err
|
||||
}
|
||||
|
||||
// UnmarshalJSON is a custom unmarshaler for FrontendPolicySpec_Logging_OtlpAccessLog
|
||||
func (this *FrontendPolicySpec_Logging_OtlpAccessLog) UnmarshalJSON(b []byte) error {
|
||||
return ResourceUnmarshaler.Unmarshal(bytes.NewReader(b), this)
|
||||
}
|
||||
|
||||
// MarshalJSON is a custom marshaler for FrontendPolicySpec_Tracing
|
||||
func (this *FrontendPolicySpec_Tracing) MarshalJSON() ([]byte, error) {
|
||||
str, err := ResourceMarshaler.MarshalToString(this)
|
||||
@ -655,6 +688,17 @@ func (this *FrontendPolicySpec_TracingAttribute) UnmarshalJSON(b []byte) error {
|
||||
return ResourceUnmarshaler.Unmarshal(bytes.NewReader(b), this)
|
||||
}
|
||||
|
||||
// MarshalJSON is a custom marshaler for JWTValidationOptions
|
||||
func (this *JWTValidationOptions) MarshalJSON() ([]byte, error) {
|
||||
str, err := ResourceMarshaler.MarshalToString(this)
|
||||
return []byte(str), err
|
||||
}
|
||||
|
||||
// UnmarshalJSON is a custom unmarshaler for JWTValidationOptions
|
||||
func (this *JWTValidationOptions) UnmarshalJSON(b []byte) error {
|
||||
return ResourceUnmarshaler.Unmarshal(bytes.NewReader(b), this)
|
||||
}
|
||||
|
||||
// MarshalJSON is a custom marshaler for TrafficPolicySpec
|
||||
func (this *TrafficPolicySpec) MarshalJSON() ([]byte, error) {
|
||||
str, err := ResourceMarshaler.MarshalToString(this)
|
||||
@ -787,6 +831,17 @@ func (this *TrafficPolicySpec_JWT) UnmarshalJSON(b []byte) error {
|
||||
return ResourceUnmarshaler.Unmarshal(bytes.NewReader(b), this)
|
||||
}
|
||||
|
||||
// MarshalJSON is a custom marshaler for TrafficPolicySpec_JWT_MCP
|
||||
func (this *TrafficPolicySpec_JWT_MCP) MarshalJSON() ([]byte, error) {
|
||||
str, err := ResourceMarshaler.MarshalToString(this)
|
||||
return []byte(str), err
|
||||
}
|
||||
|
||||
// UnmarshalJSON is a custom unmarshaler for TrafficPolicySpec_JWT_MCP
|
||||
func (this *TrafficPolicySpec_JWT_MCP) UnmarshalJSON(b []byte) error {
|
||||
return ResourceUnmarshaler.Unmarshal(bytes.NewReader(b), this)
|
||||
}
|
||||
|
||||
// MarshalJSON is a custom marshaler for TrafficPolicySpec_BasicAuthentication
|
||||
func (this *TrafficPolicySpec_BasicAuthentication) MarshalJSON() ([]byte, error) {
|
||||
str, err := ResourceMarshaler.MarshalToString(this)
|
||||
@ -1095,6 +1150,28 @@ func (this *BackendPolicySpec_InferenceRouting) UnmarshalJSON(b []byte) error {
|
||||
return ResourceUnmarshaler.Unmarshal(bytes.NewReader(b), this)
|
||||
}
|
||||
|
||||
// MarshalJSON is a custom marshaler for BackendPolicySpec_Eviction
|
||||
func (this *BackendPolicySpec_Eviction) MarshalJSON() ([]byte, error) {
|
||||
str, err := ResourceMarshaler.MarshalToString(this)
|
||||
return []byte(str), err
|
||||
}
|
||||
|
||||
// UnmarshalJSON is a custom unmarshaler for BackendPolicySpec_Eviction
|
||||
func (this *BackendPolicySpec_Eviction) UnmarshalJSON(b []byte) error {
|
||||
return ResourceUnmarshaler.Unmarshal(bytes.NewReader(b), this)
|
||||
}
|
||||
|
||||
// MarshalJSON is a custom marshaler for BackendPolicySpec_Health
|
||||
func (this *BackendPolicySpec_Health) MarshalJSON() ([]byte, error) {
|
||||
str, err := ResourceMarshaler.MarshalToString(this)
|
||||
return []byte(str), err
|
||||
}
|
||||
|
||||
// UnmarshalJSON is a custom unmarshaler for BackendPolicySpec_Health
|
||||
func (this *BackendPolicySpec_Health) UnmarshalJSON(b []byte) error {
|
||||
return ResourceUnmarshaler.Unmarshal(bytes.NewReader(b), this)
|
||||
}
|
||||
|
||||
// MarshalJSON is a custom marshaler for BackendPolicySpec_BackendTLS
|
||||
func (this *BackendPolicySpec_BackendTLS) MarshalJSON() ([]byte, error) {
|
||||
str, err := ResourceMarshaler.MarshalToString(this)
|
||||
@ -1117,6 +1194,17 @@ func (this *BackendPolicySpec_BackendHTTP) UnmarshalJSON(b []byte) error {
|
||||
return ResourceUnmarshaler.Unmarshal(bytes.NewReader(b), this)
|
||||
}
|
||||
|
||||
// MarshalJSON is a custom marshaler for BackendPolicySpec_BackendTunnel
|
||||
func (this *BackendPolicySpec_BackendTunnel) MarshalJSON() ([]byte, error) {
|
||||
str, err := ResourceMarshaler.MarshalToString(this)
|
||||
return []byte(str), err
|
||||
}
|
||||
|
||||
// UnmarshalJSON is a custom unmarshaler for BackendPolicySpec_BackendTunnel
|
||||
func (this *BackendPolicySpec_BackendTunnel) UnmarshalJSON(b []byte) error {
|
||||
return ResourceUnmarshaler.Unmarshal(bytes.NewReader(b), this)
|
||||
}
|
||||
|
||||
// MarshalJSON is a custom marshaler for BackendPolicySpec_BackendTCP
|
||||
func (this *BackendPolicySpec_BackendTCP) MarshalJSON() ([]byte, error) {
|
||||
str, err := ResourceMarshaler.MarshalToString(this)
|
||||
@ -1183,6 +1271,28 @@ func (this *DynamicForwardProxy) UnmarshalJSON(b []byte) error {
|
||||
return ResourceUnmarshaler.Unmarshal(bytes.NewReader(b), this)
|
||||
}
|
||||
|
||||
// MarshalJSON is a custom marshaler for AwsBackend
|
||||
func (this *AwsBackend) MarshalJSON() ([]byte, error) {
|
||||
str, err := ResourceMarshaler.MarshalToString(this)
|
||||
return []byte(str), err
|
||||
}
|
||||
|
||||
// UnmarshalJSON is a custom unmarshaler for AwsBackend
|
||||
func (this *AwsBackend) UnmarshalJSON(b []byte) error {
|
||||
return ResourceUnmarshaler.Unmarshal(bytes.NewReader(b), this)
|
||||
}
|
||||
|
||||
// MarshalJSON is a custom marshaler for AwsAgentCoreBackend
|
||||
func (this *AwsAgentCoreBackend) MarshalJSON() ([]byte, error) {
|
||||
str, err := ResourceMarshaler.MarshalToString(this)
|
||||
return []byte(str), err
|
||||
}
|
||||
|
||||
// UnmarshalJSON is a custom unmarshaler for AwsAgentCoreBackend
|
||||
func (this *AwsAgentCoreBackend) UnmarshalJSON(b []byte) error {
|
||||
return ResourceUnmarshaler.Unmarshal(bytes.NewReader(b), this)
|
||||
}
|
||||
|
||||
// MarshalJSON is a custom marshaler for AIBackend
|
||||
func (this *AIBackend) MarshalJSON() ([]byte, error) {
|
||||
str, err := ResourceMarshaler.MarshalToString(this)
|
||||
|
||||
@ -5,6 +5,10 @@ CEL is an expression language that can evaluate user-defined (at runtime) expres
|
||||
|
||||
A simple example of an expression that could be used for MCP authorization: `jwt.sub == "test-user" && mcp.tool.name == "add"`.
|
||||
|
||||
For post-request logging, tracing, and metrics CEL, MCP tool calls also expose payload fields such as
|
||||
`mcp.methodName`, `mcp.sessionId`, `mcp.tool.arguments`, `mcp.tool.result`, and `mcp.tool.error`.
|
||||
Request-time authorization keeps the `mcp` context identity-only, so those payload fields are absent during RBAC evaluation.
|
||||
|
||||
While CEL is not as powerful as alternatives like Lua or WASM, it is pretty fast and good enough for many use cases.
|
||||
|
||||
Agentgateway currently uses CEL for:
|
||||
|
||||
2
buf.yaml
2
buf.yaml
@ -1,4 +1,4 @@
|
||||
version: v1beta1
|
||||
build:
|
||||
roots:
|
||||
- crates/agentgateway/proto
|
||||
- crates/protos/proto
|
||||
@ -104,10 +104,6 @@ linters:
|
||||
alias: gwv1a2
|
||||
- pkg: sigs.k8s.io/gateway-api/apis/v1beta1
|
||||
alias: gwv1b1
|
||||
- pkg: github.com/envoyproxy/go-control-plane/envoy/config/(\w+)/(v[\w\d]+)
|
||||
alias: envoy$1$2
|
||||
- pkg: github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/tls/v3
|
||||
alias: envoytlsv3
|
||||
- pkg: github.com/agentgateway/agentgateway/controller/api/annotations
|
||||
alias: apiannotations
|
||||
- pkg: github.com/agentgateway/agentgateway/controller/api/settings
|
||||
@ -165,7 +161,6 @@ linters:
|
||||
- third_party$
|
||||
- builtin$
|
||||
- examples$
|
||||
- hack/dummy-idp
|
||||
rules:
|
||||
# Forbid t.Cleanup only in e2e tests (exclude the rule from non-e2e paths)
|
||||
- path-except: test/e2e/
|
||||
|
||||
@ -117,7 +117,6 @@ mod-download: ## Download the dependencies
|
||||
.PHONY: mod-tidy-nested
|
||||
mod-tidy-nested: ## Tidy go mod files in nested modules
|
||||
@echo "Tidying tools..." && cd ../tools && go mod tidy
|
||||
@echo "Tidying test/e2e/defaults/extproc..." && cd test/e2e/defaults/extproc && go mod tidy
|
||||
|
||||
.PHONY: mod-tidy
|
||||
mod-tidy: mod-download mod-tidy-nested ## Tidy the go mod file
|
||||
@ -175,7 +174,7 @@ test: ## Run all tests with ginkgo, or only run the test package at {TEST_PKG} i
|
||||
# will still have e2e tests run by Github Actions once they publish a pull
|
||||
# request.
|
||||
.PHONY: e2e-test
|
||||
e2e-test: extproc-server-docker kind-load-extproc-server
|
||||
e2e-test: testbox-docker kind-load-testbox
|
||||
e2e-test: go-test
|
||||
e2e-test: TEST_TAG = e2e
|
||||
e2e-test: GO_TEST_ARGS = $(E2E_GO_TEST_ARGS)
|
||||
@ -427,67 +426,42 @@ agentgateway-controller-docker-local: agentgateway-controller $(CONTROLLER_OUTPU
|
||||
-t localhost:5000/$(AGENTGATEWAY_IMAGE_REPO):$(TAG)
|
||||
|
||||
#----------------------------------------------------------------------------------
|
||||
# dummy idp (used in e2e tests)
|
||||
# testbox (used in e2e tests)
|
||||
#----------------------------------------------------------------------------------
|
||||
|
||||
DUMMY_IDP_DIR=hack/dummy-idp
|
||||
DUMMY_IDP_OUTPUT_DIR=$(OUTPUT_DIR)/$(DUMMY_IDP_DIR)
|
||||
export DUMMY_IDP_IMAGE_REPO ?= dummy-idp
|
||||
DUMMY_IDP_VERSION=0.0.1
|
||||
TESTBOX_DIR=hack/testbox
|
||||
TESTBOX_OUTPUT_DIR=$(OUTPUT_DIR)/$(TESTBOX_DIR)
|
||||
export TESTBOX_IMAGE_REPO ?= testbox
|
||||
TESTBOX_VERSION=0.0.1
|
||||
|
||||
.PHONY: dummy-idp
|
||||
dummy-idp:
|
||||
$(GO_BUILD_FLAGS) GOOS=linux go build -ldflags='$(LDFLAGS)' -gcflags='$(GCFLAGS)' -o $(DUMMY_IDP_OUTPUT_DIR)/dummy-idp-linux-$(GOARCH) ./hack/dummy-idp...
|
||||
.PHONY: testbox
|
||||
testbox:
|
||||
$(GO_BUILD_FLAGS) GOOS=linux go build -ldflags='$(LDFLAGS)' -gcflags='$(GCFLAGS)' -o $(TESTBOX_OUTPUT_DIR)/testbox-linux-$(GOARCH) ./hack/testbox...
|
||||
|
||||
$(DUMMY_IDP_OUTPUT_DIR)/Dockerfile.dummy-idp: ./hack/dummy-idp/Dockerfile
|
||||
$(TESTBOX_OUTPUT_DIR)/Dockerfile.testbox: ./hack/testbox/Dockerfile
|
||||
cp $< $@
|
||||
|
||||
.PHONY: dummy-idp-docker
|
||||
dummy-idp-docker: dummy-idp $(DUMMY_IDP_OUTPUT_DIR)/Dockerfile.dummy-idp
|
||||
$(BUILDX_BUILD) --load $(PLATFORM) $(DUMMY_IDP_OUTPUT_DIR) -f $(DUMMY_IDP_OUTPUT_DIR)/Dockerfile.dummy-idp \
|
||||
.PHONY: testbox-docker
|
||||
testbox-docker: testbox $(TESTBOX_OUTPUT_DIR)/Dockerfile.testbox
|
||||
$(BUILDX_BUILD) --load $(PLATFORM) $(TESTBOX_OUTPUT_DIR) -f $(TESTBOX_OUTPUT_DIR)/Dockerfile.testbox \
|
||||
--build-arg GOARCH=$(GOARCH) \
|
||||
--build-arg BASE_IMAGE=$(ALPINE_BASE_IMAGE) \
|
||||
-t $(IMAGE_REGISTRY)/$(DUMMY_IDP_IMAGE_REPO):$(DUMMY_IDP_VERSION)
|
||||
-t $(IMAGE_REGISTRY)/$(TESTBOX_IMAGE_REPO):$(TESTBOX_VERSION)
|
||||
|
||||
.PHONY: kind-load-dummy-idp
|
||||
kind-load-dummy-idp:
|
||||
kind load docker-image $(IMAGE_REGISTRY)/$(DUMMY_IDP_IMAGE_REPO):$(DUMMY_IDP_VERSION) --name $(CLUSTER_NAME)
|
||||
|
||||
#----------------------------------------------------------------------------------
|
||||
# extproc-server (used in e2e tests)
|
||||
#----------------------------------------------------------------------------------
|
||||
|
||||
EXTPROC_SERVER_DIR=test/e2e/defaults/extproc
|
||||
EXTPROC_SERVER_OUTPUT_DIR=$(OUTPUT_DIR)/$(EXTPROC_SERVER_DIR)
|
||||
export EXTPROC_SERVER_IMAGE_REPO ?= extproc-server
|
||||
EXTPROC_SERVER_VERSION=0.0.1
|
||||
|
||||
$(EXTPROC_SERVER_OUTPUT_DIR)/.docker-stamp-$(EXTPROC_SERVER_VERSION)-$(GOARCH): $(shell find $(EXTPROC_SERVER_DIR) -name '*.go') $(EXTPROC_SERVER_DIR)/Dockerfile
|
||||
$(BUILDX_BUILD) --load $(PLATFORM) $(EXTPROC_SERVER_DIR) -f $(EXTPROC_SERVER_DIR)/Dockerfile \
|
||||
-t $(IMAGE_REGISTRY)/$(EXTPROC_SERVER_IMAGE_REPO):$(EXTPROC_SERVER_VERSION)
|
||||
@mkdir -p $(dir $@)
|
||||
@touch $@
|
||||
|
||||
.PHONY: extproc-server-docker
|
||||
extproc-server-docker: $(EXTPROC_SERVER_OUTPUT_DIR)/.docker-stamp-$(EXTPROC_SERVER_VERSION)-$(GOARCH)
|
||||
|
||||
.PHONY: kind-load-extproc-server
|
||||
kind-load-extproc-server:
|
||||
kind load docker-image $(IMAGE_REGISTRY)/$(EXTPROC_SERVER_IMAGE_REPO):$(EXTPROC_SERVER_VERSION) --name $(CLUSTER_NAME)
|
||||
.PHONY: kind-load-testbox
|
||||
kind-load-testbox:
|
||||
kind load docker-image $(IMAGE_REGISTRY)/$(TESTBOX_IMAGE_REPO):$(TESTBOX_VERSION) --name $(CLUSTER_NAME)
|
||||
|
||||
#----------------------------------------------------------------------------------
|
||||
# Helm
|
||||
#----------------------------------------------------------------------------------
|
||||
|
||||
HELM ?= helm
|
||||
# It would be nice to use actual semver '--version', as Helm docs clearly state
|
||||
# is intended (and yet is not enforced by 'helm lint'). Here we say '--version
|
||||
# v2.0.0', not '--version 2.0.0', e.g. To do it cleanly, you'd probably
|
||||
# repackage all published versions' charts and republish as vA.B.C and A.B.C
|
||||
# both. Users would be surprised if their installation recipes had to change on
|
||||
# some patch or minor version release. ('--app-version v2.0.0' is acceptable
|
||||
# and in fact preferred since it matches our git tags and OCI image tags.)
|
||||
HELM_PACKAGE_ARGS ?= --version $(VERSION) --app-version $(VERSION)
|
||||
# Publish charts with both semver variants to preserve compatibility.
|
||||
# Keep VERSION as-is for image tags and other release identifiers.
|
||||
HELM_CHART_VERSION_NO_V ?= $(patsubst v%,%,$(VERSION))
|
||||
HELM_CHART_VERSION_V ?= v$(HELM_CHART_VERSION_NO_V)
|
||||
HELM_PACKAGE_ARGS ?= --version $(HELM_CHART_VERSION_NO_V) --app-version $(HELM_CHART_VERSION_NO_V)
|
||||
EXTRA_HELM_TAG ?=
|
||||
HELM_CHART_DIR_AGW=install/helm/agentgateway
|
||||
HELM_CHART_DIR_AGW_CRD=install/helm/agentgateway-crds
|
||||
HELM_ADDITIONAL_VALUES ?= hack/helm/dev.yaml
|
||||
@ -507,26 +481,39 @@ package-agentgateway-crd-chart: ## Package the agentgateway crd chart
|
||||
$(HELM) package $(HELM_PACKAGE_ARGS) --destination $(TEST_ASSET_DIR) $(HELM_CHART_DIR_AGW_CRD); \
|
||||
$(HELM) repo index $(TEST_ASSET_DIR);
|
||||
|
||||
# VERSION_NO_V strips the leading 'v' from VERSION (e.g., v2.0.0 -> 2.0.0)
|
||||
VERSION_NO_V := $(patsubst v%,%,$(VERSION))
|
||||
CHART_NAMES := agentgateway agentgateway-crds
|
||||
|
||||
.PHONY: release-charts
|
||||
release-charts: ## Release the agentgateway charts (publishes both vX.Y.Z and X.Y.Z tags)
|
||||
@for v in $(VERSION) $(VERSION_NO_V); do \
|
||||
$(MAKE) package-agentgateway-charts VERSION=$$v; \
|
||||
for chart in $(CHART_NAMES); do \
|
||||
$(HELM) push $(TEST_ASSET_DIR)/$$chart-$$v.tgz oci://$(IMAGE_REGISTRY)/charts; \
|
||||
done; \
|
||||
done
|
||||
release-charts: package-agentgateway-charts
|
||||
mkdir -p $(TEST_ASSET_DIR); \
|
||||
$(HELM) package --version $(HELM_CHART_VERSION_V) --app-version $(HELM_CHART_VERSION_V) --destination $(TEST_ASSET_DIR) $(HELM_CHART_DIR_AGW); \
|
||||
$(HELM) repo index $(TEST_ASSET_DIR);
|
||||
mkdir -p $(TEST_ASSET_DIR); \
|
||||
$(HELM) package --version $(HELM_CHART_VERSION_V) --app-version $(HELM_CHART_VERSION_V) --destination $(TEST_ASSET_DIR) $(HELM_CHART_DIR_AGW_CRD); \
|
||||
$(HELM) repo index $(TEST_ASSET_DIR);
|
||||
@if [ -n "$(EXTRA_HELM_TAG)" ]; then \
|
||||
mkdir -p $(TEST_ASSET_DIR); \
|
||||
$(HELM) package --version $(EXTRA_HELM_TAG) --app-version $(VERSION) --destination $(TEST_ASSET_DIR) $(HELM_CHART_DIR_AGW); \
|
||||
$(HELM) repo index $(TEST_ASSET_DIR); \
|
||||
mkdir -p $(TEST_ASSET_DIR); \
|
||||
$(HELM) package --version $(EXTRA_HELM_TAG) --app-version $(VERSION) --destination $(TEST_ASSET_DIR) $(HELM_CHART_DIR_AGW_CRD); \
|
||||
$(HELM) repo index $(TEST_ASSET_DIR); \
|
||||
fi
|
||||
@for chart in $(CHART_NAMES); do \
|
||||
$(HELM) push $(TEST_ASSET_DIR)/$$chart-$(HELM_CHART_VERSION_NO_V).tgz oci://$(IMAGE_REGISTRY)/charts; \
|
||||
$(HELM) push $(TEST_ASSET_DIR)/$$chart-$(HELM_CHART_VERSION_V).tgz oci://$(IMAGE_REGISTRY)/charts; \
|
||||
if [ -n "$(EXTRA_HELM_TAG)" ]; then \
|
||||
$(HELM) push $(TEST_ASSET_DIR)/$$chart-$(EXTRA_HELM_TAG).tgz oci://$(IMAGE_REGISTRY)/charts; \
|
||||
fi; \
|
||||
done;
|
||||
|
||||
.PHONY: deploy-agentgateway-crd-chart
|
||||
deploy-agentgateway-crd-chart: ## Deploy the agentgateway crd chart
|
||||
$(HELM) upgrade --install agentgateway-crds $(TEST_ASSET_DIR)/agentgateway-crds-$(VERSION).tgz --namespace $(INSTALL_NAMESPACE) --create-namespace
|
||||
$(HELM) upgrade --install agentgateway-crds $(TEST_ASSET_DIR)/agentgateway-crds-$(HELM_CHART_VERSION_NO_V).tgz --namespace $(INSTALL_NAMESPACE) --create-namespace
|
||||
|
||||
.PHONY: deploy-agentgateway-chart
|
||||
deploy-agentgateway-chart: ## Deploy the agentgateway chart
|
||||
$(HELM) upgrade --install agentgateway $(TEST_ASSET_DIR)/agentgateway-$(VERSION).tgz \
|
||||
$(HELM) upgrade --install agentgateway $(TEST_ASSET_DIR)/agentgateway-$(HELM_CHART_VERSION_NO_V).tgz \
|
||||
--namespace $(INSTALL_NAMESPACE) --create-namespace \
|
||||
--set image.registry=$(IMAGE_REGISTRY) \
|
||||
--set image.tag=$(VERSION) \
|
||||
@ -542,13 +529,6 @@ lint-charts: ## Lint the agentgateway charts
|
||||
# Release
|
||||
#----------------------------------------------------------------------------------
|
||||
|
||||
GORELEASER_ARGS ?= --snapshot --clean
|
||||
GORELEASER_TIMEOUT ?= 60m
|
||||
GORELEASER_CURRENT_TAG ?= $(VERSION)
|
||||
|
||||
.PHONY: release
|
||||
release: ## Create a release using goreleaser
|
||||
GORELEASER_CURRENT_TAG=$(GORELEASER_CURRENT_TAG) goreleaser release $(GORELEASER_ARGS) --timeout $(GORELEASER_TIMEOUT)
|
||||
.PHONY: release-notes
|
||||
release-notes: ## Generate release notes (PREVIOUS_TAG required, CURRENT_TAG optional)
|
||||
./hack/generate-release-notes.sh -p $(PREVIOUS_TAG) -c $(or $(CURRENT_TAG),HEAD)
|
||||
@ -569,7 +549,7 @@ kind-create: ## Create a KinD cluster
|
||||
kind get clusters | grep $(CLUSTER_NAME) || kind create cluster --name $(CLUSTER_NAME) --image kindest/node:$(CLUSTER_NODE_VERSION)
|
||||
|
||||
CONFORMANCE_CHANNEL ?= experimental
|
||||
CONFORMANCE_VERSION ?= v1.4.1
|
||||
CONFORMANCE_VERSION ?= $(shell go list -m -f '{{.Version}}' sigs.k8s.io/gateway-api)
|
||||
.PHONY: gw-api-crds
|
||||
gw-api-crds: ## Install the Gateway API CRDs. HACK: Use SSA to avoid the issue with the CRD annotations being too long.
|
||||
ifeq ($(shell echo $(CONFORMANCE_VERSION) | grep -q '^v[0-9]' && echo yes),yes)
|
||||
@ -583,10 +563,7 @@ endif
|
||||
endif
|
||||
|
||||
# The version of the k8s gateway api inference extension CRDs to install.
|
||||
# Managed by `make bump-gie`.
|
||||
GIE_CRD_VERSION ?= v1.3.0
|
||||
# When we are back on a release version instead of `main`, we can do this
|
||||
#GIE_CRD_VERSION ?= $(shell go list -m -f '{{.Version}}' sigs.k8s.io/gateway-api-inference-extension)
|
||||
GIE_CRD_VERSION ?= $(shell go list -m -f '{{.Version}}' sigs.k8s.io/gateway-api-inference-extension)
|
||||
|
||||
.PHONY: gie-crds
|
||||
gie-crds: ## Install the Gateway API Inference Extension CRDs
|
||||
@ -596,9 +573,11 @@ else
|
||||
kubectl apply --kustomize "https://github.com/kubernetes-sigs/gateway-api-inference-extension/config/crd?ref=$(GIE_CRD_VERSION)"
|
||||
endif
|
||||
|
||||
.PHONY: kind-metallb
|
||||
.PHONY: metallb
|
||||
metallb: ## Install the MetalLB load balancer
|
||||
./hack/kind/setup-metalllb-on-kind.sh
|
||||
kubectl apply -f ./test/setup/metallb.yaml
|
||||
kubectl rollout status -n metallb-system deployment/controller --timeout=120s
|
||||
kubectl rollout status -n metallb-system daemonset/speaker --timeout=120s
|
||||
|
||||
.PHONY: deploy-agentgateway
|
||||
deploy-agentgateway: package-agentgateway-charts deploy-agentgateway-crd-chart deploy-agentgateway-chart ## Deploy the agentgateway chart and CRDs
|
||||
@ -609,7 +588,7 @@ setup-base: kind-create gw-api-crds gie-crds metallb ## Setup the base infrastru
|
||||
# Creates a functional kind cluster, builds and loads all images, and packages charts
|
||||
# Does NOT deploy anything to the cluster
|
||||
.PHONY: setup
|
||||
setup: setup-base kind-build-and-load package-agentgateway-charts dummy-idp-docker kind-load-dummy-idp ## Setup the complete infrastructure (base setup plus images and charts)
|
||||
setup: setup-base kind-build-and-load package-agentgateway-charts ## Setup base infra, build/load images, and package charts (without deployment)
|
||||
|
||||
.PHONY: run
|
||||
run: setup deploy-agentgateway ## Set up complete development environment
|
||||
@ -626,7 +605,6 @@ kind-load-%:
|
||||
|
||||
# Build an image and load it into the KinD cluster
|
||||
# Depends on: IMAGE_REGISTRY, VERSION, CLUSTER_NAME
|
||||
# Envoy image may be specified via ENVOY_IMAGE on the command line or at the top of this file
|
||||
kind-build-and-load-%: %-docker kind-load-% ; ## Use to build specified image and load it into kind
|
||||
|
||||
# Update the docker image used by a deployment
|
||||
@ -646,16 +624,15 @@ kind-set-image-%:
|
||||
# You can reload an image, which means it will be rebuilt and reloaded into the kind cluster, and the deployment
|
||||
# will be updated to reference it
|
||||
# Depends on: IMAGE_REGISTRY, VERSION, INSTALL_NAMESPACE , CLUSTER_NAME
|
||||
# Envoy image may be specified via ENVOY_IMAGE on the command line or at the top of this file
|
||||
kind-reload-%: kind-build-and-load-% kind-set-image-% ; ## Use to build specified image, load it into kind, and restart its deployment
|
||||
|
||||
.PHONY: kind-build-and-load ## Use to build all images and load them into kind
|
||||
kind-build-and-load: kind-build-and-load-agentgateway-controller
|
||||
kind-build-and-load: kind-build-and-load-dummy-idp
|
||||
kind-build-and-load: kind-build-and-load-testbox
|
||||
|
||||
.PHONY: kind-load ## Use to load all images into kind
|
||||
kind-load: kind-load-agentgateway-controller
|
||||
kind-load: kind-load-dummy-idp
|
||||
kind-load: kind-load-testbox
|
||||
|
||||
#----------------------------------------------------------------------------------
|
||||
# Targets for running Agent Gateway conformance tests
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# APIs for kgateway
|
||||
# APIs for Agentgateway Controller
|
||||
|
||||
This directory contains Go types for kgateway APIs & custom resources.
|
||||
This directory contains Go types for Agentgateway Controller APIs & custom resources.
|
||||
|
||||
## Adding a new API / CRD
|
||||
|
||||
@ -9,14 +9,14 @@ These are the steps required to add a new CRD to be used in the Kubernetes Gatew
|
||||
1. If creating a new API version (e.g. `v1`, `v2alpha1`), create a new directory for the version and create a `doc.go` file with the `// +kubebuilder:object:generate=true` annotation, so that Go types in that directory will be converted into CRDs when codegen is run.
|
||||
- The `groupName` marker specifies the API group name for the generated CRD.
|
||||
- RBAC rules are defined via the `+kubebuilder:rbac` annotation (note: this annotation should not belong to the type, but rather the file or package).
|
||||
2. Create a `_types.go` file in the API version directory. Following [gateway_parameters_types.go](/api/v1alpha1/kgateway/gateway_parameters_types.go) as an example:
|
||||
2. Create a `_types.go` file in the API version directory. Following [agentgateway_parameters_types.go](/controller/api/v1alpha1/agentgateway/agentgateway_parameters_types.go) as an example:
|
||||
- Define a struct for the resource (containing the metadata fields, `Spec`, and `Status`). Follow the [API guidelines](#api-guidelines) below.
|
||||
- Define a struct for the resource list (containing the metadata fields and `Items`)
|
||||
3. Run codegen via `make generated-code -B`. This will invoke the `controller-gen` command specified in [generate.go](/hack/generate.go), which should result in the following:
|
||||
3. Run codegen via `make generated-code -B`. This will invoke the `controller-gen` command specified in [generate.go](/controller/hack/generate.go), which should result in the following:
|
||||
- A `zz_generated.deepcopy.go` file is created in the same directory as the Go types.
|
||||
- A `zz_generated.register.go` file is created in the same directory as the Go types, to help with registering the Go types with the scheme.
|
||||
- CRDs are generated in the CRD helm chart template dir: [install/helm/kgateway-crds/templates](/install/helm/kgateway-crds/templates)
|
||||
- RBAC roles are generated in [install/helm/kgateway/templates/role.yaml](/install/helm/kgateway/templates/role.yaml)
|
||||
- CRDs are generated in the CRD helm chart template dir: [install/helm/agentgateway-crds/templates](/controller/install/helm/agentgateway-crds/templates)
|
||||
- RBAC roles are generated in [controller/install/helm/templates/role.yaml](/agentgateway/install/helm/agentgateway/templates/role.yaml)
|
||||
- Updates the [api/applyconfiguration](/api/applyconfiguration), [pkg/generated](/pkg/generated) and [pkg/client](/pkg/client) folders with kube clients. These are used in plugin initialization and the fake client is used in tests.
|
||||
|
||||
## API guidelines
|
||||
@ -32,10 +32,27 @@ These are the steps required to add a new CRD to be used in the Kubernetes Gatew
|
||||
- Avoid using slices with pointers (e.g. use `[]string` instead of `[]*string`). See: https://github.com/kubernetes/code-generator/issues/166
|
||||
- For time duration fields, use the `metav1.Duration` type and use CEL validation rules to ensure it is within the correct range.
|
||||
|
||||
### Custom validation markers
|
||||
|
||||
The CRD generation pipeline supports custom kubebuilder validation markers, implemented in
|
||||
`controller/hack/crdgen`.
|
||||
|
||||
- `+kubebuilder:validation:AtLeastOneFieldSet` requires at least one field on the struct to be set.
|
||||
- `+kubebuilder:validation:ExactlyOneFieldSet` requires exactly one field on the struct to be set.
|
||||
- `+kubebuilder:validation:IfThenOnlyFields:if="...",fields=a;b;c,message="..."` requires that, when `if` is true,
|
||||
only the listed fields may be set.
|
||||
|
||||
Optional arguments for `AtLeastOneFieldSet` and `ExactlyOneFieldSet`:
|
||||
|
||||
- `fields=a;b;c` to explicitly pick fields to count.
|
||||
- `exclude=a;b` to drop fields from the counted set.
|
||||
- `message="..."` to override the generated validation message.
|
||||
|
||||
These markers are intended for struct/type comments (`markers.DescribesType`).
|
||||
|
||||
### Replicating Gateway API policies in TrafficPolicy API
|
||||
|
||||
Gateway API policies may be replicated as a part of the TrafficPolicy API to enable policy attachment at different levels in the config hierarchy, such as at the Gateway, Gateway's listener, or route level. The following guidelines should be considered when doing so:
|
||||
- When the Gateway API types are considered sufficient to meet the requirements, they can be embedded as is in the TrafficPolicy API. TrafficPolicy's `cors` is an example where the Gateway API type `HTTPCORSFilter` is embedded directly.
|
||||
- When embedding the Gateway API type, it is important to consider whether the type is marked as `<gateway:experimental>`, as experimental types may introduce breaking changes and should be noted similarly in the TrafficPolicy API. It is discouraged to embed experimental types in the TrafficPolicy API. However, if there is a breaking change in the Gateway API type, it is recommended to replicate the previous version of that type into the TrafficPolicy API and not propagate the breaking change to the TrafficPolicy API.
|
||||
- When the Gateway API types are not sufficient and a more advanced API is required, a new type should be created in the TrafficPolicy API instead of embedding the Gateway API type. TrafficPolicy's `retry` and `timeouts` are examples that define new types instead of reusing the `HTTPRouteRetry` and `HTTPRouteTimeouts` types from the Gateway API.
|
||||
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
package annotations
|
||||
|
||||
// LegacyMCPServiceHTTPPath is the legacy annotation used to specify the HTTP path for the MCP service. Users should switch to MCPServiceHTTPPath.
|
||||
const LegacyMCPServiceHTTPPath = "kgateway.dev/mcp-path"
|
||||
|
||||
// MCPServiceHTTPPath is the annotation used to specify the HTTP path for the MCP service
|
||||
const MCPServiceHTTPPath = "kgateway.dev/mcp-path"
|
||||
const MCPServiceHTTPPath = "agentgateway.dev/mcp-path"
|
||||
|
||||
@ -9,37 +9,6 @@ import (
|
||||
gwv1 "sigs.k8s.io/gateway-api/apis/v1"
|
||||
)
|
||||
|
||||
// ValidationMode determines how invalid routes and policies are handled during translation.
|
||||
// Higher levels increase safety guarantees, but may have performance implications.
|
||||
type ValidationMode string
|
||||
|
||||
const (
|
||||
// ValidationStandard rewrites invalid routes to direct responses
|
||||
// (typically HTTP 500), preserving a valid config while isolating failures.
|
||||
// This limits the blast radius of misconfigured routes or policies without
|
||||
// affecting unrelated tenants.
|
||||
ValidationStandard ValidationMode = "STANDARD"
|
||||
// ValidationStrict builds on standard by running targeted validation
|
||||
// (e.g. RDS, CDS, and security-related policies). Routes that fail these
|
||||
// checks are also replaced with direct responses, and helps prevent unsafe
|
||||
// config from reaching Envoy.
|
||||
// Strict Validation is not supported with Rustformation yet,
|
||||
// see docs/guides/transformation.md for details
|
||||
ValidationStrict ValidationMode = "STRICT"
|
||||
)
|
||||
|
||||
// Decode implements envconfig.Decoder.
|
||||
func (v *ValidationMode) Decode(value string) error {
|
||||
level := ValidationMode(strings.ToUpper(value))
|
||||
switch level {
|
||||
case ValidationStandard, ValidationStrict:
|
||||
*v = level
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("invalid validation mode: %q", value)
|
||||
}
|
||||
}
|
||||
|
||||
// DnsLookupFamily controls the DNS lookup family for all static clusters created via Backend resources.
|
||||
type DnsLookupFamily string
|
||||
|
||||
@ -158,19 +127,19 @@ type Settings struct {
|
||||
// Defaults to "istio-system".
|
||||
IstioNamespace string `split_words:"true" default:"istio-system"`
|
||||
|
||||
// IstioRevision is the Istio revision of the Istio control plane.
|
||||
// Defaults to "default".
|
||||
IstioRevision string `split_words:"true" default:"default"`
|
||||
|
||||
// XdsServiceHost is the host that serves xDS config.
|
||||
// It overrides xdsServiceName if set.
|
||||
XdsServiceHost string `split_words:"true"`
|
||||
|
||||
// XdsServiceName is the name of the Kubernetes Service that serves xDS config.
|
||||
// It is assumed to be in the kgateway install namespace.
|
||||
// It is assumed to be in the agentgateway install namespace.
|
||||
// Ignored if XdsServiceHost is set.
|
||||
XdsServiceName string `split_words:"true" default:"agentgateway"`
|
||||
|
||||
// XdsServicePort is the port of the Kubernetes Service that serves xDS config.
|
||||
// This corresponds to the value of the `grpc-xds` port in the service.
|
||||
XdsServicePort uint32 `split_words:"true" default:"9977"`
|
||||
|
||||
// XdsAuth enables or disables xDS authentication between the data-plane and control-plane.
|
||||
// By default, this is enabled.
|
||||
XdsAuth bool `split_words:"true" default:"true"`
|
||||
@ -183,6 +152,10 @@ type Settings struct {
|
||||
// This corresponds to the value of the `grpc-xds-agw` port in the service.
|
||||
AgentgatewayXdsServicePort uint32 `split_words:"true" default:"9978"`
|
||||
|
||||
// NoListenersDummyPort is the port exposed on the generated Service when a Gateway has no listeners.
|
||||
// This keeps the LoadBalancer provisioned and address stable across transitions to zero listeners.
|
||||
NoListenersDummyPort uint16 `split_words:"true" default:"443"`
|
||||
|
||||
// EnableInferExt defines whether to enable/disable support for Gateway API inference extension.
|
||||
// If enabled, EnableAgentgateway should also be set to true. Enabling inference extension without agentgateway
|
||||
// is deprecated in v2.1 and will not be supported in v2.2.
|
||||
@ -199,14 +172,23 @@ type Settings struct {
|
||||
// Defaults to "info" if not set.
|
||||
LogLevel string `split_words:"true" default:"info"`
|
||||
|
||||
// JSON representation of list of metav1.LabelSelector to select namespaces considered for resource discovery.
|
||||
// Defaults to an empty list which selects all namespaces.
|
||||
// E.g., [{"matchExpressions":[{"key":"kubernetes.io/metadata.name","operator":"In","values":["infra"]}]},{"matchLabels":{"app":"a"}}]
|
||||
DiscoveryNamespaceSelectors string `split_words:"true" default:"[]"`
|
||||
|
||||
// EnableBuiltinDefaultMetrics enables the default builtin controller-runtime metrics and go runtime metrics.
|
||||
// Since these metrics can be numerous, it is disabled by default.
|
||||
EnableBuiltinDefaultMetrics bool `split_words:"true" default:"false"`
|
||||
|
||||
// GlobalPolicyNamespace is the namespace where policies that can attach to resources
|
||||
// in any namespace are defined.
|
||||
GlobalPolicyNamespace string `split_words:"true"`
|
||||
|
||||
// Controls if leader election is disabled. Defaults to false.
|
||||
DisableLeaderElection bool `split_words:"true" default:"false"`
|
||||
|
||||
// EnableExperimentalGatewayAPIFeatures enables kgateway to support experimental features and APIs
|
||||
// EnableExperimentalGatewayAPIFeatures enables support for experimental features and APIs
|
||||
EnableExperimentalGatewayAPIFeatures bool `split_words:"true" default:"true"`
|
||||
|
||||
// GatewayClassParametersRefs configures the GatewayParameters references to set on the default GatewayClasses.
|
||||
|
||||
@ -21,13 +21,16 @@ func allEnvVarsSet() map[string]string {
|
||||
"AGW_DNS_LOOKUP_FAMILY": string(DnsLookupFamilyV4Only),
|
||||
"AGW_LISTENER_BIND_IPV6": "false",
|
||||
"AGW_ISTIO_NAMESPACE": "my-istio-namespace",
|
||||
"AGW_ISTIO_REVISION": "my-istio-revision",
|
||||
"AGW_XDS_SERVICE_HOST": "my-xds-host",
|
||||
"AGW_XDS_SERVICE_NAME": "custom-svc",
|
||||
"AGW_XDS_SERVICE_PORT": "1234",
|
||||
"AGW_AGENTGATEWAY_XDS_SERVICE_PORT": "5678",
|
||||
"AGW_NO_LISTENERS_DUMMY_PORT": "8443",
|
||||
"AGW_ENABLE_INFER_EXT": "true",
|
||||
"AGW_LOG_LEVEL": "debug",
|
||||
"AGW_DISCOVERY_NAMESPACE_SELECTORS": `[{"matchLabels":{"app":"test"}}]`,
|
||||
"AGW_ENABLE_BUILTIN_DEFAULT_METRICS": "true",
|
||||
"AGW_GLOBAL_POLICY_NAMESPACE": "policy-ns",
|
||||
"AGW_DISABLE_LEADER_ELECTION": "true",
|
||||
"AGW_GATEWAY_CLASS_PARAMETERS_REFS": `{"kgateway":{"name":"custom-gwp","namespace":"infra"},"agentgateway":{"name":"custom-gwp-agw","namespace":"infra"}}`,
|
||||
"AGW_XDS_AUTH": "false",
|
||||
@ -62,13 +65,16 @@ func TestSettings(t *testing.T) {
|
||||
DnsLookupFamily: DnsLookupFamilyV4Preferred,
|
||||
ListenerBindIpv6: true,
|
||||
IstioNamespace: "istio-system",
|
||||
IstioRevision: "default",
|
||||
XdsServiceHost: "",
|
||||
XdsServiceName: "agentgateway",
|
||||
XdsServicePort: 9977,
|
||||
AgentgatewayXdsServicePort: 9978,
|
||||
NoListenersDummyPort: 443,
|
||||
EnableInferExt: false,
|
||||
LogLevel: "info",
|
||||
DiscoveryNamespaceSelectors: "[]",
|
||||
EnableBuiltinDefaultMetrics: false,
|
||||
GlobalPolicyNamespace: "",
|
||||
DisableLeaderElection: false,
|
||||
XdsAuth: true,
|
||||
XdsTLS: false,
|
||||
@ -87,13 +93,16 @@ func TestSettings(t *testing.T) {
|
||||
DnsLookupFamily: DnsLookupFamilyV4Only,
|
||||
ListenerBindIpv6: false,
|
||||
IstioNamespace: "my-istio-namespace",
|
||||
IstioRevision: "my-istio-revision",
|
||||
XdsServiceHost: "my-xds-host",
|
||||
XdsServiceName: "custom-svc",
|
||||
XdsServicePort: 1234,
|
||||
AgentgatewayXdsServicePort: 5678,
|
||||
NoListenersDummyPort: 8443,
|
||||
EnableInferExt: true,
|
||||
LogLevel: "debug",
|
||||
DiscoveryNamespaceSelectors: `[{"matchLabels":{"app":"test"}}]`,
|
||||
EnableBuiltinDefaultMetrics: true,
|
||||
GlobalPolicyNamespace: "policy-ns",
|
||||
DisableLeaderElection: true,
|
||||
XdsAuth: false,
|
||||
XdsTLS: true,
|
||||
@ -121,9 +130,9 @@ func TestSettings(t *testing.T) {
|
||||
expectedErrorStr: "invalid syntax",
|
||||
},
|
||||
{
|
||||
name: "errors on invalid port",
|
||||
name: "errors on invalid bool",
|
||||
envVars: map[string]string{
|
||||
"AGW_XDS_SERVICE_PORT": "a123",
|
||||
"AGW_LISTENER_BIND_IPV6": "true123",
|
||||
},
|
||||
expectedErrorStr: "invalid syntax",
|
||||
},
|
||||
@ -166,10 +175,16 @@ func TestSettings(t *testing.T) {
|
||||
DnsLookupFamily: DnsLookupFamilyV4Preferred,
|
||||
ListenerBindIpv6: true,
|
||||
IstioNamespace: "istio-system",
|
||||
IstioRevision: "default",
|
||||
XdsServiceName: "agentgateway",
|
||||
XdsServicePort: 9977,
|
||||
AgentgatewayXdsServicePort: 9978,
|
||||
EnableInferExt: false,
|
||||
NoListenersDummyPort: 443,
|
||||
LogLevel: "info",
|
||||
DiscoveryNamespaceSelectors: "[]",
|
||||
EnableBuiltinDefaultMetrics: false,
|
||||
GlobalPolicyNamespace: "",
|
||||
DisableLeaderElection: false,
|
||||
XdsAuth: true,
|
||||
XdsTLS: false,
|
||||
EnableExperimentalGatewayAPIFeatures: true,
|
||||
|
||||
@ -86,7 +86,7 @@ spec:
|
||||
{{end}}
|
||||
{{.policy|nindent 2}}
|
||||
`
|
||||
v := NewKgatewayValidator(t)
|
||||
v := NewAgentgatewayValidator(t)
|
||||
for _, tt := range cases {
|
||||
for _, ref := range []bool{true, false} {
|
||||
sn := "ref"
|
||||
|
||||
@ -34,7 +34,7 @@ type TestExpectation struct {
|
||||
}
|
||||
|
||||
func TestCRDs(t *testing.T) {
|
||||
v := NewKgatewayValidator(t)
|
||||
v := NewAgentgatewayValidator(t)
|
||||
base := "testdata"
|
||||
d, err := os.ReadDir(base)
|
||||
if err != nil {
|
||||
|
||||
@ -41,6 +41,51 @@ spec:
|
||||
matchExpressions:
|
||||
- 'true'
|
||||
---
|
||||
_err: unknown fields
|
||||
apiVersion: agentgateway.dev/v1alpha1
|
||||
kind: AgentgatewayBackend
|
||||
metadata:
|
||||
name: mcp-static-target-authentication
|
||||
spec:
|
||||
mcp:
|
||||
targets:
|
||||
- name: target
|
||||
static:
|
||||
host: example.com
|
||||
port: 443
|
||||
policies:
|
||||
mcp:
|
||||
authentication:
|
||||
issuer: https://issuer.example.com/
|
||||
jwks:
|
||||
backendRef:
|
||||
name: jwks
|
||||
port: 443
|
||||
jwksPath: /.well-known/jwks.json
|
||||
---
|
||||
_err: path and pathPrefix are mutually exclusive
|
||||
apiVersion: agentgateway.dev/v1alpha1
|
||||
kind: AgentgatewayBackend
|
||||
metadata:
|
||||
name: path-and-pathprefix
|
||||
spec:
|
||||
ai:
|
||||
provider:
|
||||
openai: {}
|
||||
path: /custom/path
|
||||
pathPrefix: /custom
|
||||
---
|
||||
_err: pathPrefix requires host to be set
|
||||
apiVersion: agentgateway.dev/v1alpha1
|
||||
kind: AgentgatewayBackend
|
||||
metadata:
|
||||
name: pathprefix-without-host
|
||||
spec:
|
||||
ai:
|
||||
provider:
|
||||
openai: {}
|
||||
pathPrefix: /custom
|
||||
---
|
||||
_err: both host and port must be set together
|
||||
apiVersion: agentgateway.dev/v1alpha1
|
||||
kind: AgentgatewayBackend
|
||||
@ -50,4 +95,47 @@ spec:
|
||||
ai:
|
||||
provider:
|
||||
openai: {}
|
||||
host: example.com
|
||||
host: example.com
|
||||
---
|
||||
_err: exactly one of the fields in [host backendRef] must be set
|
||||
apiVersion: agentgateway.dev/v1alpha1
|
||||
kind: AgentgatewayBackend
|
||||
metadata:
|
||||
name: mcp-backend-ref-missing-port
|
||||
spec:
|
||||
mcp:
|
||||
targets:
|
||||
- name: bad-ref
|
||||
static:
|
||||
host: mcp.example.com
|
||||
backendRef:
|
||||
name: mcp-service
|
||||
port: 8080
|
||||
---
|
||||
_err: exactly one of the fields in [host backendRef] must be set
|
||||
apiVersion: agentgateway.dev/v1alpha1
|
||||
kind: AgentgatewayBackend
|
||||
metadata:
|
||||
name: mcp-backend-ref-no-target
|
||||
spec:
|
||||
mcp:
|
||||
targets:
|
||||
- name: bad-ref
|
||||
static:
|
||||
port: 8080
|
||||
---
|
||||
_err: mcp target policies may not be used with backendRef
|
||||
apiVersion: agentgateway.dev/v1alpha1
|
||||
kind: AgentgatewayBackend
|
||||
metadata:
|
||||
name: mcp-backend-ref-with-policies
|
||||
spec:
|
||||
mcp:
|
||||
targets:
|
||||
- name: bad-ref
|
||||
static:
|
||||
backendRef:
|
||||
name: mcp-service
|
||||
port: 8080
|
||||
policies:
|
||||
tls: {}
|
||||
|
||||
@ -63,6 +63,20 @@ kind: AgentgatewayBackend
|
||||
metadata:
|
||||
name: mcp-full
|
||||
spec:
|
||||
policies:
|
||||
mcp:
|
||||
authorization:
|
||||
action: Deny
|
||||
policy:
|
||||
matchExpressions:
|
||||
- 'mcp.tool.name == "hello"'
|
||||
authentication:
|
||||
issuer: https://issuer.example.com/
|
||||
jwks:
|
||||
backendRef:
|
||||
name: jwks
|
||||
port: 443
|
||||
jwksPath: /.well-known/jwks.json
|
||||
mcp:
|
||||
targets:
|
||||
- name: everything
|
||||
@ -71,12 +85,6 @@ spec:
|
||||
port: 443
|
||||
policies:
|
||||
tls: {}
|
||||
mcp:
|
||||
authorization:
|
||||
action: Deny
|
||||
policy:
|
||||
matchExpressions:
|
||||
- 'mcp.tool.name == "hello"'
|
||||
- name: k8s
|
||||
selector:
|
||||
namespaces:
|
||||
@ -124,4 +132,36 @@ spec:
|
||||
model: ollama
|
||||
host: localhost
|
||||
port: 8443
|
||||
path: /custom
|
||||
path: /custom
|
||||
---
|
||||
apiVersion: agentgateway.dev/v1alpha1
|
||||
kind: AgentgatewayBackend
|
||||
metadata:
|
||||
name: mcp-require
|
||||
spec:
|
||||
mcp:
|
||||
targets:
|
||||
- name: everything
|
||||
static:
|
||||
host: example.com
|
||||
port: 443
|
||||
policies:
|
||||
mcp:
|
||||
authorization:
|
||||
action: Require
|
||||
policy:
|
||||
matchExpressions:
|
||||
- 'mcp.tool.name == "hello"'
|
||||
---
|
||||
apiVersion: agentgateway.dev/v1alpha1
|
||||
kind: AgentgatewayBackend
|
||||
metadata:
|
||||
name: mcp-backend-ref
|
||||
spec:
|
||||
mcp:
|
||||
targets:
|
||||
- name: local-svc
|
||||
static:
|
||||
backendRef:
|
||||
name: mcp-service
|
||||
port: 8080
|
||||
|
||||
@ -247,6 +247,39 @@ spec:
|
||||
expression: 'request.headers["x-user"]'
|
||||
unit: Minutes
|
||||
---
|
||||
_err: 'failureMode: Unsupported value'
|
||||
apiVersion: agentgateway.dev/v1alpha1
|
||||
kind: AgentgatewayPolicy
|
||||
metadata:
|
||||
name: traffic-extauth-invalid-failure-mode
|
||||
spec:
|
||||
traffic:
|
||||
extAuth:
|
||||
backendRef:
|
||||
name: auth-server
|
||||
kind: Service
|
||||
failureMode: IgnoreErrors
|
||||
grpc: {}
|
||||
---
|
||||
_err: 'failureMode: Unsupported value'
|
||||
apiVersion: agentgateway.dev/v1alpha1
|
||||
kind: AgentgatewayPolicy
|
||||
metadata:
|
||||
name: traffic-ratelimit-global-invalid-failure-mode
|
||||
spec:
|
||||
traffic:
|
||||
rateLimit:
|
||||
global:
|
||||
backendRef:
|
||||
name: ratelimit-service
|
||||
kind: Service
|
||||
failureMode: IgnoreErrors
|
||||
domain: example.com
|
||||
descriptors:
|
||||
- entries:
|
||||
- name: user
|
||||
expression: 'request.headers["x-user"]'
|
||||
---
|
||||
_err: 'phase: Unsupported value'
|
||||
apiVersion: agentgateway.dev/v1alpha1
|
||||
kind: AgentgatewayPolicy
|
||||
@ -261,6 +294,21 @@ spec:
|
||||
- name: X-Test
|
||||
value: '"test"'
|
||||
---
|
||||
_err: 'jwtAuthentication.mcp requires mode Strict'
|
||||
apiVersion: agentgateway.dev/v1alpha1
|
||||
kind: AgentgatewayPolicy
|
||||
metadata:
|
||||
name: traffic-jwt-mcp-nonstrict
|
||||
spec:
|
||||
traffic:
|
||||
jwtAuthentication:
|
||||
mode: Optional
|
||||
providers:
|
||||
- issuer: https://example.com
|
||||
jwks:
|
||||
inline: '{"keys":[]}'
|
||||
mcp: {}
|
||||
---
|
||||
_err: 'pseudo-headers must be one of'
|
||||
apiVersion: agentgateway.dev/v1alpha1
|
||||
kind: AgentgatewayPolicy
|
||||
@ -287,14 +335,30 @@ spec:
|
||||
kind: Service
|
||||
protocol: TCP
|
||||
---
|
||||
_err: 'hostRewrite: Unsupported value'
|
||||
_err: 'path is only valid with protocol HTTP'
|
||||
apiVersion: agentgateway.dev/v1alpha1
|
||||
kind: AgentgatewayPolicy
|
||||
metadata:
|
||||
name: traffic-tracing-path-with-grpc
|
||||
spec:
|
||||
frontend:
|
||||
tracing:
|
||||
backendRef:
|
||||
name: otel-collector
|
||||
kind: Service
|
||||
port: 4317
|
||||
protocol: GRPC
|
||||
path: /v1/traces
|
||||
---
|
||||
_err: 'spec.traffic.hostRewrite.mode: Unsupported value'
|
||||
apiVersion: agentgateway.dev/v1alpha1
|
||||
kind: AgentgatewayPolicy
|
||||
metadata:
|
||||
name: traffic-hostrewrite-invalid
|
||||
spec:
|
||||
traffic:
|
||||
hostRewrite: Custom
|
||||
hostRewrite:
|
||||
mode: Custom
|
||||
---
|
||||
_err: ' exactly one of the fields in [targetRefs targetSelectors] must be set'
|
||||
apiVersion: agentgateway.dev/v1alpha1
|
||||
@ -370,6 +434,28 @@ spec:
|
||||
- field: a
|
||||
value: b
|
||||
---
|
||||
_err: 'traffic.jwtAuthentication may not be used with backend.mcp.authentication in the same policy'
|
||||
apiVersion: agentgateway.dev/v1alpha1
|
||||
kind: AgentgatewayPolicy
|
||||
metadata:
|
||||
name: jwt-and-mcp-authentication
|
||||
spec:
|
||||
traffic:
|
||||
jwtAuthentication:
|
||||
providers:
|
||||
- issuer: https://example.com
|
||||
jwks:
|
||||
inline: '{"keys":[]}'
|
||||
backend:
|
||||
mcp:
|
||||
authentication:
|
||||
issuer: https://example.com
|
||||
jwks:
|
||||
backendRef:
|
||||
kind: Service
|
||||
name: jwks
|
||||
jwksPath: /.well-known/jwks.json
|
||||
---
|
||||
_err: "targetRefs may only"
|
||||
apiVersion: agentgateway.dev/v1alpha1
|
||||
kind: AgentgatewayPolicy
|
||||
@ -381,7 +467,7 @@ spec:
|
||||
kind: Backend
|
||||
name: dummy
|
||||
---
|
||||
_err: "the 'traffic.phase=PreRouting' field can only target a Gateway or XListenerSet"
|
||||
_err: "the 'traffic.phase=PreRouting' field can only target a Gateway or ListenerSet"
|
||||
apiVersion: agentgateway.dev/v1alpha1
|
||||
kind: AgentgatewayPolicy
|
||||
metadata:
|
||||
@ -414,4 +500,4 @@ spec:
|
||||
rateLimit:
|
||||
local:
|
||||
- requests: 100
|
||||
unit: Minutes
|
||||
unit: Minutes
|
||||
|
||||
@ -308,6 +308,7 @@ spec:
|
||||
name: auth-server
|
||||
kind: AgentgatewayBackend
|
||||
group: agentgateway.dev
|
||||
failureMode: FailOpen
|
||||
forwardBody:
|
||||
maxSize: 1048576
|
||||
---
|
||||
@ -358,6 +359,7 @@ spec:
|
||||
name: ratelimit-service
|
||||
kind: Service
|
||||
port: 8080
|
||||
failureMode: FailOpen
|
||||
domain: example.com
|
||||
descriptors:
|
||||
- entries:
|
||||
@ -456,6 +458,26 @@ spec:
|
||||
expression: 'request.headers["x-custom"]'
|
||||
remove:
|
||||
- http.method
|
||||
---
|
||||
apiVersion: agentgateway.dev/v1alpha1
|
||||
kind: AgentgatewayPolicy
|
||||
metadata:
|
||||
name: traffic-tracing-http-path
|
||||
spec:
|
||||
targetRefs:
|
||||
- group: gateway.networking.k8s.io
|
||||
kind: Gateway
|
||||
name: dummy
|
||||
frontend:
|
||||
tracing:
|
||||
backendRef:
|
||||
name: otel-collector
|
||||
kind: Service
|
||||
port: 4318
|
||||
protocol: HTTP
|
||||
path: /custom/v1/traces
|
||||
randomSampling: '0.1'
|
||||
clientSampling: '1.0'
|
||||
#---
|
||||
#apiVersion: agentgateway.dev/v1alpha1
|
||||
#kind: AgentgatewayPolicy
|
||||
@ -638,4 +660,4 @@ spec:
|
||||
unit: Minutes
|
||||
- requests: 10
|
||||
unit: Seconds
|
||||
burst: 5
|
||||
burst: 5
|
||||
|
||||
@ -7,16 +7,38 @@ import (
|
||||
"testing"
|
||||
|
||||
"istio.io/istio/pkg/config/crd"
|
||||
"istio.io/istio/pkg/lazy"
|
||||
"istio.io/istio/pkg/test/util/assert"
|
||||
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/utils/fsutils"
|
||||
)
|
||||
|
||||
func NewKgatewayValidator(t *testing.T) *crd.Validator {
|
||||
var validator = lazy.New(func() (*crd.Validator, error) {
|
||||
return newAgentgatewayValidator(false)
|
||||
})
|
||||
var validatorSkipMissing = lazy.New(func() (*crd.Validator, error) {
|
||||
return newAgentgatewayValidator(true)
|
||||
})
|
||||
|
||||
func NewAgentgatewayValidator(t *testing.T) *crd.Validator {
|
||||
v, err := validator.Get()
|
||||
assert.NoError(t, err)
|
||||
return v
|
||||
}
|
||||
|
||||
func NewAgentgatewayValidatorSkipMissing(t *testing.T) *crd.Validator {
|
||||
v, err := validatorSkipMissing.Get()
|
||||
assert.NoError(t, err)
|
||||
return v
|
||||
}
|
||||
|
||||
func newAgentgatewayValidator(skipMissing bool) (*crd.Validator, error) {
|
||||
root := fsutils.GetModuleRoot()
|
||||
dirs := []string{}
|
||||
agentgatewayDir, err := os.ReadDir(filepath.Join(root, "controller/install/helm/agentgateway-crds/templates/"))
|
||||
assert.NoError(t, err)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, d := range agentgatewayDir {
|
||||
if strings.HasSuffix(d.Name(), ".yaml") {
|
||||
dirs = append(dirs, filepath.Join(root, "controller/install/helm/agentgateway-crds/templates", d.Name()))
|
||||
@ -26,7 +48,8 @@ func NewKgatewayValidator(t *testing.T) *crd.Validator {
|
||||
dirs...,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
return nil, err
|
||||
}
|
||||
return v
|
||||
v.SkipMissing = skipMissing
|
||||
return v, nil
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package agentgateway
|
||||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
gwv1 "sigs.k8s.io/gateway-api/apis/v1"
|
||||
)
|
||||
@ -13,8 +14,8 @@ import (
|
||||
|
||||
// +genclient
|
||||
// +kubebuilder:object:root=true
|
||||
// +kubebuilder:metadata:labels={app=kgateway,app.kubernetes.io/name=kgateway}
|
||||
// +kubebuilder:resource:categories=kgateway,shortName=agbe
|
||||
// +kubebuilder:metadata:labels={app=agentgateway,app.kubernetes.io/name=agentgateway}
|
||||
// +kubebuilder:resource:categories=agentgateway,shortName=agbe
|
||||
// +kubebuilder:subresource:status
|
||||
type AgentgatewayBackend struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
@ -51,7 +52,7 @@ type AgentgatewayBackendList struct {
|
||||
Items []AgentgatewayBackend `json:"items"`
|
||||
}
|
||||
|
||||
// +kubebuilder:validation:ExactlyOneOf=ai;static;dynamicForwardProxy;mcp
|
||||
// +kubebuilder:validation:ExactlyOneOf=ai;static;dynamicForwardProxy;mcp;aws
|
||||
// +kubebuilder:validation:XValidation:rule="has(self.policies) && has(self.policies.ai) ? has(self.ai) : true",message="AI policies require AI backend"
|
||||
// +kubebuilder:validation:XValidation:rule="has(self.policies) && has(self.policies.mcp) ? has(self.mcp) : true",message="MCP policies require MCP backend"
|
||||
type AgentgatewayBackendSpec struct {
|
||||
@ -75,6 +76,10 @@ type AgentgatewayBackendSpec struct {
|
||||
// +optional
|
||||
DynamicForwardProxy *DynamicForwardProxyBackend `json:"dynamicForwardProxy,omitempty"`
|
||||
|
||||
// aws represents an AWS service backend (AgentCore, etc.).
|
||||
// +optional
|
||||
Aws *AwsBackend `json:"aws,omitempty"`
|
||||
|
||||
// policies controls policies for communicating with this backend. Policies may also be set in AgentgatewayPolicy;
|
||||
// policies are merged on a field-level basis, with policies on the Backend (this field) taking precedence.
|
||||
// +optional
|
||||
@ -84,6 +89,24 @@ type AgentgatewayBackendSpec struct {
|
||||
type DynamicForwardProxyBackend struct {
|
||||
}
|
||||
|
||||
// AwsBackend configures an AWS service backend.
|
||||
// +kubebuilder:validation:ExactlyOneOf=agentCore
|
||||
type AwsBackend struct {
|
||||
// agentCore configures Amazon Bedrock AgentCore as a backend.
|
||||
// +optional
|
||||
AgentCore *AwsAgentCoreBackend `json:"agentCore,omitempty"`
|
||||
}
|
||||
|
||||
// AwsAgentCoreBackend configures Amazon Bedrock AgentCore.
|
||||
type AwsAgentCoreBackend struct {
|
||||
// agentRuntimeArn is the ARN of the AgentCore runtime.
|
||||
// +required
|
||||
AgentRuntimeArn string `json:"agentRuntimeArn"`
|
||||
// qualifier optionally specifies the alias or version qualifier.
|
||||
// +optional
|
||||
Qualifier *string `json:"qualifier,omitempty"`
|
||||
}
|
||||
|
||||
type StaticBackend struct {
|
||||
// host to connect to.
|
||||
// +required
|
||||
@ -98,35 +121,37 @@ type StaticBackend struct {
|
||||
// AIBackend specifies the AI backend configuration
|
||||
// +kubebuilder:validation:ExactlyOneOf=provider;groups
|
||||
type AIBackend struct {
|
||||
// provider specifies configuration for how to reach the configured LLM provider.
|
||||
// `provider` specifies configuration for how to reach the configured LLM
|
||||
// provider.
|
||||
// +optional
|
||||
LLM *LLMProvider `json:"provider,omitempty"`
|
||||
|
||||
// groups specifies a list of groups in priority order where each group defines
|
||||
// a set of LLM providers. The priority determines the priority of the backend endpoints chosen.
|
||||
// Note: provider names must be unique across all providers in all priority groups. Backend policies
|
||||
// may target a specific provider by name using targetRefs[].sectionName.
|
||||
// `groups` specifies a list of groups in priority order where each group
|
||||
// defines a set of LLM providers. The priority determines the priority of
|
||||
// the backend endpoints chosen.
|
||||
// Note: provider names must be unique across all providers in all priority
|
||||
// groups. Backend policies may target a specific provider by name using
|
||||
// `targetRefs[].sectionName`.
|
||||
//
|
||||
// Example configuration with two priority groups:
|
||||
// ```yaml
|
||||
// groups:
|
||||
// - providers:
|
||||
// - azureopenai:
|
||||
// deploymentName: gpt-4o-mini
|
||||
// apiVersion: 2024-02-15-preview
|
||||
// endpoint: ai-gateway.openai.azure.com
|
||||
// - providers:
|
||||
// - azureopenai:
|
||||
// deploymentName: gpt-4o-mini-2
|
||||
// apiVersion: 2024-02-15-preview
|
||||
// endpoint: ai-gateway-2.openai.azure.com
|
||||
// policies:
|
||||
// auth:
|
||||
// secretRef:
|
||||
// name: azure-secret
|
||||
// ```
|
||||
//
|
||||
// groups:
|
||||
// - providers:
|
||||
// - azureopenai:
|
||||
// deploymentName: gpt-4o-mini
|
||||
// apiVersion: 2024-02-15-preview
|
||||
// endpoint: ai-gateway.openai.azure.com
|
||||
// - providers:
|
||||
// - azureopenai:
|
||||
// deploymentName: gpt-4o-mini-2
|
||||
// apiVersion: 2024-02-15-preview
|
||||
// endpoint: ai-gateway-2.openai.azure.com
|
||||
// policies:
|
||||
// auth:
|
||||
// secretRef:
|
||||
// name: azure-secret
|
||||
// +kubebuilder:validation:MinItems=1
|
||||
// +kubebuilder:validation:MaxItems=32
|
||||
// +kubebuilder:validation:MaxItems=8
|
||||
// +optional
|
||||
// TODO: enable this rule when we don't need to support older k8s versions where this rule breaks // +kubebuilder:validation:XValidation:message="provider names must be unique across groups",rule="self.map(pg, pg.providers.map(pp, pp.name)).map(p, self.map(pg, pg.providers.map(pp, pp.name)).filter(cp, cp != p).exists(cp, p.exists(pn, pn in cp))).exists(p, !p)"
|
||||
PriorityGroups []PriorityGroup `json:"groups,omitempty"`
|
||||
@ -137,7 +162,7 @@ type PriorityGroup struct {
|
||||
// with automatic weighting based on health.
|
||||
//
|
||||
// +kubebuilder:validation:MinItems=1
|
||||
// +kubebuilder:validation:MaxItems=32
|
||||
// +kubebuilder:validation:MaxItems=16
|
||||
// +kubebuilder:validation:XValidation:message="provider names must be unique within a group",rule="self.all(p1, self.exists_one(p2, p1.name == p2.name))"
|
||||
// +required
|
||||
Providers []NamedLLMProvider `json:"providers"`
|
||||
@ -148,9 +173,11 @@ type NamedLLMProvider struct {
|
||||
// +required
|
||||
Name gwv1.SectionName `json:"name"`
|
||||
|
||||
// policies controls policies for communicating with this backend. Policies may also be set in AgentgatewayPolicy, or
|
||||
// in the top level AgentgatewayBackend. policies are merged on a field-level basis, with order: AgentgatewayPolicy <
|
||||
// AgentgatewayBackend < AgentgatewayBackend LLM provider (this field).
|
||||
// `policies` controls policies for communicating with this backend.
|
||||
// Policies may also be set in `AgentgatewayPolicy`, or in the top-level
|
||||
// `AgentgatewayBackend`. Policies are merged on a field-level basis, with
|
||||
// order: `AgentgatewayPolicy` < `AgentgatewayBackend` < `AgentgatewayBackend`
|
||||
// LLM provider (this field).
|
||||
// +optional
|
||||
Policies *BackendWithAI `json:"policies,omitempty"`
|
||||
|
||||
@ -160,6 +187,8 @@ type NamedLLMProvider struct {
|
||||
// LLMProvider specifies the target large language model provider that the backend should route requests to.
|
||||
// +kubebuilder:validation:ExactlyOneOf=openai;azureopenai;anthropic;gemini;vertexai;bedrock
|
||||
// +kubebuilder:validation:XValidation:rule="has(self.host) || has(self.port) ? has(self.host) && has(self.port) : true",message="both host and port must be set together"
|
||||
// +kubebuilder:validation:XValidation:rule="!(has(self.path) && has(self.pathPrefix))",message="path and pathPrefix are mutually exclusive"
|
||||
// +kubebuilder:validation:XValidation:rule="has(self.pathPrefix) ? has(self.host) : true",message="pathPrefix requires host to be set"
|
||||
type LLMProvider struct {
|
||||
// OpenAI provider
|
||||
// +optional
|
||||
@ -202,9 +231,15 @@ type LLMProvider struct {
|
||||
// If not specified, the default path for the provider is used.
|
||||
// +optional
|
||||
Path LongString `json:"path,omitempty"`
|
||||
|
||||
// PathPrefix overrides the default base path prefix (e.g. "/v1") for upstream requests.
|
||||
// Path translation for cross-format requests still applies using this prefix.
|
||||
// Only supported for OpenAI and Anthropic providers.
|
||||
// +optional
|
||||
PathPrefix LongString `json:"pathPrefix,omitempty"`
|
||||
}
|
||||
|
||||
// OpenAIConfig settings for the [OpenAI](https://platform.openai.com/docs/api-reference/streaming) LLM provider.
|
||||
// OpenAIConfig settings for the [OpenAI](https://developers.openai.com/api/docs/guides/streaming-responses) LLM provider.
|
||||
type OpenAIConfig struct {
|
||||
// Optional: Override the model name, such as `gpt-4o-mini`.
|
||||
// If unset, the model name is taken from the request.
|
||||
@ -212,7 +247,7 @@ type OpenAIConfig struct {
|
||||
Model *ShortString `json:"model,omitempty"`
|
||||
}
|
||||
|
||||
// AzureOpenAIConfig settings for the [Azure OpenAI](https://learn.microsoft.com/en-us/azure/ai-services/openai/) LLM provider.
|
||||
// AzureOpenAIConfig settings for the [Azure OpenAI](https://learn.microsoft.com/en-us/azure/ai-foundry/?view=foundry-classic) LLM provider.
|
||||
// +kubebuilder:validation:XValidation:message="deploymentName is required for this apiVersion",rule="!has(self.apiVersion) || self.apiVersion == 'v1' ? true : has(self.deploymentName)"
|
||||
type AzureOpenAIConfig struct {
|
||||
// The endpoint for the Azure OpenAI API to use, such as `my-endpoint.openai.azure.com`.
|
||||
@ -221,14 +256,15 @@ type AzureOpenAIConfig struct {
|
||||
Endpoint ShortString `json:"endpoint"`
|
||||
|
||||
// The name of the Azure OpenAI model deployment to use.
|
||||
// For more information, see the [Azure OpenAI model docs](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models).
|
||||
// This is required if ApiVersion is not 'v1'. For v1, the model can be set in the request.
|
||||
// For more information, see the [Azure OpenAI model docs](https://learn.microsoft.com/en-us/azure/ai-foundry/foundry-models/concepts/models-sold-directly-by-azure?view=foundry-classic).
|
||||
// This is required if `apiVersion` is not `v1`. For `v1`, the model can be
|
||||
// set in the request.
|
||||
// +optional
|
||||
DeploymentName *ShortString `json:"deploymentName,omitempty"`
|
||||
|
||||
// The version of the Azure OpenAI API to use.
|
||||
// For more information, see the [Azure OpenAI API version reference](https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs).
|
||||
// If unset, defaults to "v1"
|
||||
// For more information, see the [Azure OpenAI API version reference](https://learn.microsoft.com/en-us/azure/ai-foundry/?view=foundry-classicreference#api-specs).
|
||||
// If unset, defaults to `v1`.
|
||||
// +optional
|
||||
ApiVersion *TinyString `json:"apiVersion,omitempty"`
|
||||
}
|
||||
@ -241,7 +277,7 @@ type GeminiConfig struct {
|
||||
Model *ShortString `json:"model,omitempty"`
|
||||
}
|
||||
|
||||
// VertexAIConfig settings for the [Vertex AI](https://cloud.google.com/vertex-ai/docs) LLM provider.
|
||||
// VertexAIConfig settings for the [Vertex AI](https://docs.cloud.google.com/vertex-ai/docs) LLM provider.
|
||||
type VertexAIConfig struct {
|
||||
// Optional: Override the model name, such as `gpt-4o-mini`.
|
||||
// If unset, the model name is taken from the request.
|
||||
@ -253,11 +289,13 @@ type VertexAIConfig struct {
|
||||
ProjectId TinyString `json:"projectId"`
|
||||
|
||||
// The location of the Google Cloud Project that you use for the Vertex AI.
|
||||
// +required
|
||||
Region TinyString `json:"region"`
|
||||
// Defaults to `global` if not specified.
|
||||
// +optional
|
||||
// +kubebuilder:default=global
|
||||
Region TinyString `json:"region,omitempty"`
|
||||
}
|
||||
|
||||
// AnthropicConfig settings for the [Anthropic](https://docs.anthropic.com/en/release-notes/api) LLM provider.
|
||||
// AnthropicConfig settings for the [Anthropic](https://platform.claude.com/docs/en/release-notes/overview) LLM provider.
|
||||
type AnthropicConfig struct {
|
||||
// Optional: Override the model name, such as `gpt-4o-mini`.
|
||||
// If unset, the model name is taken from the request.
|
||||
@ -267,7 +305,7 @@ type AnthropicConfig struct {
|
||||
|
||||
type BedrockConfig struct {
|
||||
// Region is the AWS region to use for the backend.
|
||||
// Defaults to us-east-1 if not specified.
|
||||
// Defaults to `us-east-1` if not specified.
|
||||
// +optional
|
||||
// +kubebuilder:default=us-east-1
|
||||
// +kubebuilder:validation:MinLength=1
|
||||
@ -280,7 +318,8 @@ type BedrockConfig struct {
|
||||
// +optional
|
||||
Model *ShortString `json:"model,omitempty"`
|
||||
|
||||
// Guardrail configures the Guardrail policy to use for the backend. See <https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails.html>
|
||||
// `guardrail` configures the Guardrail policy to use for the backend. See
|
||||
// <https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails.html>.
|
||||
// If not specified, the AWS Guardrail policy will not be used.
|
||||
// +optional
|
||||
Guardrail *AWSGuardrailConfig `json:"guardrail,omitempty"`
|
||||
@ -296,11 +335,12 @@ type AWSGuardrailConfig struct {
|
||||
GuardrailVersion ShortString `json:"version"`
|
||||
}
|
||||
|
||||
// MCPBackend configures mcp backends
|
||||
// MCPBackend configures `mcp` backends.
|
||||
type MCPBackend struct {
|
||||
// Targets is a list of MCPBackend targets to use for this backend.
|
||||
// Policies targeting MCPBackend targets must use targetRefs[].sectionName
|
||||
// to select the target by name.
|
||||
// `targets` is a list of MCP targets to use for this backend. Policies
|
||||
// targeting MCP targets must use `targetRefs[].sectionName` to select
|
||||
// the target by name.
|
||||
//
|
||||
// +listType=map
|
||||
// +listMapKey=name
|
||||
// +kubebuilder:validation:MinItems=1
|
||||
@ -309,32 +349,52 @@ type MCPBackend struct {
|
||||
// +required
|
||||
Targets []McpTargetSelector `json:"targets"`
|
||||
|
||||
// SessionRouting configures MCP session behavior for requests.
|
||||
// Defaults to Stateful if not set.
|
||||
// `sessionRouting` configures MCP session behavior for requests.
|
||||
// Defaults to `Stateful` if not set.
|
||||
// +optional
|
||||
SessionRouting SessionRouting `json:"sessionRouting,omitempty"`
|
||||
|
||||
// `failureMode` controls behavior when MCP targets fail to initialize or
|
||||
// become unavailable at runtime. `FailOpen` skips failed targets and
|
||||
// continues serving from healthy ones. `FailClosed` (default) fails the
|
||||
// entire session if any target fails.
|
||||
// +optional
|
||||
FailureMode FailureMode `json:"failureMode,omitempty"`
|
||||
}
|
||||
|
||||
const (
|
||||
// FailClosed fails the entire MCP session if any target fails.
|
||||
FailClosed FailureMode = "FailClosed"
|
||||
// FailOpen skips failed targets and continues serving from healthy ones.
|
||||
FailOpen FailureMode = "FailOpen"
|
||||
)
|
||||
|
||||
// +kubebuilder:validation:Enum=FailOpen;FailClosed
|
||||
type FailureMode string
|
||||
|
||||
// McpTargetSelector defines the MCPBackend target to use for this backend.
|
||||
// +kubebuilder:validation:ExactlyOneOf=selector;static
|
||||
type McpTargetSelector struct {
|
||||
// Name of the MCPBackend target.
|
||||
// Name of the MCP target.
|
||||
// +required
|
||||
Name gwv1.SectionName `json:"name"`
|
||||
|
||||
// selector is a label selector is the selector to use to select Services.
|
||||
// If policies are needed on a per-service basis, AgentgatewayPolicy can target the desired Service.
|
||||
// `selector` is the label selector used to select `Service` resources.
|
||||
// If policies are needed on a per-service basis, `AgentgatewayPolicy` can
|
||||
// target the desired `Service`.
|
||||
// +optional
|
||||
Selector *McpSelector `json:"selector,omitempty"`
|
||||
|
||||
// static configures a static MCP destination. When connecting to in-cluster Services, it is recommended to use
|
||||
// 'selector' instead.
|
||||
// `static` configures a static MCP destination. When connecting to
|
||||
// in-cluster `Service` resources, it is recommended to use `selector`
|
||||
// instead.
|
||||
// +optional
|
||||
Static *McpTarget `json:"static,omitempty"`
|
||||
}
|
||||
|
||||
const (
|
||||
// Stateful mode creates an MCP session (via mcp-session-id) and internally
|
||||
// `Stateful` mode creates an MCP session (via `mcp-session-id`) and
|
||||
// internally
|
||||
// ensures requests for that session are routed to a consistent backend replica.
|
||||
Stateful SessionRouting = "Stateful"
|
||||
Stateless SessionRouting = "Stateless"
|
||||
@ -343,55 +403,71 @@ const (
|
||||
// +kubebuilder:validation:Enum=Stateful;Stateless
|
||||
type SessionRouting string
|
||||
|
||||
// +kubebuilder:validation:AtLeastOneOf=namespaces;services
|
||||
// +kubebuilder:validation:AtLeastOneFieldSet
|
||||
type McpSelector struct {
|
||||
// namespace is the label selector in which namespaces Services should be selected from.
|
||||
// If unset, only the namespace of the AgentgatewayBackend is searched.
|
||||
// `namespace` is the label selector for namespaces that `Service`
|
||||
// resources should be selected from. If unset, only the namespace of the
|
||||
// `AgentgatewayBackend` is searched.
|
||||
// +optional
|
||||
Namespace *metav1.LabelSelector `json:"namespaces,omitempty"`
|
||||
|
||||
// services is the label selector for which Services should be selected.
|
||||
// `services` is the label selector for which `Service` resources should be
|
||||
// selected.
|
||||
// +optional
|
||||
Service *metav1.LabelSelector `json:"services,omitempty"`
|
||||
}
|
||||
|
||||
// McpTarget defines a single MCPBackend target configuration.
|
||||
// +kubebuilder:validation:ExactlyOneOf=host;backendRef
|
||||
// +kubebuilder:validation:XValidation:rule="!has(self.backendRef) || !has(self.policies)",message="mcp target policies may not be used with backendRef"
|
||||
type McpTarget struct {
|
||||
// Host is the hostname or IP address of the MCPBackend target.
|
||||
// +required
|
||||
Host ShortString `json:"host"`
|
||||
// Host is the hostname or IP address of the MCP target.
|
||||
// +optional
|
||||
Host *ShortString `json:"host,omitempty"`
|
||||
|
||||
// Port is the port number of the MCPBackend target.
|
||||
// `backendRef` references a namespace-local `Service` resource by name.
|
||||
// When set, this replaces `host` only; `port`, `path`, and `protocol`
|
||||
// remain configured on this target.
|
||||
// +optional
|
||||
BackendRef *corev1.LocalObjectReference `json:"backendRef,omitempty"`
|
||||
|
||||
// Port is the port number of the MCP target.
|
||||
// +kubebuilder:validation:Minimum=1
|
||||
// +kubebuilder:validation:Maximum=65535
|
||||
// +required
|
||||
Port int32 `json:"port"`
|
||||
|
||||
// Path is the URL path of the MCPBackend target endpoint.
|
||||
// Defaults to "/sse" for SSE protocol or "/mcp" for StreamableHTTP protocol if not specified.
|
||||
// Path is the URL path of the MCP target endpoint.
|
||||
// Defaults to `"/sse"` for the `SSE` protocol or `"/mcp"` for the
|
||||
// `StreamableHTTP` protocol if not specified.
|
||||
// +optional
|
||||
Path *LongString `json:"path,omitempty"`
|
||||
|
||||
// Protocol is the protocol to use for the connection to the MCPBackend target.
|
||||
// Protocol is the protocol to use for the connection to the MCP
|
||||
// target.
|
||||
// +optional
|
||||
Protocol *MCPProtocol `json:"protocol,omitempty"`
|
||||
|
||||
// policies controls policies for communicating with this backend. Policies may also be set in AgentgatewayPolicy, or
|
||||
// in the top level AgentgatewayBackend. Policies are merged on a field-level basis, with order: AgentgatewayPolicy <
|
||||
// AgentgatewayBackend < AgentgatewayBackend MCP (this field).
|
||||
// `policies` controls policies for communicating with this backend.
|
||||
// Policies may also be set in `AgentgatewayPolicy`, or in the top-level
|
||||
// `AgentgatewayBackend`. Policies are merged on a field-level basis, with
|
||||
// order: `AgentgatewayPolicy` < `AgentgatewayBackend` < `AgentgatewayBackend` MCP (this field).
|
||||
// This field may only be used with host-based static targets, not
|
||||
// `backendRef`.
|
||||
// +optional
|
||||
Policies *BackendWithMCP `json:"policies,omitempty"`
|
||||
Policies *BackendSimple `json:"policies,omitempty"`
|
||||
}
|
||||
|
||||
// MCPProtocol defines the protocol to use for the MCPBackend target
|
||||
// MCPProtocol defines the protocol to use for the `MCPBackend` target.
|
||||
// +kubebuilder:validation:Enum=StreamableHTTP;SSE
|
||||
type MCPProtocol string
|
||||
|
||||
const (
|
||||
|
||||
// MCPProtocolStreamableHTTP specifies Streamable HTTP must be used as the protocol
|
||||
// MCPProtocolStreamableHTTP specifies that `StreamableHTTP` must be used as
|
||||
// the protocol.
|
||||
MCPProtocolStreamableHTTP MCPProtocol = "StreamableHTTP"
|
||||
|
||||
// MCPProtocolSSE specifies Server-Sent Events (SSE) must be used as the protocol
|
||||
// MCPProtocolSSE specifies that Server-Sent Events (`SSE`) must be used as
|
||||
// the protocol.
|
||||
MCPProtocolSSE MCPProtocol = "SSE"
|
||||
)
|
||||
|
||||
@ -19,8 +19,8 @@ import (
|
||||
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
|
||||
// +genclient
|
||||
// +kubebuilder:object:root=true
|
||||
// +kubebuilder:metadata:labels={app=kgateway,app.kubernetes.io/name=kgateway}
|
||||
// +kubebuilder:resource:categories=kgateway,shortName=agpar,path=agentgatewayparameters
|
||||
// +kubebuilder:metadata:labels={app=agentgateway,app.kubernetes.io/name=agentgateway}
|
||||
// +kubebuilder:resource:categories=agentgateway,shortName=agpar,path=agentgatewayparameters
|
||||
// +kubebuilder:subresource:status
|
||||
// +kubebuilder:metadata:labels="gateway.networking.k8s.io/policy=Direct"
|
||||
type AgentgatewayParameters struct {
|
||||
@ -64,9 +64,9 @@ const (
|
||||
)
|
||||
|
||||
type AgentgatewayParametersLogging struct {
|
||||
// Logging level in standard RUST_LOG syntax, e.g. 'info', the default, or
|
||||
// by module, comma-separated. E.g.,
|
||||
// "rmcp=warn,hickory_server::server::server_future=off,typespec_client_core::http::policies::logging=warn"
|
||||
// Logging level in standard `RUST_LOG` syntax, for example `info` (the
|
||||
// default), or a comma-separated per-module setting such as
|
||||
// `rmcp=warn,hickory_server::server::server_future=off,typespec_client_core::http::policies::logging=warn`.
|
||||
// +optional
|
||||
Level string `json:"level,omitempty"`
|
||||
// +optional
|
||||
@ -74,16 +74,16 @@ type AgentgatewayParametersLogging struct {
|
||||
}
|
||||
|
||||
type AgentgatewayParametersConfigs struct {
|
||||
// logging configuration for Agentgateway. By default, all logs are set to "info" level.
|
||||
// `logging` configuration for Agentgateway. By default, all logs are set to
|
||||
// `info` level.
|
||||
// +optional
|
||||
Logging *AgentgatewayParametersLogging `json:"logging,omitempty"`
|
||||
|
||||
// rawConfig provides an opaque mechanism to configure the agentgateway
|
||||
// config file (the agentgateway binary has a '-f' option to specify a
|
||||
// config file, and this is that file). This will be merged with
|
||||
// configuration derived from typed fields like
|
||||
// AgentgatewayParametersLogging.Format, and those typed fields will take
|
||||
// precedence.
|
||||
// `rawConfig` provides an opaque mechanism to configure the `agentgateway`
|
||||
// config file. The `agentgateway` binary has a `-f` option to specify a
|
||||
// config file, and this field supplies that file. This will be merged with
|
||||
// configuration derived from typed fields like `logging.format`, and those
|
||||
// typed fields will take precedence.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
@ -95,11 +95,11 @@ type AgentgatewayParametersConfigs struct {
|
||||
// - policies:
|
||||
// cors:
|
||||
// allowOrigins:
|
||||
// - "*"
|
||||
// - "*"
|
||||
// allowHeaders:
|
||||
// - mcp-protocol-version
|
||||
// - content-type
|
||||
// - cache-control
|
||||
// - mcp-protocol-version
|
||||
// - content-type
|
||||
// - cache-control
|
||||
// backends:
|
||||
// - mcp:
|
||||
// targets:
|
||||
@ -129,14 +129,17 @@ type AgentgatewayParametersConfigs struct {
|
||||
|
||||
// The container environment variables. These override any existing
|
||||
// values. If you want to delete an environment variable entirely, use
|
||||
// `$patch: delete` with AgentgatewayParametersOverlays instead. Note that
|
||||
// `$patch: delete` with `AgentgatewayParametersOverlays` instead. Note that
|
||||
// [variable
|
||||
// expansion](https://kubernetes.io/docs/tasks/inject-data-application/define-interdependent-environment-variables/)
|
||||
// does apply, but is highly discouraged -- to set dependent environment
|
||||
// variables, you can use $(VAR_NAME), but it's highly
|
||||
// discouraged. `$$(VAR_NAME)` avoids expansion and results in a literal
|
||||
// variables, you can use `$(VAR_NAME)`, but it's highly discouraged.
|
||||
// `$$(VAR_NAME)` avoids expansion and results in a literal
|
||||
// `$(VAR_NAME)`.
|
||||
//
|
||||
// If `SESSION_KEY` is specified, it takes precedence over the
|
||||
// controller-managed per-`Gateway` session key `Secret`.
|
||||
//
|
||||
// +optional
|
||||
Env []corev1.EnvVar `json:"env,omitempty"`
|
||||
|
||||
@ -147,10 +150,11 @@ type AgentgatewayParametersConfigs struct {
|
||||
// +optional
|
||||
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
|
||||
|
||||
// Shutdown delay configuration. How graceful planned or unplanned data
|
||||
// Shutdown delay configuration. How graceful planned or unplanned data
|
||||
// plane changes happen is in tension with how quickly rollouts of the data
|
||||
// plane complete. How long a data plane pod must wait for shutdown to be
|
||||
// perfectly graceful depends on how you have configured your Gateways.
|
||||
// perfectly graceful depends on how you have configured your `Gateway`
|
||||
// resources.
|
||||
//
|
||||
// +optional
|
||||
Shutdown *ShutdownSpec `json:"shutdown,omitempty"`
|
||||
@ -175,8 +179,8 @@ type IstioSpec struct {
|
||||
// +kubebuilder:validation:XValidation:rule="self.min <= self.max",message="The 'min' value must be less than or equal to the 'max' value."
|
||||
type ShutdownSpec struct {
|
||||
// Minimum time (in seconds) to wait before allowing Agentgateway to
|
||||
// terminate. Refer to the CONNECTION_MIN_TERMINATION_DEADLINE environment
|
||||
// variable for details.
|
||||
// terminate. Refer to the `CONNECTION_MIN_TERMINATION_DEADLINE`
|
||||
// environment variable for details.
|
||||
//
|
||||
// +required
|
||||
// +kubebuilder:validation:Minimum=0
|
||||
@ -184,8 +188,8 @@ type ShutdownSpec struct {
|
||||
Min int64 `json:"min"`
|
||||
|
||||
// Maximum time (in seconds) to wait before allowing Agentgateway to
|
||||
// terminate. Refer to the TERMINATION_GRACE_PERIOD_SECONDS environment
|
||||
// variable for details.
|
||||
// terminate. Refer to the `TERMINATION_GRACE_PERIOD_SECONDS`
|
||||
// environment variable for details.
|
||||
//
|
||||
// +required
|
||||
// +kubebuilder:validation:Minimum=0
|
||||
@ -194,29 +198,34 @@ type ShutdownSpec struct {
|
||||
}
|
||||
|
||||
type AgentgatewayParametersOverlays struct {
|
||||
// deployment allows specifying overrides for the generated Deployment resource.
|
||||
// `deployment` allows specifying overrides for the generated
|
||||
// `Deployment` resource.
|
||||
// +optional
|
||||
Deployment *shared.KubernetesResourceOverlay `json:"deployment,omitempty"`
|
||||
|
||||
// service allows specifying overrides for the generated Service resource.
|
||||
// `service` allows specifying overrides for the generated `Service`
|
||||
// resource.
|
||||
// +optional
|
||||
Service *shared.KubernetesResourceOverlay `json:"service,omitempty"`
|
||||
|
||||
// serviceAccount allows specifying overrides for the generated ServiceAccount resource.
|
||||
// `serviceAccount` allows specifying overrides for the generated
|
||||
// `ServiceAccount` resource.
|
||||
// +optional
|
||||
ServiceAccount *shared.KubernetesResourceOverlay `json:"serviceAccount,omitempty"`
|
||||
|
||||
// podDisruptionBudget allows creating a PodDisruptionBudget for the agentgateway proxy.
|
||||
// If absent, no PDB is created. If present, a PDB is created with its selector
|
||||
// automatically configured to target the agentgateway proxy Deployment.
|
||||
// The metadata and spec fields from this overlay are applied to the generated PDB.
|
||||
// `podDisruptionBudget` allows creating a `PodDisruptionBudget` for the
|
||||
// agentgateway proxy. If absent, no PDB is created. If present, a PDB is
|
||||
// created with its selector automatically configured to target the
|
||||
// agentgateway proxy `Deployment`. The `metadata` and `spec` fields from
|
||||
// this overlay are applied to the generated PDB.
|
||||
// +optional
|
||||
PodDisruptionBudget *shared.KubernetesResourceOverlay `json:"podDisruptionBudget,omitempty"`
|
||||
|
||||
// horizontalPodAutoscaler allows creating a HorizontalPodAutoscaler for the agentgateway proxy.
|
||||
// If absent, no HPA is created. If present, an HPA is created with its scaleTargetRef
|
||||
// automatically configured to target the agentgateway proxy Deployment.
|
||||
// The metadata and spec fields from this overlay are applied to the generated HPA.
|
||||
// `horizontalPodAutoscaler` allows creating a `HorizontalPodAutoscaler`
|
||||
// for the agentgateway proxy. If absent, no HPA is created. If present, an
|
||||
// HPA is created with its `scaleTargetRef` automatically configured to
|
||||
// target the agentgateway proxy `Deployment`. The `metadata` and `spec`
|
||||
// fields from this overlay are applied to the generated HPA.
|
||||
// +optional
|
||||
HorizontalPodAutoscaler *shared.KubernetesResourceOverlay `json:"horizontalPodAutoscaler,omitempty"`
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,8 @@ package agentgateway
|
||||
import (
|
||||
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||
gwv1 "sigs.k8s.io/gateway-api/apis/v1"
|
||||
|
||||
"github.com/agentgateway/agentgateway/controller/api/v1alpha1/shared"
|
||||
)
|
||||
|
||||
// AIPromptEnrichment defines the config to enrich requests sent to the LLM provider by appending and prepending system prompts.
|
||||
@ -10,16 +12,18 @@ import (
|
||||
// Prompt enrichment allows you to add additional context to the prompt before sending it to the model.
|
||||
// Unlike RAG or other dynamic context methods, prompt enrichment is static and is applied to every request.
|
||||
//
|
||||
// **Note**: Some providers, including Anthropic, do not support SYSTEM role messages, and instead have a dedicated
|
||||
// system field in the input JSON. In this case, use the [`defaults` setting](#fielddefault) to set the system field.
|
||||
// **Note**: Some providers, including Anthropic, do not support `SYSTEM`
|
||||
// role messages, and instead have a dedicated `system` field in the input
|
||||
// JSON. In this case, use the [`defaults` setting](#fielddefault) to set the
|
||||
// `system` field.
|
||||
//
|
||||
// The following example prepends a system prompt of `Answer all questions in French.`
|
||||
// and appends `Describe the painting as if you were a famous art critic from the 17th century.`
|
||||
// to each request that is sent to the `openai` HTTPRoute.
|
||||
// ```yaml
|
||||
// The following example prepends a system prompt of
|
||||
// `Answer all questions in French.` and appends
|
||||
// `Describe the painting as if you were a famous art critic from the 17th century.`
|
||||
// to each request that is sent to the `openai` `HTTPRoute`.
|
||||
//
|
||||
// name: openai-opt
|
||||
// namespace: kgateway-system
|
||||
// namespace: agentgateway-system
|
||||
//
|
||||
// spec:
|
||||
//
|
||||
@ -35,8 +39,6 @@ import (
|
||||
// append:
|
||||
// - role: USER
|
||||
// content: "Describe the painting as if you were a famous art critic from the 17th century."
|
||||
//
|
||||
// ```
|
||||
type AIPromptEnrichment struct {
|
||||
// A list of messages to be prepended to the prompt sent by the client.
|
||||
// +optional
|
||||
@ -59,7 +61,7 @@ type Message struct {
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
// BuiltIn regex patterns for specific types of strings in prompts.
|
||||
// Built-in regex patterns for specific types of strings in prompts.
|
||||
// For example, if you specify `CreditCard`, any credit card numbers
|
||||
// in the request or response are matched.
|
||||
// +kubebuilder:validation:Enum=Ssn;CreditCard;PhoneNumber;Email;CaSin
|
||||
@ -83,7 +85,8 @@ const (
|
||||
)
|
||||
|
||||
// Action to take if a regex pattern is matched in a request or response.
|
||||
// This setting applies only to request matches. PromptguardResponse matches are always masked by default.
|
||||
// This setting applies only to request matches. `PromptguardResponse`
|
||||
// matches are always masked by default.
|
||||
// +kubebuilder:validation:Enum=Mask;Reject
|
||||
type Action string
|
||||
|
||||
@ -108,7 +111,8 @@ type Regex struct {
|
||||
Builtins []BuiltIn `json:"builtins,omitempty"`
|
||||
|
||||
// The action to take if a regex pattern is matched in a request or response.
|
||||
// This setting applies only to request matches. PromptguardResponse matches are always masked by default.
|
||||
// This setting applies only to request matches. `PromptguardResponse`
|
||||
// matches are always masked by default.
|
||||
// Defaults to `Mask`.
|
||||
// +kubebuilder:default=Mask
|
||||
// +optional
|
||||
@ -134,10 +138,10 @@ type Webhook struct {
|
||||
|
||||
// CustomResponse configures a response to return to the client if request content
|
||||
// is matched against a regex pattern and the action is `REJECT`.
|
||||
// +kubebuilder:validation:AtLeastOneOf=message;statusCode
|
||||
// +kubebuilder:validation:AtLeastOneFieldSet
|
||||
type CustomResponse struct {
|
||||
// A custom response message to return to the client. If not specified, defaults to
|
||||
// "The request was rejected due to inappropriate content".
|
||||
// `The request was rejected due to inappropriate content`.
|
||||
// +kubebuilder:default="The request was rejected due to inappropriate content"
|
||||
// +optional
|
||||
Message string `json:"message,omitempty"`
|
||||
@ -151,11 +155,12 @@ type CustomResponse struct {
|
||||
}
|
||||
|
||||
type OpenAIModeration struct {
|
||||
// model specifies the moderation model to use. For example, `omni-moderation`.
|
||||
// `model` specifies the moderation model to use. For example,
|
||||
// `omni-moderation`.
|
||||
// +optional
|
||||
Model *string `json:"model,omitempty"`
|
||||
// policies controls policies for communicating with OpenAI.
|
||||
// +kubebuilder:validation:AtLeastOneOf=tcp;tls;http;auth
|
||||
// +kubebuilder:validation:AtLeastOneFieldSet
|
||||
// +optional
|
||||
Policies *BackendSimple `json:"policies,omitempty"`
|
||||
}
|
||||
@ -169,12 +174,13 @@ type BedrockGuardrails struct {
|
||||
// +required
|
||||
GuardrailVersion ShortString `json:"version"`
|
||||
|
||||
// Region is the AWS region where the guardrail is deployed (e.g., "us-west-2").
|
||||
// Region is the AWS region where the guardrail is deployed (for example,
|
||||
// `us-west-2`).
|
||||
// +required
|
||||
Region ShortString `json:"region"`
|
||||
|
||||
// policies controls policies for communicating with AWS Bedrock Guardrails.
|
||||
// +kubebuilder:validation:AtLeastOneOf=tcp;tls;http;auth
|
||||
// +kubebuilder:validation:AtLeastOneFieldSet
|
||||
// +optional
|
||||
Policies *BackendSimple `json:"policies,omitempty"`
|
||||
}
|
||||
@ -188,14 +194,14 @@ type GoogleModelArmor struct {
|
||||
// +required
|
||||
ProjectID ShortString `json:"projectId"`
|
||||
|
||||
// Location is the Google Cloud location (e.g., "us-central1").
|
||||
// Defaults to "us-central1" if not specified.
|
||||
// Location is the Google Cloud location (for example, `us-central1`).
|
||||
// Defaults to `us-central1` if not specified.
|
||||
// +kubebuilder:default="us-central1"
|
||||
// +optional
|
||||
Location *ShortString `json:"location,omitempty"`
|
||||
|
||||
// policies controls policies for communicating with Google Model Armor.
|
||||
// +kubebuilder:validation:AtLeastOneOf=tcp;tls;http;auth
|
||||
// +kubebuilder:validation:AtLeastOneFieldSet
|
||||
// +optional
|
||||
Policies *BackendSimple `json:"policies,omitempty"`
|
||||
}
|
||||
@ -204,7 +210,7 @@ type GoogleModelArmor struct {
|
||||
// +kubebuilder:validation:ExactlyOneOf=regex;webhook;openAIModeration;bedrockGuardrails;googleModelArmor
|
||||
type PromptguardRequest struct {
|
||||
// A custom response message to return to the client. If not specified, defaults to
|
||||
// "The request was rejected due to inappropriate content".
|
||||
// `The request was rejected due to inappropriate content`.
|
||||
// +optional
|
||||
CustomResponse *CustomResponse `json:"response,omitempty"`
|
||||
|
||||
@ -216,16 +222,18 @@ type PromptguardRequest struct {
|
||||
// +optional
|
||||
Webhook *Webhook `json:"webhook,omitempty"`
|
||||
|
||||
// openAIModeration passes prompt data through the OpenAI Moderations endpoint.
|
||||
// See https://platform.openai.com/docs/api-reference/moderations for more information.
|
||||
// `openAIModeration` passes prompt data through the OpenAI Moderations
|
||||
// endpoint.
|
||||
// See https://developers.openai.com/api/reference/resources/moderations for more information.
|
||||
// +optional
|
||||
OpenAIModeration *OpenAIModeration `json:"openAIModeration,omitempty"`
|
||||
|
||||
// bedrockGuardrails configures AWS Bedrock Guardrails for prompt guarding.
|
||||
// `bedrockGuardrails` configures AWS Bedrock Guardrails for prompt
|
||||
// guarding.
|
||||
// +optional
|
||||
BedrockGuardrails *BedrockGuardrails `json:"bedrockGuardrails,omitempty"`
|
||||
|
||||
// googleModelArmor configures Google Model Armor for prompt guarding.
|
||||
// `googleModelArmor` configures Google Model Armor for prompt guarding.
|
||||
// +optional
|
||||
GoogleModelArmor *GoogleModelArmor `json:"googleModelArmor,omitempty"`
|
||||
}
|
||||
@ -234,7 +242,7 @@ type PromptguardRequest struct {
|
||||
// +kubebuilder:validation:ExactlyOneOf=regex;webhook;bedrockGuardrails;googleModelArmor
|
||||
type PromptguardResponse struct {
|
||||
// A custom response message to return to the client. If not specified, defaults to
|
||||
// "The response was rejected due to inappropriate content".
|
||||
// `The response was rejected due to inappropriate content`.
|
||||
// +optional
|
||||
CustomResponse *CustomResponse `json:"response,omitempty"`
|
||||
|
||||
@ -246,11 +254,12 @@ type PromptguardResponse struct {
|
||||
// +optional
|
||||
Webhook *Webhook `json:"webhook,omitempty"`
|
||||
|
||||
// bedrockGuardrails configures AWS Bedrock Guardrails for prompt guarding.
|
||||
// `bedrockGuardrails` configures AWS Bedrock Guardrails for prompt
|
||||
// guarding.
|
||||
// +optional
|
||||
BedrockGuardrails *BedrockGuardrails `json:"bedrockGuardrails,omitempty"`
|
||||
|
||||
// googleModelArmor configures Google Model Armor for prompt guarding.
|
||||
// `googleModelArmor` configures Google Model Armor for prompt guarding.
|
||||
// +optional
|
||||
GoogleModelArmor *GoogleModelArmor `json:"googleModelArmor,omitempty"`
|
||||
}
|
||||
@ -261,25 +270,23 @@ type PromptguardResponse struct {
|
||||
//
|
||||
// This example rejects any request prompts that contain
|
||||
// the string "credit card", and masks any credit card numbers in the response.
|
||||
// ```yaml
|
||||
// promptGuard:
|
||||
//
|
||||
// request:
|
||||
// - response:
|
||||
// message: "Rejected due to inappropriate content"
|
||||
// regex:
|
||||
// action: REJECT
|
||||
// matches:
|
||||
// - pattern: "credit card"
|
||||
// name: "CC"
|
||||
// response:
|
||||
// - regex:
|
||||
// builtins:
|
||||
// - CREDIT_CARD
|
||||
// action: MASK
|
||||
// promptGuard:
|
||||
// request:
|
||||
// - response:
|
||||
// message: "Rejected due to inappropriate content"
|
||||
// regex:
|
||||
// action: REJECT
|
||||
// matches:
|
||||
// - pattern: "credit card"
|
||||
// name: "CC"
|
||||
// response:
|
||||
// - regex:
|
||||
// builtins:
|
||||
// - CREDIT_CARD
|
||||
// action: MASK
|
||||
//
|
||||
// ```
|
||||
// +kubebuilder:validation:AtLeastOneOf=request;response
|
||||
// +kubebuilder:validation:AtLeastOneFieldSet
|
||||
type AIPromptGuard struct {
|
||||
// Prompt guards to apply to requests sent by the client.
|
||||
// +kubebuilder:validation:MinItems=1
|
||||
@ -301,35 +308,29 @@ type AIPromptGuard struct {
|
||||
// Defaults set here do _not_ override those user-provided values unless you explicitly set `override` to `true`.
|
||||
//
|
||||
// Example: Setting a default system field for Anthropic, which does not support system role messages:
|
||||
// ```yaml
|
||||
// defaults:
|
||||
// - field: "system"
|
||||
// value: "answer all questions in French"
|
||||
//
|
||||
// ```
|
||||
// defaults:
|
||||
// - field: "system"
|
||||
// value: "answer all questions in French"
|
||||
//
|
||||
// Example: Setting a default temperature and overriding `max_tokens`:
|
||||
// ```yaml
|
||||
// defaults:
|
||||
// - field: "temperature"
|
||||
// value: "0.5"
|
||||
// - field: "max_tokens"
|
||||
// value: "100"
|
||||
// override: true
|
||||
//
|
||||
// ```
|
||||
// defaults:
|
||||
// - field: "temperature"
|
||||
// value: "0.5"
|
||||
// - field: "max_tokens"
|
||||
// value: "100"
|
||||
// override: true
|
||||
//
|
||||
// Example: Setting custom lists fields:
|
||||
// ```yaml
|
||||
// defaults:
|
||||
// - field: "custom_integer_list"
|
||||
// value: [1,2,3]
|
||||
//
|
||||
// overrides:
|
||||
// - field: "custom_string_list"
|
||||
// value: ["one","two","three"]
|
||||
// defaults:
|
||||
// - field: "custom_integer_list"
|
||||
// value: [1,2,3]
|
||||
//
|
||||
// ```
|
||||
// overrides:
|
||||
// - field: "custom_string_list"
|
||||
// value: ["one","two","three"]
|
||||
//
|
||||
// Note: The `field` values correspond to keys in the JSON request body, not fields in this CRD.
|
||||
type FieldDefault struct {
|
||||
@ -344,6 +345,20 @@ type FieldDefault struct {
|
||||
Value apiextensionsv1.JSON `json:"value"`
|
||||
}
|
||||
|
||||
// FieldTransformation maps a request JSON field to a CEL expression string.
|
||||
// The expression is evaluated against the current request body and its result
|
||||
// is assigned to the configured field.
|
||||
type FieldTransformation struct {
|
||||
// The name of the field to set.
|
||||
// +kubebuilder:validation:MinLength=1
|
||||
// +required
|
||||
Field ShortString `json:"field"`
|
||||
|
||||
// CEL expression used to compute the field value.
|
||||
// +required
|
||||
Expression shared.CELExpression `json:"expression"`
|
||||
}
|
||||
|
||||
// PromptCachingConfig configures automatic prompt caching for supported LLM providers.
|
||||
// Currently only AWS Bedrock supports this feature (Claude 3+ and Nova models).
|
||||
//
|
||||
@ -353,10 +368,9 @@ type FieldDefault struct {
|
||||
// Example:
|
||||
//
|
||||
// promptCaching:
|
||||
// cacheSystem: true # Cache system prompts
|
||||
// cacheMessages: true # Cache conversation history
|
||||
// cacheTools: false # Don't cache tool definitions
|
||||
// minTokens: 1024 # Only cache if ≥1024 tokens
|
||||
// cacheSystem: true
|
||||
// cacheMessages: true
|
||||
// cacheTools: false
|
||||
//
|
||||
// Cost savings example:
|
||||
// - Without caching: 10,000 tokens × $3/MTok = $0.03
|
||||
@ -387,4 +401,13 @@ type PromptCachingConfig struct {
|
||||
// +kubebuilder:validation:Minimum=0
|
||||
// +kubebuilder:default=1024
|
||||
MinTokens int `json:"minTokens,omitempty"`
|
||||
|
||||
// CacheMessageOffset shifts the message cache point further back in the
|
||||
// conversation. 0 (default) places it at the second-to-last message.
|
||||
// Higher values move it N additional messages towards the start, clamped
|
||||
// to bounds.
|
||||
// +optional
|
||||
// +kubebuilder:validation:Minimum=0
|
||||
// +kubebuilder:default=0
|
||||
CacheMessageOffset int `json:"cacheMessageOffset,omitempty"`
|
||||
}
|
||||
|
||||
@ -3,44 +3,3 @@
|
||||
// +groupName=agentgateway.dev
|
||||
// +versionName=v1alpha1
|
||||
package agentgateway
|
||||
|
||||
// Gateway API resources with status management
|
||||
// +kubebuilder:rbac:groups=gateway.networking.k8s.io,resources=gatewayclasses;gateways;httproutes;grpcroutes;tcproutes;tlsroutes;referencegrants;backendtlspolicies,verbs=get;list;watch
|
||||
// +kubebuilder:rbac:groups=gateway.networking.x-k8s.io,resources=xlistenersets,verbs=get;list;watch
|
||||
// +kubebuilder:rbac:groups=gateway.networking.k8s.io,resources=gatewayclasses/status;gateways/status;httproutes/status;grpcroutes/status;tcproutes/status;tlsroutes/status;backendtlspolicies/status,verbs=patch;update
|
||||
// +kubebuilder:rbac:groups=gateway.networking.x-k8s.io,resources=xlistenersets/status,verbs=patch;update
|
||||
// +kubebuilder:rbac:groups=gateway.networking.k8s.io,resources=gatewayclasses,verbs=create;patch;update
|
||||
|
||||
// Controller resources
|
||||
// +kubebuilder:rbac:groups="",resources=pods,verbs=get;list;watch
|
||||
// +kubebuilder:rbac:groups="",resources=nodes,verbs=get;list;watch
|
||||
// +kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch
|
||||
// +kubebuilder:rbac:groups="",resources=namespaces,verbs=get;list;watch
|
||||
// +kubebuilder:rbac:groups="",resources=endpoints,verbs=get;list;watch
|
||||
|
||||
// jwks store controller that require extra permissions
|
||||
// +kubebuilder:rbac:groups="",resources=configmaps,verbs=get;list;watch;create;patch;update;delete
|
||||
|
||||
// Proxy deployer resources that require extra permissions
|
||||
// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;create;patch;update;delete
|
||||
// +kubebuilder:rbac:groups="",resources=services,verbs=get;list;watch;create;patch;update;delete
|
||||
// +kubebuilder:rbac:groups="",resources=secrets;serviceaccounts,verbs=get;list;watch;create;patch;delete
|
||||
// +kubebuilder:rbac:groups="",resources=serviceaccounts,verbs=get;list;watch;create;patch;delete
|
||||
// +kubebuilder:rbac:groups=policy,resources=poddisruptionbudgets,verbs=get;list;watch;create;patch;update;delete
|
||||
// +kubebuilder:rbac:groups=autoscaling,resources=horizontalpodautoscalers,verbs=get;list;watch;create;patch;update;delete
|
||||
|
||||
// EDS discovery resources
|
||||
// +kubebuilder:rbac:groups=discovery.k8s.io,resources=endpointslices,verbs=get;list;watch
|
||||
|
||||
// CRD access for scheme registration
|
||||
// +kubebuilder:rbac:groups=apiextensions.k8s.io,resources=customresourcedefinitions,verbs=get;list;watch
|
||||
|
||||
// Istio resources for traffic management
|
||||
// +kubebuilder:rbac:groups=networking.istio.io,resources=destinationrules,verbs=get;list;watch
|
||||
// +kubebuilder:rbac:groups=networking.istio.io,resources=serviceentries,verbs=get;list;watch
|
||||
// +kubebuilder:rbac:groups=networking.istio.io,resources=workloadentries,verbs=get;list;watch
|
||||
// +kubebuilder:rbac:groups=security.istio.io,resources=authorizationpolicies,verbs=get;list;watch
|
||||
|
||||
// Leases for leader election
|
||||
// +kubebuilder:rbac:groups=coordination.k8s.io,resources=leases,verbs=get;create;update
|
||||
// +kubebuilder:rbac:groups="",resources=events,verbs=create;patch
|
||||
|
||||
@ -147,6 +147,11 @@ func (in *AccessLog) DeepCopyInto(out *AccessLog) {
|
||||
*out = new(LogTracingAttributes)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.Otlp != nil {
|
||||
in, out := &in.Otlp, &out.Otlp
|
||||
*out = new(OtlpAccessLog)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AccessLog.
|
||||
@ -319,6 +324,11 @@ func (in *AgentgatewayBackendSpec) DeepCopyInto(out *AgentgatewayBackendSpec) {
|
||||
*out = new(DynamicForwardProxyBackend)
|
||||
**out = **in
|
||||
}
|
||||
if in.Aws != nil {
|
||||
in, out := &in.Aws, &out.Aws
|
||||
*out = new(AwsBackend)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.Policies != nil {
|
||||
in, out := &in.Policies, &out.Policies
|
||||
*out = new(BackendFull)
|
||||
@ -694,6 +704,26 @@ func (in *AttributeAdd) DeepCopy() *AttributeAdd {
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *AwsAgentCoreBackend) DeepCopyInto(out *AwsAgentCoreBackend) {
|
||||
*out = *in
|
||||
if in.Qualifier != nil {
|
||||
in, out := &in.Qualifier, &out.Qualifier
|
||||
*out = new(string)
|
||||
**out = **in
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AwsAgentCoreBackend.
|
||||
func (in *AwsAgentCoreBackend) DeepCopy() *AwsAgentCoreBackend {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(AwsAgentCoreBackend)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *AwsAuth) DeepCopyInto(out *AwsAuth) {
|
||||
*out = *in
|
||||
@ -710,6 +740,62 @@ func (in *AwsAuth) DeepCopy() *AwsAuth {
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *AwsBackend) DeepCopyInto(out *AwsBackend) {
|
||||
*out = *in
|
||||
if in.AgentCore != nil {
|
||||
in, out := &in.AgentCore, &out.AgentCore
|
||||
*out = new(AwsAgentCoreBackend)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AwsBackend.
|
||||
func (in *AwsBackend) DeepCopy() *AwsBackend {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(AwsBackend)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *AzureAuth) DeepCopyInto(out *AzureAuth) {
|
||||
*out = *in
|
||||
out.SecretRef = in.SecretRef
|
||||
if in.ManagedIdentity != nil {
|
||||
in, out := &in.ManagedIdentity, &out.ManagedIdentity
|
||||
*out = new(AzureManagedIdentity)
|
||||
**out = **in
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureAuth.
|
||||
func (in *AzureAuth) DeepCopy() *AzureAuth {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(AzureAuth)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *AzureManagedIdentity) DeepCopyInto(out *AzureManagedIdentity) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureManagedIdentity.
|
||||
func (in *AzureManagedIdentity) DeepCopy() *AzureManagedIdentity {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(AzureManagedIdentity)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *AzureOpenAIConfig) DeepCopyInto(out *AzureOpenAIConfig) {
|
||||
*out = *in
|
||||
@ -762,6 +848,13 @@ func (in *BackendAI) DeepCopyInto(out *BackendAI) {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
if in.Transformations != nil {
|
||||
in, out := &in.Transformations, &out.Transformations
|
||||
*out = make([]FieldTransformation, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
if in.ModelAliases != nil {
|
||||
in, out := &in.ModelAliases, &out.ModelAliases
|
||||
*out = make(map[string]string, len(*in))
|
||||
@ -816,6 +909,11 @@ func (in *BackendAuth) DeepCopyInto(out *BackendAuth) {
|
||||
*out = new(AwsAuth)
|
||||
**out = **in
|
||||
}
|
||||
if in.Azure != nil {
|
||||
in, out := &in.Azure, &out.Azure
|
||||
*out = new(AzureAuth)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.GCP != nil {
|
||||
in, out := &in.GCP, &out.GCP
|
||||
*out = new(GcpAuth)
|
||||
@ -848,6 +946,41 @@ func (in *BackendAuthPassthrough) DeepCopy() *BackendAuthPassthrough {
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *BackendEviction) DeepCopyInto(out *BackendEviction) {
|
||||
*out = *in
|
||||
if in.Duration != nil {
|
||||
in, out := &in.Duration, &out.Duration
|
||||
*out = new(v1.Duration)
|
||||
**out = **in
|
||||
}
|
||||
if in.RestoreHealth != nil {
|
||||
in, out := &in.RestoreHealth, &out.RestoreHealth
|
||||
*out = new(int32)
|
||||
**out = **in
|
||||
}
|
||||
if in.ConsecutiveFailures != nil {
|
||||
in, out := &in.ConsecutiveFailures, &out.ConsecutiveFailures
|
||||
*out = new(int32)
|
||||
**out = **in
|
||||
}
|
||||
if in.HealthThreshold != nil {
|
||||
in, out := &in.HealthThreshold, &out.HealthThreshold
|
||||
*out = new(int32)
|
||||
**out = **in
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackendEviction.
|
||||
func (in *BackendEviction) DeepCopy() *BackendEviction {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(BackendEviction)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *BackendFull) DeepCopyInto(out *BackendFull) {
|
||||
*out = *in
|
||||
@ -942,11 +1075,26 @@ func (in *BackendSimple) DeepCopyInto(out *BackendSimple) {
|
||||
*out = new(BackendHTTP)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.Tunnel != nil {
|
||||
in, out := &in.Tunnel, &out.Tunnel
|
||||
*out = new(BackendTunnel)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.Transformation != nil {
|
||||
in, out := &in.Transformation, &out.Transformation
|
||||
*out = new(Transformation)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.Auth != nil {
|
||||
in, out := &in.Auth, &out.Auth
|
||||
*out = new(BackendAuth)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.Health != nil {
|
||||
in, out := &in.Health, &out.Health
|
||||
*out = new(Health)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackendSimple.
|
||||
@ -1033,6 +1181,22 @@ func (in *BackendTLS) DeepCopy() *BackendTLS {
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *BackendTunnel) DeepCopyInto(out *BackendTunnel) {
|
||||
*out = *in
|
||||
in.BackendRef.DeepCopyInto(&out.BackendRef)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackendTunnel.
|
||||
func (in *BackendTunnel) DeepCopy() *BackendTunnel {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(BackendTunnel)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *BackendWithAI) DeepCopyInto(out *BackendWithAI) {
|
||||
*out = *in
|
||||
@ -1054,27 +1218,6 @@ func (in *BackendWithAI) DeepCopy() *BackendWithAI {
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *BackendWithMCP) DeepCopyInto(out *BackendWithMCP) {
|
||||
*out = *in
|
||||
in.BackendSimple.DeepCopyInto(&out.BackendSimple)
|
||||
if in.MCP != nil {
|
||||
in, out := &in.MCP, &out.MCP
|
||||
*out = new(BackendMCP)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackendWithMCP.
|
||||
func (in *BackendWithMCP) DeepCopy() *BackendWithMCP {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(BackendWithMCP)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *BasicAuthentication) DeepCopyInto(out *BasicAuthentication) {
|
||||
*out = *in
|
||||
@ -1318,6 +1461,21 @@ func (in *FieldDefault) DeepCopy() *FieldDefault {
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FieldTransformation) DeepCopyInto(out *FieldTransformation) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FieldTransformation.
|
||||
func (in *FieldTransformation) DeepCopy() *FieldTransformation {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FieldTransformation)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Frontend) DeepCopyInto(out *Frontend) {
|
||||
*out = *in
|
||||
@ -1326,6 +1484,11 @@ func (in *Frontend) DeepCopyInto(out *Frontend) {
|
||||
*out = new(FrontendTCP)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.NetworkAuthorization != nil {
|
||||
in, out := &in.NetworkAuthorization, &out.NetworkAuthorization
|
||||
*out = new(shared.Authorization)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.TLS != nil {
|
||||
in, out := &in.TLS, &out.TLS
|
||||
*out = new(FrontendTLS)
|
||||
@ -1585,6 +1748,31 @@ func (in *HeaderTransformation) DeepCopy() *HeaderTransformation {
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Health) DeepCopyInto(out *Health) {
|
||||
*out = *in
|
||||
if in.UnhealthyCondition != nil {
|
||||
in, out := &in.UnhealthyCondition, &out.UnhealthyCondition
|
||||
*out = new(shared.CELExpression)
|
||||
**out = **in
|
||||
}
|
||||
if in.Eviction != nil {
|
||||
in, out := &in.Eviction, &out.Eviction
|
||||
*out = new(BackendEviction)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Health.
|
||||
func (in *Health) DeepCopy() *Health {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Health)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *HostnameRewrite) DeepCopyInto(out *HostnameRewrite) {
|
||||
*out = *in
|
||||
@ -1690,6 +1878,11 @@ func (in *JWTAuthentication) DeepCopyInto(out *JWTAuthentication) {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
if in.MCP != nil {
|
||||
in, out := &in.MCP, &out.MCP
|
||||
*out = new(JWTMCPConfig)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JWTAuthentication.
|
||||
@ -1702,6 +1895,33 @@ func (in *JWTAuthentication) DeepCopy() *JWTAuthentication {
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *JWTMCPConfig) DeepCopyInto(out *JWTMCPConfig) {
|
||||
*out = *in
|
||||
if in.ResourceMetadata != nil {
|
||||
in, out := &in.ResourceMetadata, &out.ResourceMetadata
|
||||
*out = make(map[string]apiextensionsv1.JSON, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = *val.DeepCopy()
|
||||
}
|
||||
}
|
||||
if in.Provider != nil {
|
||||
in, out := &in.Provider, &out.Provider
|
||||
*out = new(McpIDP)
|
||||
**out = **in
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JWTMCPConfig.
|
||||
func (in *JWTMCPConfig) DeepCopy() *JWTMCPConfig {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(JWTMCPConfig)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *JWTProvider) DeepCopyInto(out *JWTProvider) {
|
||||
*out = *in
|
||||
@ -1938,6 +2158,16 @@ func (in *McpSelector) DeepCopy() *McpSelector {
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *McpTarget) DeepCopyInto(out *McpTarget) {
|
||||
*out = *in
|
||||
if in.Host != nil {
|
||||
in, out := &in.Host, &out.Host
|
||||
*out = new(ShortString)
|
||||
**out = **in
|
||||
}
|
||||
if in.BackendRef != nil {
|
||||
in, out := &in.BackendRef, &out.BackendRef
|
||||
*out = new(corev1.LocalObjectReference)
|
||||
**out = **in
|
||||
}
|
||||
if in.Path != nil {
|
||||
in, out := &in.Path, &out.Path
|
||||
*out = new(LongString)
|
||||
@ -1950,7 +2180,7 @@ func (in *McpTarget) DeepCopyInto(out *McpTarget) {
|
||||
}
|
||||
if in.Policies != nil {
|
||||
in, out := &in.Policies, &out.Policies
|
||||
*out = new(BackendWithMCP)
|
||||
*out = new(BackendSimple)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
@ -2071,6 +2301,27 @@ func (in *OpenAIModeration) DeepCopy() *OpenAIModeration {
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *OtlpAccessLog) DeepCopyInto(out *OtlpAccessLog) {
|
||||
*out = *in
|
||||
in.BackendRef.DeepCopyInto(&out.BackendRef)
|
||||
if in.Path != nil {
|
||||
in, out := &in.Path, &out.Path
|
||||
*out = new(LongString)
|
||||
**out = **in
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OtlpAccessLog.
|
||||
func (in *OtlpAccessLog) DeepCopy() *OtlpAccessLog {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(OtlpAccessLog)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *PriorityGroup) DeepCopyInto(out *PriorityGroup) {
|
||||
*out = *in
|
||||
@ -2424,6 +2675,11 @@ func (in *Timeouts) DeepCopy() *Timeouts {
|
||||
func (in *Tracing) DeepCopyInto(out *Tracing) {
|
||||
*out = *in
|
||||
in.BackendRef.DeepCopyInto(&out.BackendRef)
|
||||
if in.Path != nil {
|
||||
in, out := &in.Path, &out.Path
|
||||
*out = new(LongString)
|
||||
**out = **in
|
||||
}
|
||||
if in.Attributes != nil {
|
||||
in, out := &in.Attributes, &out.Attributes
|
||||
*out = new(LogTracingAttributes)
|
||||
@ -2576,6 +2832,13 @@ func (in *Transform) DeepCopyInto(out *Transform) {
|
||||
*out = new(shared.CELExpression)
|
||||
**out = **in
|
||||
}
|
||||
if in.Metadata != nil {
|
||||
in, out := &in.Metadata, &out.Metadata
|
||||
*out = make(map[string]shared.CELExpression, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Transform.
|
||||
|
||||
@ -29,34 +29,36 @@ type ObjectMetadata struct {
|
||||
// Overlays are applied **after** all typed configuration fields have been processed.
|
||||
// The full merge order is:
|
||||
//
|
||||
// 1. GatewayClass typed configuration fields (e.g., replicas, image settings from parametersRef)
|
||||
// 2. Gateway typed configuration fields (from infrastructure.parametersRef)
|
||||
// 3. GatewayClass overlays are applied
|
||||
// 4. Gateway overlays are applied
|
||||
// 1. `GatewayClass` typed configuration fields, for example replicas or image settings from `parametersRef`
|
||||
// 2. `Gateway` typed configuration fields from `infrastructure.parametersRef`
|
||||
// 3. `GatewayClass` overlays are applied
|
||||
// 4. `Gateway` overlays are applied
|
||||
//
|
||||
// This ordering means Gateway-level configuration overrides GatewayClass-level configuration
|
||||
// This ordering means `Gateway`-level configuration overrides
|
||||
// `GatewayClass`-level configuration
|
||||
// at each stage. For example, if both levels set the same label, the Gateway value wins.
|
||||
type KubernetesResourceOverlay struct {
|
||||
// metadata defines a subset of object metadata to be customized.
|
||||
// Labels and annotations are merged with existing values. If both GatewayClass
|
||||
// and Gateway parameters define the same label or annotation key, the Gateway
|
||||
// value takes precedence (applied second).
|
||||
// `metadata` defines a subset of object metadata to be customized.
|
||||
// `labels` and `annotations` are merged with existing values. If both
|
||||
// `GatewayClass` and `Gateway` parameters define the same label or
|
||||
// annotation key, the `Gateway` value takes precedence (applied second).
|
||||
// +optional
|
||||
Metadata *ObjectMetadata `json:"metadata,omitempty"`
|
||||
|
||||
// Spec provides an opaque mechanism to configure the resource Spec.
|
||||
// This field accepts a complete or partial Kubernetes resource spec (e.g., PodSpec, ServiceSpec)
|
||||
// and will be merged with the generated configuration using **Strategic Merge Patch** semantics.
|
||||
// `spec` provides an opaque mechanism to configure the resource spec.
|
||||
// This field accepts a complete or partial Kubernetes resource spec, such
|
||||
// as `PodSpec` or `ServiceSpec`, and will be merged with the generated
|
||||
// configuration using **Strategic Merge Patch** semantics.
|
||||
//
|
||||
// # Application Order
|
||||
//
|
||||
// Overlays are applied after all typed configuration fields from both levels.
|
||||
// The full merge order is:
|
||||
//
|
||||
// 1. GatewayClass typed configuration fields
|
||||
// 2. Gateway typed configuration fields
|
||||
// 3. GatewayClass overlays
|
||||
// 4. Gateway overlays (can override all previous values)
|
||||
// 1. `GatewayClass` typed configuration fields
|
||||
// 2. `Gateway` typed configuration fields
|
||||
// 3. `GatewayClass` overlays
|
||||
// 4. `Gateway` overlays (can override all previous values)
|
||||
//
|
||||
// # Strategic Merge Patch & Deletion Guide
|
||||
//
|
||||
@ -67,7 +69,8 @@ type KubernetesResourceOverlay struct {
|
||||
// Simple fields (strings, integers, booleans) in your config will overwrite the generated defaults.
|
||||
//
|
||||
// **2. Merging Lists (Append/Merge):**
|
||||
// Lists with "merge keys" (like `containers` which merges on `name`, or `tolerations` which merges on `key`)
|
||||
// Lists with "merge keys", like `containers` which merges on `name`, or
|
||||
// `tolerations` which merges on `key`,
|
||||
// will append your items to the generated list, or update existing items if keys match.
|
||||
//
|
||||
// **3. Deleting Fields or List Items ($patch: delete):**
|
||||
@ -76,6 +79,7 @@ type KubernetesResourceOverlay struct {
|
||||
// and is the recommended approach because it works with both client-side
|
||||
// and server-side apply.
|
||||
//
|
||||
//
|
||||
// spec:
|
||||
// template:
|
||||
// spec:
|
||||
@ -86,11 +90,12 @@ type KubernetesResourceOverlay struct {
|
||||
// nodeSelector:
|
||||
// $patch: delete
|
||||
// containers:
|
||||
// # Be sure to use the correct proxy name here or you will add a container instead of modifying a container:
|
||||
// - name: proxy-name
|
||||
// # Delete container-level securityContext
|
||||
// securityContext:
|
||||
// $patch: delete
|
||||
// # Be sure to use the correct proxy name here or you will add a
|
||||
// # container instead of modifying a container.
|
||||
// - name: proxy-name
|
||||
// # Delete container-level securityContext
|
||||
// securityContext:
|
||||
// $patch: delete
|
||||
//
|
||||
// **4. Null Values (server-side apply only):**
|
||||
// Setting a field to `null` can also remove it, but this ONLY works with
|
||||
@ -99,6 +104,7 @@ type KubernetesResourceOverlay struct {
|
||||
// the API server, so the deletion won't occur. Prefer `$patch: delete`
|
||||
// for consistent behavior across both apply modes.
|
||||
//
|
||||
//
|
||||
// spec:
|
||||
// template:
|
||||
// spec:
|
||||
@ -108,6 +114,7 @@ type KubernetesResourceOverlay struct {
|
||||
// To replace an entire map with your values (instead of merging), use `$patch: replace`.
|
||||
// This removes all existing keys and replaces them with only your specified keys.
|
||||
//
|
||||
//
|
||||
// spec:
|
||||
// template:
|
||||
// spec:
|
||||
@ -118,18 +125,19 @@ type KubernetesResourceOverlay struct {
|
||||
// **6. Replacing Lists Entirely ($patch: replace):**
|
||||
// If you want to strictly define a list and ignore all generated defaults, use `$patch: replace`.
|
||||
//
|
||||
//
|
||||
// service:
|
||||
// spec:
|
||||
// ports:
|
||||
// - $patch: replace
|
||||
// - name: http
|
||||
// port: 80
|
||||
// targetPort: 8080
|
||||
// protocol: TCP
|
||||
// - name: https
|
||||
// port: 443
|
||||
// targetPort: 8443
|
||||
// protocol: TCP
|
||||
// - $patch: replace
|
||||
// - name: http
|
||||
// port: 80
|
||||
// targetPort: 8080
|
||||
// protocol: TCP
|
||||
// - name: https
|
||||
// port: 443
|
||||
// targetPort: 8443
|
||||
// protocol: TCP
|
||||
//
|
||||
// +optional
|
||||
// +kubebuilder:validation:Type=object
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package shared
|
||||
|
||||
// PolicyConditionType is a type of condition for a policy. This type should be
|
||||
// used with a Policy resource Status.Conditions field.
|
||||
// used with a Policy resource `Status.Conditions` field.
|
||||
type PolicyConditionType string
|
||||
|
||||
// PolicyConditionReason is a reason for a policy condition.
|
||||
@ -10,44 +10,47 @@ type PolicyConditionReason string
|
||||
const (
|
||||
// PolicyConditionAccepted indicates whether the policy has been accepted or rejected, and why.
|
||||
//
|
||||
// Possible reasons for this condition to be True are:
|
||||
// * Valid
|
||||
// Possible reasons for this condition to be `True` are:
|
||||
// * `Valid`
|
||||
//
|
||||
// Possible reasons for this condition to be False are:
|
||||
// * Pending
|
||||
// * Invalid
|
||||
// Possible reasons for this condition to be `False` are:
|
||||
// * `Pending`
|
||||
// * `Invalid`
|
||||
//
|
||||
PolicyConditionAccepted PolicyConditionType = "Accepted"
|
||||
|
||||
// PolicyConditionAttached indicates whether the policy has attached to the targeted resources.
|
||||
//
|
||||
// Possible reasons for this condition to be True are:
|
||||
// * Attached
|
||||
// * Merged
|
||||
// Possible reasons for this condition to be `True` are:
|
||||
// * `Attached`
|
||||
// * `Merged`
|
||||
//
|
||||
// Possible reasons for this condition to be False are:
|
||||
// * Pending
|
||||
// * Overridden
|
||||
// Possible reasons for this condition to be `False` are:
|
||||
// * `Pending`
|
||||
// * `Overridden`
|
||||
//
|
||||
PolicyConditionAttached PolicyConditionType = "Attached"
|
||||
|
||||
// PolicyReasonValid is used with the "Accepted" condition when the policy
|
||||
// PolicyReasonValid is used with the `Accepted` condition when the policy
|
||||
// has been accepted by the system.
|
||||
PolicyReasonValid PolicyConditionReason = "Valid"
|
||||
|
||||
// PolicyReasonInvalid is used with the "Accepted" or "Attached" condition when the policy
|
||||
// is syntactically or semantically invalid.
|
||||
// PolicyReasonInvalid is used with the `Accepted` or `Attached` condition
|
||||
// when the policy is syntactically or semantically invalid.
|
||||
PolicyReasonInvalid PolicyConditionReason = "Invalid"
|
||||
|
||||
// PolicyReasonAttached is used with the "Attached" condition when the
|
||||
// PolicyReasonAttached is used with the `Attached` condition when the
|
||||
// policy has been successfully attached to all the targeted resources.
|
||||
PolicyReasonAttached PolicyConditionReason = "Attached"
|
||||
|
||||
// PolicyReasonPending is used with the "Accepted" or "Attached" condition when the policy has been referenced but not yet fully processed by the controller.
|
||||
// PolicyReasonPending is used with the `Accepted` or `Attached` condition
|
||||
// when the policy has been referenced but not yet fully processed by the
|
||||
// controller.
|
||||
PolicyReasonPending PolicyConditionReason = "Pending"
|
||||
|
||||
// PolicyReasonPartiallyValid is used with the "Accepted" condition when the policy has been accepted by the system,
|
||||
// but some of the referenced resources are not valid.
|
||||
// PolicyReasonPartiallyValid is used with the `Accepted` condition when the
|
||||
// policy has been accepted by the system, but some of the referenced
|
||||
// resources are not valid.
|
||||
PolicyReasonPartiallyValid PolicyConditionReason = "PartiallyValid"
|
||||
)
|
||||
|
||||
|
||||
@ -2,14 +2,22 @@ package shared
|
||||
|
||||
// Authorization defines the configuration for role-based access control.
|
||||
type Authorization struct {
|
||||
// Policy specifies the Authorization rule to evaluate.
|
||||
// A policy matches when **any** of the conditions evaluates to true.
|
||||
// `policy` specifies the authorization rule to evaluate.
|
||||
//
|
||||
// * For `Allow` rules: any policy allows the request.
|
||||
// * For `Require` rules: all policies must match for the request to be allowed.
|
||||
// * For `Deny` rules: any matching policy denies the request. Note: a CEL expression that fails to evaluate is not
|
||||
// considered to match, making this a risky policy; prefer to use `Require`.
|
||||
//
|
||||
// The presence of at least one `Allow` rule triggers a deny-by-default policy, requiring at least 1 match to allow.
|
||||
// With no rules, all requires are allowed.
|
||||
// +required
|
||||
Policy AuthorizationPolicy `json:"policy"`
|
||||
|
||||
// Action defines whether the rule allows or denies the request if matched.
|
||||
// If unspecified, the default is "Allow".
|
||||
// +kubebuilder:validation:Enum=Allow;Deny
|
||||
// `action` defines whether the rule allows, denies, or requires the request if
|
||||
// matched. If unspecified, the default is `Allow`.
|
||||
// Require policies are conjunctive across merged policies: all require policies must match.
|
||||
// +kubebuilder:validation:Enum=Allow;Deny;Require
|
||||
// +kubebuilder:default=Allow
|
||||
// +optional
|
||||
Action AuthorizationPolicyAction `json:"action,omitempty"`
|
||||
@ -21,10 +29,11 @@ type Authorization struct {
|
||||
// +k8s:deepcopy-gen=false
|
||||
type CELExpression string
|
||||
|
||||
// AuthorizationPolicy defines a single Authorization rule.
|
||||
// AuthorizationPolicy defines a single authorization rule.
|
||||
type AuthorizationPolicy struct {
|
||||
// MatchExpressions defines a set of conditions that must be satisfied for the rule to match.
|
||||
// These expression should be in the form of a Common Expression Language (CEL) expression.
|
||||
// These expressions should be in the form of a Common Expression Language
|
||||
// (`CEL`) expression.
|
||||
//
|
||||
// +kubebuilder:validation:MinItems=1
|
||||
// +kubebuilder:validation:MaxItems=256
|
||||
@ -32,12 +41,17 @@ type AuthorizationPolicy struct {
|
||||
MatchExpressions []CELExpression `json:"matchExpressions"`
|
||||
}
|
||||
|
||||
// AuthorizationPolicyAction defines the action to take when the RBACPolicies matches.
|
||||
// AuthorizationPolicyAction defines the action to take when the
|
||||
// `RBACPolicies` matches.
|
||||
type AuthorizationPolicyAction string
|
||||
|
||||
const (
|
||||
// AuthorizationPolicyActionAllow defines the action to take when the RBACPolicies matches.
|
||||
// AuthorizationPolicyActionAllow defines the action to take when the
|
||||
// `RBACPolicies` matches.
|
||||
AuthorizationPolicyActionAllow AuthorizationPolicyAction = "Allow"
|
||||
// AuthorizationPolicyActionDeny denies the action to take when the RBACPolicies matches.
|
||||
// AuthorizationPolicyActionDeny denies the action to take when the
|
||||
// `RBACPolicies` matches.
|
||||
AuthorizationPolicyActionDeny AuthorizationPolicyAction = "Deny"
|
||||
// AuthorizationPolicyActionRequire requires the action to take when the RBACPolicies matches.
|
||||
AuthorizationPolicyActionRequire AuthorizationPolicyAction = "Require"
|
||||
)
|
||||
|
||||
@ -8,7 +8,7 @@ import (
|
||||
// Control-plane Authorization rules not specific to policies:
|
||||
// +kubebuilder:rbac:groups=authentication.k8s.io,resources=tokenreviews,verbs=create
|
||||
|
||||
// Select the object by Name and Namespace.
|
||||
// Select the object by `name` and `namespace`.
|
||||
// You can target only one object at a time.
|
||||
type NamespacedObjectReference struct {
|
||||
// The name of the target resource.
|
||||
@ -21,7 +21,7 @@ type NamespacedObjectReference struct {
|
||||
Namespace *gwv1.Namespace `json:"namespace,omitempty"`
|
||||
}
|
||||
|
||||
// Select the object to attach the policy by Group, Kind, and Name.
|
||||
// Select the object to attach the policy by `Group`, `Kind`, and `Name`.
|
||||
// The object must be in the same namespace as the policy.
|
||||
// You can target only one object at a time.
|
||||
type LocalPolicyTargetReference struct {
|
||||
@ -30,8 +30,7 @@ type LocalPolicyTargetReference struct {
|
||||
// +required
|
||||
Group gwv1.Group `json:"group"`
|
||||
|
||||
// The API kind of the target resource,
|
||||
// such as Gateway or HTTPRoute.
|
||||
// The API kind of the target resource, such as `Gateway` or `HTTPRoute`.
|
||||
// +required
|
||||
Kind gwv1.Kind `json:"kind"`
|
||||
|
||||
@ -40,7 +39,8 @@ type LocalPolicyTargetReference struct {
|
||||
Name gwv1.ObjectName `json:"name"`
|
||||
}
|
||||
|
||||
// Select the object to attach the policy by Group, Kind, Name and SectionName.
|
||||
// Select the object to attach the policy by `Group`, `Kind`, `Name`, and
|
||||
// `SectionName`.
|
||||
// The object must be in the same namespace as the policy.
|
||||
// You can target only one object at a time.
|
||||
type LocalPolicyTargetReferenceWithSectionName struct {
|
||||
@ -51,20 +51,17 @@ type LocalPolicyTargetReferenceWithSectionName struct {
|
||||
SectionName *gwv1.SectionName `json:"sectionName,omitempty"`
|
||||
}
|
||||
|
||||
// LocalPolicyTargetSelector selects the object to attach the policy by Group, Kind, and MatchLabels.
|
||||
// LocalPolicyTargetSelector selects the object to attach the policy by
|
||||
// `Group`, `Kind`, and `MatchLabels`.
|
||||
// The object must be in the same namespace as the policy and match the
|
||||
// specified labels.
|
||||
// Do not use targetSelectors when reconciliation times are critical, especially if you
|
||||
// have a large number of policies that target the same resource.
|
||||
// Instead, use targetRefs to attach the policy.
|
||||
type LocalPolicyTargetSelector struct {
|
||||
// The API group of the target resource.
|
||||
// For Kubernetes Gateway API resources, the group is `gateway.networking.k8s.io`.
|
||||
// +required
|
||||
Group gwv1.Group `json:"group"`
|
||||
|
||||
// The API kind of the target resource,
|
||||
// such as Gateway or HTTPRoute.
|
||||
// The API kind of the target resource, such as `Gateway` or `HTTPRoute`.
|
||||
// +required
|
||||
Kind gwv1.Kind `json:"kind"`
|
||||
|
||||
@ -73,12 +70,14 @@ type LocalPolicyTargetSelector struct {
|
||||
MatchLabels map[string]string `json:"matchLabels"`
|
||||
}
|
||||
|
||||
// LocalPolicyTargetSelectorWithSectionName the object to attach the policy by Group, Kind, MatchLabels, and optionally SectionName.
|
||||
// LocalPolicyTargetSelectorWithSectionName selects the object to attach the
|
||||
// policy by `Group`, `Kind`, `MatchLabels`, and optionally `SectionName`.
|
||||
// The object must be in the same namespace as the policy and match the
|
||||
// specified labels.
|
||||
// Do not use targetSelectors when reconciliation times are critical, especially if you
|
||||
// Do not use `targetSelectors` when reconciliation times are critical,
|
||||
// especially if you
|
||||
// have a large number of policies that target the same resource.
|
||||
// Instead, use targetRefs to attach the policy.
|
||||
// Instead, use `targetRefs` to attach the policy.
|
||||
type LocalPolicyTargetSelectorWithSectionName struct {
|
||||
LocalPolicyTargetSelector `json:",inline"`
|
||||
|
||||
@ -108,17 +107,17 @@ type PolicyAncestorStatus struct {
|
||||
|
||||
// ControllerName is a domain/path string that indicates the name of the
|
||||
// controller that wrote this status. This corresponds with the
|
||||
// controllerName field on GatewayClass.
|
||||
// `controllerName` field on `GatewayClass`.
|
||||
//
|
||||
// Example: "example.net/gateway-controller".
|
||||
// Example: `example.net/gateway-controller`.
|
||||
//
|
||||
// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are
|
||||
// The format of this field is `DOMAIN "/" PATH`, where `DOMAIN` and `PATH` are
|
||||
// valid Kubernetes names
|
||||
// (https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names).
|
||||
//
|
||||
// Controllers MUST populate this field when writing status. Controllers should ensure that
|
||||
// entries to status populated with their ControllerName are cleaned up when they are no
|
||||
// longer necessary.
|
||||
// Controllers MUST populate this field when writing status. Controllers
|
||||
// should ensure that entries in status populated with their `ControllerName`
|
||||
// are cleaned up when they are no longer necessary.
|
||||
// +required
|
||||
ControllerName string `json:"controllerName"`
|
||||
|
||||
@ -136,24 +135,24 @@ type PolicyAncestorStatus struct {
|
||||
// +kubebuilder:validation:ExactlyOneOf=exact;prefix;suffix;contains;safeRegex
|
||||
type StringMatcher struct {
|
||||
// The input string must match exactly the string specified here.
|
||||
// Example: abc matches the value abc
|
||||
// Example: `abc` matches the value `abc`.
|
||||
// +optional
|
||||
Exact *string `json:"exact,omitempty"`
|
||||
|
||||
// The input string must have the prefix specified here.
|
||||
// Note: empty prefix is not allowed, please use regex instead.
|
||||
// Example: abc matches the value abc.xyz
|
||||
// Example: `abc` matches the value `abc.xyz`.
|
||||
// +optional
|
||||
Prefix *string `json:"prefix,omitempty"`
|
||||
|
||||
// The input string must have the suffix specified here.
|
||||
// Note: empty prefix is not allowed, please use regex instead.
|
||||
// Example: abc matches the value xyz.abc
|
||||
// Example: `abc` matches the value `xyz.abc`.
|
||||
// +optional
|
||||
Suffix *string `json:"suffix,omitempty"`
|
||||
|
||||
// The input string must contain the substring specified here.
|
||||
// Example: abc matches the value xyz.abc.def
|
||||
// Example: `abc` matches the value `xyz.abc.def`.
|
||||
// +optional
|
||||
Contains *string `json:"contains,omitempty"`
|
||||
|
||||
@ -171,7 +170,7 @@ type StringMatcher struct {
|
||||
}
|
||||
|
||||
// HeaderModifiers can be used to define the policy to modify request and response headers.
|
||||
// +kubebuilder:validation:AtLeastOneOf=request;response
|
||||
// +kubebuilder:validation:AtLeastOneFieldSet
|
||||
type HeaderModifiers struct {
|
||||
// Request modifies request headers.
|
||||
// +optional
|
||||
|
||||
@ -4,17 +4,19 @@ import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
type Timeouts struct {
|
||||
// Request specifies a timeout for an individual request from the gateway to a backend.
|
||||
// This spans between the point at which the entire downstream request (i.e. end-of-stream) has been
|
||||
// This spans between the point at which the entire downstream request
|
||||
// (i.e. end-of-stream) has been
|
||||
// processed and when the backend response has been completely processed.
|
||||
// A value of 0 effectively disables the timeout.
|
||||
// It is specified as a sequence of decimal numbers, each with optional fraction and a unit suffix, such as "1s" or "500ms".
|
||||
// A value of `0` effectively disables the timeout.
|
||||
// It is specified as a sequence of decimal numbers, each with optional
|
||||
// fraction and a unit suffix, such as `1s` or `500ms`.
|
||||
// +optional
|
||||
//
|
||||
// +kubebuilder:validation:XValidation:rule="matches(self, '^([0-9]{1,5}(h|m|s|ms)){1,4}$')",message="invalid duration value"
|
||||
Request *metav1.Duration `json:"request,omitempty"`
|
||||
|
||||
// StreamIdle specifies a timeout for a requests' idle streams.
|
||||
// A value of 0 effectively disables the timeout.
|
||||
// A value of `0` effectively disables the timeout.
|
||||
// +optional
|
||||
//
|
||||
// +kubebuilder:validation:XValidation:rule="matches(self, '^([0-9]{1,5}(h|m|s|ms)){1,4}$')",message="invalid duration value"
|
||||
|
||||
@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/kgateway/setup"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/setup"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/version"
|
||||
)
|
||||
|
||||
@ -20,7 +20,7 @@ func main() {
|
||||
fmt.Println(version.String())
|
||||
return nil
|
||||
}
|
||||
s, err := setup.New()
|
||||
s, err := setup.New(setup.Options{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("error setting up agentgateway: %w", err)
|
||||
}
|
||||
|
||||
@ -1,341 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o pipefail
|
||||
set -o nounset
|
||||
set -o errexit
|
||||
|
||||
# The GIE EPP used in e2e tests
|
||||
EPP_YAML_PATH="test/e2e/features/inferenceextension/testdata/epp.yaml"
|
||||
|
||||
# The base URLs for fetching CRDs
|
||||
GIE_CRD_BASE="https://raw.githubusercontent.com/kubernetes-sigs/gateway-api-inference-extension"
|
||||
GATEWAY_CRD_BASE="https://raw.githubusercontent.com/kubernetes-sigs/gateway-api"
|
||||
|
||||
# The Gateway API channel (experimental or stable)
|
||||
CONFORMANCE_CHANNEL="${CONFORMANCE_CHANNEL:-experimental}"
|
||||
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "Usage: $0 {gie|gtw} REF"
|
||||
echo " REF can be a tag (e.g. v1.3.0) or a commit SHA."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
kind="$1"; shift
|
||||
ref="$1"; shift
|
||||
|
||||
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
|
||||
echo "Bumping $kind to ref: $ref ..."
|
||||
|
||||
# Check the current module version
|
||||
case "$kind" in
|
||||
gie) module="sigs.k8s.io/gateway-api-inference-extension";;
|
||||
gtw) module="sigs.k8s.io/gateway-api";;
|
||||
*) echo "Unknown kind: $kind" >&2; exit 1;;
|
||||
set -euo pipefail
|
||||
[ $# -eq 2 ] || { echo "usage: $0 {gie|gtw} REF" >&2; exit 2; }
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
||||
case "$1" in
|
||||
gtw) kubectl kustomize "https://github.com/kubernetes-sigs/gateway-api/config/crd/experimental?ref=$2" > pkg/kgateway/crds/gateway-crds.yaml ;;
|
||||
gie) kubectl kustomize "https://github.com/kubernetes-sigs/gateway-api-inference-extension/config/crd?ref=$2" > pkg/kgateway/crds/inference-crds.yaml ;;
|
||||
*) echo "usage: $0 {gie|gtw} REF" >&2; exit 2 ;;
|
||||
esac
|
||||
|
||||
current_version="$(go list -m -f '{{.Version}}' "$module" 2>/dev/null || true)"
|
||||
|
||||
# Resolve desired ref to a module version (pseudo-version if ref is non-tag)
|
||||
resolved_version="$(
|
||||
go list -m -json "${module}@${ref}" 2>/dev/null \
|
||||
| sed -n 's/.*"Version": *"\([^"]*\)".*/\1/p'
|
||||
)"
|
||||
|
||||
if [ -z "${resolved_version}" ]; then
|
||||
echo "ERROR: Could not resolve ${module}@${ref} to a module version."
|
||||
echo " Verify the ref exists in the upstream repo."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Current version: ${current_version:-<none>}"
|
||||
echo "Desired version (resolved): ${resolved_version}"
|
||||
|
||||
# If already at the desired version, skip go get/mod tidy but still refresh CRDs.
|
||||
skip_get=0
|
||||
if [ -n "$current_version" ] && [ "$current_version" = "$resolved_version" ]; then
|
||||
echo "Already at ${resolved_version} - skipping dependency bump, refreshing CRDs..."
|
||||
skip_get=1
|
||||
fi
|
||||
|
||||
if [ $skip_get -eq 0 ]; then
|
||||
# Bump the module deps
|
||||
echo "Running: go get ${module}@${ref}"
|
||||
go get "${module}@${ref}"
|
||||
|
||||
echo "Running: go mod tidy"
|
||||
go mod tidy
|
||||
fi
|
||||
|
||||
# Update GIE_CRD_VERSION in files (for GIE bumps only) to the exact ref passed in.
|
||||
update_gie_crd_version_line() {
|
||||
# $1 = file path, $2 = mode ("mk" for Makefile-style, "sh" for shell)
|
||||
local file="$1"
|
||||
local mode="$2"
|
||||
if [ ! -f "$file" ]; then
|
||||
echo "WARN: $file not found, skipping"
|
||||
return 0
|
||||
fi
|
||||
echo "Setting GIE_CRD_VERSION to '${ref}' in $file"
|
||||
|
||||
if [ "$mode" = "mk" ]; then
|
||||
# If the var exists, replace its RHS (supports '=', '?=', '=').
|
||||
if grep -Eq '^[[:space:]]*GIE_CRD_VERSION[[:space:]]*([?:]?=)' "$file"; then
|
||||
sed -i.bak -E \
|
||||
-e 's|^([[:space:]]*GIE_CRD_VERSION[[:space:]]*[?:]?=)[[:space:]]*.*$|\1 '"$ref"'|g' \
|
||||
"$file"
|
||||
rm -f "$file.bak"
|
||||
else
|
||||
# Append a sane default form if not present.
|
||||
printf '\nGIE_CRD_VERSION ?= %s\n' "$ref" >> "$file"
|
||||
fi
|
||||
else
|
||||
# Shell-style assignment; replace the whole line if present, else append.
|
||||
if grep -Eq '^[[:space:]]*GIE_CRD_VERSION=' "$file"; then
|
||||
sed -i.bak -E \
|
||||
-e 's|^[[:space:]]*GIE_CRD_VERSION=.*$|GIE_CRD_VERSION="'"$ref"'"|g' \
|
||||
"$file"
|
||||
rm -f "$file.bak"
|
||||
else
|
||||
printf '\nGIE_CRD_VERSION="%s"\n' "$ref" >> "$file"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Helper: derive image tag from module version.
|
||||
# - For pseudo-versions that end with '...-YYYYMMDDHHMMSS-<sha>', produce 'vYYYYMMDD-<sha7>'
|
||||
# - Otherwise (e.g., semver tag), use the version itself as the image tag.
|
||||
derive_image_tag() {
|
||||
local ver="$1"
|
||||
# Match the trailing timestamp + sha anywhere at the end (robust for different pseudo-version bases)
|
||||
if [[ "$ver" =~ ([0-9]{14})-([0-9a-f]{7,40})$ ]]; then
|
||||
local ts="${BASH_REMATCH[1]}"
|
||||
local sha="${BASH_REMATCH[2]}"
|
||||
# Use YYYYMMDD and first 7 chars of sha
|
||||
echo "v${ts:0:8}-${sha:0:7}"
|
||||
else
|
||||
# Fall back to the version string itself (for true tags like v1.0.0 or v1.0.0-rc.2)
|
||||
echo "$ver"
|
||||
fi
|
||||
}
|
||||
|
||||
# Update e2e EPP image tag (GIE only)
|
||||
if [ "$kind" = gie ]; then
|
||||
img_tag="$(derive_image_tag "$resolved_version")"
|
||||
echo "Updating EPP image tag in $EPP_YAML_PATH to ${img_tag} (from module version: ${resolved_version})"
|
||||
# macOS/BSD-safe inline edit
|
||||
sed -i.bak -E \
|
||||
-e "s|(gateway-api-inference-extension/epp:)[^[:space:]\"]+|\1${img_tag}|g" \
|
||||
"$root/$EPP_YAML_PATH"
|
||||
rm -f "$root/$EPP_YAML_PATH.bak"
|
||||
|
||||
# Also update GIE_CRD_VERSION to the ref we were given (tag or SHA).
|
||||
update_gie_crd_version_line "$root/Makefile" "mk"
|
||||
if [ -f "$root/hack/kind/setup-kind.sh" ]; then
|
||||
update_gie_crd_version_line "$root/hack/kind/setup-kind.sh" "sh"
|
||||
elif [ -f "$root/kind/setup-kind.sh" ]; then
|
||||
update_gie_crd_version_line "$root/kind/setup-kind.sh" "sh"
|
||||
else
|
||||
echo "WARN: No setup-kind.sh found under hack/kind or kind/, skipping"
|
||||
fi
|
||||
fi
|
||||
|
||||
update_make_var_line() {
|
||||
local file="$1"
|
||||
local var="$2"
|
||||
local val="$3"
|
||||
|
||||
if [ ! -f "$file" ]; then
|
||||
echo "WARN: $file not found, skipping"
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "Setting ${var} to '${val}' in ${file}"
|
||||
|
||||
if grep -Eq "^[[:space:]]*${var}[[:space:]]*([?:]?=)" "$file"; then
|
||||
sed -i.bak -E \
|
||||
-e "s|^([[:space:]]*${var}[[:space:]]*[?:]?=)[[:space:]]*.*$|\1 ${val}|g" \
|
||||
"$file"
|
||||
rm -f "$file.bak"
|
||||
else
|
||||
printf '\n%s ?= %s\n' "$var" "$val" >> "$file"
|
||||
fi
|
||||
}
|
||||
|
||||
update_nightly_gateway_api_matrix_versions() {
|
||||
local file="$1"
|
||||
local old="$2"
|
||||
local new="$3"
|
||||
|
||||
if [ ! -f "$file" ]; then
|
||||
echo "WARN: $file not found, skipping"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Escape dots for ERE (good enough for vX.Y.Z / -rc.N)
|
||||
local old_esc="${old//./\\.}"
|
||||
|
||||
echo "Updating nightly-tests gateway-api matrix: ${old} -> ${new} in ${file}"
|
||||
sed -i.bak -E \
|
||||
-e "s|(version:[[:space:]]*')${old_esc}(')|\1${new}\2|g" \
|
||||
"$file"
|
||||
rm -f "$file.bak"
|
||||
}
|
||||
|
||||
# Fetch and store the CRDs
|
||||
crd_dir="$root/pkg/kgateway/crds"
|
||||
mkdir -p "$crd_dir"
|
||||
|
||||
if [ "$kind" = gie ]; then
|
||||
# Build a single all-in-one CRD file.
|
||||
outfile="${crd_dir}/inference-crds.yaml"
|
||||
tmpdir="$(mktemp -d)"
|
||||
trap 'rm -rf "$tmpdir"' EXIT
|
||||
|
||||
# Known CRDs/sources
|
||||
declare -a SOURCES=(
|
||||
"${GIE_CRD_BASE}/${ref}/config/crd/bases/inference.networking.k8s.io_inferencepools.yaml"
|
||||
"${GIE_CRD_BASE}/${ref}/config/crd/bases/inference.networking.x-k8s.io_inferenceobjectives.yaml"
|
||||
)
|
||||
|
||||
tmpout="$(mktemp)"
|
||||
: > "$tmpout"
|
||||
|
||||
for url in "${SOURCES[@]}"; do
|
||||
fname="$tmpdir/$(basename "$url")"
|
||||
echo "Fetching $url"
|
||||
curl -fsS "$url" -o "$fname"
|
||||
{
|
||||
echo "# Source: $url"
|
||||
cat "$fname"
|
||||
echo "---"
|
||||
} >> "$tmpout"
|
||||
done
|
||||
|
||||
# Remove the trailing '---' and any trailing blank lines
|
||||
# shellcheck disable=SC2016
|
||||
awk '{
|
||||
lines[NR]=$0
|
||||
} END {
|
||||
# drop trailing separators/blank lines
|
||||
i=NR
|
||||
while (i>0 && (lines[i] ~ /^---[[:space:]]*$/ || lines[i] ~ /^[[:space:]]*$/)) { i-- }
|
||||
for (j=1; j<=i; j++) print lines[j]
|
||||
}' "$tmpout" > "${tmpout}.trim"
|
||||
|
||||
mv -f "${tmpout}.trim" "$outfile"
|
||||
rm -f "$tmpout"
|
||||
echo "Wrote GIE all-in-one CRDs to $outfile"
|
||||
|
||||
elif [ "$kind" = gtw ]; then
|
||||
# Gateway API CRDs
|
||||
# Use release assets when ref resolves to a non-pseudo version (tags incl. -rc.*),
|
||||
# otherwise iterate files from the repo for pseudo-versions (timestamps/SHAs).
|
||||
|
||||
out_all="${crd_dir}/gateway-crds.yaml"
|
||||
|
||||
is_pseudo=0
|
||||
if [[ "$resolved_version" =~ ([0-9]{14})-([0-9a-f]{7,40})$ ]]; then
|
||||
is_pseudo=1
|
||||
fi
|
||||
|
||||
# Read current pinned conformance version from the Makefile (so we only replace “latest”)
|
||||
current_conf="$(
|
||||
sed -nE 's/^[[:space:]]*CONFORMANCE_VERSION[[:space:]]*[?:]?=[[:space:]]*([^[:space:]#]+).*$/\1/p' \
|
||||
"$root/Makefile" | head -n1
|
||||
)"
|
||||
|
||||
if [ $is_pseudo -eq 0 ]; then
|
||||
# Update Makefile pin
|
||||
update_make_var_line "$root/Makefile" "CONFORMANCE_VERSION" "$resolved_version"
|
||||
|
||||
# Update nightly-tests “latest” entries (the ones matching current_conf)
|
||||
if [ -n "${current_conf:-}" ]; then
|
||||
update_nightly_gateway_api_matrix_versions \
|
||||
"$root/.github/workflows/nightly-tests.yaml" \
|
||||
"$current_conf" \
|
||||
"$resolved_version"
|
||||
else
|
||||
echo "WARN: Could not parse current CONFORMANCE_VERSION from Makefile; skipping workflow update"
|
||||
fi
|
||||
else
|
||||
echo "WARN: Gateway API resolved to pseudo-version (${resolved_version}); leaving CONFORMANCE_VERSION and nightly matrix unchanged"
|
||||
fi
|
||||
|
||||
if [ $is_pseudo -eq 0 ]; then
|
||||
# Try to download prebuilt install manifest from the GitHub release
|
||||
if [ "${CONFORMANCE_CHANNEL}" = "experimental" ]; then
|
||||
asset="experimental-install.yaml"
|
||||
else
|
||||
asset="standard-install.yaml"
|
||||
fi
|
||||
release_url="https://github.com/kubernetes-sigs/gateway-api/releases/download/${resolved_version}/${asset}"
|
||||
echo "Attempting to fetch Gateway API release asset: ${release_url}"
|
||||
tmp_release="$(mktemp)"
|
||||
if curl -fLSs "${release_url}" -o "${tmp_release}"; then
|
||||
# Extra safety: ensure non-empty before replacing
|
||||
if [ -s "${tmp_release}" ]; then
|
||||
mv -f "${tmp_release}" "${out_all}"
|
||||
echo "Wrote Gateway (${CONFORMANCE_CHANNEL}) CRDs to ${out_all} from release asset"
|
||||
else
|
||||
echo "Release asset downloaded but empty; falling back to repo iteration for ${ref}"
|
||||
rm -f "${tmp_release}"
|
||||
is_pseudo=1
|
||||
fi
|
||||
else
|
||||
echo "Release asset not available (or download failed); falling back to repo iteration for ${ref}"
|
||||
rm -f "${tmp_release}"
|
||||
is_pseudo=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $is_pseudo -eq 1 ]; then
|
||||
# Fallback for pseudo-versions (or when release asset unavailable):
|
||||
# fetch all YAMLs under config/crd/${CONFORMANCE_CHANNEL} and concatenate.
|
||||
tmpdir="$(mktemp -d)"
|
||||
trap 'rm -rf "$tmpdir"' EXIT
|
||||
|
||||
archive_url="https://codeload.github.com/kubernetes-sigs/gateway-api/tar.gz/${ref}"
|
||||
echo "Downloading Gateway API archive: $archive_url"
|
||||
curl -fsSL "$archive_url" -o "$tmpdir/gtw.tar.gz"
|
||||
|
||||
echo "Extracting archive..."
|
||||
tar -xzf "$tmpdir/gtw.tar.gz" -C "$tmpdir"
|
||||
|
||||
srcdir="$(echo "$tmpdir"/gateway-api-*/config/crd/${CONFORMANCE_CHANNEL})"
|
||||
if [ ! -d "$srcdir" ]; then
|
||||
echo "ERROR: Could not find extracted CRD directory: $srcdir"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
tmp_all="$(mktemp)"
|
||||
: > "$tmp_all"
|
||||
echo "Building all-in-one CRD file at ${out_all} from ${srcdir}"
|
||||
# Concatenate in a stable order and include both x-k8s.io and k8s.io groups.
|
||||
for f in $(ls "$srcdir"/*.yaml | sort); do
|
||||
base="$(basename "$f")"
|
||||
echo "# Source: ${GATEWAY_CRD_BASE}/${ref}/config/crd/${CONFORMANCE_CHANNEL}/${base}" >> "$tmp_all"
|
||||
cat "$f" >> "$tmp_all"
|
||||
echo "---" >> "$tmp_all"
|
||||
done
|
||||
|
||||
# Trim trailing separators/blank lines
|
||||
awk '{
|
||||
lines[NR]=$0
|
||||
} END {
|
||||
i=NR
|
||||
while (i>0 && (lines[i] ~ /^---[[:space:]]*$/ || lines[i] ~ /^[[:space:]]*$/)) { i-- }
|
||||
for (j=1; j<=i; j++) print lines[j]
|
||||
}' "$tmp_all" > "${out_all}"
|
||||
rm -f "$tmp_all"
|
||||
echo "Wrote Gateway (${CONFORMANCE_CHANNEL}) all-in-one CRDs to $out_all"
|
||||
fi
|
||||
|
||||
# Final sanity: if ${out_all} exists but is empty, fail loudly
|
||||
if [ -e "${out_all}" ] && [ ! -s "${out_all}" ]; then
|
||||
echo "ERROR: ${out_all} is empty after CRD refresh. Please check the logs above."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "$kind bumped to ${resolved_version} (ref: ${ref}) successfully!"
|
||||
|
||||
882
controller/hack/crdgen/main.go
Normal file
882
controller/hack/crdgen/main.go
Normal file
@ -0,0 +1,882 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"go/ast"
|
||||
"go/types"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"slices"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/tools/go/packages"
|
||||
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"sigs.k8s.io/controller-tools/pkg/crd"
|
||||
crdmarkers "sigs.k8s.io/controller-tools/pkg/crd/markers"
|
||||
"sigs.k8s.io/controller-tools/pkg/loader"
|
||||
"sigs.k8s.io/controller-tools/pkg/markers"
|
||||
"sigs.k8s.io/yaml"
|
||||
)
|
||||
|
||||
const (
|
||||
atLeastOneFieldSetMarker = "kubebuilder:validation:AtLeastOneFieldSet"
|
||||
ifThenOnlyFieldsMarker = "kubebuilder:validation:IfThenOnlyFields"
|
||||
overrideXValidationMarker = "kubebuilder:validation:OverrideXValidation"
|
||||
controllerGenVersion = "v0.20.0"
|
||||
)
|
||||
|
||||
type pathList []string
|
||||
|
||||
func (p *pathList) String() string {
|
||||
return strings.Join(*p, ",")
|
||||
}
|
||||
|
||||
func (p *pathList) Set(value string) error {
|
||||
for part := range strings.SplitSeq(value, ",") {
|
||||
part = strings.TrimSpace(part)
|
||||
if part == "" {
|
||||
continue
|
||||
}
|
||||
*p = append(*p, part)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// +controllertools:marker:generateHelp:category="CRD validation"
|
||||
type AtLeastOneFieldSet struct {
|
||||
Fields []string `marker:",optional"`
|
||||
Exclude []string `marker:",optional"`
|
||||
Message string `marker:",optional"`
|
||||
}
|
||||
|
||||
// +controllertools:marker:generateHelp:category="CRD validation"
|
||||
type IfThenOnlyFields struct {
|
||||
If string
|
||||
Fields []string
|
||||
Message string `marker:",optional"`
|
||||
}
|
||||
|
||||
// +controllertools:marker:generateHelp:category="CRD validation"
|
||||
type OverrideXValidation struct {
|
||||
MessageContains string `marker:"messageContains"`
|
||||
Rule string `marker:",optional"`
|
||||
Message string `marker:",optional"`
|
||||
MessageExpression string `marker:"messageExpression,optional"`
|
||||
Reason string `marker:"reason,optional"`
|
||||
FieldPath string `marker:"fieldPath,optional"`
|
||||
OptionalOldSelf *bool `marker:"optionalOldSelf,optional"`
|
||||
}
|
||||
|
||||
func (m AtLeastOneFieldSet) ApplyToSchema(schema *apiextensionsv1.JSONSchemaProps) error {
|
||||
allFields := sortedPropertyNames(schema)
|
||||
if len(m.Fields) > 0 {
|
||||
allFields = dedupeAndSort(append(allFields, m.Fields...))
|
||||
}
|
||||
if len(m.Exclude) > 0 {
|
||||
allFields = dedupeAndSort(append(allFields, m.Exclude...))
|
||||
}
|
||||
return applyAtLeastOneFieldSet(schema, allFields, m)
|
||||
}
|
||||
|
||||
func (AtLeastOneFieldSet) ApplyPriority() crdmarkers.ApplyPriority {
|
||||
return crdmarkers.AtLeastOneOf{}.ApplyPriority() + 1
|
||||
}
|
||||
|
||||
func main() {
|
||||
var paths pathList
|
||||
outputDir := flag.String("output-dir", "", "directory to write CRD YAMLs")
|
||||
maxDescLen := flag.Int("max-desc-len", 0, "maximum description length (0 disables descriptions)")
|
||||
crdVersion := flag.String("crd-version", apiextensionsv1.SchemeGroupVersion.Version, "CRD API version")
|
||||
flag.Var(&paths, "path", "Go package path root to load (repeatable or comma-separated)")
|
||||
flag.Parse()
|
||||
|
||||
if *outputDir == "" {
|
||||
exitWithErr(fmt.Errorf("--output-dir is required"))
|
||||
}
|
||||
if len(paths) == 0 {
|
||||
exitWithErr(fmt.Errorf("at least one --path is required"))
|
||||
}
|
||||
|
||||
if err := os.MkdirAll(*outputDir, 0o755); err != nil {
|
||||
exitWithErr(fmt.Errorf("create output dir %q: %w", *outputDir, err))
|
||||
}
|
||||
|
||||
if err := generateCRDs(paths, *outputDir, *maxDescLen, *crdVersion); err != nil {
|
||||
exitWithErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
func exitWithErr(err error) {
|
||||
_, _ = fmt.Fprintf(os.Stderr, "custom CRD generation failed: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func generateCRDs(paths []string, outputDir string, maxDescLen int, crdVersion string) error {
|
||||
roots, err := loader.LoadRoots(paths...)
|
||||
if err != nil {
|
||||
return fmt.Errorf("load roots: %w", err)
|
||||
}
|
||||
|
||||
generator := &crd.Generator{}
|
||||
parser := &crd.Parser{
|
||||
Collector: &markers.Collector{Registry: &markers.Registry{}},
|
||||
Checker: &loader.TypeChecker{
|
||||
NodeFilters: []loader.NodeFilter{generator.CheckFilter()},
|
||||
},
|
||||
}
|
||||
|
||||
if err := generator.RegisterMarkers(parser.Collector.Registry); err != nil {
|
||||
return fmt.Errorf("register builtin markers: %w", err)
|
||||
}
|
||||
if err := registerCustomMarkers(parser.Collector.Registry); err != nil {
|
||||
return fmt.Errorf("register custom markers: %w", err)
|
||||
}
|
||||
|
||||
crd.AddKnownTypes(parser)
|
||||
for _, root := range roots {
|
||||
parser.NeedPackage(root)
|
||||
}
|
||||
|
||||
if err := populateInferredMarkerFields(parser); err != nil {
|
||||
return fmt.Errorf("populate inferred marker fields: %w", err)
|
||||
}
|
||||
metav1Pkg := crd.FindMetav1(roots)
|
||||
if metav1Pkg == nil {
|
||||
return fmt.Errorf("no objects in roots (nothing imported metav1)")
|
||||
}
|
||||
|
||||
kubeKinds := crd.FindKubeKinds(parser, metav1Pkg)
|
||||
if len(kubeKinds) == 0 {
|
||||
return fmt.Errorf("found zero Kubernetes kinds for paths: %s", strings.Join(paths, ", "))
|
||||
}
|
||||
|
||||
for _, groupKind := range kubeKinds {
|
||||
parser.NeedCRDFor(groupKind, &maxDescLen)
|
||||
crdRaw := parser.CustomResourceDefinitions[groupKind]
|
||||
if err := applyPostSchemaMarkersToCRD(parser, &crdRaw, groupKind); err != nil {
|
||||
return fmt.Errorf("apply post-schema markers to CRD %s/%s: %w", groupKind.Group, groupKind.Kind, err)
|
||||
}
|
||||
addAttribution(&crdRaw)
|
||||
crd.FixTopLevelMetadata(crdRaw)
|
||||
|
||||
converted, err := crd.AsVersion(crdRaw, schema.GroupVersion{Group: apiextensionsv1.SchemeGroupVersion.Group, Version: crdVersion})
|
||||
if err != nil {
|
||||
return fmt.Errorf("convert CRD %s/%s: %w", groupKind.Group, groupKind.Kind, err)
|
||||
}
|
||||
|
||||
crdV1, ok := converted.(*apiextensionsv1.CustomResourceDefinition)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected converted type %T", converted)
|
||||
}
|
||||
removeDescriptionFromMetadata(crdV1)
|
||||
|
||||
out, err := marshalCRD(crdV1)
|
||||
if err != nil {
|
||||
return fmt.Errorf("marshal CRD %s/%s: %w", groupKind.Group, groupKind.Kind, err)
|
||||
}
|
||||
|
||||
fileName := fmt.Sprintf("%s_%s.yaml", crdRaw.Spec.Group, crdRaw.Spec.Names.Plural)
|
||||
filePath := filepath.Join(outputDir, fileName)
|
||||
// nolint:gosec // G306: not relevant here
|
||||
if err := os.WriteFile(filePath, out, 0o644); err != nil {
|
||||
return fmt.Errorf("write CRD %q: %w", filePath, err)
|
||||
}
|
||||
}
|
||||
|
||||
if loader.PrintErrors(roots, packages.TypeError) {
|
||||
return fmt.Errorf("not all generators ran successfully")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func registerCustomMarkers(registry *markers.Registry) error {
|
||||
defs := []*markers.Definition{
|
||||
markers.Must(markers.MakeDefinition(atLeastOneFieldSetMarker, markers.DescribesType, AtLeastOneFieldSet{})),
|
||||
markers.Must(markers.MakeDefinition(ifThenOnlyFieldsMarker, markers.DescribesType, IfThenOnlyFields{})),
|
||||
markers.Must(markers.MakeDefinition(overrideXValidationMarker, markers.DescribesType, OverrideXValidation{})),
|
||||
}
|
||||
for _, def := range defs {
|
||||
if err := registry.Register(def); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func populateInferredMarkerFields(parser *crd.Parser) error {
|
||||
fieldCache := make(map[crd.TypeIdent][]string)
|
||||
inProgress := make(map[crd.TypeIdent]bool)
|
||||
|
||||
for typ, info := range parser.Types {
|
||||
needInferredFields := false
|
||||
for _, raw := range info.Markers[atLeastOneFieldSetMarker] {
|
||||
marker, err := asAtLeastOneFieldSet(raw)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s: %w", typ, err)
|
||||
}
|
||||
if len(marker.Fields) == 0 {
|
||||
needInferredFields = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !needInferredFields {
|
||||
continue
|
||||
}
|
||||
|
||||
inferredFields, err := allJSONFieldNamesForType(parser, typ, info, fieldCache, inProgress)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s: %w", typ, err)
|
||||
}
|
||||
|
||||
if markerVals, ok := info.Markers[atLeastOneFieldSetMarker]; ok {
|
||||
for i, raw := range markerVals {
|
||||
marker, err := asAtLeastOneFieldSet(raw)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s: %w", typ, err)
|
||||
}
|
||||
if len(marker.Fields) == 0 {
|
||||
marker.Fields = append([]string(nil), inferredFields...)
|
||||
markerVals[i] = marker
|
||||
}
|
||||
}
|
||||
info.Markers[atLeastOneFieldSetMarker] = markerVals
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func asAtLeastOneFieldSet(raw any) (AtLeastOneFieldSet, error) {
|
||||
switch marker := raw.(type) {
|
||||
case AtLeastOneFieldSet:
|
||||
return marker, nil
|
||||
case *AtLeastOneFieldSet:
|
||||
if marker == nil {
|
||||
return AtLeastOneFieldSet{}, fmt.Errorf("unexpected nil marker for %s", atLeastOneFieldSetMarker)
|
||||
}
|
||||
return *marker, nil
|
||||
default:
|
||||
return AtLeastOneFieldSet{}, fmt.Errorf("unexpected marker value %T for %s", raw, atLeastOneFieldSetMarker)
|
||||
}
|
||||
}
|
||||
|
||||
func asOverrideXValidation(raw any) (OverrideXValidation, error) {
|
||||
switch marker := raw.(type) {
|
||||
case OverrideXValidation:
|
||||
return marker, nil
|
||||
case *OverrideXValidation:
|
||||
if marker == nil {
|
||||
return OverrideXValidation{}, fmt.Errorf("unexpected nil marker for %s", overrideXValidationMarker)
|
||||
}
|
||||
return *marker, nil
|
||||
default:
|
||||
return OverrideXValidation{}, fmt.Errorf("unexpected marker value %T for %s", raw, overrideXValidationMarker)
|
||||
}
|
||||
}
|
||||
|
||||
func asIfThenOnlyFields(raw any) (IfThenOnlyFields, error) {
|
||||
switch marker := raw.(type) {
|
||||
case IfThenOnlyFields:
|
||||
return marker, nil
|
||||
case *IfThenOnlyFields:
|
||||
if marker == nil {
|
||||
return IfThenOnlyFields{}, fmt.Errorf("unexpected nil marker for %s", ifThenOnlyFieldsMarker)
|
||||
}
|
||||
return *marker, nil
|
||||
default:
|
||||
return IfThenOnlyFields{}, fmt.Errorf("unexpected marker value %T for %s", raw, ifThenOnlyFieldsMarker)
|
||||
}
|
||||
}
|
||||
|
||||
func applyAtLeastOneFieldSet(schema *apiextensionsv1.JSONSchemaProps, allFields []string, marker AtLeastOneFieldSet) error {
|
||||
fields, err := resolveFields(allFields, marker.Fields, marker.Exclude)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(fields) == 0 {
|
||||
return errors.New("AtLeastOneFieldSet resolved to zero fields")
|
||||
}
|
||||
|
||||
message := marker.Message
|
||||
if message == "" {
|
||||
message = fmt.Sprintf("at least one of the fields in %v must be set", fields)
|
||||
}
|
||||
|
||||
return crdmarkers.XValidation{
|
||||
Rule: fmt.Sprintf("%s >= 1", fieldsToOneOfCelRuleStr(fields)),
|
||||
Message: message,
|
||||
}.ApplyToSchema(schema)
|
||||
}
|
||||
|
||||
func applyIfThenOnlyFields(schema *apiextensionsv1.JSONSchemaProps, allFields []string, marker IfThenOnlyFields) error {
|
||||
if strings.TrimSpace(marker.If) == "" {
|
||||
return errors.New("IfThenOnlyFields requires 'if'")
|
||||
}
|
||||
if len(marker.Fields) == 0 {
|
||||
return errors.New("IfThenOnlyFields requires at least one field")
|
||||
}
|
||||
|
||||
allowedFields, err := validateFieldList(allFields, dedupeAndSort(marker.Fields), "fields")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
allowed := make(map[string]struct{}, len(allowedFields))
|
||||
for _, field := range allowedFields {
|
||||
allowed[field] = struct{}{}
|
||||
}
|
||||
|
||||
disallowedFields := make([]string, 0, len(allFields))
|
||||
for _, field := range allFields {
|
||||
if _, ok := allowed[field]; !ok {
|
||||
disallowedFields = append(disallowedFields, field)
|
||||
}
|
||||
}
|
||||
if len(disallowedFields) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
message := marker.Message
|
||||
if message == "" {
|
||||
message = fmt.Sprintf("only fields in %v may be set when %s", allowedFields, marker.If)
|
||||
}
|
||||
|
||||
return crdmarkers.XValidation{
|
||||
Rule: fmt.Sprintf("%s ? %s == 0 : true", marker.If, fieldsToOneOfCelRuleStr(disallowedFields)),
|
||||
Message: message,
|
||||
}.ApplyToSchema(schema)
|
||||
}
|
||||
|
||||
func applyOverrideXValidation(schema *apiextensionsv1.JSONSchemaProps, override OverrideXValidation) error {
|
||||
if strings.TrimSpace(override.MessageContains) == "" {
|
||||
return errors.New("OverrideXValidation requires messageContains")
|
||||
}
|
||||
|
||||
matches := make([]int, 0, 1)
|
||||
for i, validation := range schema.XValidations {
|
||||
if strings.Contains(validation.Message, override.MessageContains) {
|
||||
matches = append(matches, i)
|
||||
}
|
||||
}
|
||||
|
||||
if len(matches) != 1 {
|
||||
return fmt.Errorf("OverrideXValidation matched %d rules for messageContains %q, expected exactly 1", len(matches), override.MessageContains)
|
||||
}
|
||||
|
||||
if strings.TrimSpace(override.Rule) == "" {
|
||||
schema.XValidations = append(schema.XValidations[:matches[0]], schema.XValidations[matches[0]+1:]...)
|
||||
return nil
|
||||
}
|
||||
|
||||
replaced, err := overrideValidationRule(schema.XValidations[matches[0]], override)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
schema.XValidations[matches[0]] = replaced
|
||||
return nil
|
||||
}
|
||||
|
||||
func applyPostSchemaMarkersToCRD(parser *crd.Parser, crdObj *apiextensionsv1.CustomResourceDefinition, groupKind schema.GroupKind) error {
|
||||
for i := range crdObj.Spec.Versions {
|
||||
versionSpec := &crdObj.Spec.Versions[i]
|
||||
if versionSpec.Schema == nil || versionSpec.Schema.OpenAPIV3Schema == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
rootType, ok := rootTypeForCRDVersion(parser, groupKind, versionSpec.Name)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
inProgress := map[crd.TypeIdent]bool{}
|
||||
if err := applyPostSchemaMarkersForType(parser, rootType, versionSpec.Schema.OpenAPIV3Schema, inProgress); err != nil {
|
||||
return fmt.Errorf("%s: %w", rootType, err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func rootTypeForCRDVersion(parser *crd.Parser, groupKind schema.GroupKind, version string) (crd.TypeIdent, bool) {
|
||||
for pkg, gv := range parser.GroupVersions {
|
||||
if gv.Group != groupKind.Group || gv.Version != version {
|
||||
continue
|
||||
}
|
||||
|
||||
typ := crd.TypeIdent{
|
||||
Package: pkg,
|
||||
Name: groupKind.Kind,
|
||||
}
|
||||
if parser.LookupType(pkg, groupKind.Kind) != nil {
|
||||
return typ, true
|
||||
}
|
||||
}
|
||||
|
||||
return crd.TypeIdent{}, false
|
||||
}
|
||||
|
||||
func applyPostSchemaMarkersForType(
|
||||
parser *crd.Parser,
|
||||
typ crd.TypeIdent,
|
||||
schema *apiextensionsv1.JSONSchemaProps,
|
||||
inProgress map[crd.TypeIdent]bool,
|
||||
) error {
|
||||
if schema == nil {
|
||||
return nil
|
||||
}
|
||||
if inProgress[typ] {
|
||||
return nil
|
||||
}
|
||||
|
||||
info := parser.LookupType(typ.Package, typ.Name)
|
||||
if info == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
inProgress[typ] = true
|
||||
defer delete(inProgress, typ)
|
||||
|
||||
for _, field := range info.Fields {
|
||||
fieldName, inline, include := jsonFieldInfo(field.Tag)
|
||||
if !include {
|
||||
continue
|
||||
}
|
||||
|
||||
fieldType, ok := typeIdentForExpr(parser, typ.Package, field.RawField.Type)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
if inline {
|
||||
if err := applyPostSchemaMarkersForType(parser, fieldType, schema, inProgress); err != nil {
|
||||
return err
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
fieldSchema, ok := schema.Properties[fieldName]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if err := applyPostSchemaMarkersForType(parser, fieldType, &fieldSchema, inProgress); err != nil {
|
||||
return err
|
||||
}
|
||||
schema.Properties[fieldName] = fieldSchema
|
||||
}
|
||||
|
||||
if rawMarkers, ok := info.Markers[overrideXValidationMarker]; ok {
|
||||
for _, raw := range rawMarkers {
|
||||
marker, err := asOverrideXValidation(raw)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := applyOverrideXValidation(schema, marker); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if rawMarkers, ok := info.Markers[ifThenOnlyFieldsMarker]; ok {
|
||||
allFields := sortedPropertyNames(schema)
|
||||
for _, raw := range rawMarkers {
|
||||
marker, err := asIfThenOnlyFields(raw)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := applyIfThenOnlyFields(schema, allFields, marker); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resolveFields(allFields, includes, excludes []string) ([]string, error) {
|
||||
var err error
|
||||
includes, err = normalizeFieldList(includes, "fields")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
excludes, err = normalizeFieldList(excludes, "exclude")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(includes) > 0 {
|
||||
includes, err = validateFieldList(allFields, includes, "fields")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
if len(excludes) > 0 {
|
||||
excludes, err = validateFieldList(allFields, excludes, "exclude")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
if len(includes) == 0 {
|
||||
includes = append([]string(nil), allFields...)
|
||||
}
|
||||
|
||||
excluded := make(map[string]struct{}, len(excludes))
|
||||
for _, field := range excludes {
|
||||
excluded[field] = struct{}{}
|
||||
}
|
||||
|
||||
result := make([]string, 0, len(includes))
|
||||
for _, field := range includes {
|
||||
if _, ok := excluded[field]; !ok {
|
||||
result = append(result, field)
|
||||
}
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func normalizeFieldList(fields []string, listName string) ([]string, error) {
|
||||
fields = dedupeAndSort(fields)
|
||||
for _, field := range fields {
|
||||
if strings.Contains(field, ".") {
|
||||
return nil, fmt.Errorf("%s: cannot reference nested fields: %s", listName, strings.Join(fields, ","))
|
||||
}
|
||||
}
|
||||
return fields, nil
|
||||
}
|
||||
|
||||
func validateFieldList(allFields []string, fields []string, listName string) ([]string, error) {
|
||||
fields, err := normalizeFieldList(fields, listName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(fields) == 0 {
|
||||
return fields, nil
|
||||
}
|
||||
|
||||
all := make(map[string]struct{}, len(allFields))
|
||||
for _, name := range allFields {
|
||||
all[name] = struct{}{}
|
||||
}
|
||||
|
||||
for _, field := range fields {
|
||||
if _, ok := all[field]; !ok {
|
||||
return nil, fmt.Errorf("%s: unknown field %q", listName, field)
|
||||
}
|
||||
}
|
||||
|
||||
return fields, nil
|
||||
}
|
||||
|
||||
func dedupeAndSort(in []string) []string {
|
||||
if len(in) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
seen := make(map[string]struct{}, len(in))
|
||||
out := make([]string, 0, len(in))
|
||||
for _, v := range in {
|
||||
v = strings.TrimSpace(v)
|
||||
if v == "" {
|
||||
continue
|
||||
}
|
||||
if _, ok := seen[v]; ok {
|
||||
continue
|
||||
}
|
||||
seen[v] = struct{}{}
|
||||
out = append(out, v)
|
||||
}
|
||||
sort.Strings(out)
|
||||
return out
|
||||
}
|
||||
|
||||
func sortedPropertyNames(schema *apiextensionsv1.JSONSchemaProps) []string {
|
||||
namesSet := map[string]struct{}{}
|
||||
for name := range schema.Properties {
|
||||
namesSet[name] = struct{}{}
|
||||
}
|
||||
|
||||
var collect func(items []apiextensionsv1.JSONSchemaProps)
|
||||
collect = func(items []apiextensionsv1.JSONSchemaProps) {
|
||||
for _, item := range items {
|
||||
for name := range item.Properties {
|
||||
namesSet[name] = struct{}{}
|
||||
}
|
||||
if len(item.AllOf) > 0 {
|
||||
collect(item.AllOf)
|
||||
}
|
||||
}
|
||||
}
|
||||
collect(schema.AllOf)
|
||||
|
||||
names := make([]string, 0, len(namesSet))
|
||||
for name := range namesSet {
|
||||
names = append(names, name)
|
||||
}
|
||||
sort.Strings(names)
|
||||
return names
|
||||
}
|
||||
|
||||
func allJSONFieldNamesForType(
|
||||
parser *crd.Parser,
|
||||
typ crd.TypeIdent,
|
||||
info *markers.TypeInfo,
|
||||
fieldCache map[crd.TypeIdent][]string,
|
||||
inProgress map[crd.TypeIdent]bool,
|
||||
) ([]string, error) {
|
||||
if cached, ok := fieldCache[typ]; ok {
|
||||
return append([]string(nil), cached...), nil
|
||||
}
|
||||
|
||||
if inProgress[typ] {
|
||||
return nil, fmt.Errorf("%s: recursive inline embedding detected", typ)
|
||||
}
|
||||
|
||||
if _, isStruct := info.RawSpec.Type.(*ast.StructType); !isStruct {
|
||||
return nil, fmt.Errorf("%s marker is only supported on struct types", typ)
|
||||
}
|
||||
|
||||
inProgress[typ] = true
|
||||
defer delete(inProgress, typ)
|
||||
|
||||
fieldSet := map[string]struct{}{}
|
||||
for _, field := range info.Fields {
|
||||
fieldName, inline, include := jsonFieldInfo(field.Tag)
|
||||
if !include {
|
||||
continue
|
||||
}
|
||||
|
||||
if inline {
|
||||
embeddedType, ok := typeIdentForExpr(parser, typ.Package, field.RawField.Type)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
parser.NeedPackage(embeddedType.Package)
|
||||
embeddedInfo := parser.LookupType(embeddedType.Package, embeddedType.Name)
|
||||
if embeddedInfo == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
embeddedFields, err := allJSONFieldNamesForType(parser, embeddedType, embeddedInfo, fieldCache, inProgress)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, embeddedField := range embeddedFields {
|
||||
fieldSet[embeddedField] = struct{}{}
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
fieldSet[fieldName] = struct{}{}
|
||||
}
|
||||
|
||||
fields := make([]string, 0, len(fieldSet))
|
||||
for field := range fieldSet {
|
||||
fields = append(fields, field)
|
||||
}
|
||||
sort.Strings(fields)
|
||||
|
||||
fieldCache[typ] = fields
|
||||
return append([]string(nil), fields...), nil
|
||||
}
|
||||
|
||||
func jsonFieldInfo(tag reflect.StructTag) (name string, inline bool, include bool) {
|
||||
jsonTag, hasTag := tag.Lookup("json")
|
||||
if !hasTag {
|
||||
return "", false, false
|
||||
}
|
||||
|
||||
jsonOpts := strings.Split(jsonTag, ",")
|
||||
if len(jsonOpts) == 1 && jsonOpts[0] == "-" {
|
||||
return "", false, false
|
||||
}
|
||||
|
||||
if slices.Contains(jsonOpts[1:], "inline") {
|
||||
inline = true
|
||||
}
|
||||
|
||||
name = jsonOpts[0]
|
||||
inline = inline || name == ""
|
||||
if inline {
|
||||
return "", true, true
|
||||
}
|
||||
|
||||
return name, false, true
|
||||
}
|
||||
|
||||
func typeIdentForExpr(parser *crd.Parser, contextPkg *loader.Package, expr ast.Expr) (crd.TypeIdent, bool) {
|
||||
if contextPkg == nil {
|
||||
return crd.TypeIdent{}, false
|
||||
}
|
||||
|
||||
contextPkg.NeedTypesInfo()
|
||||
goType := contextPkg.TypesInfo.TypeOf(expr)
|
||||
if goType == nil {
|
||||
return crd.TypeIdent{}, false
|
||||
}
|
||||
|
||||
for {
|
||||
goType = types.Unalias(goType)
|
||||
|
||||
switch typed := goType.(type) {
|
||||
case *types.Pointer:
|
||||
goType = typed.Elem()
|
||||
case *types.Named:
|
||||
obj := typed.Obj()
|
||||
if obj == nil || obj.Pkg() == nil {
|
||||
return crd.TypeIdent{}, false
|
||||
}
|
||||
|
||||
typePkg := packageForPath(parser, contextPkg, obj.Pkg().Path())
|
||||
if typePkg == nil {
|
||||
return crd.TypeIdent{}, false
|
||||
}
|
||||
|
||||
return crd.TypeIdent{
|
||||
Package: typePkg,
|
||||
Name: obj.Name(),
|
||||
}, true
|
||||
default:
|
||||
return crd.TypeIdent{}, false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func packageForPath(parser *crd.Parser, contextPkg *loader.Package, pkgPath string) *loader.Package {
|
||||
targetPath := loader.NonVendorPath(pkgPath)
|
||||
if loader.NonVendorPath(contextPkg.PkgPath) == targetPath {
|
||||
return contextPkg
|
||||
}
|
||||
|
||||
if imported := contextPkg.Imports()[targetPath]; imported != nil {
|
||||
return imported
|
||||
}
|
||||
|
||||
for _, imported := range contextPkg.Imports() {
|
||||
if loader.NonVendorPath(imported.PkgPath) == targetPath {
|
||||
return imported
|
||||
}
|
||||
}
|
||||
|
||||
for typ := range parser.Types {
|
||||
if loader.NonVendorPath(typ.Package.PkgPath) == targetPath {
|
||||
return typ.Package
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func fieldsToOneOfCelRuleStr(fields []string) string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("[")
|
||||
for i, field := range fields {
|
||||
if i > 0 {
|
||||
builder.WriteString(",")
|
||||
}
|
||||
builder.WriteString("has(self.")
|
||||
builder.WriteString(field)
|
||||
builder.WriteString(")")
|
||||
}
|
||||
builder.WriteString("].filter(x,x==true).size()")
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
func overrideValidationRule(existing apiextensionsv1.ValidationRule, override OverrideXValidation) (apiextensionsv1.ValidationRule, error) {
|
||||
result := existing
|
||||
result.Rule = override.Rule
|
||||
if override.Message != "" {
|
||||
result.Message = override.Message
|
||||
}
|
||||
if override.MessageExpression != "" {
|
||||
result.MessageExpression = override.MessageExpression
|
||||
}
|
||||
if override.Reason != "" {
|
||||
switch override.Reason {
|
||||
case string(apiextensionsv1.FieldValueRequired), string(apiextensionsv1.FieldValueInvalid), string(apiextensionsv1.FieldValueForbidden), string(apiextensionsv1.FieldValueDuplicate):
|
||||
reason := apiextensionsv1.FieldValueErrorReason(override.Reason)
|
||||
result.Reason = &reason
|
||||
default:
|
||||
return apiextensionsv1.ValidationRule{}, fmt.Errorf("invalid reason %s, valid values are %s, %s, %s and %s", override.Reason, apiextensionsv1.FieldValueRequired, apiextensionsv1.FieldValueInvalid, apiextensionsv1.FieldValueForbidden, apiextensionsv1.FieldValueDuplicate)
|
||||
}
|
||||
}
|
||||
if override.FieldPath != "" {
|
||||
result.FieldPath = override.FieldPath
|
||||
}
|
||||
if override.OptionalOldSelf != nil {
|
||||
result.OptionalOldSelf = override.OptionalOldSelf
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func addAttribution(crd *apiextensionsv1.CustomResourceDefinition) {
|
||||
if crd.ObjectMeta.Annotations == nil {
|
||||
crd.ObjectMeta.Annotations = map[string]string{}
|
||||
}
|
||||
crd.ObjectMeta.Annotations["controller-gen.kubebuilder.io/version"] = controllerGenVersion
|
||||
}
|
||||
|
||||
func removeDescriptionFromMetadata(crd *apiextensionsv1.CustomResourceDefinition) {
|
||||
for _, versionSpec := range crd.Spec.Versions {
|
||||
if versionSpec.Schema != nil {
|
||||
removeDescriptionFromMetadataProps(versionSpec.Schema.OpenAPIV3Schema)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func removeDescriptionFromMetadataProps(schema *apiextensionsv1.JSONSchemaProps) {
|
||||
metadataSchema, ok := schema.Properties["metadata"]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if metadataSchema.Description == "" {
|
||||
return
|
||||
}
|
||||
metadataSchema.Description = ""
|
||||
schema.Properties["metadata"] = metadataSchema
|
||||
}
|
||||
|
||||
func marshalCRD(crd *apiextensionsv1.CustomResourceDefinition) ([]byte, error) {
|
||||
type output struct {
|
||||
APIVersion string `json:"apiVersion"`
|
||||
Kind string `json:"kind"`
|
||||
Metadata map[string]any `json:"metadata,omitempty"`
|
||||
Spec apiextensionsv1.CustomResourceDefinitionSpec `json:"spec"`
|
||||
}
|
||||
|
||||
metadataBytes, err := yaml.Marshal(crd.ObjectMeta)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
metadata := map[string]any{}
|
||||
if err := yaml.Unmarshal(metadataBytes, &metadata); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
delete(metadata, "creationTimestamp")
|
||||
|
||||
out, err := yaml.Marshal(output{
|
||||
APIVersion: crd.APIVersion,
|
||||
Kind: crd.Kind,
|
||||
Metadata: metadata,
|
||||
Spec: crd.Spec,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if bytes.HasPrefix(out, []byte("---\n")) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
return append([]byte("---\n"), out...), nil
|
||||
}
|
||||
188
controller/hack/crdgen/main_test.go
Normal file
188
controller/hack/crdgen/main_test.go
Normal file
@ -0,0 +1,188 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||
"sigs.k8s.io/controller-tools/pkg/crd"
|
||||
"sigs.k8s.io/controller-tools/pkg/loader"
|
||||
"sigs.k8s.io/controller-tools/pkg/markers"
|
||||
)
|
||||
|
||||
func newTestParser(t *testing.T, rootPath string) ([]*loader.Package, *crd.Parser) {
|
||||
t.Helper()
|
||||
|
||||
roots, err := loader.LoadRoots(rootPath)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, roots, 1)
|
||||
|
||||
generator := &crd.Generator{}
|
||||
parser := &crd.Parser{
|
||||
Collector: &markers.Collector{Registry: &markers.Registry{}},
|
||||
Checker: &loader.TypeChecker{
|
||||
NodeFilters: []loader.NodeFilter{generator.CheckFilter()},
|
||||
},
|
||||
}
|
||||
require.NoError(t, generator.RegisterMarkers(parser.Collector.Registry))
|
||||
require.NoError(t, registerCustomMarkers(parser.Collector.Registry))
|
||||
crd.AddKnownTypes(parser)
|
||||
parser.NeedPackage(roots[0])
|
||||
|
||||
return roots, parser
|
||||
}
|
||||
|
||||
func TestAllJSONFieldNamesForTypeIncludesImportedInlineFields(t *testing.T) {
|
||||
const rootPath = "github.com/agentgateway/agentgateway/controller/hack/crdgen/testdata/root"
|
||||
|
||||
roots, parser := newTestParser(t, rootPath)
|
||||
|
||||
typ := crd.TypeIdent{
|
||||
Package: roots[0],
|
||||
Name: "Wrapper",
|
||||
}
|
||||
info := parser.LookupType(typ.Package, typ.Name)
|
||||
require.NotNil(t, info)
|
||||
|
||||
fields, err := allJSONFieldNamesForType(parser, typ, info, map[crd.TypeIdent][]string{}, map[crd.TypeIdent]bool{})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []string{"bar", "baz", "foo"}, fields)
|
||||
}
|
||||
|
||||
func TestOverrideXValidationReplacesExactlyOneMatch(t *testing.T) {
|
||||
schema := &apiextensionsv1.JSONSchemaProps{
|
||||
XValidations: []apiextensionsv1.ValidationRule{
|
||||
{
|
||||
Rule: "old-rule",
|
||||
Message: "phase PreRouting only supports extAuth",
|
||||
},
|
||||
{
|
||||
Rule: "keep-rule",
|
||||
Message: "some other validation",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
err := applyOverrideXValidation(schema, OverrideXValidation{
|
||||
MessageContains: "phase PreRouting only",
|
||||
Rule: "new-rule",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, apiextensionsv1.ValidationRules{
|
||||
{
|
||||
Rule: "new-rule",
|
||||
Message: "phase PreRouting only supports extAuth",
|
||||
},
|
||||
{
|
||||
Rule: "keep-rule",
|
||||
Message: "some other validation",
|
||||
},
|
||||
}, schema.XValidations)
|
||||
}
|
||||
|
||||
func TestOverrideXValidationRemovesMatchWhenRuleEmpty(t *testing.T) {
|
||||
schema := &apiextensionsv1.JSONSchemaProps{
|
||||
XValidations: []apiextensionsv1.ValidationRule{
|
||||
{
|
||||
Rule: "old-rule",
|
||||
Message: "phase PreRouting only supports extAuth",
|
||||
},
|
||||
{
|
||||
Rule: "keep-rule",
|
||||
Message: "some other validation",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
err := applyOverrideXValidation(schema, OverrideXValidation{
|
||||
MessageContains: "phase PreRouting only",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, apiextensionsv1.ValidationRules{
|
||||
{
|
||||
Rule: "keep-rule",
|
||||
Message: "some other validation",
|
||||
},
|
||||
}, schema.XValidations)
|
||||
}
|
||||
|
||||
func TestOverrideXValidationErrorsWithoutExactSingleMatch(t *testing.T) {
|
||||
t.Run("no matches", func(t *testing.T) {
|
||||
schema := &apiextensionsv1.JSONSchemaProps{
|
||||
XValidations: []apiextensionsv1.ValidationRule{
|
||||
{Rule: "keep-rule", Message: "some other validation"},
|
||||
},
|
||||
}
|
||||
|
||||
err := applyOverrideXValidation(schema, OverrideXValidation{
|
||||
MessageContains: "phase PreRouting only",
|
||||
Rule: "new-rule",
|
||||
})
|
||||
require.EqualError(t, err, "OverrideXValidation matched 0 rules for messageContains \"phase PreRouting only\", expected exactly 1")
|
||||
})
|
||||
|
||||
t.Run("multiple matches", func(t *testing.T) {
|
||||
schema := &apiextensionsv1.JSONSchemaProps{
|
||||
XValidations: []apiextensionsv1.ValidationRule{
|
||||
{Rule: "old-rule-1", Message: "phase PreRouting only supports extAuth"},
|
||||
{Rule: "old-rule-2", Message: "phase PreRouting only supports rateLimit"},
|
||||
},
|
||||
}
|
||||
|
||||
err := applyOverrideXValidation(schema, OverrideXValidation{
|
||||
MessageContains: "phase PreRouting only",
|
||||
Rule: "new-rule",
|
||||
})
|
||||
require.EqualError(t, err, "OverrideXValidation matched 2 rules for messageContains \"phase PreRouting only\", expected exactly 1")
|
||||
})
|
||||
}
|
||||
|
||||
func TestApplyIfThenOnlyFieldsUsesVisibleSchemaFields(t *testing.T) {
|
||||
schema := &apiextensionsv1.JSONSchemaProps{
|
||||
Properties: map[string]apiextensionsv1.JSONSchemaProps{
|
||||
"foo": {},
|
||||
"bar": {},
|
||||
"baz": {},
|
||||
},
|
||||
}
|
||||
|
||||
err := applyIfThenOnlyFields(schema, sortedPropertyNames(schema), IfThenOnlyFields{
|
||||
If: "has(self.baz)",
|
||||
Fields: []string{"foo", "baz"},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, schema.XValidations, 1)
|
||||
require.Equal(t, "has(self.baz) ? [has(self.bar)].filter(x,x==true).size() == 0 : true", schema.XValidations[0].Rule)
|
||||
require.Equal(t, "only fields in [baz foo] may be set when has(self.baz)", schema.XValidations[0].Message)
|
||||
}
|
||||
|
||||
func TestApplyPostSchemaMarkersToCRDIfThenOnlyFieldsIncludesImportedInlineFields(t *testing.T) {
|
||||
const rootPath = "github.com/agentgateway/agentgateway/controller/hack/crdgen/testdata/ifthenembedded/api/v1"
|
||||
|
||||
roots, parser := newTestParser(t, rootPath)
|
||||
metav1Pkg := crd.FindMetav1(roots)
|
||||
require.NotNil(t, metav1Pkg)
|
||||
|
||||
kubeKinds := crd.FindKubeKinds(parser, metav1Pkg)
|
||||
require.Len(t, kubeKinds, 1)
|
||||
|
||||
groupKind := kubeKinds[0]
|
||||
maxDescLen := 0
|
||||
parser.NeedCRDFor(groupKind, &maxDescLen)
|
||||
|
||||
crdObj := parser.CustomResourceDefinitions[groupKind]
|
||||
require.NoError(t, applyPostSchemaMarkersToCRD(parser, &crdObj, groupKind))
|
||||
|
||||
require.Len(t, crdObj.Spec.Versions, 1)
|
||||
rootSchema := crdObj.Spec.Versions[0].Schema.OpenAPIV3Schema
|
||||
require.NotNil(t, rootSchema)
|
||||
|
||||
specSchema, ok := rootSchema.Properties["spec"]
|
||||
require.True(t, ok)
|
||||
trafficSchema, ok := specSchema.Properties["traffic"]
|
||||
require.True(t, ok)
|
||||
|
||||
require.Len(t, trafficSchema.XValidations, 1)
|
||||
require.Equal(t, "when baz is set only foo and baz may be set", trafficSchema.XValidations[0].Message)
|
||||
require.Equal(t, "has(self.baz) ? [has(self.bar)].filter(x,x==true).size() == 0 : true", trafficSchema.XValidations[0].Rule)
|
||||
}
|
||||
6
controller/hack/crdgen/testdata/embedded/types.go
vendored
Normal file
6
controller/hack/crdgen/testdata/embedded/types.go
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
package embedded
|
||||
|
||||
type InlineFields struct {
|
||||
Foo *string `json:"foo,omitempty"`
|
||||
Bar *string `json:"bar,omitempty"`
|
||||
}
|
||||
2
controller/hack/crdgen/testdata/ifthenembedded/api/v1/doc.go
vendored
Normal file
2
controller/hack/crdgen/testdata/ifthenembedded/api/v1/doc.go
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
// +groupName=testdata.agentgateway.dev
|
||||
package v1
|
||||
26
controller/hack/crdgen/testdata/ifthenembedded/api/v1/types.go
vendored
Normal file
26
controller/hack/crdgen/testdata/ifthenembedded/api/v1/types.go
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/agentgateway/agentgateway/controller/hack/crdgen/testdata/ifthenembedded/embedded"
|
||||
)
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
// +kubebuilder:resource:path=widgets,scope=Namespaced
|
||||
type Widget struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec WidgetSpec `json:"spec,omitempty"`
|
||||
}
|
||||
|
||||
type WidgetSpec struct {
|
||||
Traffic Traffic `json:"traffic,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:validation:IfThenOnlyFields:if="has(self.baz)",fields=foo;baz,message="when baz is set only foo and baz may be set"
|
||||
type Traffic struct {
|
||||
embedded.InlineFields `json:",inline"`
|
||||
Baz *string `json:"baz,omitempty"`
|
||||
}
|
||||
6
controller/hack/crdgen/testdata/ifthenembedded/embedded/types.go
vendored
Normal file
6
controller/hack/crdgen/testdata/ifthenembedded/embedded/types.go
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
package embedded
|
||||
|
||||
type InlineFields struct {
|
||||
Foo *string `json:"foo,omitempty"`
|
||||
Bar *string `json:"bar,omitempty"`
|
||||
}
|
||||
9
controller/hack/crdgen/testdata/root/types.go
vendored
Normal file
9
controller/hack/crdgen/testdata/root/types.go
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
package root
|
||||
|
||||
import "github.com/agentgateway/agentgateway/controller/hack/crdgen/testdata/embedded"
|
||||
|
||||
// +kubebuilder:validation:AtLeastOneFieldSet
|
||||
type Wrapper struct {
|
||||
embedded.InlineFields `json:",inline"`
|
||||
Baz *string `json:"baz,omitempty"`
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
ARG BASE_IMAGE
|
||||
|
||||
FROM $BASE_IMAGE
|
||||
|
||||
ARG GOARCH=amd64
|
||||
|
||||
RUN apk -U upgrade
|
||||
|
||||
COPY dummy-idp-linux-$GOARCH /usr/local/bin/dummy-idp
|
||||
|
||||
USER 10101
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/dummy-idp"]
|
||||
@ -1,185 +0,0 @@
|
||||
Based on agentgateway auth0 example: https://github.com/agentgateway/agentgateway/tree/485a299d2199cf7f792a8f7e55677f1a4898013b/examples/mcp-authentication
|
||||
|
||||
## Building and Deploying
|
||||
|
||||
1. Build docker with the Make target
|
||||
|
||||
```shell
|
||||
VERSION=<version> make kind-build-and-load-dummy-idp
|
||||
```
|
||||
|
||||
2. Apply the mock IDP deployment
|
||||
|
||||
```shell
|
||||
kubectl apply -f test/e2e/features/agentgateway/mcp/testdata/auth0-mock-server.yaml
|
||||
```
|
||||
|
||||
## Running Locally
|
||||
|
||||
### Option 1: Using Docker (without Kubernetes)
|
||||
|
||||
Build and run the Docker container locally:
|
||||
|
||||
```shell
|
||||
# Build the Go binary and Docker image (will rebuild if source changed)
|
||||
make dummy-idp-docker
|
||||
|
||||
# Run the container
|
||||
docker run -p 8443:8443 ghcr.io/agentgateway/dummy-idp:0.0.1
|
||||
```
|
||||
|
||||
**Note:** If you see "Nothing to be done for 'dummy-idp'", that's normal - it means the binary is already built and up to date. The `dummy-idp-docker` target will automatically rebuild the binary if source files have changed.
|
||||
|
||||
**Alternative: Build with a custom tag**
|
||||
```shell
|
||||
# Build the binary first (or force rebuild by deleting _output/hack/dummy-idp/dummy-idp-linux-amd64)
|
||||
make dummy-idp
|
||||
|
||||
# Build Docker image with custom tag (from the output directory)
|
||||
docker build -f _output/hack/dummy-idp/Dockerfile.dummy-idp \
|
||||
--build-arg BASE_IMAGE=alpine:3.17.6 \
|
||||
--build-arg GOARCH=amd64 \
|
||||
-t dummy-idp:local \
|
||||
_output/hack/dummy-idp
|
||||
|
||||
# Run the container
|
||||
docker run -p 8443:8443 dummy-idp:local
|
||||
```
|
||||
|
||||
**Force a rebuild:** If you've made code changes and want to force a rebuild:
|
||||
```shell
|
||||
# Remove the binary to force rebuild
|
||||
rm -f _output/hack/dummy-idp/dummy-idp-linux-<arch>
|
||||
make dummy-idp-docker
|
||||
```
|
||||
|
||||
**Quick run command:**
|
||||
```shell
|
||||
docker run -p 8443:8443 ghcr.io/agentgateway/dummy-idp:0.0.1
|
||||
```
|
||||
|
||||
The server will be available at `https://localhost:8443`.
|
||||
|
||||
### Option 2: Using Kubernetes Port-Forward
|
||||
|
||||
To test the dummy-idp server locally via Kubernetes, port-forward the service:
|
||||
|
||||
```shell
|
||||
kubectl port-forward svc/auth0-mock 8443:8443
|
||||
```
|
||||
|
||||
The server runs on HTTPS port 8443 with a self-signed certificate. When using `curl`, use the `-k` flag to skip certificate verification.
|
||||
|
||||
## Testing Endpoints
|
||||
|
||||
### OAuth2 Discovery Endpoint
|
||||
|
||||
Get the OAuth2 discovery document:
|
||||
|
||||
```shell
|
||||
curl -k https://localhost:8443/.well-known/oauth-authorization-server
|
||||
```
|
||||
|
||||
### JWKS Endpoint
|
||||
|
||||
Get the JSON Web Key Set:
|
||||
|
||||
```shell
|
||||
curl -k https://localhost:8443/.well-known/jwks.json
|
||||
```
|
||||
|
||||
### Client Registration
|
||||
|
||||
Register a new OAuth2 client:
|
||||
|
||||
```shell
|
||||
curl -k -X POST https://localhost:8443/register \
|
||||
-H "Content-Type: application/json"
|
||||
```
|
||||
|
||||
### Authorization Endpoint
|
||||
|
||||
Request authorization (returns redirect URL with code):
|
||||
|
||||
```shell
|
||||
curl -k "https://localhost:8443/authorize?client_id=mcp_gi3APARn2_uHv2oxfJJqq2yZBDV4OyNo&redirect_uri=http://localhost:8081/callback"
|
||||
```
|
||||
|
||||
### Token Endpoint
|
||||
|
||||
Exchange authorization code for access token:
|
||||
|
||||
```shell
|
||||
curl -k -X POST https://localhost:8443/token \
|
||||
-H "Content-Type: application/x-www-form-urlencoded" \
|
||||
-d "grant_type=authorization_code" \
|
||||
-d "client_id=mcp_gi3APARn2_uHv2oxfJJqq2yZBDV4OyNo" \
|
||||
-d "code=fixed_auth_code_123" \
|
||||
-d "redirect_uri=http://localhost:8081/callback"
|
||||
```
|
||||
|
||||
Or use Basic authentication:
|
||||
|
||||
```shell
|
||||
curl -k -X POST https://localhost:8443/token \
|
||||
-H "Content-Type: application/x-www-form-urlencoded" \
|
||||
-u "mcp_gi3APARn2_uHv2oxfJJqq2yZBDV4OyNo:secret_2nGx_bjvo9z72Aw3-hKTWMusEo2-yTfH" \
|
||||
-d "grant_type=authorization_code" \
|
||||
-d "code=fixed_auth_code_123" \
|
||||
-d "redirect_uri=http://localhost:8081/callback"
|
||||
```
|
||||
|
||||
### Refresh Token
|
||||
|
||||
A request to "refresh" an access token will return the same token since this is a mock IDP server for testing. You can try the following request to refresh the token:
|
||||
|
||||
```shell
|
||||
curl -k -X POST https://localhost:8443/token \
|
||||
-H "Content-Type: application/x-www-form-urlencoded" \
|
||||
-u "mcp_gi3APARn2_uHv2oxfJJqq2yZBDV4OyNo:secret_2nGx_bjvo9z72Aw3-hKTWMusEo2-yTfH" \
|
||||
-d "grant_type=refresh_token" \
|
||||
-d "refresh_token=fixed_refresh_token_123"
|
||||
```
|
||||
|
||||
### Organization-specific Endpoints
|
||||
|
||||
Get JWKS for different organizations:
|
||||
|
||||
```shell
|
||||
curl -k https://localhost:8443/org-one/keys
|
||||
curl -k https://localhost:8443/org-two/keys
|
||||
curl -k https://localhost:8443/org-three/keys
|
||||
```
|
||||
|
||||
Get JWT tokens for different organizations:
|
||||
|
||||
```shell
|
||||
curl -k https://localhost:8443/org-one/jwt
|
||||
curl -k https://localhost:8443/org-two/jwt
|
||||
curl -k https://localhost:8443/org-three/jwt
|
||||
```
|
||||
|
||||
## Hardcoded Values for MCP Auth Flow
|
||||
|
||||
The mock server will always return the same JWT token and key pair, which has a 10-year expiration date set. The values for
|
||||
the token returned are:
|
||||
```json
|
||||
{
|
||||
"iss": "https://kgateway.dev",
|
||||
"sub": "ignore@kgateway.dev",
|
||||
"exp": 2071163407,
|
||||
"nbf": 1763579407,
|
||||
"iat": 1763579407
|
||||
}
|
||||
```
|
||||
|
||||
**Hardcoded OAuth2 values:**
|
||||
- Client ID: `mcp_gi3APARn2_uHv2oxfJJqq2yZBDV4OyNo`
|
||||
- Client Secret: `secret_2nGx_bjvo9z72Aw3-hKTWMusEo2-yTfH`
|
||||
- Authorization Code: `fixed_auth_code_123`
|
||||
- Refresh Token: `fixed_refresh_token_123`
|
||||
- Redirect URI: `http://localhost:8081/callback`
|
||||
|
||||
The mock IDP provider will use a hard coded code `fixed_auth_code_123` for the `handle_authorize` endpoint. The mock
|
||||
server also sets the redirect url to `http://localhost:8081/callback`, so when testing the MCP Inspector locally,
|
||||
make sure to expose this through the gateway and route configuration.
|
||||
@ -50,23 +50,15 @@ for VERSION in "${VERSIONS[@]}"; do
|
||||
rm -f "${ROOT_DIR}/api/${VERSION}/agentgateway/zz_generated.register.go.bak"
|
||||
done
|
||||
|
||||
# Generate agentgateway CRDs and RBAC
|
||||
(cd "${REPO_ROOT}" && controller-gen crd:maxDescLen=50000 object rbac:roleName=agentgateway paths="${APIS_PKG}/api/${VERSION}/agentgateway" paths="${APIS_PKG}/api/${VERSION}/shared" \
|
||||
output:crd:artifacts:config=${ROOT_DIR}/${AGENTGATEWAY_CRD_DIR} output:rbac:artifacts:config=${ROOT_DIR}/${AGENTGATEWAY_MANIFESTS_DIR})
|
||||
# Template the ClusterRole name to include the namespace
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# On macOS, prefer gsed (GNU sed) if available
|
||||
if command -v gsed &> /dev/null; then
|
||||
gsed -i 's/name: agentgateway/name: agentgateway-{{ .Release.Namespace }}/g' "${ROOT_DIR}/${AGENTGATEWAY_MANIFESTS_DIR}/role.yaml"
|
||||
else
|
||||
# Fallback to macOS's native sed
|
||||
sed -i '' 's/name: agentgateway/name: agentgateway-{{ .Release.Namespace }}/g' "${ROOT_DIR}/${AGENTGATEWAY_MANIFESTS_DIR}/role.yaml"
|
||||
fi
|
||||
else
|
||||
# For other OSes like Linux
|
||||
sed -i 's/name: agentgateway/name: agentgateway-{{ .Release.Namespace }}/g' "${ROOT_DIR}/${AGENTGATEWAY_MANIFESTS_DIR}/role.yaml"
|
||||
fi
|
||||
# Generate objects and RBAC with stock controller-gen.
|
||||
(cd "${REPO_ROOT}" && controller-gen object paths="${APIS_PKG}/api/${VERSION}/agentgateway" paths="${APIS_PKG}/api/${VERSION}/shared")
|
||||
|
||||
# Generate CRDs with custom kubebuilder validation markers.
|
||||
(cd "${REPO_ROOT}" && go run ./controller/hack/crdgen \
|
||||
--max-desc-len 50000 \
|
||||
--output-dir "${ROOT_DIR}/${AGENTGATEWAY_CRD_DIR}" \
|
||||
--path "${APIS_PKG}/api/${VERSION}/agentgateway" \
|
||||
--path "${APIS_PKG}/api/${VERSION}/shared")
|
||||
|
||||
# throw away
|
||||
new_report="$(mktemp -t "$(basename "$0").api_violations.XXXXXX")"
|
||||
@ -80,4 +72,3 @@ new_report="$(mktemp -t "$(basename "$0").api_violations.XXXXXX")"
|
||||
--plural-exceptions "AgentgatewayParameters:AgentgatewayParameters")
|
||||
|
||||
go generate ${ROOT_DIR}/pkg/...
|
||||
|
||||
|
||||
9
controller/hack/testbox/Dockerfile
Normal file
9
controller/hack/testbox/Dockerfile
Normal file
@ -0,0 +1,9 @@
|
||||
FROM cgr.dev/chainguard/static
|
||||
|
||||
ARG GOARCH=amd64
|
||||
|
||||
COPY testbox-linux-$GOARCH /usr/local/bin/testbox
|
||||
|
||||
USER nonroot:nonroot
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/testbox"]
|
||||
17
controller/hack/testbox/README.md
Normal file
17
controller/hack/testbox/README.md
Normal file
@ -0,0 +1,17 @@
|
||||
# testbox
|
||||
|
||||
Single e2e helper image used by multiple tests.
|
||||
|
||||
Ports:
|
||||
- `80/443/7070/9090`: Istio echo app server (`backend` service)
|
||||
- `8443`: dummy-idp/auth0-mock
|
||||
- `18080`: ext-proc gRPC server
|
||||
- `9000`: ext-authz gRPC server
|
||||
- `8000`: mcp-website-fetcher
|
||||
- `3001`: mcp-admin-server
|
||||
- `9999`: a2a-helloworld
|
||||
|
||||
Build/load:
|
||||
```bash
|
||||
make -C controller testbox-docker kind-load-testbox
|
||||
```
|
||||
115
controller/hack/testbox/a2a.go
Normal file
115
controller/hack/testbox/a2a.go
Normal file
@ -0,0 +1,115 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type a2aRequest struct {
|
||||
JSONRPC string `json:"jsonrpc"`
|
||||
ID json.RawMessage `json:"id,omitempty"`
|
||||
Method string `json:"method"`
|
||||
Params struct {
|
||||
ID string `json:"id"`
|
||||
Message struct {
|
||||
Parts []struct {
|
||||
Text string `json:"text"`
|
||||
} `json:"parts"`
|
||||
} `json:"message"`
|
||||
} `json:"params"`
|
||||
}
|
||||
|
||||
func startA2AServer() (shutdownFunc, error) {
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/agent-card", handleAgentCard)
|
||||
mux.HandleFunc("/", handleA2ARequest)
|
||||
|
||||
// nolint: gosec // Test code only
|
||||
httpServer := &http.Server{
|
||||
Addr: ":9999",
|
||||
Handler: mux,
|
||||
}
|
||||
|
||||
return serveHTTP("a2a", httpServer, httpServer.ListenAndServe), nil
|
||||
}
|
||||
|
||||
func handleAgentCard(w http.ResponseWriter, _ *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_ = json.NewEncoder(w).Encode(map[string]any{
|
||||
"name": "Example A2A Agent",
|
||||
"version": "1.0.0",
|
||||
"description": "An example A2A agent using the a2a-protocol crate",
|
||||
"skills": []map[string]any{
|
||||
{
|
||||
"id": "echo",
|
||||
"name": "Echo Skill",
|
||||
"description": "Echoes back the user's message",
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func handleA2ARequest(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodPost {
|
||||
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
body, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
var req a2aRequest
|
||||
if err := json.Unmarshal(body, &req); err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
if req.Method != "tasks/send" {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
userText := ""
|
||||
if len(req.Params.Message.Parts) > 0 {
|
||||
userText = req.Params.Message.Parts[0].Text
|
||||
}
|
||||
if userText == "" {
|
||||
userText = "hello"
|
||||
}
|
||||
|
||||
agentMessage := map[string]any{
|
||||
"kind": "message",
|
||||
"messageId": "agent-reply-1",
|
||||
"role": "agent",
|
||||
"parts": []map[string]any{
|
||||
{"kind": "text", "text": "Echo: " + strings.TrimSpace(userText)},
|
||||
},
|
||||
}
|
||||
|
||||
result := map[string]any{
|
||||
"contextId": "ctx-1",
|
||||
"history": []any{agentMessage},
|
||||
"id": req.Params.ID,
|
||||
"kind": "task",
|
||||
"status": map[string]any{
|
||||
"message": agentMessage,
|
||||
"state": "working",
|
||||
"timestamp": time.Now().UTC().Format(time.RFC3339Nano),
|
||||
},
|
||||
}
|
||||
|
||||
resp := map[string]any{
|
||||
"jsonrpc": "2.0",
|
||||
"id": req.ID,
|
||||
"result": result,
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_ = json.NewEncoder(w).Encode(resp)
|
||||
}
|
||||
48
controller/hack/testbox/app_echo.go
Normal file
48
controller/hack/testbox/app_echo.go
Normal file
@ -0,0 +1,48 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"istio.io/istio/pkg/config/protocol"
|
||||
"istio.io/istio/pkg/test/echo/common"
|
||||
echoserver "istio.io/istio/pkg/test/echo/server"
|
||||
)
|
||||
|
||||
func startEchoAppServer() (shutdownFunc, error) {
|
||||
ports := common.PortList{
|
||||
&common.Port{Name: "http-0", Protocol: protocol.HTTP, Port: 80},
|
||||
&common.Port{Name: "tcp-0", Protocol: protocol.TCP, Port: 9090},
|
||||
&common.Port{Name: "grpc-0", Protocol: protocol.GRPC, Port: 7070},
|
||||
}
|
||||
cfg := echoserver.Config{
|
||||
Ports: ports,
|
||||
Namespace: os.Getenv("NAMESPACE"),
|
||||
ReportRequest: func() {
|
||||
},
|
||||
}
|
||||
|
||||
if fileExists("/tls/tls.crt") && fileExists("/tls/tls.key") {
|
||||
cfg.TLSCert = "/tls/tls.crt"
|
||||
cfg.TLSKey = "/tls/tls.key"
|
||||
cfg.Ports = append(cfg.Ports, &common.Port{Name: "https", Protocol: protocol.HTTP, Port: 443, TLS: true})
|
||||
} else {
|
||||
log.Println("app TLS certs are not mounted; skipping echo TLS")
|
||||
}
|
||||
|
||||
s := echoserver.New(cfg)
|
||||
|
||||
if err := s.Start(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return func(_ context.Context) error {
|
||||
return s.Close()
|
||||
}, nil
|
||||
}
|
||||
|
||||
func fileExists(path string) bool {
|
||||
_, err := os.Stat(path)
|
||||
return err == nil
|
||||
}
|
||||
@ -6,7 +6,6 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
@ -20,15 +19,15 @@ var cert []byte
|
||||
//go:embed dummy-idp.key
|
||||
var key []byte
|
||||
|
||||
func main() {
|
||||
func startDummyIDP() (shutdownFunc, error) {
|
||||
roots := x509.NewCertPool()
|
||||
if !roots.AppendCertsFromPEM(cert) {
|
||||
log.Fatal("failed to append Cert from PEM")
|
||||
return nil, fmt.Errorf("failed to append Cert from PEM")
|
||||
}
|
||||
|
||||
cert, err := tls.X509KeyPair(cert, key)
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
mux := http.NewServeMux()
|
||||
@ -82,12 +81,14 @@ func main() {
|
||||
mux.ServeHTTP(w, r)
|
||||
})
|
||||
|
||||
// nolint: gosec // Test code only
|
||||
cfg := &tls.Config{
|
||||
RootCAs: roots,
|
||||
Certificates: []tls.Certificate{cert},
|
||||
NextProtos: []string{"http/1.1"},
|
||||
}
|
||||
|
||||
// nolint: gosec // Test code only
|
||||
srv := &http.Server{
|
||||
Addr: "0.0.0.0:8443",
|
||||
Handler: muxWithCORS,
|
||||
@ -95,20 +96,23 @@ func main() {
|
||||
TLSNextProto: make(map[string]func(*http.Server, *tls.Conn, http.Handler), 0),
|
||||
}
|
||||
|
||||
log.Fatal(srv.ListenAndServeTLS("", ""))
|
||||
return serveHTTP("dummy-idp", srv, func() error {
|
||||
return srv.ListenAndServeTLS("", "")
|
||||
}), nil
|
||||
}
|
||||
|
||||
// OAuth2/OIDC constants
|
||||
const (
|
||||
hardcodedClientID = "mcp_gi3APARn2_uHv2oxfJJqq2yZBDV4OyNo"
|
||||
hardcodedCode = "fixed_auth_code_123"
|
||||
hardcodedClientID = "mcp_gi3APARn2_uHv2oxfJJqq2yZBDV4OyNo"
|
||||
hardcodedCode = "fixed_auth_code_123"
|
||||
// nolint: gosec // Test code only
|
||||
hardcodedClientSecret = "secret_2nGx_bjvo9z72Aw3-hKTWMusEo2-yTfH"
|
||||
hardcodedRefreshToken = "fixed_refresh_token_123"
|
||||
redirectURI = "http://localhost:8081/callback"
|
||||
)
|
||||
|
||||
// sendJSONResponse sends a JSON response with CORS headers
|
||||
func sendJSONResponse(w http.ResponseWriter, r *http.Request, data interface{}, statusCode int) {
|
||||
func sendJSONResponse(w http.ResponseWriter, r *http.Request, data any, statusCode int) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
origin := r.Header.Get("Origin")
|
||||
if origin == "" {
|
||||
@ -133,7 +137,7 @@ func handleRegister(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
registration := map[string]interface{}{
|
||||
registration := map[string]any{
|
||||
"client_id": hardcodedClientID,
|
||||
"client_secret": hardcodedClientSecret,
|
||||
"client_name": "Test Client",
|
||||
@ -202,7 +206,7 @@ func handleToken(w http.ResponseWriter, r *http.Request) {
|
||||
// Be lenient for generic MCP inspectors/SPAs using PKCE:
|
||||
// - Do not require client_secret (public client)
|
||||
// - Accept any code/redirect_uri/code_verifier
|
||||
response := map[string]interface{}{
|
||||
response := map[string]any{
|
||||
"access_token": string(orgOneJwt),
|
||||
"refresh_token": hardcodedRefreshToken,
|
||||
"token_type": "bearer",
|
||||
@ -217,7 +221,7 @@ func handleToken(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
// Accept any refresh_token for testing purposes
|
||||
response := map[string]interface{}{
|
||||
response := map[string]any{
|
||||
"access_token": string(orgOneJwt),
|
||||
"refresh_token": hardcodedRefreshToken,
|
||||
"token_type": "bearer",
|
||||
@ -267,7 +271,7 @@ func handleDiscovery(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
baseURL := fmt.Sprintf("%s://%s", scheme, host)
|
||||
|
||||
discovery := map[string]interface{}{
|
||||
discovery := map[string]any{
|
||||
"issuer": "https://kgateway.dev",
|
||||
"authorization_endpoint": fmt.Sprintf("%s/authorize", baseURL),
|
||||
"token_endpoint": fmt.Sprintf("%s/token", baseURL),
|
||||
120
controller/hack/testbox/extauth.go
Normal file
120
controller/hack/testbox/extauth.go
Normal file
@ -0,0 +1,120 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
envoycorev3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
|
||||
authv3 "github.com/envoyproxy/go-control-plane/envoy/service/auth/v3"
|
||||
typev3 "github.com/envoyproxy/go-control-plane/envoy/type/v3"
|
||||
"google.golang.org/genproto/googleapis/rpc/status"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
)
|
||||
|
||||
const (
|
||||
extAuthzCheckHeader = "x-ext-authz"
|
||||
extAuthzAllowedValue = "allow"
|
||||
extAuthzResultHeader = "x-ext-authz-check-result"
|
||||
extAuthzReceivedHeader = "x-ext-authz-check-received"
|
||||
extAuthzOverrideHeader = "x-ext-authz-additional-header-override"
|
||||
extAuthzOverrideGRPCValue = "grpc-additional-header-override-value"
|
||||
extAuthzResultAllowed = "allowed"
|
||||
extAuthzResultDenied = "denied"
|
||||
extAuthzAllowedServiceAccount = "a"
|
||||
)
|
||||
|
||||
var extAuthzDenyBody = "denied by ext_authz for not found header `x-ext-authz: allow` in the request"
|
||||
|
||||
type extAuthzServerV3 struct{}
|
||||
|
||||
func startExtAuthzServer() (shutdownFunc, error) {
|
||||
// nolint: gosec // Test code only
|
||||
listener, err := net.Listen("tcp", ":9000")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
grpcServer := grpc.NewServer()
|
||||
authv3.RegisterAuthorizationServer(grpcServer, &extAuthzServerV3{})
|
||||
|
||||
return serveGRPC("ext-authz", listener, grpcServer), nil
|
||||
}
|
||||
|
||||
func (s *extAuthzServerV3) Check(_ context.Context, request *authv3.CheckRequest) (*authv3.CheckResponse, error) {
|
||||
attrs := request.GetAttributes()
|
||||
allow := false
|
||||
|
||||
checkHeaderValue, contains := attrs.GetRequest().GetHttp().GetHeaders()[extAuthzCheckHeader]
|
||||
if contains {
|
||||
allow = checkHeaderValue == extAuthzAllowedValue
|
||||
} else {
|
||||
allow = attrs.Source != nil && strings.HasSuffix(attrs.Source.Principal, "/sa/"+extAuthzAllowedServiceAccount)
|
||||
}
|
||||
|
||||
if allow {
|
||||
return s.allow(request), nil
|
||||
}
|
||||
|
||||
return s.deny(request), nil
|
||||
}
|
||||
|
||||
func (s *extAuthzServerV3) allow(request *authv3.CheckRequest) *authv3.CheckResponse {
|
||||
s.logRequest("allowed", request)
|
||||
return &authv3.CheckResponse{
|
||||
HttpResponse: &authv3.CheckResponse_OkResponse{
|
||||
OkResponse: &authv3.OkHttpResponse{
|
||||
Headers: []*envoycorev3.HeaderValueOption{
|
||||
{
|
||||
Header: &envoycorev3.HeaderValue{Key: extAuthzResultHeader, Value: extAuthzResultAllowed},
|
||||
},
|
||||
{
|
||||
Header: &envoycorev3.HeaderValue{Key: extAuthzReceivedHeader, Value: returnIfNotTooLong(request.GetAttributes().String())},
|
||||
},
|
||||
{
|
||||
Header: &envoycorev3.HeaderValue{Key: extAuthzOverrideHeader, Value: extAuthzOverrideGRPCValue},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Status: &status.Status{Code: int32(codes.OK)},
|
||||
}
|
||||
}
|
||||
|
||||
func (s *extAuthzServerV3) deny(request *authv3.CheckRequest) *authv3.CheckResponse {
|
||||
s.logRequest("denied", request)
|
||||
return &authv3.CheckResponse{
|
||||
HttpResponse: &authv3.CheckResponse_DeniedResponse{
|
||||
DeniedResponse: &authv3.DeniedHttpResponse{
|
||||
Status: &typev3.HttpStatus{Code: typev3.StatusCode_Forbidden},
|
||||
Body: extAuthzDenyBody,
|
||||
Headers: []*envoycorev3.HeaderValueOption{
|
||||
{
|
||||
Header: &envoycorev3.HeaderValue{Key: extAuthzResultHeader, Value: extAuthzResultDenied},
|
||||
},
|
||||
{
|
||||
Header: &envoycorev3.HeaderValue{Key: extAuthzReceivedHeader, Value: returnIfNotTooLong(request.GetAttributes().String())},
|
||||
},
|
||||
{
|
||||
Header: &envoycorev3.HeaderValue{Key: extAuthzOverrideHeader, Value: extAuthzOverrideGRPCValue},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Status: &status.Status{Code: int32(codes.PermissionDenied)},
|
||||
}
|
||||
}
|
||||
|
||||
func (s *extAuthzServerV3) logRequest(state string, request *authv3.CheckRequest) {
|
||||
httpAttrs := request.GetAttributes().GetRequest().GetHttp()
|
||||
log.Printf("[ext-authz][%s] %s%s", state, httpAttrs.GetHost(), httpAttrs.GetPath())
|
||||
}
|
||||
|
||||
func returnIfNotTooLong(body string) string {
|
||||
if len(body) > 60000 {
|
||||
return "<too-long>"
|
||||
}
|
||||
return body
|
||||
}
|
||||
@ -5,17 +5,12 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"io"
|
||||
"log/slog"
|
||||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strconv"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
core_v3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
|
||||
envoycorev3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
|
||||
service_ext_proc_v3 "github.com/envoyproxy/go-control-plane/envoy/service/ext_proc/v3"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
@ -23,9 +18,7 @@ import (
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
var (
|
||||
grpcport = flag.String("grpcport", ":18080", "grpcport")
|
||||
)
|
||||
const extProcPort = ":18080"
|
||||
|
||||
type Instructions struct {
|
||||
// Header key/value pairs to add to the request or response.
|
||||
@ -162,7 +155,7 @@ func (s *server) Process(srv service_ext_proc_v3.ExternalProcessor_ProcessServer
|
||||
resp.Response = &service_ext_proc_v3.ProcessingResponse_ResponseTrailers{}
|
||||
|
||||
default:
|
||||
slog.Info("unknown request type", "request type", v)
|
||||
slog.Info("unknown request type", "request_type", v)
|
||||
}
|
||||
|
||||
// At this point we believe we have created a valid response...
|
||||
@ -173,18 +166,14 @@ func (s *server) Process(srv service_ext_proc_v3.ExternalProcessor_ProcessServer
|
||||
slog.Info("send error", "error", err)
|
||||
return err
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
flag.Parse()
|
||||
|
||||
lis, err := net.Listen("tcp", *grpcport)
|
||||
func startExtProcServer() (shutdownFunc, error) {
|
||||
// nolint: gosec // Test code only
|
||||
lis, err := net.Listen("tcp", extProcPort)
|
||||
if err != nil {
|
||||
slog.Error("failed to listen", "error", err)
|
||||
os.Exit(1)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sopts := []grpc.ServerOption{grpc.MaxConcurrentStreams(1000)}
|
||||
@ -194,22 +183,8 @@ func main() {
|
||||
|
||||
grpc_health_v1.RegisterHealthServer(s, &healthServer{})
|
||||
|
||||
slog.Info("starting gRPC server", "port", *grpcport)
|
||||
|
||||
var gracefulStop = make(chan os.Signal, 1)
|
||||
signal.Notify(gracefulStop, syscall.SIGTERM, syscall.SIGINT)
|
||||
go func() {
|
||||
sig := <-gracefulStop
|
||||
slog.Info("caught sig", "sig", sig)
|
||||
time.Sleep(time.Second)
|
||||
slog.Info("graceful stop completed")
|
||||
os.Exit(0)
|
||||
}()
|
||||
err = s.Serve(lis)
|
||||
if err != nil {
|
||||
slog.Error("killing server", "error", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
slog.Info("starting gRPC server", "port", extProcPort)
|
||||
return serveGRPC("extproc", lis, s), nil
|
||||
}
|
||||
|
||||
func getInstructionsFromHeaders(in *service_ext_proc_v3.HttpHeaders) string {
|
||||
@ -243,10 +218,10 @@ func getHeadersResponseFromInstructions(in *service_ext_proc_v3.HttpHeaders) (*s
|
||||
|
||||
// headers
|
||||
if len(instructions.AddHeaders) > 0 || len(instructions.RemoveHeaders) > 0 {
|
||||
var addHeaders []*core_v3.HeaderValueOption
|
||||
var addHeaders []*envoycorev3.HeaderValueOption
|
||||
for k, v := range instructions.AddHeaders {
|
||||
addHeaders = append(addHeaders, &core_v3.HeaderValueOption{
|
||||
Header: &core_v3.HeaderValue{Key: k, RawValue: []byte(v)},
|
||||
addHeaders = append(addHeaders, &envoycorev3.HeaderValueOption{
|
||||
Header: &envoycorev3.HeaderValue{Key: k, RawValue: []byte(v)},
|
||||
})
|
||||
}
|
||||
resp.Response.HeaderMutation = &service_ext_proc_v3.HeaderMutation{
|
||||
@ -263,15 +238,15 @@ func getHeadersResponseFromInstructions(in *service_ext_proc_v3.HttpHeaders) (*s
|
||||
resp.Response.HeaderMutation = &service_ext_proc_v3.HeaderMutation{}
|
||||
}
|
||||
resp.Response.HeaderMutation.SetHeaders = append(resp.Response.HeaderMutation.SetHeaders,
|
||||
[]*core_v3.HeaderValueOption{
|
||||
[]*envoycorev3.HeaderValueOption{
|
||||
{
|
||||
Header: &core_v3.HeaderValue{
|
||||
Header: &envoycorev3.HeaderValue{
|
||||
Key: "content-type",
|
||||
Value: "text/plain",
|
||||
},
|
||||
},
|
||||
{
|
||||
Header: &core_v3.HeaderValue{
|
||||
Header: &envoycorev3.HeaderValue{
|
||||
Key: "Content-Length",
|
||||
Value: strconv.Itoa(len(body)),
|
||||
},
|
||||
@ -286,11 +261,11 @@ func getHeadersResponseFromInstructions(in *service_ext_proc_v3.HttpHeaders) (*s
|
||||
|
||||
// trailers
|
||||
if len(instructions.SetTrailers) > 0 {
|
||||
var setTrailers []*core_v3.HeaderValue
|
||||
var setTrailers []*envoycorev3.HeaderValue
|
||||
for k, v := range instructions.SetTrailers {
|
||||
setTrailers = append(setTrailers, &core_v3.HeaderValue{Key: k, Value: v})
|
||||
setTrailers = append(setTrailers, &envoycorev3.HeaderValue{Key: k, Value: v})
|
||||
}
|
||||
resp.Response.Trailers = &core_v3.HeaderMap{
|
||||
resp.Response.Trailers = &envoycorev3.HeaderMap{
|
||||
Headers: setTrailers,
|
||||
}
|
||||
}
|
||||
51
controller/hack/testbox/main.go
Normal file
51
controller/hack/testbox/main.go
Normal file
@ -0,0 +1,51 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
type shutdownFunc func(context.Context) error
|
||||
|
||||
func main() {
|
||||
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
|
||||
defer stop()
|
||||
|
||||
shutdowns := make([]shutdownFunc, 0, 7)
|
||||
|
||||
start := func(name string, fn func() (shutdownFunc, error)) {
|
||||
shutdown, err := fn()
|
||||
if err != nil {
|
||||
log.Fatalf("failed to start %s: %v", name, err)
|
||||
}
|
||||
if shutdown != nil {
|
||||
shutdowns = append(shutdowns, shutdown)
|
||||
}
|
||||
log.Printf("started %s", name)
|
||||
}
|
||||
|
||||
start("dummy-idp", startDummyIDP)
|
||||
start("extproc", startExtProcServer)
|
||||
start("ext-authz", startExtAuthzServer)
|
||||
start("mcp-website-fetcher", startMCPWebsiteServer)
|
||||
start("mcp-admin-server", startMCPAdminServer)
|
||||
start("test-a2a-server", startA2AServer)
|
||||
start("app", startEchoAppServer)
|
||||
|
||||
<-ctx.Done()
|
||||
log.Printf("received shutdown signal")
|
||||
|
||||
shutdownCtx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
for i := len(shutdowns) - 1; i >= 0; i-- {
|
||||
if err := shutdowns[i](shutdownCtx); err != nil {
|
||||
log.Printf("shutdown error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("testbox stopped")
|
||||
}
|
||||
91
controller/hack/testbox/mcp.go
Normal file
91
controller/hack/testbox/mcp.go
Normal file
@ -0,0 +1,91 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/modelcontextprotocol/go-sdk/mcp"
|
||||
)
|
||||
|
||||
func startMCPWebsiteServer() (shutdownFunc, error) {
|
||||
return startMCPServer(":8000", "mcp-website-fetcher", newMCPWebsiteServer())
|
||||
}
|
||||
|
||||
func startMCPAdminServer() (shutdownFunc, error) {
|
||||
return startMCPServer(":3001", "mcp-admin-server", newMCPAdminServer())
|
||||
}
|
||||
|
||||
func startMCPServer(addr, name string, server *mcp.Server) (shutdownFunc, error) {
|
||||
mux := http.NewServeMux()
|
||||
mux.Handle("/mcp", mcp.NewStreamableHTTPHandler(func(*http.Request) *mcp.Server {
|
||||
return server
|
||||
}, nil))
|
||||
mux.Handle("/", mcp.NewSSEHandler(func(*http.Request) *mcp.Server {
|
||||
return server
|
||||
}, nil))
|
||||
|
||||
// nolint: gosec // Test code only
|
||||
httpServer := &http.Server{
|
||||
Addr: addr,
|
||||
Handler: mux,
|
||||
}
|
||||
|
||||
return serveHTTP(name, httpServer, httpServer.ListenAndServe), nil
|
||||
}
|
||||
|
||||
func newMCPWebsiteServer() *mcp.Server {
|
||||
s := mcp.NewServer(&mcp.Implementation{
|
||||
Name: "mcp-website-fetcher",
|
||||
Version: "1.0.0",
|
||||
}, &mcp.ServerOptions{})
|
||||
|
||||
mcp.AddTool(s, &mcp.Tool{
|
||||
Name: "fetch",
|
||||
Description: "Fetch a URL and return extracted content.",
|
||||
}, fetchTool)
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
func newMCPAdminServer() *mcp.Server {
|
||||
s := mcp.NewServer(&mcp.Implementation{
|
||||
Name: "mcp-admin-server",
|
||||
Version: "1.0.0",
|
||||
}, &mcp.ServerOptions{})
|
||||
|
||||
mcp.AddTool(s, &mcp.Tool{
|
||||
Name: "fetch",
|
||||
Description: "Fetch a URL and return extracted content.",
|
||||
}, fetchTool)
|
||||
|
||||
mcp.AddTool(s, &mcp.Tool{
|
||||
Name: "admin_status",
|
||||
Description: "Return admin diagnostics.",
|
||||
}, adminStatusTool)
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
type fetchArgs struct {
|
||||
URL string `json:"url" jsonschema:"The URL to fetch"`
|
||||
}
|
||||
|
||||
func fetchTool(_ context.Context, _ *mcp.CallToolRequest, args fetchArgs) (*mcp.CallToolResult, any, error) {
|
||||
if args.URL == "" {
|
||||
return nil, nil, fmt.Errorf("missing url")
|
||||
}
|
||||
return &mcp.CallToolResult{
|
||||
Content: []mcp.Content{
|
||||
&mcp.TextContent{Text: "fetched: " + args.URL},
|
||||
},
|
||||
}, nil, nil
|
||||
}
|
||||
|
||||
func adminStatusTool(_ context.Context, _ *mcp.CallToolRequest, _ struct{}) (*mcp.CallToolResult, any, error) {
|
||||
return &mcp.CallToolResult{
|
||||
Content: []mcp.Content{
|
||||
&mcp.TextContent{Text: "ok"},
|
||||
},
|
||||
}, nil, nil
|
||||
}
|
||||
47
controller/hack/testbox/runtime.go
Normal file
47
controller/hack/testbox/runtime.go
Normal file
@ -0,0 +1,47 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
func serveHTTP(name string, srv *http.Server, listen func() error) shutdownFunc {
|
||||
go func() {
|
||||
if err := listen(); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||
log.Fatalf("%s exited: %v", name, err)
|
||||
}
|
||||
}()
|
||||
|
||||
return func(ctx context.Context) error {
|
||||
return srv.Shutdown(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
func serveGRPC(name string, listener net.Listener, server *grpc.Server) shutdownFunc {
|
||||
go func() {
|
||||
if err := server.Serve(listener); err != nil && !errors.Is(err, grpc.ErrServerStopped) {
|
||||
log.Fatalf("%s exited: %v", name, err)
|
||||
}
|
||||
}()
|
||||
|
||||
return func(ctx context.Context) error {
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
server.GracefulStop()
|
||||
close(done)
|
||||
}()
|
||||
|
||||
select {
|
||||
case <-done:
|
||||
return nil
|
||||
case <-ctx.Done():
|
||||
server.Stop()
|
||||
return ctx.Err()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,49 +1,55 @@
|
||||
Name|Version|License
|
||||
---|---|---
|
||||
[semver/v3](https://github.com/Masterminds/semver)|v3.4.0|MIT License
|
||||
[anthropics/anthropic-sdk-go](https://github.com/anthropics/anthropic-sdk-go)|v1.19.0|MIT License
|
||||
[anthropics/anthropic-sdk-go](https://github.com/anthropics/anthropic-sdk-go)|v1.27.1|MIT License
|
||||
[retry-go/v4](https://github.com/avast/retry-go)|v4.7.0|MIT License
|
||||
[xds/go](https://github.com/cncf/xds)|v0.0.0-20251110193048-8bfbf64dc13e|Apache License 2.0
|
||||
[go-control-plane/envoy](https://github.com/envoyproxy/go-control-plane)|v1.36.1-0.20251120180717-7c66c7f1d0b2|Apache License 2.0
|
||||
[xds/go](https://github.com/cncf/xds)|v0.0.0-20260202195803-dba9d589def2|Apache License 2.0
|
||||
[go-control-plane/envoy](https://github.com/envoyproxy/go-control-plane)|v1.37.1-0.20260402053555-4e9843ddb8d0|Apache License 2.0
|
||||
[ghodss/yaml](https://github.com/ghodss/yaml)|v1.0.1-0.20190212211648-25d852aebe32|MIT License
|
||||
[go-jose/v4](https://github.com/go-jose/go-jose)|v4.1.3|Apache License 2.0
|
||||
[go-logr/logr](https://github.com/go-logr/logr)|v1.4.3|Apache License 2.0
|
||||
[jwt/v5](https://github.com/golang-jwt/jwt)|v5.3.0|MIT License
|
||||
[golang/protobuf](https://github.com/golang/protobuf)|v1.5.4|BSD 3-clause "New" or "Revised" License
|
||||
[google/cel-go](https://github.com/google/cel-go)|v0.26.1|Apache License 2.0
|
||||
[jwt/v5](https://github.com/golang-jwt/jwt)|v5.3.1|MIT License
|
||||
[google/cel-go](https://github.com/google/cel-go)|v0.27.0|Apache License 2.0
|
||||
[google/go-cmp](https://github.com/google/go-cmp)|v0.7.0|BSD 3-clause "New" or "Revised" License
|
||||
[google/uuid](https://github.com/google/uuid)|v1.6.0|BSD 3-clause "New" or "Revised" License
|
||||
[grpc-ecosystem/go-grpc-middleware](https://github.com/grpc-ecosystem/go-grpc-middleware)|v1.4.0|Apache License 2.0
|
||||
[kagent-dev/mockllm](https://github.com/kagent-dev/mockllm)|v0.0.2-0.20251008144831-c6105837f767|Apache License 2.0
|
||||
[kagent-dev/mockllm](https://github.com/kagent-dev/mockllm)|v0.0.5|Apache License 2.0
|
||||
[kelseyhightower/envconfig](https://github.com/kelseyhightower/envconfig)|v1.4.0|MIT License
|
||||
[ginkgo/v2](https://github.com/onsi/ginkgo)|v2.27.2|MIT License
|
||||
[onsi/gomega](https://github.com/onsi/gomega)|v1.38.2|MIT License
|
||||
[openai/openai-go](https://github.com/openai/openai-go)|v1.12.0|Apache License 2.0
|
||||
[modelcontextprotocol/go-sdk](https://github.com/modelcontextprotocol/go-sdk)|v1.4.1|Apache License 2.0
|
||||
[ginkgo/v2](https://github.com/onsi/ginkgo)|v2.28.1|MIT License
|
||||
[onsi/gomega](https://github.com/onsi/gomega)|v1.39.1|MIT License
|
||||
[openai-go/v3](https://github.com/openai/openai-go)|v3.29.0|Apache License 2.0
|
||||
[prometheus/client_golang](https://github.com/prometheus/client_golang)|v1.23.2|Apache License 2.0
|
||||
[prometheus/client_model](https://github.com/prometheus/client_model)|v0.6.2|Apache License 2.0
|
||||
[prometheus/common](https://github.com/prometheus/common)|v0.67.1|Apache License 2.0
|
||||
[prometheus/common](https://github.com/prometheus/common)|v0.67.5|Apache License 2.0
|
||||
[spf13/cobra](https://github.com/spf13/cobra)|v1.10.2|Apache License 2.0
|
||||
[stretchr/testify](https://github.com/stretchr/testify)|v1.11.1|MIT License
|
||||
[go.opencensus.io](https://go.opencensus.io)|v0.24.0|Apache License 2.0
|
||||
[go.uber.org/atomic](https://go.uber.org/atomic)|v1.11.0|MIT License
|
||||
[go.uber.org/zap](https://go.uber.org/zap)|v1.27.1|MIT License
|
||||
[x/net](https://golang.org/x/net)|v0.48.0|BSD 3-clause "New" or "Revised" License
|
||||
[x/time](https://golang.org/x/time)|v0.14.0|BSD 3-clause "New" or "Revised" License
|
||||
[google.golang.org/grpc](https://google.golang.org/grpc)|v1.77.0|Apache License 2.0
|
||||
[x/net](https://golang.org/x/net)|v0.52.0|BSD 3-clause "New" or "Revised" License
|
||||
[x/sync](https://golang.org/x/sync)|v0.20.0|BSD 3-clause "New" or "Revised" License
|
||||
[x/time](https://golang.org/x/time)|v0.15.0|BSD 3-clause "New" or "Revised" License
|
||||
[x/tools](https://golang.org/x/tools)|v0.43.0|BSD 3-clause "New" or "Revised" License
|
||||
[googleapis/rpc](https://google.golang.org/genproto/googleapis/rpc)|v0.0.0-20260319201613-d00831a3d3e7|Apache License 2.0
|
||||
[google.golang.org/grpc](https://google.golang.org/grpc)|v1.79.3|Apache License 2.0
|
||||
[google.golang.org/protobuf](https://google.golang.org/protobuf)|v1.36.11|BSD 3-clause "New" or "Revised" License
|
||||
[helm/v3](https://helm.sh/helm/v3)|v3.19.2|Apache License 2.0
|
||||
[istio.io/api](https://istio.io/api)|v1.28.0-alpha.0.0.20251210001900-ce7b5802387c|Apache License 2.0
|
||||
[istio.io/client-go](https://istio.io/client-go)|v1.28.0-alpha.0.0.20251210002059-b67694478a4b|Apache License 2.0
|
||||
[istio.io/istio](https://istio.io/istio)|v0.0.0-20251218162427-600ea84d2996|Apache License 2.0
|
||||
[k8s.io/api](https://k8s.io/api)|v0.34.1|Apache License 2.0
|
||||
[k8s.io/apiextensions-apiserver](https://k8s.io/apiextensions-apiserver)|v0.34.1|Apache License 2.0
|
||||
[k8s.io/apimachinery](https://k8s.io/apimachinery)|v0.34.3|Apache License 2.0
|
||||
[k8s.io/client-go](https://k8s.io/client-go)|v0.34.1|Apache License 2.0
|
||||
[klog/v2](https://k8s.io/klog/v2)|v2.130.1|Apache License 2.0
|
||||
[k8s.io/utils](https://k8s.io/utils)|v0.0.0-20251002143259-bc988d571ff4|Apache License 2.0
|
||||
[sigs.k8s.io/controller-runtime](https://sigs.k8s.io/controller-runtime)|v0.22.3|Apache License 2.0
|
||||
[sigs.k8s.io/gateway-api](https://sigs.k8s.io/gateway-api)|v1.4.1|Apache License 2.0
|
||||
[sigs.k8s.io/gateway-api-inference-extension](https://sigs.k8s.io/gateway-api-inference-extension)|v1.1.0|Apache License 2.0
|
||||
[helm/v3](https://helm.sh/helm/v3)|v3.20.1|Apache License 2.0
|
||||
[istio.io/api](https://istio.io/api)|v1.29.0-alpha.0.0.20260315093121-ce7e56c13e1d|Apache License 2.0
|
||||
[istio.io/client-go](https://istio.io/client-go)|v1.29.0-alpha.0.0.20260315093321-a99807642da7|Apache License 2.0
|
||||
[istio.io/istio](https://istio.io/istio)|v0.0.0-20260407051556-b9f70d130eb6|Apache License 2.0
|
||||
[k8s.io/api](https://k8s.io/api)|v0.35.3|Apache License 2.0
|
||||
[k8s.io/apiextensions-apiserver](https://k8s.io/apiextensions-apiserver)|v0.35.3|Apache License 2.0
|
||||
[k8s.io/apimachinery](https://k8s.io/apimachinery)|v0.35.3|Apache License 2.0
|
||||
[k8s.io/client-go](https://k8s.io/client-go)|v0.35.3|Apache License 2.0
|
||||
[klog/v2](https://k8s.io/klog/v2)|v2.140.0|Apache License 2.0
|
||||
[k8s.io/utils](https://k8s.io/utils)|v0.0.0-20260319190234-28399d86e0b5|Apache License 2.0
|
||||
[sigs.k8s.io/controller-runtime](https://sigs.k8s.io/controller-runtime)|v0.23.3|Apache License 2.0
|
||||
[sigs.k8s.io/controller-tools](https://sigs.k8s.io/controller-tools)|v0.20.1|Apache License 2.0
|
||||
[sigs.k8s.io/gateway-api](https://sigs.k8s.io/gateway-api)|v1.5.1|Apache License 2.0
|
||||
[sigs.k8s.io/gateway-api-inference-extension](https://sigs.k8s.io/gateway-api-inference-extension)|v1.4.0|Apache License 2.0
|
||||
[gateway-api-inference-extension/conformance](https://sigs.k8s.io/gateway-api-inference-extension/conformance)|v0.0.0-20260319184001-6e787dd396f0|Apache License 2.0
|
||||
[gateway-api/conformance](https://sigs.k8s.io/gateway-api/conformance)|v1.5.1|Apache License 2.0
|
||||
[sigs.k8s.io/yaml](https://sigs.k8s.io/yaml)|v1.6.0|MIT License
|
||||
[cmd/goimports](https://golang.org/x/tools/cmd/goimports)|latest|MIT License
|
||||
[gogo/protobuf](https://github.com/gogo/protobuf)|latest|MIT License
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -5,15 +5,15 @@ metadata:
|
||||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.20.0
|
||||
labels:
|
||||
app: kgateway
|
||||
app.kubernetes.io/name: kgateway
|
||||
app: agentgateway
|
||||
app.kubernetes.io/name: agentgateway
|
||||
gateway.networking.k8s.io/policy: Direct
|
||||
name: agentgatewayparameters.agentgateway.dev
|
||||
spec:
|
||||
group: agentgateway.dev
|
||||
names:
|
||||
categories:
|
||||
- kgateway
|
||||
- agentgateway
|
||||
kind: AgentgatewayParameters
|
||||
listKind: AgentgatewayParametersList
|
||||
plural: agentgatewayparameters
|
||||
@ -56,15 +56,16 @@ spec:
|
||||
description: spec defines the desired state of AgentgatewayParameters.
|
||||
properties:
|
||||
deployment:
|
||||
description: deployment allows specifying overrides for the generated
|
||||
Deployment resource.
|
||||
description: |-
|
||||
`deployment` allows specifying overrides for the generated
|
||||
`Deployment` resource.
|
||||
properties:
|
||||
metadata:
|
||||
description: |-
|
||||
metadata defines a subset of object metadata to be customized.
|
||||
Labels and annotations are merged with existing values. If both GatewayClass
|
||||
and Gateway parameters define the same label or annotation key, the Gateway
|
||||
value takes precedence (applied second).
|
||||
`metadata` defines a subset of object metadata to be customized.
|
||||
`labels` and `annotations` are merged with existing values. If both
|
||||
`GatewayClass` and `Gateway` parameters define the same label or
|
||||
annotation key, the `Gateway` value takes precedence (applied second).
|
||||
properties:
|
||||
annotations:
|
||||
additionalProperties:
|
||||
@ -86,55 +87,56 @@ spec:
|
||||
type: object
|
||||
type: object
|
||||
spec:
|
||||
description: "Spec provides an opaque mechanism to configure the
|
||||
resource Spec.\nThis field accepts a complete or partial Kubernetes
|
||||
resource spec (e.g., PodSpec, ServiceSpec)\nand will be merged
|
||||
with the generated configuration using **Strategic Merge Patch**
|
||||
semantics.\n\n# Application Order\n\nOverlays are applied after
|
||||
all typed configuration fields from both levels.\nThe full merge
|
||||
order is:\n\n 1. GatewayClass typed configuration fields\n 2.
|
||||
Gateway typed configuration fields\n 3. GatewayClass overlays\n
|
||||
4. Gateway overlays (can override all previous values)\n\n#
|
||||
Strategic Merge Patch & Deletion Guide\n\nThis merge strategy
|
||||
allows you to override individual fields, merge lists, or delete
|
||||
items\nwithout needing to provide the entire resource definition.\n\n**1.
|
||||
Replacing Values (Scalars):**\nSimple fields (strings, integers,
|
||||
booleans) in your config will overwrite the generated defaults.\n\n**2.
|
||||
Merging Lists (Append/Merge):**\nLists with \"merge keys\" (like
|
||||
`containers` which merges on `name`, or `tolerations` which
|
||||
merges on `key`)\nwill append your items to the generated list,
|
||||
or update existing items if keys match.\n\n**3. Deleting Fields
|
||||
or List Items ($patch: delete):**\nTo remove a field or list
|
||||
item from the generated resource, use the\n`$patch: delete`
|
||||
directive. This works for both map fields and list items,\nand
|
||||
description: "`spec` provides an opaque mechanism to configure
|
||||
the resource spec.\nThis field accepts a complete or partial
|
||||
Kubernetes resource spec, such\nas `PodSpec` or `ServiceSpec`,
|
||||
and will be merged with the generated\nconfiguration using **Strategic
|
||||
Merge Patch** semantics.\n\n# Application Order\n\nOverlays
|
||||
are applied after all typed configuration fields from both levels.\nThe
|
||||
full merge order is:\n\n 1. `GatewayClass` typed configuration
|
||||
fields\n 2. `Gateway` typed configuration fields\n 3. `GatewayClass`
|
||||
overlays\n 4. `Gateway` overlays (can override all previous
|
||||
values)\n\n# Strategic Merge Patch & Deletion Guide\n\nThis
|
||||
merge strategy allows you to override individual fields, merge
|
||||
lists, or delete items\nwithout needing to provide the entire
|
||||
resource definition.\n\n**1. Replacing Values (Scalars):**\nSimple
|
||||
fields (strings, integers, booleans) in your config will overwrite
|
||||
the generated defaults.\n\n**2. Merging Lists (Append/Merge):**\nLists
|
||||
with \"merge keys\", like `containers` which merges on `name`,
|
||||
or\n`tolerations` which merges on `key`,\nwill append your items
|
||||
to the generated list, or update existing items if keys match.\n\n**3.
|
||||
Deleting Fields or List Items ($patch: delete):**\nTo remove
|
||||
a field or list item from the generated resource, use the\n`$patch:
|
||||
delete` directive. This works for both map fields and list items,\nand
|
||||
is the recommended approach because it works with both client-side\nand
|
||||
server-side apply.\n\n\tspec:\n\t template:\n\t spec:\n\t
|
||||
\ # Delete pod-level securityContext\n\t securityContext:\n\t
|
||||
\ $patch: delete\n\t # Delete nodeSelector\n\t nodeSelector:\n\t
|
||||
\ $patch: delete\n\t containers:\n\t # Be
|
||||
sure to use the correct proxy name here or you will add a container
|
||||
instead of modifying a container:\n\t - name: proxy-name\n\t
|
||||
\ # Delete container-level securityContext\n\t securityContext:\n\t
|
||||
\ $patch: delete\n\n**4. Null Values (server-side
|
||||
apply only):**\nSetting a field to `null` can also remove it,
|
||||
but this ONLY works with\n`kubectl apply --server-side` or equivalent.
|
||||
With regular client-side\n`kubectl apply`, null values are stripped
|
||||
by kubectl before reaching\nthe API server, so the deletion
|
||||
won't occur. Prefer `$patch: delete`\nfor consistent behavior
|
||||
across both apply modes.\n\n\tspec:\n\t template:\n\t spec:\n\t
|
||||
\ nodeSelector: null # Removes nodeSelector (server-side
|
||||
apply only!)\n\n**5. Replacing Maps Entirely ($patch: replace):**\nTo
|
||||
replace an entire map with your values (instead of merging),
|
||||
use `$patch: replace`.\nThis removes all existing keys and replaces
|
||||
them with only your specified keys.\n\n\tspec:\n\t template:\n\t
|
||||
\ spec:\n\t nodeSelector:\n\t $patch: replace\n\t
|
||||
\ custom-key: custom-value\n\n**6. Replacing Lists Entirely
|
||||
($patch: replace):**\nIf you want to strictly define a list
|
||||
and ignore all generated defaults, use `$patch: replace`.\n\n\tservice:\n\t
|
||||
\ spec:\n\t ports:\n\t - $patch: replace\n\t -
|
||||
name: http\n\t port: 80\n\t targetPort: 8080\n\t
|
||||
\ protocol: TCP\n\t - name: https\n\t port:
|
||||
443\n\t targetPort: 8443\n\t protocol: TCP"
|
||||
\ $patch: delete\n\t containers:\n\t # Be sure
|
||||
to use the correct proxy name here or you will add a\n\t #
|
||||
container instead of modifying a container.\n\t - name:
|
||||
proxy-name\n\t # Delete container-level securityContext\n\t
|
||||
\ securityContext:\n\t $patch: delete\n\n**4.
|
||||
Null Values (server-side apply only):**\nSetting a field to
|
||||
`null` can also remove it, but this ONLY works with\n`kubectl
|
||||
apply --server-side` or equivalent. With regular client-side\n`kubectl
|
||||
apply`, null values are stripped by kubectl before reaching\nthe
|
||||
API server, so the deletion won't occur. Prefer `$patch: delete`\nfor
|
||||
consistent behavior across both apply modes.\n\n\tspec:\n\t
|
||||
\ template:\n\t spec:\n\t nodeSelector: null # Removes
|
||||
nodeSelector (server-side apply only!)\n\n**5. Replacing Maps
|
||||
Entirely ($patch: replace):**\nTo replace an entire map with
|
||||
your values (instead of merging), use `$patch: replace`.\nThis
|
||||
removes all existing keys and replaces them with only your specified
|
||||
keys.\n\n\tspec:\n\t template:\n\t spec:\n\t nodeSelector:\n\t
|
||||
\ $patch: replace\n\t custom-key: custom-value\n\n**6.
|
||||
Replacing Lists Entirely ($patch: replace):**\nIf you want to
|
||||
strictly define a list and ignore all generated defaults, use
|
||||
`$patch: replace`.\n\n\tservice:\n\t spec:\n\t ports:\n\t
|
||||
\ - $patch: replace\n\t - name: http\n\t port: 80\n\t
|
||||
\ targetPort: 8080\n\t protocol: TCP\n\t - name:
|
||||
https\n\t port: 443\n\t targetPort: 8443\n\t protocol:
|
||||
TCP"
|
||||
type: object
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
type: object
|
||||
@ -142,13 +144,16 @@ spec:
|
||||
description: |-
|
||||
The container environment variables. These override any existing
|
||||
values. If you want to delete an environment variable entirely, use
|
||||
`$patch: delete` with AgentgatewayParametersOverlays instead. Note that
|
||||
`$patch: delete` with `AgentgatewayParametersOverlays` instead. Note that
|
||||
[variable
|
||||
expansion](https://kubernetes.io/docs/tasks/inject-data-application/define-interdependent-environment-variables/)
|
||||
does apply, but is highly discouraged -- to set dependent environment
|
||||
variables, you can use $(VAR_NAME), but it's highly
|
||||
discouraged. `$$(VAR_NAME)` avoids expansion and results in a literal
|
||||
variables, you can use `$(VAR_NAME)`, but it's highly discouraged.
|
||||
`$$(VAR_NAME)` avoids expansion and results in a literal
|
||||
`$(VAR_NAME)`.
|
||||
|
||||
If `SESSION_KEY` is specified, it takes precedence over the
|
||||
controller-managed per-`Gateway` session key `Secret`.
|
||||
items:
|
||||
description: EnvVar represents an environment variable present in
|
||||
a Container.
|
||||
@ -306,17 +311,18 @@ spec:
|
||||
type: array
|
||||
horizontalPodAutoscaler:
|
||||
description: |-
|
||||
horizontalPodAutoscaler allows creating a HorizontalPodAutoscaler for the agentgateway proxy.
|
||||
If absent, no HPA is created. If present, an HPA is created with its scaleTargetRef
|
||||
automatically configured to target the agentgateway proxy Deployment.
|
||||
The metadata and spec fields from this overlay are applied to the generated HPA.
|
||||
`horizontalPodAutoscaler` allows creating a `HorizontalPodAutoscaler`
|
||||
for the agentgateway proxy. If absent, no HPA is created. If present, an
|
||||
HPA is created with its `scaleTargetRef` automatically configured to
|
||||
target the agentgateway proxy `Deployment`. The `metadata` and `spec`
|
||||
fields from this overlay are applied to the generated HPA.
|
||||
properties:
|
||||
metadata:
|
||||
description: |-
|
||||
metadata defines a subset of object metadata to be customized.
|
||||
Labels and annotations are merged with existing values. If both GatewayClass
|
||||
and Gateway parameters define the same label or annotation key, the Gateway
|
||||
value takes precedence (applied second).
|
||||
`metadata` defines a subset of object metadata to be customized.
|
||||
`labels` and `annotations` are merged with existing values. If both
|
||||
`GatewayClass` and `Gateway` parameters define the same label or
|
||||
annotation key, the `Gateway` value takes precedence (applied second).
|
||||
properties:
|
||||
annotations:
|
||||
additionalProperties:
|
||||
@ -338,55 +344,56 @@ spec:
|
||||
type: object
|
||||
type: object
|
||||
spec:
|
||||
description: "Spec provides an opaque mechanism to configure the
|
||||
resource Spec.\nThis field accepts a complete or partial Kubernetes
|
||||
resource spec (e.g., PodSpec, ServiceSpec)\nand will be merged
|
||||
with the generated configuration using **Strategic Merge Patch**
|
||||
semantics.\n\n# Application Order\n\nOverlays are applied after
|
||||
all typed configuration fields from both levels.\nThe full merge
|
||||
order is:\n\n 1. GatewayClass typed configuration fields\n 2.
|
||||
Gateway typed configuration fields\n 3. GatewayClass overlays\n
|
||||
4. Gateway overlays (can override all previous values)\n\n#
|
||||
Strategic Merge Patch & Deletion Guide\n\nThis merge strategy
|
||||
allows you to override individual fields, merge lists, or delete
|
||||
items\nwithout needing to provide the entire resource definition.\n\n**1.
|
||||
Replacing Values (Scalars):**\nSimple fields (strings, integers,
|
||||
booleans) in your config will overwrite the generated defaults.\n\n**2.
|
||||
Merging Lists (Append/Merge):**\nLists with \"merge keys\" (like
|
||||
`containers` which merges on `name`, or `tolerations` which
|
||||
merges on `key`)\nwill append your items to the generated list,
|
||||
or update existing items if keys match.\n\n**3. Deleting Fields
|
||||
or List Items ($patch: delete):**\nTo remove a field or list
|
||||
item from the generated resource, use the\n`$patch: delete`
|
||||
directive. This works for both map fields and list items,\nand
|
||||
description: "`spec` provides an opaque mechanism to configure
|
||||
the resource spec.\nThis field accepts a complete or partial
|
||||
Kubernetes resource spec, such\nas `PodSpec` or `ServiceSpec`,
|
||||
and will be merged with the generated\nconfiguration using **Strategic
|
||||
Merge Patch** semantics.\n\n# Application Order\n\nOverlays
|
||||
are applied after all typed configuration fields from both levels.\nThe
|
||||
full merge order is:\n\n 1. `GatewayClass` typed configuration
|
||||
fields\n 2. `Gateway` typed configuration fields\n 3. `GatewayClass`
|
||||
overlays\n 4. `Gateway` overlays (can override all previous
|
||||
values)\n\n# Strategic Merge Patch & Deletion Guide\n\nThis
|
||||
merge strategy allows you to override individual fields, merge
|
||||
lists, or delete items\nwithout needing to provide the entire
|
||||
resource definition.\n\n**1. Replacing Values (Scalars):**\nSimple
|
||||
fields (strings, integers, booleans) in your config will overwrite
|
||||
the generated defaults.\n\n**2. Merging Lists (Append/Merge):**\nLists
|
||||
with \"merge keys\", like `containers` which merges on `name`,
|
||||
or\n`tolerations` which merges on `key`,\nwill append your items
|
||||
to the generated list, or update existing items if keys match.\n\n**3.
|
||||
Deleting Fields or List Items ($patch: delete):**\nTo remove
|
||||
a field or list item from the generated resource, use the\n`$patch:
|
||||
delete` directive. This works for both map fields and list items,\nand
|
||||
is the recommended approach because it works with both client-side\nand
|
||||
server-side apply.\n\n\tspec:\n\t template:\n\t spec:\n\t
|
||||
\ # Delete pod-level securityContext\n\t securityContext:\n\t
|
||||
\ $patch: delete\n\t # Delete nodeSelector\n\t nodeSelector:\n\t
|
||||
\ $patch: delete\n\t containers:\n\t # Be
|
||||
sure to use the correct proxy name here or you will add a container
|
||||
instead of modifying a container:\n\t - name: proxy-name\n\t
|
||||
\ # Delete container-level securityContext\n\t securityContext:\n\t
|
||||
\ $patch: delete\n\n**4. Null Values (server-side
|
||||
apply only):**\nSetting a field to `null` can also remove it,
|
||||
but this ONLY works with\n`kubectl apply --server-side` or equivalent.
|
||||
With regular client-side\n`kubectl apply`, null values are stripped
|
||||
by kubectl before reaching\nthe API server, so the deletion
|
||||
won't occur. Prefer `$patch: delete`\nfor consistent behavior
|
||||
across both apply modes.\n\n\tspec:\n\t template:\n\t spec:\n\t
|
||||
\ nodeSelector: null # Removes nodeSelector (server-side
|
||||
apply only!)\n\n**5. Replacing Maps Entirely ($patch: replace):**\nTo
|
||||
replace an entire map with your values (instead of merging),
|
||||
use `$patch: replace`.\nThis removes all existing keys and replaces
|
||||
them with only your specified keys.\n\n\tspec:\n\t template:\n\t
|
||||
\ spec:\n\t nodeSelector:\n\t $patch: replace\n\t
|
||||
\ custom-key: custom-value\n\n**6. Replacing Lists Entirely
|
||||
($patch: replace):**\nIf you want to strictly define a list
|
||||
and ignore all generated defaults, use `$patch: replace`.\n\n\tservice:\n\t
|
||||
\ spec:\n\t ports:\n\t - $patch: replace\n\t -
|
||||
name: http\n\t port: 80\n\t targetPort: 8080\n\t
|
||||
\ protocol: TCP\n\t - name: https\n\t port:
|
||||
443\n\t targetPort: 8443\n\t protocol: TCP"
|
||||
\ $patch: delete\n\t containers:\n\t # Be sure
|
||||
to use the correct proxy name here or you will add a\n\t #
|
||||
container instead of modifying a container.\n\t - name:
|
||||
proxy-name\n\t # Delete container-level securityContext\n\t
|
||||
\ securityContext:\n\t $patch: delete\n\n**4.
|
||||
Null Values (server-side apply only):**\nSetting a field to
|
||||
`null` can also remove it, but this ONLY works with\n`kubectl
|
||||
apply --server-side` or equivalent. With regular client-side\n`kubectl
|
||||
apply`, null values are stripped by kubectl before reaching\nthe
|
||||
API server, so the deletion won't occur. Prefer `$patch: delete`\nfor
|
||||
consistent behavior across both apply modes.\n\n\tspec:\n\t
|
||||
\ template:\n\t spec:\n\t nodeSelector: null # Removes
|
||||
nodeSelector (server-side apply only!)\n\n**5. Replacing Maps
|
||||
Entirely ($patch: replace):**\nTo replace an entire map with
|
||||
your values (instead of merging), use `$patch: replace`.\nThis
|
||||
removes all existing keys and replaces them with only your specified
|
||||
keys.\n\n\tspec:\n\t template:\n\t spec:\n\t nodeSelector:\n\t
|
||||
\ $patch: replace\n\t custom-key: custom-value\n\n**6.
|
||||
Replacing Lists Entirely ($patch: replace):**\nIf you want to
|
||||
strictly define a list and ignore all generated defaults, use
|
||||
`$patch: replace`.\n\n\tservice:\n\t spec:\n\t ports:\n\t
|
||||
\ - $patch: replace\n\t - name: http\n\t port: 80\n\t
|
||||
\ targetPort: 8080\n\t protocol: TCP\n\t - name:
|
||||
https\n\t port: 443\n\t targetPort: 8443\n\t protocol:
|
||||
TCP"
|
||||
type: object
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
type: object
|
||||
@ -429,8 +436,9 @@ spec:
|
||||
type: string
|
||||
type: object
|
||||
logging:
|
||||
description: logging configuration for Agentgateway. By default, all
|
||||
logs are set to "info" level.
|
||||
description: |-
|
||||
`logging` configuration for Agentgateway. By default, all logs are set to
|
||||
`info` level.
|
||||
properties:
|
||||
format:
|
||||
description: The default logging format is text.
|
||||
@ -440,24 +448,25 @@ spec:
|
||||
type: string
|
||||
level:
|
||||
description: |-
|
||||
Logging level in standard RUST_LOG syntax, e.g. 'info', the default, or
|
||||
by module, comma-separated. E.g.,
|
||||
"rmcp=warn,hickory_server::server::server_future=off,typespec_client_core::http::policies::logging=warn"
|
||||
Logging level in standard `RUST_LOG` syntax, for example `info` (the
|
||||
default), or a comma-separated per-module setting such as
|
||||
`rmcp=warn,hickory_server::server::server_future=off,typespec_client_core::http::policies::logging=warn`.
|
||||
type: string
|
||||
type: object
|
||||
podDisruptionBudget:
|
||||
description: |-
|
||||
podDisruptionBudget allows creating a PodDisruptionBudget for the agentgateway proxy.
|
||||
If absent, no PDB is created. If present, a PDB is created with its selector
|
||||
automatically configured to target the agentgateway proxy Deployment.
|
||||
The metadata and spec fields from this overlay are applied to the generated PDB.
|
||||
`podDisruptionBudget` allows creating a `PodDisruptionBudget` for the
|
||||
agentgateway proxy. If absent, no PDB is created. If present, a PDB is
|
||||
created with its selector automatically configured to target the
|
||||
agentgateway proxy `Deployment`. The `metadata` and `spec` fields from
|
||||
this overlay are applied to the generated PDB.
|
||||
properties:
|
||||
metadata:
|
||||
description: |-
|
||||
metadata defines a subset of object metadata to be customized.
|
||||
Labels and annotations are merged with existing values. If both GatewayClass
|
||||
and Gateway parameters define the same label or annotation key, the Gateway
|
||||
value takes precedence (applied second).
|
||||
`metadata` defines a subset of object metadata to be customized.
|
||||
`labels` and `annotations` are merged with existing values. If both
|
||||
`GatewayClass` and `Gateway` parameters define the same label or
|
||||
annotation key, the `Gateway` value takes precedence (applied second).
|
||||
properties:
|
||||
annotations:
|
||||
additionalProperties:
|
||||
@ -479,71 +488,73 @@ spec:
|
||||
type: object
|
||||
type: object
|
||||
spec:
|
||||
description: "Spec provides an opaque mechanism to configure the
|
||||
resource Spec.\nThis field accepts a complete or partial Kubernetes
|
||||
resource spec (e.g., PodSpec, ServiceSpec)\nand will be merged
|
||||
with the generated configuration using **Strategic Merge Patch**
|
||||
semantics.\n\n# Application Order\n\nOverlays are applied after
|
||||
all typed configuration fields from both levels.\nThe full merge
|
||||
order is:\n\n 1. GatewayClass typed configuration fields\n 2.
|
||||
Gateway typed configuration fields\n 3. GatewayClass overlays\n
|
||||
4. Gateway overlays (can override all previous values)\n\n#
|
||||
Strategic Merge Patch & Deletion Guide\n\nThis merge strategy
|
||||
allows you to override individual fields, merge lists, or delete
|
||||
items\nwithout needing to provide the entire resource definition.\n\n**1.
|
||||
Replacing Values (Scalars):**\nSimple fields (strings, integers,
|
||||
booleans) in your config will overwrite the generated defaults.\n\n**2.
|
||||
Merging Lists (Append/Merge):**\nLists with \"merge keys\" (like
|
||||
`containers` which merges on `name`, or `tolerations` which
|
||||
merges on `key`)\nwill append your items to the generated list,
|
||||
or update existing items if keys match.\n\n**3. Deleting Fields
|
||||
or List Items ($patch: delete):**\nTo remove a field or list
|
||||
item from the generated resource, use the\n`$patch: delete`
|
||||
directive. This works for both map fields and list items,\nand
|
||||
description: "`spec` provides an opaque mechanism to configure
|
||||
the resource spec.\nThis field accepts a complete or partial
|
||||
Kubernetes resource spec, such\nas `PodSpec` or `ServiceSpec`,
|
||||
and will be merged with the generated\nconfiguration using **Strategic
|
||||
Merge Patch** semantics.\n\n# Application Order\n\nOverlays
|
||||
are applied after all typed configuration fields from both levels.\nThe
|
||||
full merge order is:\n\n 1. `GatewayClass` typed configuration
|
||||
fields\n 2. `Gateway` typed configuration fields\n 3. `GatewayClass`
|
||||
overlays\n 4. `Gateway` overlays (can override all previous
|
||||
values)\n\n# Strategic Merge Patch & Deletion Guide\n\nThis
|
||||
merge strategy allows you to override individual fields, merge
|
||||
lists, or delete items\nwithout needing to provide the entire
|
||||
resource definition.\n\n**1. Replacing Values (Scalars):**\nSimple
|
||||
fields (strings, integers, booleans) in your config will overwrite
|
||||
the generated defaults.\n\n**2. Merging Lists (Append/Merge):**\nLists
|
||||
with \"merge keys\", like `containers` which merges on `name`,
|
||||
or\n`tolerations` which merges on `key`,\nwill append your items
|
||||
to the generated list, or update existing items if keys match.\n\n**3.
|
||||
Deleting Fields or List Items ($patch: delete):**\nTo remove
|
||||
a field or list item from the generated resource, use the\n`$patch:
|
||||
delete` directive. This works for both map fields and list items,\nand
|
||||
is the recommended approach because it works with both client-side\nand
|
||||
server-side apply.\n\n\tspec:\n\t template:\n\t spec:\n\t
|
||||
\ # Delete pod-level securityContext\n\t securityContext:\n\t
|
||||
\ $patch: delete\n\t # Delete nodeSelector\n\t nodeSelector:\n\t
|
||||
\ $patch: delete\n\t containers:\n\t # Be
|
||||
sure to use the correct proxy name here or you will add a container
|
||||
instead of modifying a container:\n\t - name: proxy-name\n\t
|
||||
\ # Delete container-level securityContext\n\t securityContext:\n\t
|
||||
\ $patch: delete\n\n**4. Null Values (server-side
|
||||
apply only):**\nSetting a field to `null` can also remove it,
|
||||
but this ONLY works with\n`kubectl apply --server-side` or equivalent.
|
||||
With regular client-side\n`kubectl apply`, null values are stripped
|
||||
by kubectl before reaching\nthe API server, so the deletion
|
||||
won't occur. Prefer `$patch: delete`\nfor consistent behavior
|
||||
across both apply modes.\n\n\tspec:\n\t template:\n\t spec:\n\t
|
||||
\ nodeSelector: null # Removes nodeSelector (server-side
|
||||
apply only!)\n\n**5. Replacing Maps Entirely ($patch: replace):**\nTo
|
||||
replace an entire map with your values (instead of merging),
|
||||
use `$patch: replace`.\nThis removes all existing keys and replaces
|
||||
them with only your specified keys.\n\n\tspec:\n\t template:\n\t
|
||||
\ spec:\n\t nodeSelector:\n\t $patch: replace\n\t
|
||||
\ custom-key: custom-value\n\n**6. Replacing Lists Entirely
|
||||
($patch: replace):**\nIf you want to strictly define a list
|
||||
and ignore all generated defaults, use `$patch: replace`.\n\n\tservice:\n\t
|
||||
\ spec:\n\t ports:\n\t - $patch: replace\n\t -
|
||||
name: http\n\t port: 80\n\t targetPort: 8080\n\t
|
||||
\ protocol: TCP\n\t - name: https\n\t port:
|
||||
443\n\t targetPort: 8443\n\t protocol: TCP"
|
||||
\ $patch: delete\n\t containers:\n\t # Be sure
|
||||
to use the correct proxy name here or you will add a\n\t #
|
||||
container instead of modifying a container.\n\t - name:
|
||||
proxy-name\n\t # Delete container-level securityContext\n\t
|
||||
\ securityContext:\n\t $patch: delete\n\n**4.
|
||||
Null Values (server-side apply only):**\nSetting a field to
|
||||
`null` can also remove it, but this ONLY works with\n`kubectl
|
||||
apply --server-side` or equivalent. With regular client-side\n`kubectl
|
||||
apply`, null values are stripped by kubectl before reaching\nthe
|
||||
API server, so the deletion won't occur. Prefer `$patch: delete`\nfor
|
||||
consistent behavior across both apply modes.\n\n\tspec:\n\t
|
||||
\ template:\n\t spec:\n\t nodeSelector: null # Removes
|
||||
nodeSelector (server-side apply only!)\n\n**5. Replacing Maps
|
||||
Entirely ($patch: replace):**\nTo replace an entire map with
|
||||
your values (instead of merging), use `$patch: replace`.\nThis
|
||||
removes all existing keys and replaces them with only your specified
|
||||
keys.\n\n\tspec:\n\t template:\n\t spec:\n\t nodeSelector:\n\t
|
||||
\ $patch: replace\n\t custom-key: custom-value\n\n**6.
|
||||
Replacing Lists Entirely ($patch: replace):**\nIf you want to
|
||||
strictly define a list and ignore all generated defaults, use
|
||||
`$patch: replace`.\n\n\tservice:\n\t spec:\n\t ports:\n\t
|
||||
\ - $patch: replace\n\t - name: http\n\t port: 80\n\t
|
||||
\ targetPort: 8080\n\t protocol: TCP\n\t - name:
|
||||
https\n\t port: 443\n\t targetPort: 8443\n\t protocol:
|
||||
TCP"
|
||||
type: object
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
type: object
|
||||
rawConfig:
|
||||
description: "rawConfig provides an opaque mechanism to configure
|
||||
the agentgateway\nconfig file (the agentgateway binary has a '-f'
|
||||
option to specify a\nconfig file, and this is that file). This
|
||||
will be merged with\nconfiguration derived from typed fields like\nAgentgatewayParametersLogging.Format,
|
||||
and those typed fields will take\nprecedence.\n\nExample:\n\n\trawConfig:\n\t
|
||||
\ binds:\n\t - port: 3000\n\t listeners:\n\t - routes:\n\t
|
||||
\ - policies:\n\t cors:\n\t allowOrigins:\n\t
|
||||
\ - \"*\"\n\t allowHeaders:\n\t -
|
||||
mcp-protocol-version\n\t - content-type\n\t -
|
||||
cache-control\n\t backends:\n\t - mcp:\n\t targets:\n\t
|
||||
\ - name: everything\n\t stdio:\n\t cmd:
|
||||
npx\n\t args: [\"@modelcontextprotocol/server-everything\"]"
|
||||
description: "`rawConfig` provides an opaque mechanism to configure
|
||||
the `agentgateway`\nconfig file. The `agentgateway` binary has a
|
||||
`-f` option to specify a\nconfig file, and this field supplies that
|
||||
file. This will be merged with\nconfiguration derived from typed
|
||||
fields like `logging.format`, and those\ntyped fields will take
|
||||
precedence.\n\nExample:\n\n\trawConfig:\n\t binds:\n\t - port:
|
||||
3000\n\t listeners:\n\t - routes:\n\t - policies:\n\t
|
||||
\ cors:\n\t allowOrigins:\n\t - \"*\"\n\t
|
||||
\ allowHeaders:\n\t - mcp-protocol-version\n\t
|
||||
\ - content-type\n\t - cache-control\n\t backends:\n\t
|
||||
\ - mcp:\n\t targets:\n\t - name: everything\n\t
|
||||
\ stdio:\n\t cmd: npx\n\t args:
|
||||
[\"@modelcontextprotocol/server-everything\"]"
|
||||
type: object
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
resources:
|
||||
@ -609,15 +620,16 @@ spec:
|
||||
type: object
|
||||
type: object
|
||||
service:
|
||||
description: service allows specifying overrides for the generated
|
||||
Service resource.
|
||||
description: |-
|
||||
`service` allows specifying overrides for the generated `Service`
|
||||
resource.
|
||||
properties:
|
||||
metadata:
|
||||
description: |-
|
||||
metadata defines a subset of object metadata to be customized.
|
||||
Labels and annotations are merged with existing values. If both GatewayClass
|
||||
and Gateway parameters define the same label or annotation key, the Gateway
|
||||
value takes precedence (applied second).
|
||||
`metadata` defines a subset of object metadata to be customized.
|
||||
`labels` and `annotations` are merged with existing values. If both
|
||||
`GatewayClass` and `Gateway` parameters define the same label or
|
||||
annotation key, the `Gateway` value takes precedence (applied second).
|
||||
properties:
|
||||
annotations:
|
||||
additionalProperties:
|
||||
@ -639,68 +651,70 @@ spec:
|
||||
type: object
|
||||
type: object
|
||||
spec:
|
||||
description: "Spec provides an opaque mechanism to configure the
|
||||
resource Spec.\nThis field accepts a complete or partial Kubernetes
|
||||
resource spec (e.g., PodSpec, ServiceSpec)\nand will be merged
|
||||
with the generated configuration using **Strategic Merge Patch**
|
||||
semantics.\n\n# Application Order\n\nOverlays are applied after
|
||||
all typed configuration fields from both levels.\nThe full merge
|
||||
order is:\n\n 1. GatewayClass typed configuration fields\n 2.
|
||||
Gateway typed configuration fields\n 3. GatewayClass overlays\n
|
||||
4. Gateway overlays (can override all previous values)\n\n#
|
||||
Strategic Merge Patch & Deletion Guide\n\nThis merge strategy
|
||||
allows you to override individual fields, merge lists, or delete
|
||||
items\nwithout needing to provide the entire resource definition.\n\n**1.
|
||||
Replacing Values (Scalars):**\nSimple fields (strings, integers,
|
||||
booleans) in your config will overwrite the generated defaults.\n\n**2.
|
||||
Merging Lists (Append/Merge):**\nLists with \"merge keys\" (like
|
||||
`containers` which merges on `name`, or `tolerations` which
|
||||
merges on `key`)\nwill append your items to the generated list,
|
||||
or update existing items if keys match.\n\n**3. Deleting Fields
|
||||
or List Items ($patch: delete):**\nTo remove a field or list
|
||||
item from the generated resource, use the\n`$patch: delete`
|
||||
directive. This works for both map fields and list items,\nand
|
||||
description: "`spec` provides an opaque mechanism to configure
|
||||
the resource spec.\nThis field accepts a complete or partial
|
||||
Kubernetes resource spec, such\nas `PodSpec` or `ServiceSpec`,
|
||||
and will be merged with the generated\nconfiguration using **Strategic
|
||||
Merge Patch** semantics.\n\n# Application Order\n\nOverlays
|
||||
are applied after all typed configuration fields from both levels.\nThe
|
||||
full merge order is:\n\n 1. `GatewayClass` typed configuration
|
||||
fields\n 2. `Gateway` typed configuration fields\n 3. `GatewayClass`
|
||||
overlays\n 4. `Gateway` overlays (can override all previous
|
||||
values)\n\n# Strategic Merge Patch & Deletion Guide\n\nThis
|
||||
merge strategy allows you to override individual fields, merge
|
||||
lists, or delete items\nwithout needing to provide the entire
|
||||
resource definition.\n\n**1. Replacing Values (Scalars):**\nSimple
|
||||
fields (strings, integers, booleans) in your config will overwrite
|
||||
the generated defaults.\n\n**2. Merging Lists (Append/Merge):**\nLists
|
||||
with \"merge keys\", like `containers` which merges on `name`,
|
||||
or\n`tolerations` which merges on `key`,\nwill append your items
|
||||
to the generated list, or update existing items if keys match.\n\n**3.
|
||||
Deleting Fields or List Items ($patch: delete):**\nTo remove
|
||||
a field or list item from the generated resource, use the\n`$patch:
|
||||
delete` directive. This works for both map fields and list items,\nand
|
||||
is the recommended approach because it works with both client-side\nand
|
||||
server-side apply.\n\n\tspec:\n\t template:\n\t spec:\n\t
|
||||
\ # Delete pod-level securityContext\n\t securityContext:\n\t
|
||||
\ $patch: delete\n\t # Delete nodeSelector\n\t nodeSelector:\n\t
|
||||
\ $patch: delete\n\t containers:\n\t # Be
|
||||
sure to use the correct proxy name here or you will add a container
|
||||
instead of modifying a container:\n\t - name: proxy-name\n\t
|
||||
\ # Delete container-level securityContext\n\t securityContext:\n\t
|
||||
\ $patch: delete\n\n**4. Null Values (server-side
|
||||
apply only):**\nSetting a field to `null` can also remove it,
|
||||
but this ONLY works with\n`kubectl apply --server-side` or equivalent.
|
||||
With regular client-side\n`kubectl apply`, null values are stripped
|
||||
by kubectl before reaching\nthe API server, so the deletion
|
||||
won't occur. Prefer `$patch: delete`\nfor consistent behavior
|
||||
across both apply modes.\n\n\tspec:\n\t template:\n\t spec:\n\t
|
||||
\ nodeSelector: null # Removes nodeSelector (server-side
|
||||
apply only!)\n\n**5. Replacing Maps Entirely ($patch: replace):**\nTo
|
||||
replace an entire map with your values (instead of merging),
|
||||
use `$patch: replace`.\nThis removes all existing keys and replaces
|
||||
them with only your specified keys.\n\n\tspec:\n\t template:\n\t
|
||||
\ spec:\n\t nodeSelector:\n\t $patch: replace\n\t
|
||||
\ custom-key: custom-value\n\n**6. Replacing Lists Entirely
|
||||
($patch: replace):**\nIf you want to strictly define a list
|
||||
and ignore all generated defaults, use `$patch: replace`.\n\n\tservice:\n\t
|
||||
\ spec:\n\t ports:\n\t - $patch: replace\n\t -
|
||||
name: http\n\t port: 80\n\t targetPort: 8080\n\t
|
||||
\ protocol: TCP\n\t - name: https\n\t port:
|
||||
443\n\t targetPort: 8443\n\t protocol: TCP"
|
||||
\ $patch: delete\n\t containers:\n\t # Be sure
|
||||
to use the correct proxy name here or you will add a\n\t #
|
||||
container instead of modifying a container.\n\t - name:
|
||||
proxy-name\n\t # Delete container-level securityContext\n\t
|
||||
\ securityContext:\n\t $patch: delete\n\n**4.
|
||||
Null Values (server-side apply only):**\nSetting a field to
|
||||
`null` can also remove it, but this ONLY works with\n`kubectl
|
||||
apply --server-side` or equivalent. With regular client-side\n`kubectl
|
||||
apply`, null values are stripped by kubectl before reaching\nthe
|
||||
API server, so the deletion won't occur. Prefer `$patch: delete`\nfor
|
||||
consistent behavior across both apply modes.\n\n\tspec:\n\t
|
||||
\ template:\n\t spec:\n\t nodeSelector: null # Removes
|
||||
nodeSelector (server-side apply only!)\n\n**5. Replacing Maps
|
||||
Entirely ($patch: replace):**\nTo replace an entire map with
|
||||
your values (instead of merging), use `$patch: replace`.\nThis
|
||||
removes all existing keys and replaces them with only your specified
|
||||
keys.\n\n\tspec:\n\t template:\n\t spec:\n\t nodeSelector:\n\t
|
||||
\ $patch: replace\n\t custom-key: custom-value\n\n**6.
|
||||
Replacing Lists Entirely ($patch: replace):**\nIf you want to
|
||||
strictly define a list and ignore all generated defaults, use
|
||||
`$patch: replace`.\n\n\tservice:\n\t spec:\n\t ports:\n\t
|
||||
\ - $patch: replace\n\t - name: http\n\t port: 80\n\t
|
||||
\ targetPort: 8080\n\t protocol: TCP\n\t - name:
|
||||
https\n\t port: 443\n\t targetPort: 8443\n\t protocol:
|
||||
TCP"
|
||||
type: object
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
type: object
|
||||
serviceAccount:
|
||||
description: serviceAccount allows specifying overrides for the generated
|
||||
ServiceAccount resource.
|
||||
description: |-
|
||||
`serviceAccount` allows specifying overrides for the generated
|
||||
`ServiceAccount` resource.
|
||||
properties:
|
||||
metadata:
|
||||
description: |-
|
||||
metadata defines a subset of object metadata to be customized.
|
||||
Labels and annotations are merged with existing values. If both GatewayClass
|
||||
and Gateway parameters define the same label or annotation key, the Gateway
|
||||
value takes precedence (applied second).
|
||||
`metadata` defines a subset of object metadata to be customized.
|
||||
`labels` and `annotations` are merged with existing values. If both
|
||||
`GatewayClass` and `Gateway` parameters define the same label or
|
||||
annotation key, the `Gateway` value takes precedence (applied second).
|
||||
properties:
|
||||
annotations:
|
||||
additionalProperties:
|
||||
@ -722,70 +736,72 @@ spec:
|
||||
type: object
|
||||
type: object
|
||||
spec:
|
||||
description: "Spec provides an opaque mechanism to configure the
|
||||
resource Spec.\nThis field accepts a complete or partial Kubernetes
|
||||
resource spec (e.g., PodSpec, ServiceSpec)\nand will be merged
|
||||
with the generated configuration using **Strategic Merge Patch**
|
||||
semantics.\n\n# Application Order\n\nOverlays are applied after
|
||||
all typed configuration fields from both levels.\nThe full merge
|
||||
order is:\n\n 1. GatewayClass typed configuration fields\n 2.
|
||||
Gateway typed configuration fields\n 3. GatewayClass overlays\n
|
||||
4. Gateway overlays (can override all previous values)\n\n#
|
||||
Strategic Merge Patch & Deletion Guide\n\nThis merge strategy
|
||||
allows you to override individual fields, merge lists, or delete
|
||||
items\nwithout needing to provide the entire resource definition.\n\n**1.
|
||||
Replacing Values (Scalars):**\nSimple fields (strings, integers,
|
||||
booleans) in your config will overwrite the generated defaults.\n\n**2.
|
||||
Merging Lists (Append/Merge):**\nLists with \"merge keys\" (like
|
||||
`containers` which merges on `name`, or `tolerations` which
|
||||
merges on `key`)\nwill append your items to the generated list,
|
||||
or update existing items if keys match.\n\n**3. Deleting Fields
|
||||
or List Items ($patch: delete):**\nTo remove a field or list
|
||||
item from the generated resource, use the\n`$patch: delete`
|
||||
directive. This works for both map fields and list items,\nand
|
||||
description: "`spec` provides an opaque mechanism to configure
|
||||
the resource spec.\nThis field accepts a complete or partial
|
||||
Kubernetes resource spec, such\nas `PodSpec` or `ServiceSpec`,
|
||||
and will be merged with the generated\nconfiguration using **Strategic
|
||||
Merge Patch** semantics.\n\n# Application Order\n\nOverlays
|
||||
are applied after all typed configuration fields from both levels.\nThe
|
||||
full merge order is:\n\n 1. `GatewayClass` typed configuration
|
||||
fields\n 2. `Gateway` typed configuration fields\n 3. `GatewayClass`
|
||||
overlays\n 4. `Gateway` overlays (can override all previous
|
||||
values)\n\n# Strategic Merge Patch & Deletion Guide\n\nThis
|
||||
merge strategy allows you to override individual fields, merge
|
||||
lists, or delete items\nwithout needing to provide the entire
|
||||
resource definition.\n\n**1. Replacing Values (Scalars):**\nSimple
|
||||
fields (strings, integers, booleans) in your config will overwrite
|
||||
the generated defaults.\n\n**2. Merging Lists (Append/Merge):**\nLists
|
||||
with \"merge keys\", like `containers` which merges on `name`,
|
||||
or\n`tolerations` which merges on `key`,\nwill append your items
|
||||
to the generated list, or update existing items if keys match.\n\n**3.
|
||||
Deleting Fields or List Items ($patch: delete):**\nTo remove
|
||||
a field or list item from the generated resource, use the\n`$patch:
|
||||
delete` directive. This works for both map fields and list items,\nand
|
||||
is the recommended approach because it works with both client-side\nand
|
||||
server-side apply.\n\n\tspec:\n\t template:\n\t spec:\n\t
|
||||
\ # Delete pod-level securityContext\n\t securityContext:\n\t
|
||||
\ $patch: delete\n\t # Delete nodeSelector\n\t nodeSelector:\n\t
|
||||
\ $patch: delete\n\t containers:\n\t # Be
|
||||
sure to use the correct proxy name here or you will add a container
|
||||
instead of modifying a container:\n\t - name: proxy-name\n\t
|
||||
\ # Delete container-level securityContext\n\t securityContext:\n\t
|
||||
\ $patch: delete\n\n**4. Null Values (server-side
|
||||
apply only):**\nSetting a field to `null` can also remove it,
|
||||
but this ONLY works with\n`kubectl apply --server-side` or equivalent.
|
||||
With regular client-side\n`kubectl apply`, null values are stripped
|
||||
by kubectl before reaching\nthe API server, so the deletion
|
||||
won't occur. Prefer `$patch: delete`\nfor consistent behavior
|
||||
across both apply modes.\n\n\tspec:\n\t template:\n\t spec:\n\t
|
||||
\ nodeSelector: null # Removes nodeSelector (server-side
|
||||
apply only!)\n\n**5. Replacing Maps Entirely ($patch: replace):**\nTo
|
||||
replace an entire map with your values (instead of merging),
|
||||
use `$patch: replace`.\nThis removes all existing keys and replaces
|
||||
them with only your specified keys.\n\n\tspec:\n\t template:\n\t
|
||||
\ spec:\n\t nodeSelector:\n\t $patch: replace\n\t
|
||||
\ custom-key: custom-value\n\n**6. Replacing Lists Entirely
|
||||
($patch: replace):**\nIf you want to strictly define a list
|
||||
and ignore all generated defaults, use `$patch: replace`.\n\n\tservice:\n\t
|
||||
\ spec:\n\t ports:\n\t - $patch: replace\n\t -
|
||||
name: http\n\t port: 80\n\t targetPort: 8080\n\t
|
||||
\ protocol: TCP\n\t - name: https\n\t port:
|
||||
443\n\t targetPort: 8443\n\t protocol: TCP"
|
||||
\ $patch: delete\n\t containers:\n\t # Be sure
|
||||
to use the correct proxy name here or you will add a\n\t #
|
||||
container instead of modifying a container.\n\t - name:
|
||||
proxy-name\n\t # Delete container-level securityContext\n\t
|
||||
\ securityContext:\n\t $patch: delete\n\n**4.
|
||||
Null Values (server-side apply only):**\nSetting a field to
|
||||
`null` can also remove it, but this ONLY works with\n`kubectl
|
||||
apply --server-side` or equivalent. With regular client-side\n`kubectl
|
||||
apply`, null values are stripped by kubectl before reaching\nthe
|
||||
API server, so the deletion won't occur. Prefer `$patch: delete`\nfor
|
||||
consistent behavior across both apply modes.\n\n\tspec:\n\t
|
||||
\ template:\n\t spec:\n\t nodeSelector: null # Removes
|
||||
nodeSelector (server-side apply only!)\n\n**5. Replacing Maps
|
||||
Entirely ($patch: replace):**\nTo replace an entire map with
|
||||
your values (instead of merging), use `$patch: replace`.\nThis
|
||||
removes all existing keys and replaces them with only your specified
|
||||
keys.\n\n\tspec:\n\t template:\n\t spec:\n\t nodeSelector:\n\t
|
||||
\ $patch: replace\n\t custom-key: custom-value\n\n**6.
|
||||
Replacing Lists Entirely ($patch: replace):**\nIf you want to
|
||||
strictly define a list and ignore all generated defaults, use
|
||||
`$patch: replace`.\n\n\tservice:\n\t spec:\n\t ports:\n\t
|
||||
\ - $patch: replace\n\t - name: http\n\t port: 80\n\t
|
||||
\ targetPort: 8080\n\t protocol: TCP\n\t - name:
|
||||
https\n\t port: 443\n\t targetPort: 8443\n\t protocol:
|
||||
TCP"
|
||||
type: object
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
type: object
|
||||
shutdown:
|
||||
description: |-
|
||||
Shutdown delay configuration. How graceful planned or unplanned data
|
||||
Shutdown delay configuration. How graceful planned or unplanned data
|
||||
plane changes happen is in tension with how quickly rollouts of the data
|
||||
plane complete. How long a data plane pod must wait for shutdown to be
|
||||
perfectly graceful depends on how you have configured your Gateways.
|
||||
perfectly graceful depends on how you have configured your `Gateway`
|
||||
resources.
|
||||
properties:
|
||||
max:
|
||||
description: |-
|
||||
Maximum time (in seconds) to wait before allowing Agentgateway to
|
||||
terminate. Refer to the TERMINATION_GRACE_PERIOD_SECONDS environment
|
||||
variable for details.
|
||||
terminate. Refer to the `TERMINATION_GRACE_PERIOD_SECONDS`
|
||||
environment variable for details.
|
||||
format: int64
|
||||
maximum: 31536000
|
||||
minimum: 0
|
||||
@ -793,8 +809,8 @@ spec:
|
||||
min:
|
||||
description: |-
|
||||
Minimum time (in seconds) to wait before allowing Agentgateway to
|
||||
terminate. Refer to the CONNECTION_MIN_TERMINATION_DEADLINE environment
|
||||
variable for details.
|
||||
terminate. Refer to the `CONNECTION_MIN_TERMINATION_DEADLINE`
|
||||
environment variable for details.
|
||||
format: int64
|
||||
maximum: 31536000
|
||||
minimum: 0
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -44,6 +44,14 @@ spec:
|
||||
{{- with .Values.securityContext }}
|
||||
securityContext:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- else }}
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: true
|
||||
runAsNonRoot: true
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
{{- end }}
|
||||
image: "{{ .Values.controller.image.registry | default .Values.image.registry }}/{{ .Values.controller.image.repository }}:{{ include "agentgateway.imageTag" (.Values.controller.image.tag | default .Values.image.tag | default .Chart.AppVersion) }}"
|
||||
imagePullPolicy: {{ .Values.controller.image.pullPolicy | default .Values.image.pullPolicy }}
|
||||
@ -104,9 +112,30 @@ spec:
|
||||
- name: AGW_DISCOVERY_NAMESPACE_SELECTORS
|
||||
value: {{ .Values.discoveryNamespaceSelectors | toJson | quote }}
|
||||
{{- if .Values.controller.extraEnv }}
|
||||
{{- range $key, $value := .Values.controller.extraEnv }}
|
||||
{{- $extraEnv := .Values.controller.extraEnv }}
|
||||
{{- range $key := keys $extraEnv | sortAlpha }}
|
||||
{{- $value := index $extraEnv $key }}
|
||||
- name: {{ $key }}
|
||||
{{- if kindIs "map" $value }}
|
||||
{{- $hasValue := hasKey $value "value" }}
|
||||
{{- $hasValueFrom := hasKey $value "valueFrom" }}
|
||||
{{- if and $hasValue $hasValueFrom }}
|
||||
{{- fail (printf "controller.extraEnv.%s cannot set both value and valueFrom" $key) }}
|
||||
{{- else if $hasValue }}
|
||||
value: {{ get $value "value" | quote }}
|
||||
{{- else if $hasValueFrom }}
|
||||
{{- $valueFrom := get $value "valueFrom" }}
|
||||
{{- if not $valueFrom }}
|
||||
{{- fail (printf "controller.extraEnv.%s.valueFrom must be non-empty" $key) }}
|
||||
{{- end }}
|
||||
valueFrom:
|
||||
{{- toYaml $valueFrom | nindent 16 }}
|
||||
{{- else }}
|
||||
{{- fail (printf "controller.extraEnv.%s must set either value or valueFrom" $key) }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
value: {{ $value | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.inferenceExtension.enabled }}
|
||||
|
||||
@ -128,6 +128,7 @@ rules:
|
||||
- gateways
|
||||
- grpcroutes
|
||||
- httproutes
|
||||
- listenersets
|
||||
- referencegrants
|
||||
- tcproutes
|
||||
- tlsroutes
|
||||
@ -143,6 +144,7 @@ rules:
|
||||
- gateways/status
|
||||
- grpcroutes/status
|
||||
- httproutes/status
|
||||
- listenersets/status
|
||||
- tcproutes/status
|
||||
- tlsroutes/status
|
||||
verbs:
|
||||
@ -159,21 +161,6 @@ rules:
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- gateway.networking.x-k8s.io
|
||||
resources:
|
||||
- xlistenersets
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- gateway.networking.x-k8s.io
|
||||
resources:
|
||||
- xlistenersets/status
|
||||
verbs:
|
||||
- patch
|
||||
- update
|
||||
- apiGroups:
|
||||
- networking.istio.io
|
||||
resources:
|
||||
|
||||
@ -112,6 +112,16 @@ controller:
|
||||
# -- Traffic distribution.
|
||||
trafficDistribution: ""
|
||||
# -- Add extra environment variables to the controller container.
|
||||
# Supports either a direct scalar value:
|
||||
# extraEnv:
|
||||
# LOG_FORMAT: json
|
||||
# Or Kubernetes valueFrom sources:
|
||||
# extraEnv:
|
||||
# API_TOKEN:
|
||||
# valueFrom:
|
||||
# secretKeyRef:
|
||||
# name: agentgateway-secrets
|
||||
# key: apiToken
|
||||
extraEnv: {}
|
||||
# -- Configure TLS settings for the xDS gRPC servers.
|
||||
xds:
|
||||
@ -187,7 +197,7 @@ image:
|
||||
# -- Set the default image pull policy.
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
# -- Configure the integration with the Gateway API Inference Extension project, which lets you use agentgateway to route to AI inference workloads like LLMs that run locally in your Kubernetes cluster. Documentation for Inference Extension can be found here: https://kgateway.dev/docs/latest/agentgateway/inference/
|
||||
# -- Configure the integration with the Gateway API Inference Extension project, which lets you use agentgateway to route to AI inference workloads like LLMs that run locally in your Kubernetes cluster. Documentation for Inference Extension can be found here: https://agentgateway.dev/docs/kubernetes/latest/inference/
|
||||
inferenceExtension:
|
||||
# -- Enable Inference Extension support in the agentgateway controller.
|
||||
enabled: false
|
||||
|
||||
@ -9,7 +9,7 @@ import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/kgateway/admin"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/admin"
|
||||
)
|
||||
|
||||
func TestSnapshotResponseDataMarshalJSONString(t *testing.T) {
|
||||
@ -12,18 +12,16 @@ import (
|
||||
|
||||
"istio.io/istio/pkg/kube/krt"
|
||||
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/kgateway/controller"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/kgateway/wellknown"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/controller"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/version"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/wellknown"
|
||||
)
|
||||
|
||||
func RunAdminServer(ctx context.Context, setupOpts *controller.SetupOpts) error {
|
||||
func RunAdminServer(ctx context.Context, setupOpts *controller.SetupOpts) {
|
||||
// serverHandlers defines the custom handlers that the Admin Server will support
|
||||
serverHandlers := getServerHandlers(ctx, setupOpts.KrtDebugger)
|
||||
|
||||
startHandlers(ctx, serverHandlers)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// use a function for the profile descriptions so that every time the admin page is displayed, it can show
|
||||
@ -81,7 +79,7 @@ func startHandlers(ctx context.Context, addHandlers ...func(mux *http.ServeMux,
|
||||
mux.HandleFunc("/", idx)
|
||||
mux.HandleFunc("/snapshots/", idx)
|
||||
server := &http.Server{
|
||||
Addr: fmt.Sprintf("localhost:%d", wellknown.KgatewayAdminPort),
|
||||
Addr: fmt.Sprintf("localhost:%d", wellknown.AdminPort),
|
||||
Handler: mux,
|
||||
ReadHeaderTimeout: 10 * time.Second,
|
||||
}
|
||||
@ -41,6 +41,7 @@ func NewConfigMapSyncer(client apiclient.Client, storePrefix, deploymentNamespac
|
||||
cmCollection := krt.NewFilteredInformer[*corev1.ConfigMap](client,
|
||||
kclient.Filter{
|
||||
ObjectFilter: client.ObjectFilter(),
|
||||
Namespace: deploymentNamespace,
|
||||
LabelSelector: JwksStoreLabelSelector(storePrefix)},
|
||||
krtOptions.ToOptions("config_map_syncer/ConfigMaps")...)
|
||||
|
||||
|
||||
@ -37,10 +37,11 @@ type JwksHttpClient interface {
|
||||
}
|
||||
|
||||
type JwksSource struct {
|
||||
JwksURL string
|
||||
Ttl time.Duration
|
||||
Deleted bool
|
||||
TlsConfig *tls.Config
|
||||
JwksURL string
|
||||
Ttl time.Duration
|
||||
Deleted bool
|
||||
// Exclude from JSON dump as this is not safe for marshaling
|
||||
TlsConfig *tls.Config `json:"-"`
|
||||
}
|
||||
|
||||
func (js JwksSource) ResourceName() string {
|
||||
|
||||
@ -9,7 +9,7 @@ import (
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/apiclient"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/common"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/logging"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/pluginsdk/collections"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/pluginsdk/krtutil"
|
||||
)
|
||||
|
||||
// JwksStore is a top-level abstraction that relies on jwksCache and jwksFetcher to
|
||||
@ -34,7 +34,7 @@ type JwksStore struct {
|
||||
l sync.Mutex
|
||||
}
|
||||
|
||||
func BuildJwksStore(ctx context.Context, cli apiclient.Client, commonCols *collections.CommonCollections, jwksChanges <-chan JwksSource, storePrefix, deploymentNamespace string) *JwksStore {
|
||||
func BuildJwksStore(cli apiclient.Client, krtOpts krtutil.KrtOptions, jwksChanges <-chan JwksSource, storePrefix, deploymentNamespace string) *JwksStore {
|
||||
logger.Info("creating jwks store")
|
||||
|
||||
jwksCache := NewJwksCache()
|
||||
@ -43,7 +43,7 @@ func BuildJwksStore(ctx context.Context, cli apiclient.Client, commonCols *colle
|
||||
jwksCache: jwksCache,
|
||||
jwksChanges: jwksChanges,
|
||||
jwksFetcher: NewJwksFetcher(jwksCache),
|
||||
configMapSyncer: NewConfigMapSyncer(cli, storePrefix, deploymentNamespace, commonCols.KrtOpts),
|
||||
configMapSyncer: NewConfigMapSyncer(cli, storePrefix, deploymentNamespace, krtOpts),
|
||||
cmNameToJwks: make(map[string]string),
|
||||
}
|
||||
BuildJwksConfigMapNamespacedNameFunc(storePrefix, deploymentNamespace)
|
||||
|
||||
@ -13,9 +13,9 @@ import (
|
||||
gwv1 "sigs.k8s.io/gateway-api/apis/v1"
|
||||
|
||||
"github.com/agentgateway/agentgateway/controller/api/v1alpha1/agentgateway"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/kgateway/wellknown"
|
||||
krtpkg "github.com/agentgateway/agentgateway/controller/pkg/utils/krtutil"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/utils/kubeutils"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/wellknown"
|
||||
)
|
||||
|
||||
type JwksUrlBuilder interface {
|
||||
@ -191,7 +191,7 @@ func GetTLSConfig(
|
||||
certPool := x509.NewCertPool()
|
||||
for _, ref := range btls.CACertificateRefs {
|
||||
nn := types.NamespacedName{
|
||||
Name: string(ref.Name),
|
||||
Name: ref.Name,
|
||||
Namespace: namespace,
|
||||
}
|
||||
cfgmap := krt.FetchOne(krtctx, cfgmaps, krt.FilterObjectName(nn))
|
||||
|
||||
@ -164,8 +164,7 @@ func TestRemoteJwksUrlBuilder(t *testing.T) {
|
||||
}
|
||||
|
||||
func setup(t *testing.T, paths []string) plugins.PolicyCtx {
|
||||
val := apitests.NewKgatewayValidator(t)
|
||||
val.SkipMissing = true
|
||||
val := apitests.NewAgentgatewayValidatorSkipMissing(t)
|
||||
mockObjs := []any{}
|
||||
for _, f := range paths {
|
||||
data := file.AsStringOrFail(t, f)
|
||||
|
||||
@ -13,8 +13,8 @@ import (
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/agentgateway/jwks_url"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/agentgateway/plugins"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/apiclient"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/kgateway/wellknown"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/logging"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/wellknown"
|
||||
)
|
||||
|
||||
// JwksStorePolicyController watches AgentgatewayPolicies and Backends. When a resource containing
|
||||
|
||||
@ -8,25 +8,28 @@ import (
|
||||
"istio.io/istio/pkg/ptr"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
||||
"github.com/agentgateway/agentgateway/api"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/kgateway/wellknown"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/agentgateway/utils"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/utils/kubeutils"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/wellknown"
|
||||
)
|
||||
|
||||
const (
|
||||
a2aProtocol = "kgateway.dev/a2a"
|
||||
legacyA2aProtocol = "kgateway.dev/a2a"
|
||||
a2aProtocol = "agentgateway.dev/a2a"
|
||||
)
|
||||
|
||||
// NewA2APlugin creates a new A2A policy plugin
|
||||
func NewA2APlugin(agw *AgwCollections) AgwPlugin {
|
||||
policyCol := krt.NewManyCollection(agw.Services, func(krtctx krt.HandlerContext, svc *corev1.Service) []AgwPolicy {
|
||||
return translatePoliciesForService(svc, kubeutils.GetClusterDomainName())
|
||||
})
|
||||
return AgwPlugin{
|
||||
ContributesPolicies: map[schema.GroupKind]PolicyPlugin{
|
||||
wellknown.ServiceGVK.GroupKind(): {
|
||||
Build: func(input PolicyPluginInput) (krt.StatusCollection[controllers.Object, any], krt.Collection[AgwPolicy]) {
|
||||
policyCol := krt.NewManyCollection(agw.Services, func(krtctx krt.HandlerContext, svc *corev1.Service) []AgwPolicy {
|
||||
return translatePoliciesForService(krtctx, svc, kubeutils.GetClusterDomainName(), input.References)
|
||||
})
|
||||
return nil, policyCol
|
||||
},
|
||||
},
|
||||
@ -35,11 +38,19 @@ func NewA2APlugin(agw *AgwCollections) AgwPlugin {
|
||||
}
|
||||
|
||||
// translatePoliciesForService generates A2A policies for a single service
|
||||
func translatePoliciesForService(svc *corev1.Service, clusterDomain string) []AgwPolicy {
|
||||
func translatePoliciesForService(krtctx krt.HandlerContext, svc *corev1.Service, clusterDomain string, references ReferenceIndex) []AgwPolicy {
|
||||
var a2aPolicies []AgwPolicy
|
||||
gatewayTargets := references.LookupGatewaysForBackend(krtctx, utils.TypedNamespacedName{
|
||||
Kind: wellknown.ServiceKind,
|
||||
NamespacedName: types.NamespacedName{
|
||||
Namespace: svc.Namespace,
|
||||
Name: svc.Name,
|
||||
},
|
||||
}).UnsortedList()
|
||||
|
||||
for _, port := range svc.Spec.Ports {
|
||||
if port.AppProtocol != nil && *port.AppProtocol == a2aProtocol {
|
||||
// support legacy kgateway.dev/a2a and agentgateway.dev/a2a
|
||||
if port.AppProtocol != nil && (*port.AppProtocol == a2aProtocol || *port.AppProtocol == legacyA2aProtocol) {
|
||||
logger.Debug("found A2A service", "service", svc.Name, "namespace", svc.Namespace, "port", port.Port)
|
||||
hostname := fmt.Sprintf("%s.%s.svc.%s", svc.Name, svc.Namespace, clusterDomain)
|
||||
policy := &api.Policy{
|
||||
@ -60,7 +71,7 @@ func translatePoliciesForService(svc *corev1.Service, clusterDomain string) []Ag
|
||||
},
|
||||
}
|
||||
|
||||
a2aPolicies = append(a2aPolicies, AgwPolicy{Policy: policy})
|
||||
a2aPolicies = appendPolicyForGateways(a2aPolicies, gatewayTargets, policy)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -275,7 +275,7 @@ func processGoogleModelArmor(ctx PolicyCtx, namespace string, armor *agentgatewa
|
||||
|
||||
// Set location with default value if not specified
|
||||
if armor.Location != nil {
|
||||
pgArmor.Location = ptr.Of(string(*armor.Location))
|
||||
pgArmor.Location = ptr.Of(*armor.Location)
|
||||
} else {
|
||||
pgArmor.Location = ptr.Of("us-central1")
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ import (
|
||||
"istio.io/istio/pkg/ptr"
|
||||
"istio.io/istio/pkg/slices"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
||||
@ -19,19 +20,21 @@ import (
|
||||
"github.com/agentgateway/agentgateway/controller/api/v1alpha1/agentgateway"
|
||||
"github.com/agentgateway/agentgateway/controller/api/v1alpha1/shared"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/agentgateway/jwks_url"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/kgateway/translator/sslutils"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/kgateway/wellknown"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/utils/kubeutils"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/wellknown"
|
||||
)
|
||||
|
||||
const (
|
||||
aiPolicySuffix = ":ai"
|
||||
backendTlsPolicySuffix = ":backend-tls"
|
||||
backendTunnelPolicySuffix = ":backend-tunnel"
|
||||
backendauthPolicySuffix = ":backend-auth"
|
||||
backendTransformationSuffix = ":backend-transformation"
|
||||
tlsPolicySuffix = ":tls"
|
||||
backendHttpPolicySuffix = ":backend-http"
|
||||
mcpAuthorizationPolicySuffix = ":mcp-authorization"
|
||||
mcpAuthenticationPolicySuffix = ":mcp-authentication"
|
||||
healthPolicySuffix = ":health"
|
||||
)
|
||||
|
||||
func TranslateInlineBackendPolicy(
|
||||
@ -46,92 +49,181 @@ func TranslateInlineBackendPolicy(
|
||||
},
|
||||
Spec: agentgateway.AgentgatewayPolicySpec{Backend: policy},
|
||||
}
|
||||
res, err := translateBackendPolicyToAgw(ctx, dummy, nil)
|
||||
return slices.MapFilter(res, func(e AgwPolicy) **api.BackendPolicySpec {
|
||||
return ptr.Of(e.Policy.GetBackend())
|
||||
res, err := translateBackendPolicyToAgw(ctx, dummy)
|
||||
return slices.MapFilter(res, func(e *api.Policy) **api.BackendPolicySpec {
|
||||
return ptr.Of(e.GetBackend())
|
||||
}), err
|
||||
}
|
||||
|
||||
func translateBackendPolicyToAgw(
|
||||
ctx PolicyCtx,
|
||||
policy *agentgateway.AgentgatewayPolicy,
|
||||
policyTarget *api.PolicyTarget,
|
||||
) ([]AgwPolicy, error) {
|
||||
) ([]*api.Policy, error) {
|
||||
backend := policy.Spec.Backend
|
||||
if backend == nil {
|
||||
return nil, nil
|
||||
}
|
||||
agwPolicies := make([]AgwPolicy, 0)
|
||||
agwPolicies := make([]*api.Policy, 0)
|
||||
var errs []error
|
||||
|
||||
policyName := getBackendPolicyName(policy.Namespace, policy.Name)
|
||||
appendPolicy := func(kind string) func(*api.Policy, error) {
|
||||
return func(p *api.Policy, err error) {
|
||||
if err != nil {
|
||||
name := fmt.Sprintf("%s %s", kind, policyName)
|
||||
logger.Error("error processing policy", "policy", name, "error", err)
|
||||
errs = append(errs, err)
|
||||
}
|
||||
if p != nil {
|
||||
agwPolicies = append(agwPolicies, p)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if s := backend.HTTP; s != nil {
|
||||
pol := translateBackendHTTP(policy, policyTarget)
|
||||
agwPolicies = append(agwPolicies, pol...)
|
||||
appendPolicy("backendHTTP")(translateBackendHTTP(policy), nil)
|
||||
}
|
||||
|
||||
if s := backend.Tunnel; s != nil {
|
||||
appendPolicy("backendTunnel")(translateBackendTunnel(ctx, policy))
|
||||
}
|
||||
|
||||
if s := backend.TLS; s != nil {
|
||||
pol, err := translateBackendTLS(ctx, policy, policyTarget)
|
||||
if err != nil {
|
||||
logger.Error("error processing backend TLS", "err", err)
|
||||
errs = append(errs, err)
|
||||
}
|
||||
agwPolicies = append(agwPolicies, pol...)
|
||||
appendPolicy("backendTLS")(translateBackendTLS(ctx, policy))
|
||||
}
|
||||
|
||||
if s := backend.TCP; s != nil {
|
||||
pol, err := translateBackendTCP(ctx, policy, policyName, policyTarget)
|
||||
if err != nil {
|
||||
logger.Error("error processing backend TCP", "err", err)
|
||||
errs = append(errs, err)
|
||||
}
|
||||
agwPolicies = append(agwPolicies, pol...)
|
||||
appendPolicy("backendTCP")(translateBackendTCP(ctx, policy, policyName))
|
||||
}
|
||||
|
||||
if s := backend.Health; s != nil {
|
||||
appendPolicy("backendHealth")(translateBackendHealthPolicy(policy))
|
||||
}
|
||||
|
||||
if s := backend.Transformation; s != nil {
|
||||
appendPolicy("backendTransformation")(translateBackendTransformation(policy))
|
||||
}
|
||||
|
||||
if s := backend.MCP; s != nil {
|
||||
if backend.MCP.Authorization != nil {
|
||||
pol := translateBackendMCPAuthorization(policy, policyTarget)
|
||||
agwPolicies = append(agwPolicies, pol...)
|
||||
appendPolicy("backendMCPAuthorization")(translateBackendMCPAuthorization(policy))
|
||||
}
|
||||
|
||||
if backend.MCP.Authentication != nil {
|
||||
pol, err := translateBackendMCPAuthentication(ctx, policy, policyTarget)
|
||||
if err != nil {
|
||||
logger.Error("error processing backend mcp auth", "err", err)
|
||||
errs = append(errs, err)
|
||||
}
|
||||
agwPolicies = append(agwPolicies, pol...)
|
||||
appendPolicy("backendMCPAuthentication")(translateBackendMCPAuthentication(ctx, policy))
|
||||
}
|
||||
}
|
||||
|
||||
if s := backend.AI; s != nil {
|
||||
pol, err := translateBackendAI(ctx, policy, policyName, policyTarget)
|
||||
if err != nil {
|
||||
logger.Error("error processing backend AI", "err", err)
|
||||
errs = append(errs, err)
|
||||
}
|
||||
agwPolicies = append(agwPolicies, pol...)
|
||||
appendPolicy("backendAI")(translateBackendAI(ctx, policy, policyName))
|
||||
}
|
||||
|
||||
if s := backend.Auth; s != nil {
|
||||
pol, err := translateBackendAuth(ctx, policy, policyName, policyTarget)
|
||||
if err != nil {
|
||||
logger.Error("error processing backend Auth", "err", err)
|
||||
errs = append(errs, err)
|
||||
}
|
||||
agwPolicies = append(agwPolicies, pol...)
|
||||
appendPolicy("backendAuth")(translateBackendAuth(ctx, policy, policyName))
|
||||
}
|
||||
|
||||
return agwPolicies, errors.Join(errs...)
|
||||
}
|
||||
|
||||
func translateBackendTCP(ctx PolicyCtx, policy *agentgateway.AgentgatewayPolicy, name string, target *api.PolicyTarget) ([]AgwPolicy, error) {
|
||||
func translateBackendHealthPolicy(policy *agentgateway.AgentgatewayPolicy) (*api.Policy, error) {
|
||||
var errs []error
|
||||
|
||||
healthPolicy := policy.Spec.Backend.Health
|
||||
|
||||
var evictionProto *api.BackendPolicySpec_Eviction
|
||||
if healthPolicy.Eviction != nil {
|
||||
var duration *durationpb.Duration
|
||||
if healthPolicy.Eviction.Duration != nil {
|
||||
duration = durationpb.New(healthPolicy.Eviction.Duration.Duration)
|
||||
}
|
||||
|
||||
// Convert 0–100 integer scores into 0.0–1.0 doubles for proto
|
||||
var healthThreshold *float64
|
||||
if healthPolicy.Eviction.HealthThreshold != nil {
|
||||
val := float64(*healthPolicy.Eviction.HealthThreshold) / 100.0
|
||||
healthThreshold = &val
|
||||
}
|
||||
var restoreHealth *float64
|
||||
if healthPolicy.Eviction.RestoreHealth != nil {
|
||||
val := float64(*healthPolicy.Eviction.RestoreHealth) / 100.0
|
||||
restoreHealth = &val
|
||||
}
|
||||
|
||||
evictionProto = &api.BackendPolicySpec_Eviction{
|
||||
Duration: duration,
|
||||
RestoreHealth: restoreHealth,
|
||||
ConsecutiveFailures: healthPolicy.Eviction.ConsecutiveFailures,
|
||||
HealthThreshold: healthThreshold,
|
||||
}
|
||||
}
|
||||
|
||||
var unhealthyCondition string
|
||||
if healthPolicy.UnhealthyCondition != nil {
|
||||
unhealthyCondition = *castCELPtr(healthPolicy.UnhealthyCondition, func(expr shared.CELExpression) {
|
||||
errs = append(errs, fmt.Errorf("backend health unhealthyCondition is not a valid CEL expression: %s", expr))
|
||||
})
|
||||
}
|
||||
|
||||
p := &api.BackendPolicySpec_Health{
|
||||
UnhealthyCondition: unhealthyCondition,
|
||||
Eviction: evictionProto,
|
||||
}
|
||||
evictPolicy := &api.Policy{
|
||||
Key: policy.Namespace + "/" + policy.Name + healthPolicySuffix,
|
||||
Name: TypedResourceName(wellknown.AgentgatewayPolicyGVK.Kind, policy),
|
||||
Kind: &api.Policy_Backend{
|
||||
Backend: &api.BackendPolicySpec{
|
||||
Kind: &api.BackendPolicySpec_Health_{
|
||||
Health: p,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return evictPolicy, errors.Join(errs...)
|
||||
}
|
||||
|
||||
func translateBackendTCP(ctx PolicyCtx, policy *agentgateway.AgentgatewayPolicy, name string) (*api.Policy, error) {
|
||||
// TODO
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func translateBackendTLS(ctx PolicyCtx, policy *agentgateway.AgentgatewayPolicy, target *api.PolicyTarget) ([]AgwPolicy, error) {
|
||||
func translateBackendTransformation(
|
||||
policy *agentgateway.AgentgatewayPolicy,
|
||||
) (*api.Policy, error) {
|
||||
var errs []error
|
||||
transformation := policy.Spec.Backend.Transformation
|
||||
|
||||
convertedReq, err := convertTransformSpec(transformation.Request)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
convertedResp, err := convertTransformSpec(transformation.Response)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
tp := &api.Policy{
|
||||
Key: policy.Namespace + "/" + policy.Name + backendTransformationSuffix,
|
||||
Name: TypedResourceName(wellknown.AgentgatewayPolicyGVK.Kind, policy),
|
||||
Kind: &api.Policy_Backend{
|
||||
Backend: &api.BackendPolicySpec{
|
||||
Kind: &api.BackendPolicySpec_Transformation{
|
||||
Transformation: &api.TrafficPolicySpec_TransformationPolicy{
|
||||
Request: convertedReq,
|
||||
Response: convertedResp,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
logger.Debug("generated backend transformation policy",
|
||||
"policy", policy.Name,
|
||||
"agentgateway_policy", tp.Name)
|
||||
return tp, errors.Join(errs...)
|
||||
}
|
||||
|
||||
func translateBackendTLS(ctx PolicyCtx, policy *agentgateway.AgentgatewayPolicy) (*api.Policy, error) {
|
||||
var errs []error
|
||||
tls := policy.Spec.Backend.TLS
|
||||
|
||||
@ -148,7 +240,7 @@ func translateBackendTLS(ctx PolicyCtx, policy *agentgateway.AgentgatewayPolicy,
|
||||
if scrt == nil {
|
||||
errs = append(errs, fmt.Errorf("secret %s not found", nn))
|
||||
} else {
|
||||
if _, err := sslutils.ValidateTlsSecretData(nn.Name, nn.Namespace, scrt.Data); err != nil {
|
||||
if _, err := ValidateTlsSecretData(nn.Name, nn.Namespace, scrt.Data); err != nil {
|
||||
errs = append(errs, fmt.Errorf("secret %v contains invalid certificate: %v", nn, err))
|
||||
}
|
||||
p.Cert = scrt.Data[corev1.TLSCertKey]
|
||||
@ -170,7 +262,7 @@ func translateBackendTLS(ctx PolicyCtx, policy *agentgateway.AgentgatewayPolicy,
|
||||
errs = append(errs, fmt.Errorf("ConfigMap %s not found", nn))
|
||||
continue
|
||||
}
|
||||
pem, err := sslutils.GetCACertFromConfigMap(ptr.Flatten(cfgmap))
|
||||
pem, err := GetCACertFromConfigMap(ptr.Flatten(cfgmap))
|
||||
if err != nil {
|
||||
errs = append(errs, fmt.Errorf("error extracting CA cert from ConfigMap %s: %w", nn, err))
|
||||
continue
|
||||
@ -180,10 +272,9 @@ func translateBackendTLS(ctx PolicyCtx, policy *agentgateway.AgentgatewayPolicy,
|
||||
}
|
||||
sb.WriteString(pem)
|
||||
}
|
||||
// TODO: if none, submit something to make agentgateway reject requests instead of fail open.
|
||||
if sb.Len() > 0 {
|
||||
p.Root = []byte(sb.String())
|
||||
}
|
||||
// If we have a root set here, set it
|
||||
// This may send an empty root, so that we trust nothing rather than system certs.
|
||||
p.Root = []byte(sb.String())
|
||||
}
|
||||
|
||||
if len(tls.VerifySubjectAltNames) > 0 {
|
||||
@ -205,9 +296,8 @@ func translateBackendTLS(ctx PolicyCtx, policy *agentgateway.AgentgatewayPolicy,
|
||||
}
|
||||
|
||||
tlsPolicy := &api.Policy{
|
||||
Key: policy.Namespace + "/" + policy.Name + tlsPolicySuffix + attachmentName(target),
|
||||
Name: TypedResourceName(wellknown.AgentgatewayPolicyGVK.Kind, policy),
|
||||
Target: target,
|
||||
Key: policy.Namespace + "/" + policy.Name + tlsPolicySuffix,
|
||||
Name: TypedResourceName(wellknown.AgentgatewayPolicyGVK.Kind, policy),
|
||||
Kind: &api.Policy_Backend{
|
||||
Backend: &api.BackendPolicySpec{
|
||||
Kind: &api.BackendPolicySpec_BackendTls{
|
||||
@ -221,10 +311,10 @@ func translateBackendTLS(ctx PolicyCtx, policy *agentgateway.AgentgatewayPolicy,
|
||||
"policy", policy.Name,
|
||||
"agentgateway_policy", tlsPolicy.Name)
|
||||
|
||||
return []AgwPolicy{{Policy: tlsPolicy}}, errors.Join(errs...)
|
||||
return tlsPolicy, errors.Join(errs...)
|
||||
}
|
||||
|
||||
func translateBackendHTTP(policy *agentgateway.AgentgatewayPolicy, target *api.PolicyTarget) []AgwPolicy {
|
||||
func translateBackendHTTP(policy *agentgateway.AgentgatewayPolicy) *api.Policy {
|
||||
http := policy.Spec.Backend.HTTP
|
||||
p := &api.BackendPolicySpec_BackendHTTP{}
|
||||
if v := http.Version; v != nil {
|
||||
@ -239,9 +329,8 @@ func translateBackendHTTP(policy *agentgateway.AgentgatewayPolicy, target *api.P
|
||||
p.RequestTimeout = durationpb.New(rt.Duration)
|
||||
}
|
||||
tp := &api.Policy{
|
||||
Key: policy.Namespace + "/" + policy.Name + backendHttpPolicySuffix + attachmentName(target),
|
||||
Name: TypedResourceName(wellknown.AgentgatewayPolicyGVK.Kind, policy),
|
||||
Target: target,
|
||||
Key: policy.Namespace + "/" + policy.Name + backendHttpPolicySuffix,
|
||||
Name: TypedResourceName(wellknown.AgentgatewayPolicyGVK.Kind, policy),
|
||||
Kind: &api.Policy_Backend{
|
||||
Backend: &api.BackendPolicySpec{
|
||||
Kind: &api.BackendPolicySpec_BackendHttp{
|
||||
@ -254,32 +343,64 @@ func translateBackendHTTP(policy *agentgateway.AgentgatewayPolicy, target *api.P
|
||||
"policy", policy.Name,
|
||||
"agentgateway_policy", tp.Name)
|
||||
|
||||
return []AgwPolicy{{Policy: tp}}
|
||||
return tp
|
||||
}
|
||||
|
||||
func translateBackendMCPAuthorization(policy *agentgateway.AgentgatewayPolicy, target *api.PolicyTarget) []AgwPolicy {
|
||||
func translateBackendTunnel(ctx PolicyCtx, policy *agentgateway.AgentgatewayPolicy) (*api.Policy, error) {
|
||||
tunnel := policy.Spec.Backend.Tunnel
|
||||
|
||||
proxy, err := buildBackendRef(ctx, tunnel.BackendRef, policy.Namespace)
|
||||
|
||||
tunnelPolicy := &api.Policy{
|
||||
Key: policy.Namespace + "/" + policy.Name + backendTunnelPolicySuffix,
|
||||
Name: TypedResourceName(wellknown.AgentgatewayPolicyGVK.Kind, policy),
|
||||
Kind: &api.Policy_Backend{
|
||||
Backend: &api.BackendPolicySpec{
|
||||
Kind: &api.BackendPolicySpec_BackendTunnel_{
|
||||
BackendTunnel: &api.BackendPolicySpec_BackendTunnel{
|
||||
Proxy: proxy,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
logger.Debug("generated backend tunnel policy",
|
||||
"policy", policy.Name,
|
||||
"agentgateway_policy", tunnelPolicy.Name)
|
||||
|
||||
return tunnelPolicy, err
|
||||
}
|
||||
|
||||
func translateBackendMCPAuthorization(policy *agentgateway.AgentgatewayPolicy) (*api.Policy, error) {
|
||||
backend := policy.Spec.Backend
|
||||
if backend == nil || backend.MCP == nil || backend.MCP.Authorization == nil {
|
||||
return nil
|
||||
return nil, nil
|
||||
}
|
||||
auth := backend.MCP.Authorization
|
||||
var allowPolicies, denyPolicies []string
|
||||
var errs []error
|
||||
var allowPolicies, denyPolicies, requirePolicies []string
|
||||
policies := castCELSlice(auth.Policy.MatchExpressions, func(expr shared.CELExpression) {
|
||||
errs = append(errs, fmt.Errorf("backend MCP authorization matchExpression is not a valid CEL expression: %s", expr))
|
||||
})
|
||||
if auth.Action == shared.AuthorizationPolicyActionDeny {
|
||||
denyPolicies = append(denyPolicies, cast(auth.Policy.MatchExpressions)...)
|
||||
denyPolicies = append(denyPolicies, policies...)
|
||||
} else if auth.Action == shared.AuthorizationPolicyActionRequire {
|
||||
requirePolicies = append(requirePolicies, policies...)
|
||||
} else {
|
||||
allowPolicies = append(allowPolicies, cast(auth.Policy.MatchExpressions)...)
|
||||
allowPolicies = append(allowPolicies, policies...)
|
||||
}
|
||||
|
||||
mcpPolicy := &api.Policy{
|
||||
Key: policy.Namespace + "/" + policy.Name + mcpAuthorizationPolicySuffix + attachmentName(target),
|
||||
Name: TypedResourceName(wellknown.AgentgatewayPolicyGVK.Kind, policy),
|
||||
Target: target,
|
||||
Key: policy.Namespace + "/" + policy.Name + mcpAuthorizationPolicySuffix,
|
||||
Name: TypedResourceName(wellknown.AgentgatewayPolicyGVK.Kind, policy),
|
||||
Kind: &api.Policy_Backend{
|
||||
Backend: &api.BackendPolicySpec{
|
||||
Kind: &api.BackendPolicySpec_McpAuthorization_{
|
||||
McpAuthorization: &api.BackendPolicySpec_McpAuthorization{
|
||||
Allow: allowPolicies,
|
||||
Deny: denyPolicies,
|
||||
Allow: allowPolicies,
|
||||
Deny: denyPolicies,
|
||||
Require: requirePolicies,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -290,30 +411,44 @@ func translateBackendMCPAuthorization(policy *agentgateway.AgentgatewayPolicy, t
|
||||
"policy", policy.Name,
|
||||
"agentgateway_policy", mcpPolicy.Name)
|
||||
|
||||
return []AgwPolicy{{Policy: mcpPolicy}}
|
||||
return mcpPolicy, errors.Join(errs...)
|
||||
}
|
||||
|
||||
func translateBackendMCPAuthentication(ctx PolicyCtx, policy *agentgateway.AgentgatewayPolicy, target *api.PolicyTarget) ([]AgwPolicy, error) {
|
||||
backend := policy.Spec.Backend
|
||||
if backend == nil || backend.MCP == nil || backend.MCP.Authentication == nil {
|
||||
return nil, nil
|
||||
}
|
||||
authnPolicy := backend.MCP.Authentication
|
||||
if authnPolicy == nil {
|
||||
return nil, nil
|
||||
func translateBackendMCPAuthentication(ctx PolicyCtx, policy *agentgateway.AgentgatewayPolicy) (*api.Policy, error) {
|
||||
authnPolicy := policy.Spec.Backend.MCP.Authentication
|
||||
|
||||
mcpAuthn, err := translateMCPAuthenticationSpec(ctx, types.NamespacedName{
|
||||
Namespace: policy.Namespace,
|
||||
Name: policy.Name,
|
||||
}, authnPolicy)
|
||||
mcpAuthnPolicy := &api.Policy{
|
||||
Key: policy.Namespace + "/" + policy.Name + mcpAuthenticationPolicySuffix,
|
||||
Name: TypedResourceName(wellknown.AgentgatewayPolicyGVK.Kind, policy),
|
||||
Kind: &api.Policy_Backend{
|
||||
Backend: &api.BackendPolicySpec{
|
||||
Kind: &api.BackendPolicySpec_McpAuthentication_{
|
||||
McpAuthentication: mcpAuthn,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
idp := api.BackendPolicySpec_McpAuthentication_UNSPECIFIED
|
||||
if authnPolicy.McpIDP != nil {
|
||||
if *authnPolicy.McpIDP == agentgateway.Keycloak {
|
||||
idp = api.BackendPolicySpec_McpAuthentication_KEYCLOAK
|
||||
} else if *authnPolicy.McpIDP == agentgateway.Auth0 {
|
||||
idp = api.BackendPolicySpec_McpAuthentication_AUTH0
|
||||
}
|
||||
}
|
||||
logger.Debug("generated MCP authentication policy",
|
||||
"policy", policy.Name,
|
||||
"agentgateway_policy", mcpAuthnPolicy.Name)
|
||||
|
||||
// default mode is Optional
|
||||
mode := api.BackendPolicySpec_McpAuthentication_OPTIONAL
|
||||
return mcpAuthnPolicy, err
|
||||
}
|
||||
|
||||
func translateMCPAuthenticationSpec(
|
||||
ctx PolicyCtx,
|
||||
policy types.NamespacedName,
|
||||
authnPolicy *agentgateway.MCPAuthentication,
|
||||
) (*api.BackendPolicySpec_McpAuthentication, error) {
|
||||
idp := translateMcpIDP(authnPolicy.McpIDP)
|
||||
|
||||
// default mode is Strict
|
||||
mode := api.BackendPolicySpec_McpAuthentication_STRICT
|
||||
if authnPolicy.Mode == agentgateway.JWTAuthenticationModeStrict {
|
||||
mode = api.BackendPolicySpec_McpAuthentication_STRICT
|
||||
} else if authnPolicy.Mode == agentgateway.JWTAuthenticationModePermissive {
|
||||
@ -322,20 +457,70 @@ func translateBackendMCPAuthentication(ctx PolicyCtx, policy *agentgateway.Agent
|
||||
mode = api.BackendPolicySpec_McpAuthentication_OPTIONAL
|
||||
}
|
||||
|
||||
var errs []error
|
||||
jwksUrl, _, err := jwks_url.JwksUrlBuilderFactory().BuildJwksUrlAndTlsConfig(ctx.Krt, policy.Name, policy.Namespace, &authnPolicy.JWKS)
|
||||
if err != nil {
|
||||
logger.Error("failed resolving jwks url", "error", err)
|
||||
return nil, err
|
||||
errs = append(errs, err)
|
||||
}
|
||||
var translatedInlineJwks string
|
||||
if err == nil {
|
||||
translatedInlineJwks, err = resolveRemoteJWKSInline(ctx, jwksUrl)
|
||||
}
|
||||
translatedInlineJwks, err := resolveRemoteJWKSInline(ctx, jwksUrl)
|
||||
if err != nil {
|
||||
logger.Error("failed resolving jwks", "jwks_uri", jwksUrl, "error", err)
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
extraResourceMetadata, metadataErr := translateMCPResourceMetadata(authnPolicy.ResourceMetadata)
|
||||
if metadataErr != nil {
|
||||
errs = append(errs, metadataErr)
|
||||
}
|
||||
|
||||
mcpAuthn := &api.BackendPolicySpec_McpAuthentication{
|
||||
Issuer: authnPolicy.Issuer,
|
||||
Audiences: authnPolicy.Audiences,
|
||||
Provider: idp,
|
||||
ResourceMetadata: &api.BackendPolicySpec_McpAuthentication_ResourceMetadata{
|
||||
Extra: extraResourceMetadata,
|
||||
},
|
||||
JwksInline: translatedInlineJwks,
|
||||
Mode: mode,
|
||||
}
|
||||
return mcpAuthn, errors.Join(errs...)
|
||||
}
|
||||
|
||||
func translateJWTMCPConfig(mcp *agentgateway.JWTMCPConfig) (*api.TrafficPolicySpec_JWT_MCP, error) {
|
||||
extraResourceMetadata, err := translateMCPResourceMetadata(mcp.ResourceMetadata)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &api.TrafficPolicySpec_JWT_MCP{
|
||||
Provider: translateMcpIDP(mcp.Provider),
|
||||
ResourceMetadata: &api.BackendPolicySpec_McpAuthentication_ResourceMetadata{
|
||||
Extra: extraResourceMetadata,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func translateMcpIDP(provider *agentgateway.McpIDP) api.BackendPolicySpec_McpAuthentication_McpIDP {
|
||||
if provider == nil {
|
||||
return api.BackendPolicySpec_McpAuthentication_UNSPECIFIED
|
||||
}
|
||||
if *provider == agentgateway.Keycloak {
|
||||
return api.BackendPolicySpec_McpAuthentication_KEYCLOAK
|
||||
}
|
||||
if *provider == agentgateway.Auth0 {
|
||||
return api.BackendPolicySpec_McpAuthentication_AUTH0
|
||||
}
|
||||
return api.BackendPolicySpec_McpAuthentication_UNSPECIFIED
|
||||
}
|
||||
|
||||
func translateMCPResourceMetadata(resourceMetadata map[string]apiextensionsv1.JSON) (map[string]*structpb.Value, error) {
|
||||
var errs []error
|
||||
var extraResourceMetadata map[string]*structpb.Value
|
||||
for k, v := range authnPolicy.ResourceMetadata {
|
||||
for k, v := range resourceMetadata {
|
||||
if extraResourceMetadata == nil {
|
||||
extraResourceMetadata = make(map[string]*structpb.Value)
|
||||
}
|
||||
@ -350,39 +535,11 @@ func translateBackendMCPAuthentication(ctx PolicyCtx, policy *agentgateway.Agent
|
||||
|
||||
extraResourceMetadata[k] = proto
|
||||
}
|
||||
|
||||
mcpAuthn := &api.BackendPolicySpec_McpAuthentication{
|
||||
Issuer: authnPolicy.Issuer,
|
||||
Audiences: authnPolicy.Audiences,
|
||||
Provider: idp,
|
||||
ResourceMetadata: &api.BackendPolicySpec_McpAuthentication_ResourceMetadata{
|
||||
Extra: extraResourceMetadata,
|
||||
},
|
||||
JwksInline: translatedInlineJwks,
|
||||
Mode: mode,
|
||||
}
|
||||
mcpAuthnPolicy := &api.Policy{
|
||||
Key: policy.Namespace + "/" + policy.Name + mcpAuthenticationPolicySuffix + attachmentName(target),
|
||||
Name: TypedResourceName(wellknown.AgentgatewayPolicyGVK.Kind, policy),
|
||||
Target: target,
|
||||
Kind: &api.Policy_Backend{
|
||||
Backend: &api.BackendPolicySpec{
|
||||
Kind: &api.BackendPolicySpec_McpAuthentication_{
|
||||
McpAuthentication: mcpAuthn,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
logger.Debug("generated MCP authentication policy",
|
||||
"policy", policy.Name,
|
||||
"agentgateway_policy", mcpAuthnPolicy.Name)
|
||||
|
||||
return []AgwPolicy{{Policy: mcpAuthnPolicy}}, errors.Join(errs...)
|
||||
return extraResourceMetadata, errors.Join(errs...)
|
||||
}
|
||||
|
||||
// translateBackendAI processes AI configuration and creates corresponding Agw policies
|
||||
func translateBackendAI(ctx PolicyCtx, agwPolicy *agentgateway.AgentgatewayPolicy, name string, policyTarget *api.PolicyTarget) ([]AgwPolicy, error) {
|
||||
func translateBackendAI(ctx PolicyCtx, agwPolicy *agentgateway.AgentgatewayPolicy, name string) (*api.Policy, error) {
|
||||
var errs []error
|
||||
aiSpec := agwPolicy.Spec.Backend.AI
|
||||
|
||||
@ -416,6 +573,18 @@ func translateBackendAI(ctx PolicyCtx, agwPolicy *agentgateway.AgentgatewayPolic
|
||||
}
|
||||
translatedAIPolicy.Overrides[def.Field] = val
|
||||
}
|
||||
for _, xfm := range aiSpec.Transformations {
|
||||
if translatedAIPolicy.Transformations == nil {
|
||||
translatedAIPolicy.Transformations = make(map[string]string)
|
||||
}
|
||||
|
||||
if !isCEL(xfm.Expression) {
|
||||
errs = append(errs, fmt.Errorf("transformation %q is not a valid CEL expression: %v", xfm.Field, xfm.Expression))
|
||||
}
|
||||
|
||||
// Still set it so it wipes out the value on error, mirroring the header value.
|
||||
translatedAIPolicy.Transformations[xfm.Field] = string(xfm.Expression)
|
||||
}
|
||||
|
||||
if aiSpec.PromptGuard != nil {
|
||||
if translatedAIPolicy.PromptGuard == nil {
|
||||
@ -453,6 +622,9 @@ func translateBackendAI(ctx PolicyCtx, agwPolicy *agentgateway.AgentgatewayPolic
|
||||
CacheTools: aiSpec.PromptCaching.CacheTools,
|
||||
}
|
||||
translatedAIPolicy.PromptCaching.MinTokens = ptr.Of(uint32(aiSpec.PromptCaching.MinTokens)) //nolint:gosec // G115: MinTokens is validated by kubebuilder to be >= 0
|
||||
if aiSpec.PromptCaching.CacheMessageOffset > 0 {
|
||||
translatedAIPolicy.PromptCaching.CacheMessageOffset = ptr.Of(uint32(aiSpec.PromptCaching.CacheMessageOffset)) //nolint:gosec // G115: CacheMessageOffset is validated by kubebuilder to be >= 0
|
||||
}
|
||||
}
|
||||
|
||||
if aiSpec.Routes != nil {
|
||||
@ -464,9 +636,8 @@ func translateBackendAI(ctx PolicyCtx, agwPolicy *agentgateway.AgentgatewayPolic
|
||||
}
|
||||
|
||||
aiPolicy := &api.Policy{
|
||||
Key: name + aiPolicySuffix + attachmentName(policyTarget),
|
||||
Name: TypedResourceName(wellknown.AgentgatewayPolicyGVK.Kind, agwPolicy),
|
||||
Target: policyTarget,
|
||||
Key: name + aiPolicySuffix,
|
||||
Name: TypedResourceName(wellknown.AgentgatewayPolicyGVK.Kind, agwPolicy),
|
||||
Kind: &api.Policy_Backend{
|
||||
Backend: &api.BackendPolicySpec{
|
||||
Kind: &api.BackendPolicySpec_Ai_{
|
||||
@ -480,18 +651,15 @@ func translateBackendAI(ctx PolicyCtx, agwPolicy *agentgateway.AgentgatewayPolic
|
||||
"policy", agwPolicy.Name,
|
||||
"agentgateway_policy", aiPolicy.Name)
|
||||
|
||||
return []AgwPolicy{{Policy: aiPolicy}}, errors.Join(errs...)
|
||||
return aiPolicy, errors.Join(errs...)
|
||||
}
|
||||
|
||||
func translateBackendAuth(ctx PolicyCtx, policy *agentgateway.AgentgatewayPolicy, name string, target *api.PolicyTarget) ([]AgwPolicy, error) {
|
||||
func translateBackendAuth(ctx PolicyCtx, policy *agentgateway.AgentgatewayPolicy, name string) (*api.Policy, error) {
|
||||
var errs []error
|
||||
auth := policy.Spec.Backend.Auth
|
||||
|
||||
if auth == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
var translatedAuth *api.BackendAuthPolicy
|
||||
var kindErrs []error
|
||||
|
||||
if auth.InlineKey != nil && *auth.InlineKey != "" {
|
||||
translatedAuth = &api.BackendAuthPolicy{
|
||||
@ -504,6 +672,11 @@ func translateBackendAuth(ctx PolicyCtx, policy *agentgateway.AgentgatewayPolicy
|
||||
secret, err := kubeutils.GetSecret(ctx.Collections.Secrets, ctx.Krt, auth.SecretRef.Name, policy.Namespace)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
translatedAuth = &api.BackendAuthPolicy{
|
||||
Kind: &api.BackendAuthPolicy_Key{
|
||||
Key: &api.Key{},
|
||||
},
|
||||
}
|
||||
} else {
|
||||
if authKey, ok := kubeutils.GetSecretAuth(secret); ok {
|
||||
translatedAuth = &api.BackendAuthPolicy{
|
||||
@ -513,12 +686,25 @@ func translateBackendAuth(ctx PolicyCtx, policy *agentgateway.AgentgatewayPolicy
|
||||
}
|
||||
} else {
|
||||
errs = append(errs, fmt.Errorf("secret %s/%s missing Authorization value", policy.Namespace, auth.SecretRef.Name))
|
||||
translatedAuth = &api.BackendAuthPolicy{
|
||||
Kind: &api.BackendAuthPolicy_Key{
|
||||
Key: &api.Key{},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if auth.AWS != nil {
|
||||
awsAuth, err := buildAwsAuthPolicy(ctx.Krt, auth.AWS, ctx.Collections.Secrets, policy.Namespace)
|
||||
translatedAuth = awsAuth
|
||||
errs = append(errs, err)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
} else if auth.Azure != nil {
|
||||
azureAuth, err := buildAzureAuthPolicy(ctx.Krt, auth.Azure, ctx.Collections.Secrets, policy.Namespace)
|
||||
translatedAuth = azureAuth
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
} else if auth.GCP != nil {
|
||||
translatedAuth = buildGcpAuthPolicy(auth.GCP)
|
||||
} else if auth.Passthrough != nil {
|
||||
@ -529,14 +715,9 @@ func translateBackendAuth(ctx PolicyCtx, policy *agentgateway.AgentgatewayPolicy
|
||||
}
|
||||
}
|
||||
|
||||
if translatedAuth == nil {
|
||||
return nil, errors.Join(errs...)
|
||||
}
|
||||
|
||||
authPolicy := &api.Policy{
|
||||
Key: name + backendauthPolicySuffix + attachmentName(target),
|
||||
Name: TypedResourceName(wellknown.AgentgatewayPolicyGVK.Kind, policy),
|
||||
Target: target,
|
||||
Key: name + backendauthPolicySuffix,
|
||||
Name: TypedResourceName(wellknown.AgentgatewayPolicyGVK.Kind, policy),
|
||||
Kind: &api.Policy_Backend{
|
||||
Backend: &api.BackendPolicySpec{
|
||||
Kind: &api.BackendPolicySpec_Auth{
|
||||
@ -549,7 +730,7 @@ func translateBackendAuth(ctx PolicyCtx, policy *agentgateway.AgentgatewayPolicy
|
||||
"policy", policy.Name,
|
||||
"agentgateway_policy", authPolicy.Name)
|
||||
|
||||
return []AgwPolicy{{Policy: authPolicy}}, errors.Join(errs...)
|
||||
return authPolicy, errors.Join(append(errs, kindErrs...)...)
|
||||
}
|
||||
|
||||
// translateRouteType converts kgateway RouteType to agentgateway proto RouteType
|
||||
@ -563,6 +744,8 @@ func translateRouteType(rt agentgateway.RouteType) api.BackendPolicySpec_Ai_Rout
|
||||
return api.BackendPolicySpec_Ai_MODELS
|
||||
case agentgateway.RouteTypePassthrough:
|
||||
return api.BackendPolicySpec_Ai_PASSTHROUGH
|
||||
case agentgateway.RouteTypeDetect:
|
||||
return api.BackendPolicySpec_Ai_DETECT
|
||||
case agentgateway.RouteTypeResponses:
|
||||
return api.BackendPolicySpec_Ai_RESPONSES
|
||||
case agentgateway.RouteTypeAnthropicTokenCount:
|
||||
@ -579,52 +762,39 @@ func translateRouteType(rt agentgateway.RouteType) api.BackendPolicySpec_Ai_Rout
|
||||
|
||||
func buildAwsAuthPolicy(krtctx krt.HandlerContext, auth *agentgateway.AwsAuth, secrets krt.Collection[*corev1.Secret], namespace string) (*api.BackendAuthPolicy, error) {
|
||||
var errs []error
|
||||
if auth == nil {
|
||||
logger.Warn("using implicit AWS auth for AI backend")
|
||||
return &api.BackendAuthPolicy{
|
||||
Kind: &api.BackendAuthPolicy_Aws{
|
||||
Aws: &api.Aws{
|
||||
Kind: &api.Aws_Implicit{
|
||||
Implicit: &api.AwsImplicit{},
|
||||
},
|
||||
},
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
if auth.SecretRef.Name == "" {
|
||||
logger.Warn("not using any auth for AWS - it's most likely not what you want")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Get secret using the SecretIndex
|
||||
secret, err := kubeutils.GetSecret(secrets, krtctx, auth.SecretRef.Name, namespace)
|
||||
if err != nil {
|
||||
// Return nil auth policy if secret not found - this will be handled upstream
|
||||
// TODO(npolshak): Add backend status errors https://github.com/kgateway-dev/kgateway/issues/11966
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var accessKeyId, secretAccessKey string
|
||||
var sessionToken *string
|
||||
|
||||
// Extract access key
|
||||
if value, exists := kubeutils.GetSecretValue(secret, wellknown.AccessKey); !exists {
|
||||
errs = append(errs, errors.New("accessKey is missing or not a valid string"))
|
||||
// Get secret using the SecretIndex
|
||||
secret, err := kubeutils.GetSecret(secrets, krtctx, auth.SecretRef.Name, namespace)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
} else {
|
||||
accessKeyId = value
|
||||
}
|
||||
// Extract access key
|
||||
if value, exists := kubeutils.GetSecretValue(secret, wellknown.AccessKey); !exists {
|
||||
errs = append(errs, errors.New("accessKey is missing or not a valid string"))
|
||||
} else {
|
||||
accessKeyId = value
|
||||
}
|
||||
|
||||
// Extract secret key
|
||||
if value, exists := kubeutils.GetSecretValue(secret, wellknown.SecretKey); !exists {
|
||||
errs = append(errs, errors.New("secretKey is missing or not a valid string"))
|
||||
} else {
|
||||
secretAccessKey = value
|
||||
}
|
||||
// Extract secret key
|
||||
if value, exists := kubeutils.GetSecretValue(secret, wellknown.SecretKey); !exists {
|
||||
errs = append(errs, errors.New("secretKey is missing or not a valid string"))
|
||||
} else {
|
||||
secretAccessKey = value
|
||||
}
|
||||
|
||||
// Extract session token (optional)
|
||||
if value, exists := kubeutils.GetSecretValue(secret, wellknown.SessionToken); exists {
|
||||
sessionToken = ptr.Of(value)
|
||||
// Extract session token (optional)
|
||||
if secret != nil {
|
||||
if value, exists := kubeutils.GetSecretValue(secret, wellknown.SessionToken); exists {
|
||||
sessionToken = ptr.Of(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return &api.BackendAuthPolicy{
|
||||
@ -643,6 +813,98 @@ func buildAwsAuthPolicy(krtctx krt.HandlerContext, auth *agentgateway.AwsAuth, s
|
||||
}, errors.Join(errs...)
|
||||
}
|
||||
|
||||
func buildAzureAuthPolicy(krtctx krt.HandlerContext, auth *agentgateway.AzureAuth, secrets krt.Collection[*corev1.Secret], namespace string) (*api.BackendAuthPolicy, error) {
|
||||
var errs []error
|
||||
if auth.SecretRef.Name != "" {
|
||||
return buildAzureClientSecret(secrets, krtctx, auth, namespace, errs)
|
||||
}
|
||||
|
||||
if auth.ManagedIdentity != nil {
|
||||
uaid := &api.AzureManagedIdentityCredential_UserAssignedIdentity{}
|
||||
if auth.ManagedIdentity.ClientID != "" {
|
||||
uaid.Id = &api.AzureManagedIdentityCredential_UserAssignedIdentity_ClientId{
|
||||
ClientId: auth.ManagedIdentity.ClientID,
|
||||
}
|
||||
} else if auth.ManagedIdentity.ObjectID != "" {
|
||||
uaid.Id = &api.AzureManagedIdentityCredential_UserAssignedIdentity_ObjectId{
|
||||
ObjectId: auth.ManagedIdentity.ObjectID,
|
||||
}
|
||||
} else if auth.ManagedIdentity.ResourceID != "" {
|
||||
uaid.Id = &api.AzureManagedIdentityCredential_UserAssignedIdentity_ResourceId{
|
||||
ResourceId: auth.ManagedIdentity.ResourceID,
|
||||
}
|
||||
} else {
|
||||
errs = append(errs, errors.New("no valid User Assigned Identity identifier provided"))
|
||||
return nil, errors.Join(errs...)
|
||||
}
|
||||
return &api.BackendAuthPolicy{
|
||||
Kind: &api.BackendAuthPolicy_Azure{
|
||||
Azure: &api.Azure{
|
||||
Kind: &api.Azure_ExplicitConfig{
|
||||
ExplicitConfig: &api.AzureExplicitConfig{
|
||||
CredentialSource: &api.AzureExplicitConfig_ManagedIdentityCredential{
|
||||
ManagedIdentityCredential: &api.AzureManagedIdentityCredential{
|
||||
UserAssignedIdentity: uaid,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
errs = append(errs, errors.New("no valid Azure auth method provided"))
|
||||
return nil, errors.Join(errs...)
|
||||
}
|
||||
|
||||
func buildAzureClientSecret(secrets krt.Collection[*corev1.Secret], krtctx krt.HandlerContext, auth *agentgateway.AzureAuth, namespace string, errs []error) (*api.BackendAuthPolicy, error) {
|
||||
var clientID, tenantID, clientSecret string
|
||||
secret, err := kubeutils.GetSecret(secrets, krtctx, auth.SecretRef.Name, namespace)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
} else {
|
||||
// Extract client ID
|
||||
if value, exists := kubeutils.GetSecretValue(secret, wellknown.ClientID); !exists {
|
||||
errs = append(errs, errors.New("clientID is missing or not a valid string"))
|
||||
} else {
|
||||
clientID = value
|
||||
}
|
||||
|
||||
// Extract tenant ID
|
||||
if value, exists := kubeutils.GetSecretValue(secret, wellknown.TenantID); !exists {
|
||||
errs = append(errs, errors.New("tenantID is missing or not a valid string"))
|
||||
} else {
|
||||
tenantID = value
|
||||
}
|
||||
|
||||
// Extract client secret
|
||||
if value, exists := kubeutils.GetSecretValue(secret, wellknown.ClientSecret); !exists {
|
||||
errs = append(errs, errors.New("clientSecret is missing or not a valid string"))
|
||||
} else {
|
||||
clientSecret = value
|
||||
}
|
||||
}
|
||||
|
||||
return &api.BackendAuthPolicy{
|
||||
Kind: &api.BackendAuthPolicy_Azure{
|
||||
Azure: &api.Azure{
|
||||
Kind: &api.Azure_ExplicitConfig{
|
||||
ExplicitConfig: &api.AzureExplicitConfig{
|
||||
CredentialSource: &api.AzureExplicitConfig_ClientSecret{
|
||||
ClientSecret: &api.AzureClientSecret{
|
||||
ClientSecret: clientSecret,
|
||||
TenantId: tenantID,
|
||||
ClientId: clientID,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}, errors.Join(errs...)
|
||||
}
|
||||
|
||||
func buildGcpAuthPolicy(auth *agentgateway.GcpAuth) *api.BackendAuthPolicy {
|
||||
if auth.Type == nil || *auth.Type == agentgateway.GcpAuthTypeAccessToken {
|
||||
return &api.BackendAuthPolicy{
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
package plugins_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
gwv1 "sigs.k8s.io/gateway-api/apis/v1"
|
||||
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/agentgateway/plugins"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/agentgateway/testutils"
|
||||
)
|
||||
|
||||
func TestBackendPolicies(t *testing.T) {
|
||||
testutils.RunForDirectory(t, "testdata/backendpolicy", func(t *testing.T, ctx plugins.PolicyCtx) (*gwv1.PolicyStatus, []plugins.AgwPolicy) {
|
||||
pol := testutils.GetTestResource(t, ctx.Collections.AgentgatewayPolicies)
|
||||
s, o := plugins.TranslateAgentgatewayPolicy(ctx.Krt, pol, ctx.Collections)
|
||||
return s, o
|
||||
})
|
||||
}
|
||||
@ -20,8 +20,8 @@ import (
|
||||
|
||||
"github.com/agentgateway/agentgateway/api"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/agentgateway/utils"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/kgateway/translator/sslutils"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/kgateway/wellknown"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/pluginsdk/krtutil"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/wellknown"
|
||||
)
|
||||
|
||||
// NewBackendTLSPlugin creates a new BackendTLSPolicy plugin
|
||||
@ -43,9 +43,9 @@ func NewBackendTLSPlugin(agw *AgwCollections) AgwPlugin {
|
||||
wellknown.BackendTLSPolicyGVK.GroupKind(): {
|
||||
Build: func(input PolicyPluginInput) (krt.StatusCollection[controllers.Object, any], krt.Collection[AgwPolicy]) {
|
||||
st, o := krt.NewStatusManyCollection(agw.BackendTLSPolicies, func(krtctx krt.HandlerContext, btls *gwv1.BackendTLSPolicy) (*gwv1.PolicyStatus, []AgwPolicy) {
|
||||
return translatePoliciesForBackendTLS(krtctx, agw.ControllerName, input.Ancestors, agw.ConfigMaps, agw.Services, backendTLSTarget, btls)
|
||||
return translatePoliciesForBackendTLS(krtctx, agw.ControllerName, input.References, agw.ConfigMaps, agw.Secrets, agw.Services, backendTLSTarget, agw.Gateways, btls)
|
||||
}, agw.KrtOpts.ToOptions("agentgateway/BackendTLSPolicy")...)
|
||||
return convertStatusCollection(st), o
|
||||
return ConvertStatusCollection(st), o
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -56,10 +56,12 @@ func NewBackendTLSPlugin(agw *AgwCollections) AgwPlugin {
|
||||
func translatePoliciesForBackendTLS(
|
||||
krtctx krt.HandlerContext,
|
||||
controllerName string,
|
||||
ancestors krt.IndexCollection[utils.TypedNamespacedName, *utils.AncestorBackend],
|
||||
references ReferenceIndex,
|
||||
cfgmaps krt.Collection[*corev1.ConfigMap],
|
||||
secrets krt.Collection[*corev1.Secret],
|
||||
svcs krt.Collection[*corev1.Service],
|
||||
targetIndex krt.IndexCollection[utils.TypedNamespacedName, *gwv1.BackendTLSPolicy],
|
||||
gateways krt.Collection[*gwv1.Gateway],
|
||||
btls *gwv1.BackendTLSPolicy,
|
||||
) (*gwv1.PolicyStatus, []AgwPolicy) {
|
||||
logger := logger.With("plugin_kind", "backendtls")
|
||||
@ -113,23 +115,29 @@ func translatePoliciesForBackendTLS(
|
||||
Kind: string(target.Kind),
|
||||
}
|
||||
|
||||
ancestorBackends := krt.Fetch(krtctx, ancestors, krt.FilterKey(tgtRef.String()))
|
||||
for _, gwl := range ancestorBackends {
|
||||
for _, i := range gwl.Objects {
|
||||
uniqueGateways.Insert(i.Gateway)
|
||||
gatewayTargets := references.LookupGatewaysForBackend(krtctx, tgtRef).UnsortedList()
|
||||
uniqueGateways = uniqueGateways.InsertAll(gatewayTargets...)
|
||||
|
||||
var mtlsClientRef *gwv1.SecretObjectReference
|
||||
var mtlsClientRefNamespace string
|
||||
if uniqueGateways.Len() == 1 {
|
||||
// TODO: support from multiple gateways.
|
||||
// This will require us to have per-gateway policies, not global ones.
|
||||
gtw := ptr.Flatten(krt.FetchOne(krtctx, gateways, krt.FilterKey(uniqueGateways.UnsortedList()[0].String())))
|
||||
if gtw != nil && gtw.Spec.TLS != nil && gtw.Spec.TLS.Backend != nil && gtw.Spec.TLS.Backend.ClientCertificateRef != nil {
|
||||
mtlsClientRef = gtw.Spec.TLS.Backend.ClientCertificateRef
|
||||
mtlsClientRefNamespace = gtw.Namespace
|
||||
}
|
||||
}
|
||||
|
||||
backendTLSPoliciesForThisTarget := krt.FetchOne(krtctx, targetIndex, krt.FilterKey(tgtRef.String()))
|
||||
if backendTLSPoliciesForThisTarget != nil {
|
||||
if err := checkConflicted(btls, target, backendTLSPoliciesForThisTarget); err != nil {
|
||||
conds[string(gwv1.PolicyConditionAccepted)].error = &ConfigError{
|
||||
Reason: string(gwv1.PolicyReasonConflicted),
|
||||
Message: err.Error(),
|
||||
}
|
||||
// We cannot send this policy to agentgateway, as it would not know the priority logic.
|
||||
continue
|
||||
backendTLSPoliciesForThisTarget := krtutil.FetchIndexObjects(krtctx, targetIndex, tgtRef)
|
||||
if err := checkConflicted(btls, target, backendTLSPoliciesForThisTarget); err != nil {
|
||||
conds[string(gwv1.PolicyConditionAccepted)].error = &ConfigError{
|
||||
Reason: string(gwv1.PolicyReasonConflicted),
|
||||
Message: err.Error(),
|
||||
}
|
||||
// We cannot send this policy to agentgateway, as it would not know the priority logic.
|
||||
continue
|
||||
}
|
||||
|
||||
switch string(target.Kind) {
|
||||
@ -168,6 +176,49 @@ func translatePoliciesForBackendTLS(
|
||||
continue
|
||||
}
|
||||
|
||||
res := &api.BackendPolicySpec_BackendTLS{
|
||||
Root: caCert,
|
||||
// Used for mTLS, conditionally set below
|
||||
Cert: nil,
|
||||
Key: nil,
|
||||
// Validation.Hostname is a required value and validated with CEL
|
||||
Hostname: ptr.Of(string(btls.Spec.Validation.Hostname)),
|
||||
VerifySubjectAltNames: sans,
|
||||
}
|
||||
if mtlsClientRef != nil {
|
||||
skip := false
|
||||
if mtlsClientRef.Namespace != nil {
|
||||
// TODO Implement this later
|
||||
logger.Warn("ignoring Gateway.spec.tls.backend; cross namespace not permitted")
|
||||
skip = true
|
||||
}
|
||||
if mtlsClientRef.Kind != nil && *mtlsClientRef.Kind != wellknown.SecretKind {
|
||||
logger.Warn("ignoring Gateway.spec.tls.backend; only Secret is allowed")
|
||||
skip = true
|
||||
}
|
||||
if mtlsClientRef.Group != nil && string(*mtlsClientRef.Group) != wellknown.SecretGVK.Group {
|
||||
logger.Warn("ignoring Gateway.spec.tls.backend; only core is allowed")
|
||||
skip = true
|
||||
}
|
||||
if !skip {
|
||||
nn := types.NamespacedName{
|
||||
Namespace: mtlsClientRefNamespace,
|
||||
Name: string(mtlsClientRef.Name),
|
||||
}
|
||||
scrt := ptr.Flatten(krt.FetchOne(krtctx, secrets, krt.FilterObjectName(nn)))
|
||||
if scrt == nil {
|
||||
logger.Warn("ignoring Gateway.spec.tls.backend; secret not found")
|
||||
} else {
|
||||
if _, err := ValidateTlsSecretData(nn.Name, nn.Namespace, scrt.Data); err != nil {
|
||||
logger.Warn("ignoring Gateway.spec.tls.backend; secret not found")
|
||||
} else {
|
||||
res.Cert = scrt.Data[corev1.TLSCertKey]
|
||||
res.Key = scrt.Data[corev1.TLSPrivateKeyKey]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
policy := &api.Policy{
|
||||
Key: btls.Namespace + "/" + btls.Name + backendTlsPolicySuffix + attachmentName(policyTarget),
|
||||
Name: TypedResourceName(wellknown.BackendTLSPolicyKind, btls),
|
||||
@ -175,20 +226,12 @@ func translatePoliciesForBackendTLS(
|
||||
Kind: &api.Policy_Backend{
|
||||
Backend: &api.BackendPolicySpec{
|
||||
Kind: &api.BackendPolicySpec_BackendTls{
|
||||
BackendTls: &api.BackendPolicySpec_BackendTLS{
|
||||
Root: caCert,
|
||||
// Used for mTLS, not part of the spec currently
|
||||
Cert: nil,
|
||||
Key: nil,
|
||||
// Validation.Hostname is a required value and validated with CEL
|
||||
Hostname: ptr.Of(string(btls.Spec.Validation.Hostname)),
|
||||
VerifySubjectAltNames: sans,
|
||||
},
|
||||
BackendTls: res,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
policies = append(policies, AgwPolicy{policy})
|
||||
policies = appendPolicyForGateways(policies, gatewayTargets, policy)
|
||||
}
|
||||
ancestorStatus := make([]gwv1.PolicyAncestorStatus, 0, len(btls.Spec.TargetRefs))
|
||||
for g := range uniqueGateways {
|
||||
@ -209,9 +252,9 @@ func translatePoliciesForBackendTLS(
|
||||
func checkConflicted(
|
||||
btls *gwv1.BackendTLSPolicy,
|
||||
target gwv1.LocalPolicyTargetReferenceWithSectionName,
|
||||
allMatches *krt.IndexObject[utils.TypedNamespacedName, *gwv1.BackendTLSPolicy],
|
||||
allMatches []*gwv1.BackendTLSPolicy,
|
||||
) error {
|
||||
for _, m := range allMatches.Objects {
|
||||
for _, m := range allMatches {
|
||||
if m.UID == btls.UID {
|
||||
// This is ourself, skip it
|
||||
continue
|
||||
@ -308,7 +351,7 @@ func getBackendTLSCACert(
|
||||
}
|
||||
return nil, fmt.Errorf("certificate reference not found: %v", ref)
|
||||
}
|
||||
caCert, err := sslutils.GetCACertFromConfigMap(ptr.Flatten(cfgmap))
|
||||
caCert, err := GetCACertFromConfigMap(ptr.Flatten(cfgmap))
|
||||
if err != nil {
|
||||
conds[string(gwv1.BackendTLSPolicyReasonResolvedRefs)].error = &ConfigError{
|
||||
Reason: string(gwv1.BackendTLSPolicyReasonInvalidCACertificateRef),
|
||||
|
||||
@ -7,26 +7,31 @@ import (
|
||||
"istio.io/istio/pkg/kube/kclient"
|
||||
"istio.io/istio/pkg/kube/krt"
|
||||
"istio.io/istio/pkg/kube/kubetypes"
|
||||
"istio.io/istio/pkg/ptr"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
discovery "k8s.io/api/discovery/v1"
|
||||
inf "sigs.k8s.io/gateway-api-inference-extension/api/v1"
|
||||
gwv1 "sigs.k8s.io/gateway-api/apis/v1"
|
||||
gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
|
||||
gwv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1"
|
||||
gwxv1a1 "sigs.k8s.io/gateway-api/apisx/v1alpha1"
|
||||
|
||||
apisettings "github.com/agentgateway/agentgateway/controller/api/settings"
|
||||
"github.com/agentgateway/agentgateway/controller/api/v1alpha1/agentgateway"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/apiclient"
|
||||
kgwversioned "github.com/agentgateway/agentgateway/controller/pkg/client/clientset/versioned"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/kgateway/wellknown"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/pluginsdk/collections"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/pluginsdk/krtutil"
|
||||
krtpkg "github.com/agentgateway/agentgateway/controller/pkg/utils/krtutil"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/wellknown"
|
||||
)
|
||||
|
||||
type AgwCollections struct {
|
||||
OurClient kgwversioned.Interface
|
||||
Client apiclient.Client
|
||||
KrtOpts krtutil.KrtOptions
|
||||
Settings apisettings.Settings
|
||||
|
||||
GatewaysForDeployer krt.Collection[collections.GatewayForDeployer]
|
||||
|
||||
// Core Kubernetes resources
|
||||
Namespaces krt.Collection[*corev1.Namespace]
|
||||
@ -49,10 +54,10 @@ type AgwCollections struct {
|
||||
HTTPRoutes krt.Collection[*gwv1.HTTPRoute]
|
||||
GRPCRoutes krt.Collection[*gwv1.GRPCRoute]
|
||||
TCPRoutes krt.Collection[*gwv1a2.TCPRoute]
|
||||
TLSRoutes krt.Collection[*gwv1a2.TLSRoute]
|
||||
TLSRoutes krt.Collection[*gwv1.TLSRoute]
|
||||
ReferenceGrants krt.Collection[*gwv1b1.ReferenceGrant]
|
||||
BackendTLSPolicies krt.Collection[*gwv1.BackendTLSPolicy]
|
||||
XListenerSets krt.Collection[*gwxv1a1.XListenerSet]
|
||||
ListenerSets krt.Collection[*gwv1.ListenerSet]
|
||||
|
||||
// Extended resources
|
||||
InferencePools krt.Collection[*inf.InferencePool]
|
||||
@ -63,10 +68,12 @@ type AgwCollections struct {
|
||||
|
||||
// ControllerName is the name of the Gateway controller.
|
||||
ControllerName string
|
||||
// SystemNamespace is control plane system namespace (default is kgateway-system)
|
||||
// SystemNamespace is control plane system namespace (default is agentgateway-system)
|
||||
SystemNamespace string
|
||||
// IstioNamespace is the Istio control plane namespace (default is istio-system)
|
||||
IstioNamespace string
|
||||
// IstioRevision is the Istio revision of the Istio control plane (default is "default").
|
||||
IstioRevision string
|
||||
// ClusterID is the cluster ID of the cluster the proxy is running in.
|
||||
ClusterID string
|
||||
}
|
||||
@ -75,81 +82,108 @@ type AgwCollections struct {
|
||||
// Collections that rely on plugins aren't initialized here,
|
||||
// and InitPlugins must be called.
|
||||
func NewAgwCollections(
|
||||
commoncol *collections.CommonCollections,
|
||||
krtOptions krtutil.KrtOptions,
|
||||
client apiclient.Client,
|
||||
agwControllerName string,
|
||||
settings apisettings.Settings,
|
||||
systemNamespace string,
|
||||
clusterID string,
|
||||
) (*AgwCollections, error) {
|
||||
filter := kclient.Filter{ObjectFilter: client.ObjectFilter()}
|
||||
gateways := krt.WrapClient(kclient.NewFilteredDelayed[*gwv1.Gateway](
|
||||
client, wellknown.GatewayGVR, filter), krtOptions.ToOptions("informer/Gateways")...)
|
||||
gatewayClasses := krt.WrapClient(kclient.NewFilteredDelayed[*gwv1.GatewayClass](
|
||||
client, wellknown.GatewayClassGVR, filter), krtOptions.ToOptions("informer/GatewayClasses")...)
|
||||
listenerSets := krt.WrapClient(kclient.NewDelayedInformer[*gwv1.ListenerSet](
|
||||
client, wellknown.ListenerSetGVR, kubetypes.StandardInformer, filter), krtOptions.ToOptions("informer/ListenerSets")...)
|
||||
|
||||
byParentRefIndex := krtpkg.UnnamedIndex(listenerSets, func(in *gwv1.ListenerSet) []collections.TargetRefIndexKey {
|
||||
pRef := in.Spec.ParentRef
|
||||
ns := ptr.OrDefault(pRef.Namespace, gwv1.Namespace(in.GetNamespace()))
|
||||
// lookup by the root object
|
||||
return []collections.TargetRefIndexKey{{
|
||||
Group: wellknown.GatewayGroup,
|
||||
Kind: wellknown.GatewayKind,
|
||||
Name: string(pRef.Name),
|
||||
Namespace: string(ns),
|
||||
// this index intentionally doesn't include sectionName
|
||||
}}
|
||||
})
|
||||
|
||||
agwCollections := &AgwCollections{
|
||||
Client: commoncol.Client,
|
||||
KrtOpts: commoncol.KrtOpts,
|
||||
ControllerName: agwControllerName,
|
||||
SystemNamespace: systemNamespace,
|
||||
IstioNamespace: commoncol.Settings.IstioNamespace,
|
||||
ClusterID: clusterID,
|
||||
Client: client,
|
||||
KrtOpts: krtOptions,
|
||||
Settings: settings,
|
||||
GatewaysForDeployer: krt.NewCollection(gateways, collections.GatewaysForDeployerTransformationFunc(gatewayClasses, listenerSets, byParentRefIndex, agwControllerName)),
|
||||
ControllerName: agwControllerName,
|
||||
SystemNamespace: systemNamespace,
|
||||
IstioNamespace: settings.IstioNamespace,
|
||||
IstioRevision: settings.IstioRevision,
|
||||
ClusterID: clusterID,
|
||||
|
||||
// Core Kubernetes resources
|
||||
Namespaces: krt.NewInformer[*corev1.Namespace](commoncol.Client),
|
||||
Nodes: krt.NewFilteredInformer[*corev1.Node](commoncol.Client, kclient.Filter{
|
||||
ObjectFilter: commoncol.Client.ObjectFilter(),
|
||||
}, commoncol.KrtOpts.ToOptions("informer/Nodes")...),
|
||||
Pods: krt.NewFilteredInformer[*corev1.Pod](commoncol.Client, kclient.Filter{
|
||||
Namespaces: krt.NewInformer[*corev1.Namespace](client, krtOptions.ToOptions("informer/Namespaces")...),
|
||||
Nodes: krt.NewFilteredInformer[*corev1.Node](client, kclient.Filter{
|
||||
ObjectFilter: client.ObjectFilter(),
|
||||
}, krtOptions.ToOptions("informer/Nodes")...),
|
||||
Pods: krt.NewFilteredInformer[*corev1.Pod](client, kclient.Filter{
|
||||
ObjectTransform: istiokube.StripPodUnusedFields,
|
||||
ObjectFilter: commoncol.Client.ObjectFilter(),
|
||||
}, commoncol.KrtOpts.ToOptions("informer/Pods")...),
|
||||
ObjectFilter: client.ObjectFilter(),
|
||||
}, krtOptions.ToOptions("informer/Pods")...),
|
||||
|
||||
Secrets: krt.WrapClient(
|
||||
kclient.NewFiltered[*corev1.Secret](commoncol.Client, kubetypes.Filter{
|
||||
ObjectFilter: commoncol.Client.ObjectFilter(),
|
||||
kclient.NewFiltered[*corev1.Secret](client, kubetypes.Filter{
|
||||
FieldSelector: apiclient.SecretsFieldSelector,
|
||||
ObjectFilter: client.ObjectFilter(),
|
||||
}),
|
||||
),
|
||||
ConfigMaps: krt.WrapClient(
|
||||
kclient.NewFiltered[*corev1.ConfigMap](commoncol.Client, kubetypes.Filter{
|
||||
ObjectFilter: commoncol.Client.ObjectFilter(),
|
||||
kclient.NewFiltered[*corev1.ConfigMap](client, kubetypes.Filter{
|
||||
ObjectFilter: client.ObjectFilter(),
|
||||
}),
|
||||
commoncol.KrtOpts.ToOptions("informer/ConfigMaps")...,
|
||||
krtOptions.ToOptions("informer/ConfigMaps")...,
|
||||
),
|
||||
Services: krt.WrapClient(
|
||||
kclient.NewFiltered[*corev1.Service](commoncol.Client, kubetypes.Filter{ObjectFilter: commoncol.Client.ObjectFilter()}),
|
||||
commoncol.KrtOpts.ToOptions("informer/Services")...),
|
||||
kclient.NewFiltered[*corev1.Service](client, kubetypes.Filter{ObjectFilter: client.ObjectFilter()}),
|
||||
krtOptions.ToOptions("informer/Services")...),
|
||||
EndpointSlices: krt.WrapClient(
|
||||
kclient.NewFiltered[*discovery.EndpointSlice](commoncol.Client, kubetypes.Filter{ObjectFilter: commoncol.Client.ObjectFilter()}),
|
||||
commoncol.KrtOpts.ToOptions("informer/EndpointSlices")...),
|
||||
kclient.NewFiltered[*discovery.EndpointSlice](client, kubetypes.Filter{ObjectFilter: client.ObjectFilter()}),
|
||||
krtOptions.ToOptions("informer/EndpointSlices")...),
|
||||
|
||||
// Istio resources
|
||||
WorkloadEntries: krt.WrapClient(
|
||||
kclient.NewDelayedInformer[*networkingclient.WorkloadEntry](commoncol.Client, gvr.WorkloadEntry, kubetypes.StandardInformer, kclient.Filter{ObjectFilter: commoncol.Client.ObjectFilter()}),
|
||||
commoncol.KrtOpts.ToOptions("informer/WorkloadEntries")...),
|
||||
kclient.NewDelayedInformer[*networkingclient.WorkloadEntry](client, gvr.WorkloadEntry, kubetypes.StandardInformer, kclient.Filter{ObjectFilter: client.ObjectFilter()}),
|
||||
krtOptions.ToOptions("informer/WorkloadEntries")...),
|
||||
ServiceEntries: krt.WrapClient(
|
||||
kclient.NewDelayedInformer[*networkingclient.ServiceEntry](commoncol.Client, gvr.ServiceEntry, kubetypes.StandardInformer, kclient.Filter{ObjectFilter: commoncol.Client.ObjectFilter()}),
|
||||
commoncol.KrtOpts.ToOptions("informer/ServiceEntries")...),
|
||||
kclient.NewDelayedInformer[*networkingclient.ServiceEntry](client, gvr.ServiceEntry, kubetypes.StandardInformer, kclient.Filter{ObjectFilter: client.ObjectFilter()}),
|
||||
krtOptions.ToOptions("informer/ServiceEntries")...),
|
||||
|
||||
// Gateway API resources
|
||||
GatewayClasses: krt.WrapClient(kclient.NewFilteredDelayed[*gwv1.GatewayClass](commoncol.Client, wellknown.GatewayClassGVR, kubetypes.Filter{ObjectFilter: commoncol.Client.ObjectFilter()}), commoncol.KrtOpts.ToOptions("informer/GatewayClasses")...),
|
||||
Gateways: krt.WrapClient(kclient.NewFilteredDelayed[*gwv1.Gateway](commoncol.Client, wellknown.GatewayGVR, kubetypes.Filter{ObjectFilter: commoncol.Client.ObjectFilter()}), commoncol.KrtOpts.ToOptions("informer/Gateways")...),
|
||||
HTTPRoutes: krt.WrapClient(kclient.NewFilteredDelayed[*gwv1.HTTPRoute](commoncol.Client, wellknown.HTTPRouteGVR, kubetypes.Filter{ObjectFilter: commoncol.Client.ObjectFilter()}), commoncol.KrtOpts.ToOptions("informer/HTTPRoutes")...),
|
||||
GRPCRoutes: krt.WrapClient(kclient.NewFilteredDelayed[*gwv1.GRPCRoute](commoncol.Client, wellknown.GRPCRouteGVR, kubetypes.Filter{ObjectFilter: commoncol.Client.ObjectFilter()}), commoncol.KrtOpts.ToOptions("informer/GRPCRoutes")...),
|
||||
BackendTLSPolicies: krt.WrapClient(kclient.NewDelayedInformer[*gwv1.BackendTLSPolicy](commoncol.Client, gvr.BackendTLSPolicy, kubetypes.StandardInformer, kubetypes.Filter{ObjectFilter: commoncol.Client.ObjectFilter()}), commoncol.KrtOpts.ToOptions("informer/BackendTLSPolicies")...),
|
||||
GatewayClasses: gatewayClasses,
|
||||
Gateways: gateways,
|
||||
HTTPRoutes: krt.WrapClient(kclient.NewFilteredDelayed[*gwv1.HTTPRoute](client, wellknown.HTTPRouteGVR, kubetypes.Filter{ObjectFilter: client.ObjectFilter()}), krtOptions.ToOptions("informer/HTTPRoutes")...),
|
||||
GRPCRoutes: krt.WrapClient(kclient.NewFilteredDelayed[*gwv1.GRPCRoute](client, wellknown.GRPCRouteGVR, kubetypes.Filter{ObjectFilter: client.ObjectFilter()}), krtOptions.ToOptions("informer/GRPCRoutes")...),
|
||||
TLSRoutes: krt.WrapClient(kclient.NewDelayedInformer[*gwv1.TLSRoute](client, gvr.TLSRoute, kubetypes.StandardInformer, kubetypes.Filter{ObjectFilter: client.ObjectFilter()}), krtOptions.ToOptions("informer/TLSRoutes")...),
|
||||
BackendTLSPolicies: krt.WrapClient(kclient.NewDelayedInformer[*gwv1.BackendTLSPolicy](client, gvr.BackendTLSPolicy, kubetypes.StandardInformer, kubetypes.Filter{ObjectFilter: client.ObjectFilter()}), krtOptions.ToOptions("informer/BackendTLSPolicies")...),
|
||||
ListenerSets: listenerSets,
|
||||
|
||||
// Gateway API alpha
|
||||
TCPRoutes: krt.WrapClient(kclient.NewDelayedInformer[*gwv1a2.TCPRoute](commoncol.Client, gvr.TCPRoute, kubetypes.StandardInformer, kubetypes.Filter{ObjectFilter: commoncol.Client.ObjectFilter()}), commoncol.KrtOpts.ToOptions("informer/TCPRoutes")...),
|
||||
TLSRoutes: krt.WrapClient(kclient.NewDelayedInformer[*gwv1a2.TLSRoute](commoncol.Client, gvr.TLSRoute, kubetypes.StandardInformer, kubetypes.Filter{ObjectFilter: commoncol.Client.ObjectFilter()}), commoncol.KrtOpts.ToOptions("informer/TLSRoutes")...),
|
||||
ReferenceGrants: krt.WrapClient(kclient.NewFilteredDelayed[*gwv1b1.ReferenceGrant](commoncol.Client, wellknown.ReferenceGrantGVR, kubetypes.Filter{ObjectFilter: commoncol.Client.ObjectFilter()}), commoncol.KrtOpts.ToOptions("informer/ReferenceGrants")...),
|
||||
XListenerSets: krt.WrapClient(kclient.NewDelayedInformer[*gwxv1a1.XListenerSet](commoncol.Client, gvr.XListenerSet, kubetypes.StandardInformer, kubetypes.Filter{ObjectFilter: commoncol.Client.ObjectFilter()}), commoncol.KrtOpts.ToOptions("informer/XListenerSets")...),
|
||||
TCPRoutes: krt.WrapClient(kclient.NewDelayedInformer[*gwv1a2.TCPRoute](client, gvr.TCPRoute, kubetypes.StandardInformer, kubetypes.Filter{ObjectFilter: client.ObjectFilter()}), krtOptions.ToOptions("informer/TCPRoutes")...),
|
||||
ReferenceGrants: krt.WrapClient(kclient.NewFilteredDelayed[*gwv1b1.ReferenceGrant](client, wellknown.ReferenceGrantGVR, kubetypes.Filter{ObjectFilter: client.ObjectFilter()}), krtOptions.ToOptions("informer/ReferenceGrants")...),
|
||||
// BackendTrafficPolicy?
|
||||
|
||||
// inference extensions need to be enabled so control plane has permissions to watch resource. Disable by default
|
||||
InferencePools: krt.NewStaticCollection[*inf.InferencePool](nil, nil, commoncol.KrtOpts.ToOptions("disable/inferencepools")...),
|
||||
InferencePools: krt.NewStaticCollection[*inf.InferencePool](nil, nil, krtOptions.ToOptions("disable/inferencepools")...),
|
||||
|
||||
// agentgateway-specific CRDs
|
||||
AgentgatewayPolicies: krt.NewInformer[*agentgateway.AgentgatewayPolicy](commoncol.Client),
|
||||
Backends: krt.NewInformer[*agentgateway.AgentgatewayBackend](commoncol.Client),
|
||||
AgentgatewayPolicies: krt.NewInformer[*agentgateway.AgentgatewayPolicy](client),
|
||||
Backends: krt.NewInformer[*agentgateway.AgentgatewayBackend](client),
|
||||
}
|
||||
|
||||
if commoncol.Settings.EnableInferExt {
|
||||
if settings.EnableInferExt {
|
||||
// inference extensions cluster watch permissions are controlled by enabling EnableInferExt
|
||||
inferencePoolGVR := wellknown.InferencePoolGVK.GroupVersion().WithResource("inferencepools")
|
||||
agwCollections.InferencePools = krt.WrapClient(kclient.NewDelayedInformer[*inf.InferencePool](commoncol.Client, inferencePoolGVR, kubetypes.StandardInformer, kclient.Filter{ObjectFilter: commoncol.Client.ObjectFilter()}), commoncol.KrtOpts.ToOptions("informer/InferencePools")...)
|
||||
agwCollections.InferencePools = krt.WrapClient(kclient.NewDelayedInformer[*inf.InferencePool](client, inferencePoolGVR, kubetypes.StandardInformer, kclient.Filter{ObjectFilter: client.ObjectFilter()}), krtOptions.ToOptions("informer/InferencePools")...)
|
||||
}
|
||||
agwCollections.SetupIndexes()
|
||||
|
||||
@ -160,3 +194,7 @@ func (c *AgwCollections) SetupIndexes() {
|
||||
c.SecretsByNamespace = krt.NewNamespaceIndex(c.Secrets)
|
||||
c.ServicesByNamespace = krt.NewNamespaceIndex(c.Services)
|
||||
}
|
||||
|
||||
func (c *AgwCollections) HasSynced() bool {
|
||||
return c.GatewaysForDeployer.HasSynced()
|
||||
}
|
||||
|
||||
@ -6,15 +6,16 @@ import (
|
||||
|
||||
"google.golang.org/protobuf/types/known/durationpb"
|
||||
"istio.io/istio/pkg/ptr"
|
||||
"istio.io/istio/pkg/slices"
|
||||
|
||||
"github.com/agentgateway/agentgateway/api"
|
||||
"github.com/agentgateway/agentgateway/controller/api/v1alpha1/agentgateway"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/kgateway/wellknown"
|
||||
"github.com/agentgateway/agentgateway/controller/api/v1alpha1/shared"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/wellknown"
|
||||
)
|
||||
|
||||
const (
|
||||
frontendTcpPolicySuffix = ":frontend-tcp"
|
||||
frontendNetworkAuthzSuffix = ":frontend-network-authz"
|
||||
frontendTlsPolicySuffix = ":frontend-tls"
|
||||
frontendHttpPolicySuffix = ":frontend-http"
|
||||
frontendLoggingPolicySuffix = ":frontend-logging"
|
||||
@ -24,64 +25,70 @@ const (
|
||||
func translateFrontendPolicyToAgw(
|
||||
policyCtx PolicyCtx,
|
||||
policy *agentgateway.AgentgatewayPolicy,
|
||||
policyTarget *api.PolicyTarget,
|
||||
) ([]AgwPolicy, error) {
|
||||
) ([]*api.Policy, error) {
|
||||
frontend := policy.Spec.Frontend
|
||||
if frontend == nil {
|
||||
return nil, nil
|
||||
}
|
||||
agwPolicies := make([]AgwPolicy, 0)
|
||||
agwPolicies := make([]*api.Policy, 0)
|
||||
var errs []error
|
||||
|
||||
policyName := getFrontendPolicyName(policy.Namespace, policy.Name)
|
||||
appendPolicy := func(kind string) func(*api.Policy, error) {
|
||||
return func(p *api.Policy, err error) {
|
||||
if err != nil {
|
||||
name := fmt.Sprintf("%s %s", kind, policyName)
|
||||
logger.Error("error processing policy", "policy", name, "error", err)
|
||||
errs = append(errs, err)
|
||||
}
|
||||
if p != nil {
|
||||
agwPolicies = append(agwPolicies, p)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if s := frontend.HTTP; s != nil {
|
||||
pol := translateFrontendHTTP(policy, policyName, policyTarget)
|
||||
agwPolicies = append(agwPolicies, pol...)
|
||||
appendPolicy("http")(translateFrontendHTTP(policy, policyName), nil)
|
||||
}
|
||||
|
||||
if s := frontend.TLS; s != nil {
|
||||
pol := translateFrontendTLS(policy, policyName, policyTarget)
|
||||
agwPolicies = append(agwPolicies, pol...)
|
||||
appendPolicy("tls")(translateFrontendTLS(policy, policyName), nil)
|
||||
}
|
||||
|
||||
if s := frontend.TCP; s != nil {
|
||||
pol := translateFrontendTCP(policy, policyName, policyTarget)
|
||||
agwPolicies = append(agwPolicies, pol...)
|
||||
appendPolicy("tcp")(translateFrontendTCP(policy, policyName), nil)
|
||||
}
|
||||
|
||||
if s := frontend.NetworkAuthorization; s != nil {
|
||||
appendPolicy("networkAuthorization")(translateFrontendNetworkAuthorization(policy, policyName), nil)
|
||||
}
|
||||
|
||||
if s := frontend.AccessLog; s != nil {
|
||||
pol := translateFrontendAccessLog(policy, policyName, policyTarget)
|
||||
agwPolicies = append(agwPolicies, pol...)
|
||||
appendPolicy("accessLog")(translateFrontendAccessLog(policyCtx, policy, policyName))
|
||||
}
|
||||
|
||||
if s := frontend.Tracing; s != nil {
|
||||
pol, err := translateFrontendTracing(policyCtx, policy, policyName, policyTarget)
|
||||
if err != nil {
|
||||
logger.Error("error processing tracing", "err", err)
|
||||
errs = append(errs, err)
|
||||
}
|
||||
agwPolicies = append(agwPolicies, pol...)
|
||||
appendPolicy("tracing")(translateFrontendTracing(policyCtx, policy, policyName))
|
||||
}
|
||||
|
||||
return agwPolicies, errors.Join(errs...)
|
||||
}
|
||||
|
||||
func translateFrontendTracing(ctx PolicyCtx, policy *agentgateway.AgentgatewayPolicy, name string, target *api.PolicyTarget) ([]AgwPolicy, error) {
|
||||
func translateFrontendTracing(ctx PolicyCtx, policy *agentgateway.AgentgatewayPolicy, name string) (*api.Policy, error) {
|
||||
tracing := policy.Spec.Frontend.Tracing
|
||||
if tracing == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
var errs []error
|
||||
provider, err := buildBackendRef(ctx, tracing.BackendRef, policy.Namespace)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to translate tracing backend ref: %v", err)
|
||||
errs = append(errs, fmt.Errorf("failed to translate tracing backend ref: %v", err))
|
||||
}
|
||||
|
||||
var addAttributes []*api.FrontendPolicySpec_TracingAttribute
|
||||
var rmAttributes []string
|
||||
if tracing.Attributes != nil {
|
||||
for _, add := range tracing.Attributes.Add {
|
||||
if !isCEL(add.Expression) {
|
||||
errs = append(errs, fmt.Errorf("frontend tracing attribute %q is not a valid CEL expression: %s", add.Name, add.Expression))
|
||||
}
|
||||
addAttributes = append(addAttributes, &api.FrontendPolicySpec_TracingAttribute{
|
||||
Name: add.Name,
|
||||
Value: string(add.Expression),
|
||||
@ -95,6 +102,9 @@ func translateFrontendTracing(ctx PolicyCtx, policy *agentgateway.AgentgatewayPo
|
||||
var addResources []*api.FrontendPolicySpec_TracingAttribute
|
||||
if tracing.Resources != nil {
|
||||
for _, add := range tracing.Resources {
|
||||
if !isCEL(add.Expression) {
|
||||
errs = append(errs, fmt.Errorf("frontend tracing resource %q is not a valid CEL expression: %s", add.Name, add.Expression))
|
||||
}
|
||||
addResources = append(addResources, &api.FrontendPolicySpec_TracingAttribute{
|
||||
Name: add.Name,
|
||||
Value: string(add.Expression),
|
||||
@ -104,29 +114,37 @@ func translateFrontendTracing(ctx PolicyCtx, policy *agentgateway.AgentgatewayPo
|
||||
|
||||
var randomSampling *string
|
||||
if tracing.RandomSampling != nil {
|
||||
randomSampling = ptr.Of(string(*tracing.RandomSampling))
|
||||
randomSampling = castCELPtr(tracing.RandomSampling, func(expr shared.CELExpression) {
|
||||
errs = append(errs, fmt.Errorf("frontend tracing randomSampling is not a valid CEL expression: %s", expr))
|
||||
})
|
||||
}
|
||||
|
||||
var clientSampling *string
|
||||
if tracing.ClientSampling != nil {
|
||||
clientSampling = ptr.Of(string(*tracing.ClientSampling))
|
||||
clientSampling = castCELPtr(tracing.ClientSampling, func(expr shared.CELExpression) {
|
||||
errs = append(errs, fmt.Errorf("frontend tracing clientSampling is not a valid CEL expression: %s", expr))
|
||||
})
|
||||
}
|
||||
|
||||
var path *string
|
||||
if tracing.Path != nil {
|
||||
path = ptr.Of(*tracing.Path)
|
||||
}
|
||||
|
||||
var protocol api.FrontendPolicySpec_Tracing_Protocol
|
||||
switch tracing.Protocol {
|
||||
case agentgateway.TracingProtocolGrpc:
|
||||
case agentgateway.OTLPProtocolGrpc:
|
||||
protocol = api.FrontendPolicySpec_Tracing_GRPC
|
||||
case agentgateway.TracingProtocolHttp:
|
||||
case agentgateway.OTLPProtocolHttp:
|
||||
protocol = api.FrontendPolicySpec_Tracing_HTTP
|
||||
default:
|
||||
// default to HTTP
|
||||
protocol = api.FrontendPolicySpec_Tracing_HTTP
|
||||
protocol = api.FrontendPolicySpec_Tracing_GRPC
|
||||
}
|
||||
|
||||
tracingPolicy := &api.Policy{
|
||||
Key: name + frontendTracingPolicySuffix + attachmentName(target),
|
||||
Name: TypedResourceName(wellknown.AgentgatewayPolicyGVK.Kind, policy),
|
||||
Target: target,
|
||||
Key: name + frontendTracingPolicySuffix,
|
||||
Name: TypedResourceName(wellknown.AgentgatewayPolicyGVK.Kind, policy),
|
||||
Kind: &api.Policy_Frontend{
|
||||
Frontend: &api.FrontendPolicySpec{
|
||||
Kind: &api.FrontendPolicySpec_Tracing_{Tracing: &api.FrontendPolicySpec_Tracing{
|
||||
@ -135,6 +153,7 @@ func translateFrontendTracing(ctx PolicyCtx, policy *agentgateway.AgentgatewayPo
|
||||
Remove: rmAttributes,
|
||||
Resources: addResources,
|
||||
Protocol: protocol,
|
||||
Path: path,
|
||||
RandomSampling: randomSampling,
|
||||
ClientSampling: clientSampling,
|
||||
}},
|
||||
@ -144,35 +163,68 @@ func translateFrontendTracing(ctx PolicyCtx, policy *agentgateway.AgentgatewayPo
|
||||
|
||||
logger.Debug("generated tracing policy",
|
||||
"policy", policy.Name,
|
||||
"agentgateway_policy", tracingPolicy.Name,
|
||||
"target", target)
|
||||
"agentgateway_policy", tracingPolicy.Name)
|
||||
|
||||
return []AgwPolicy{{Policy: tracingPolicy}}, nil
|
||||
return tracingPolicy, errors.Join(errs...)
|
||||
}
|
||||
|
||||
func translateFrontendAccessLog(policy *agentgateway.AgentgatewayPolicy, name string, target *api.PolicyTarget) []AgwPolicy {
|
||||
func translateFrontendAccessLog(ctx PolicyCtx, policy *agentgateway.AgentgatewayPolicy, name string) (*api.Policy, error) {
|
||||
logging := policy.Spec.Frontend.AccessLog
|
||||
spec := &api.FrontendPolicySpec_Logging{}
|
||||
var errs []error
|
||||
if f := logging.Filter; f != nil {
|
||||
spec.Filter = (*string)(f)
|
||||
spec.Filter = castCELPtr(f, func(expr shared.CELExpression) {
|
||||
errs = append(errs, fmt.Errorf("frontend accessLog filter is not a valid CEL expression: %s", expr))
|
||||
})
|
||||
}
|
||||
if a := logging.Attributes; a != nil {
|
||||
fields := make([]*api.FrontendPolicySpec_Logging_Field, 0, len(a.Add))
|
||||
for _, add := range a.Add {
|
||||
if !isCEL(add.Expression) {
|
||||
errs = append(errs, fmt.Errorf("frontend accessLog field %q is not a valid CEL expression: %s", add.Name, add.Expression))
|
||||
}
|
||||
fields = append(fields, &api.FrontendPolicySpec_Logging_Field{
|
||||
Name: add.Name,
|
||||
Expression: string(add.Expression),
|
||||
})
|
||||
}
|
||||
f := &api.FrontendPolicySpec_Logging_Fields{
|
||||
Remove: a.Remove,
|
||||
Add: slices.Map(a.Add, func(e agentgateway.AttributeAdd) *api.FrontendPolicySpec_Logging_Field {
|
||||
return &api.FrontendPolicySpec_Logging_Field{
|
||||
Name: e.Name,
|
||||
Expression: string(e.Expression),
|
||||
}
|
||||
}),
|
||||
Add: fields,
|
||||
}
|
||||
spec.Fields = f
|
||||
}
|
||||
if otlp := logging.Otlp; otlp != nil {
|
||||
provider, err := buildBackendRef(ctx, otlp.BackendRef, policy.Namespace)
|
||||
if err != nil {
|
||||
errs = append(errs, fmt.Errorf("failed to translate access log OTLP backend ref: %v", err))
|
||||
}
|
||||
|
||||
var protocol api.FrontendPolicySpec_Logging_OtlpAccessLog_Protocol
|
||||
switch otlp.Protocol {
|
||||
case agentgateway.OTLPProtocolGrpc:
|
||||
protocol = api.FrontendPolicySpec_Logging_OtlpAccessLog_GRPC
|
||||
case agentgateway.OTLPProtocolHttp:
|
||||
protocol = api.FrontendPolicySpec_Logging_OtlpAccessLog_HTTP
|
||||
default:
|
||||
protocol = api.FrontendPolicySpec_Logging_OtlpAccessLog_GRPC
|
||||
}
|
||||
|
||||
var path *string
|
||||
if otlp.Path != nil {
|
||||
path = ptr.Of(*otlp.Path)
|
||||
}
|
||||
|
||||
spec.OtlpAccessLog = &api.FrontendPolicySpec_Logging_OtlpAccessLog{
|
||||
ProviderBackend: provider,
|
||||
Protocol: protocol,
|
||||
Path: path,
|
||||
}
|
||||
}
|
||||
|
||||
loggingPolicy := &api.Policy{
|
||||
Key: name + frontendLoggingPolicySuffix + attachmentName(target),
|
||||
Name: TypedResourceName(wellknown.AgentgatewayPolicyGVK.Kind, policy),
|
||||
Target: target,
|
||||
Key: name + frontendLoggingPolicySuffix,
|
||||
Name: TypedResourceName(wellknown.AgentgatewayPolicyGVK.Kind, policy),
|
||||
Kind: &api.Policy_Frontend{
|
||||
Frontend: &api.FrontendPolicySpec{
|
||||
Kind: &api.FrontendPolicySpec_Logging_{
|
||||
@ -184,13 +236,12 @@ func translateFrontendAccessLog(policy *agentgateway.AgentgatewayPolicy, name st
|
||||
|
||||
logger.Debug("generated logging policy",
|
||||
"policy", policy.Name,
|
||||
"agentgateway_policy", loggingPolicy.Name,
|
||||
"target", target)
|
||||
"agentgateway_policy", loggingPolicy.Name)
|
||||
|
||||
return []AgwPolicy{{Policy: loggingPolicy}}
|
||||
return loggingPolicy, errors.Join(errs...)
|
||||
}
|
||||
|
||||
func translateFrontendTCP(policy *agentgateway.AgentgatewayPolicy, name string, target *api.PolicyTarget) []AgwPolicy {
|
||||
func translateFrontendTCP(policy *agentgateway.AgentgatewayPolicy, name string) *api.Policy {
|
||||
tcp := policy.Spec.Frontend.TCP
|
||||
spec := &api.FrontendPolicySpec_TCP{}
|
||||
if ka := tcp.KeepAlive; ka != nil {
|
||||
@ -207,9 +258,8 @@ func translateFrontendTCP(policy *agentgateway.AgentgatewayPolicy, name string,
|
||||
}
|
||||
|
||||
tcpPolicy := &api.Policy{
|
||||
Key: name + frontendTcpPolicySuffix + attachmentName(target),
|
||||
Name: TypedResourceName(wellknown.AgentgatewayPolicyGVK.Kind, policy),
|
||||
Target: target,
|
||||
Key: name + frontendTcpPolicySuffix,
|
||||
Name: TypedResourceName(wellknown.AgentgatewayPolicyGVK.Kind, policy),
|
||||
Kind: &api.Policy_Frontend{
|
||||
Frontend: &api.FrontendPolicySpec{
|
||||
Kind: &api.FrontendPolicySpec_Tcp{
|
||||
@ -221,17 +271,50 @@ func translateFrontendTCP(policy *agentgateway.AgentgatewayPolicy, name string,
|
||||
|
||||
logger.Debug("generated tcp policy",
|
||||
"policy", policy.Name,
|
||||
"agentgateway_policy", tcpPolicy.Name,
|
||||
"target", target)
|
||||
"agentgateway_policy", tcpPolicy.Name)
|
||||
|
||||
return []AgwPolicy{{Policy: tcpPolicy}}
|
||||
return tcpPolicy
|
||||
}
|
||||
|
||||
func translateFrontendNetworkAuthorization(policy *agentgateway.AgentgatewayPolicy, name string) *api.Policy {
|
||||
auth := policy.Spec.Frontend.NetworkAuthorization
|
||||
var allowPolicies, denyPolicies, requirePolicies []string
|
||||
if auth.Action == shared.AuthorizationPolicyActionDeny {
|
||||
denyPolicies = append(denyPolicies, cast(auth.Policy.MatchExpressions)...)
|
||||
} else if auth.Action == shared.AuthorizationPolicyActionRequire {
|
||||
requirePolicies = append(requirePolicies, cast(auth.Policy.MatchExpressions)...)
|
||||
} else {
|
||||
allowPolicies = append(allowPolicies, cast(auth.Policy.MatchExpressions)...)
|
||||
}
|
||||
|
||||
pol := &api.Policy{
|
||||
Key: name + frontendNetworkAuthzSuffix,
|
||||
Name: TypedResourceName(wellknown.AgentgatewayPolicyGVK.Kind, policy),
|
||||
Kind: &api.Policy_Frontend{
|
||||
Frontend: &api.FrontendPolicySpec{
|
||||
Kind: &api.FrontendPolicySpec_NetworkAuthorization_{
|
||||
NetworkAuthorization: &api.FrontendPolicySpec_NetworkAuthorization{
|
||||
Allow: allowPolicies,
|
||||
Deny: denyPolicies,
|
||||
Require: requirePolicies,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
logger.Debug("generated frontend network authorization policy",
|
||||
"policy", policy.Name,
|
||||
"agentgateway_policy", pol.Name)
|
||||
|
||||
return pol
|
||||
}
|
||||
|
||||
func castUint32[T ~int32](ka *T) *uint32 {
|
||||
return ptr.Of((uint32)(*ka))
|
||||
}
|
||||
|
||||
func translateFrontendTLS(policy *agentgateway.AgentgatewayPolicy, name string, target *api.PolicyTarget) []AgwPolicy {
|
||||
func translateFrontendTLS(policy *agentgateway.AgentgatewayPolicy, name string) *api.Policy {
|
||||
tls := policy.Spec.Frontend.TLS
|
||||
spec := &api.FrontendPolicySpec_TLS{}
|
||||
if ka := tls.HandshakeTimeout; ka != nil {
|
||||
@ -297,9 +380,8 @@ func translateFrontendTLS(policy *agentgateway.AgentgatewayPolicy, name string,
|
||||
}
|
||||
|
||||
tlsPolicy := &api.Policy{
|
||||
Key: name + frontendTlsPolicySuffix + attachmentName(target),
|
||||
Name: TypedResourceName(wellknown.AgentgatewayPolicyGVK.Kind, policy),
|
||||
Target: target,
|
||||
Key: name + frontendTlsPolicySuffix,
|
||||
Name: TypedResourceName(wellknown.AgentgatewayPolicyGVK.Kind, policy),
|
||||
Kind: &api.Policy_Frontend{
|
||||
Frontend: &api.FrontendPolicySpec{
|
||||
Kind: &api.FrontendPolicySpec_Tls{
|
||||
@ -311,13 +393,12 @@ func translateFrontendTLS(policy *agentgateway.AgentgatewayPolicy, name string,
|
||||
|
||||
logger.Debug("generated tls policy",
|
||||
"policy", policy.Name,
|
||||
"agentgateway_policy", tlsPolicy.Name,
|
||||
"target", target)
|
||||
"agentgateway_policy", tlsPolicy.Name)
|
||||
|
||||
return []AgwPolicy{{Policy: tlsPolicy}}
|
||||
return tlsPolicy
|
||||
}
|
||||
|
||||
func translateFrontendHTTP(policy *agentgateway.AgentgatewayPolicy, name string, target *api.PolicyTarget) []AgwPolicy {
|
||||
func translateFrontendHTTP(policy *agentgateway.AgentgatewayPolicy, name string) *api.Policy {
|
||||
http := policy.Spec.Frontend.HTTP
|
||||
spec := &api.FrontendPolicySpec_HTTP{}
|
||||
if v := http.MaxBufferSize; v != nil {
|
||||
@ -346,9 +427,8 @@ func translateFrontendHTTP(policy *agentgateway.AgentgatewayPolicy, name string,
|
||||
}
|
||||
|
||||
httpPolicy := &api.Policy{
|
||||
Key: name + frontendHttpPolicySuffix + attachmentName(target),
|
||||
Name: TypedResourceName(wellknown.AgentgatewayPolicyGVK.Kind, policy),
|
||||
Target: target,
|
||||
Key: name + frontendHttpPolicySuffix,
|
||||
Name: TypedResourceName(wellknown.AgentgatewayPolicyGVK.Kind, policy),
|
||||
Kind: &api.Policy_Frontend{
|
||||
Frontend: &api.FrontendPolicySpec{
|
||||
Kind: &api.FrontendPolicySpec_Http{
|
||||
@ -360,8 +440,7 @@ func translateFrontendHTTP(policy *agentgateway.AgentgatewayPolicy, name string,
|
||||
|
||||
logger.Debug("generated http policy",
|
||||
"policy", policy.Name,
|
||||
"agentgateway_policy", httpPolicy.Name,
|
||||
"target", target)
|
||||
"agentgateway_policy", httpPolicy.Name)
|
||||
|
||||
return []AgwPolicy{{Policy: httpPolicy}}
|
||||
return httpPolicy
|
||||
}
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
package plugins_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
gwv1 "sigs.k8s.io/gateway-api/apis/v1"
|
||||
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/agentgateway/plugins"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/agentgateway/testutils"
|
||||
)
|
||||
|
||||
func TestFrontendPolicies(t *testing.T) {
|
||||
testutils.RunForDirectory(t, "testdata/frontendpolicy", func(t *testing.T, ctx plugins.PolicyCtx) (*gwv1.PolicyStatus, []plugins.AgwPolicy) {
|
||||
pol := testutils.GetTestResource(t, ctx.Collections.AgentgatewayPolicies)
|
||||
s, o := plugins.TranslateAgentgatewayPolicy(ctx.Krt, pol, ctx.Collections)
|
||||
return s, o
|
||||
})
|
||||
}
|
||||
@ -17,8 +17,8 @@ import (
|
||||
|
||||
"github.com/agentgateway/agentgateway/api"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/agentgateway/utils"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/kgateway/wellknown"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/utils/kubeutils"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/wellknown"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -33,9 +33,9 @@ func NewInferencePlugin(agw *AgwCollections) AgwPlugin {
|
||||
wellknown.InferencePoolGVK.GroupKind(): {
|
||||
Build: func(input PolicyPluginInput) (krt.StatusCollection[controllers.Object, any], krt.Collection[AgwPolicy]) {
|
||||
status, policyCol := krt.NewStatusManyCollection(agw.InferencePools, func(krtctx krt.HandlerContext, infPool *inf.InferencePool) (*inf.InferencePoolStatus, []AgwPolicy) {
|
||||
return translatePoliciesForInferencePool(krtctx, agw.ControllerName, input.Ancestors, agw.Services, infPool)
|
||||
return translatePoliciesForInferencePool(krtctx, agw.ControllerName, input.References, agw.Services, infPool)
|
||||
}, agw.KrtOpts.ToOptions("agentgateway/InferencePools")...)
|
||||
return convertStatusCollection(status), policyCol
|
||||
return ConvertStatusCollection(status), policyCol
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -46,7 +46,7 @@ func NewInferencePlugin(agw *AgwCollections) AgwPlugin {
|
||||
func translatePoliciesForInferencePool(
|
||||
krtctx krt.HandlerContext,
|
||||
controllerName string,
|
||||
ancestors krt.IndexCollection[utils.TypedNamespacedName, *utils.AncestorBackend],
|
||||
references ReferenceIndex,
|
||||
services krt.Collection[*corev1.Service],
|
||||
pool *inf.InferencePool,
|
||||
) (*inf.InferencePoolStatus, []AgwPolicy) {
|
||||
@ -54,7 +54,7 @@ func translatePoliciesForInferencePool(
|
||||
|
||||
epr := pool.Spec.EndpointPickerRef
|
||||
validationErr := validateInferencePoolEndpointPickerRef(krtctx, pool, services)
|
||||
attachedGateways := inferencePoolAttachedGateways(krtctx, ancestors, pool)
|
||||
attachedGateways := inferencePoolAttachedGateways(krtctx, references, pool)
|
||||
status := buildInferencePoolStatus(pool, controllerName, attachedGateways, validationErr)
|
||||
|
||||
// 'service/{namespace}/{hostname}:{port}'
|
||||
@ -91,7 +91,11 @@ func translatePoliciesForInferencePool(
|
||||
},
|
||||
},
|
||||
}
|
||||
infPolicies = append(infPolicies, AgwPolicy{Policy: inferencePolicy})
|
||||
gatewayTargets := make([]types.NamespacedName, 0, len(attachedGateways))
|
||||
for gatewayTarget := range attachedGateways {
|
||||
gatewayTargets = append(gatewayTargets, gatewayTarget)
|
||||
}
|
||||
infPolicies = appendPolicyForGateways(infPolicies, gatewayTargets, inferencePolicy)
|
||||
|
||||
// Create the TLS policy for the endpoint picker
|
||||
// TODO: we would want some way if they explicitly set a BackendTLSPolicy for the EPP to respect that
|
||||
@ -110,7 +114,7 @@ func translatePoliciesForInferencePool(
|
||||
},
|
||||
},
|
||||
}
|
||||
infPolicies = append(infPolicies, AgwPolicy{Policy: inferencePolicyTLS})
|
||||
infPolicies = appendPolicyForGateways(infPolicies, gatewayTargets, inferencePolicyTLS)
|
||||
|
||||
logger.Debug("generated inference pool policies",
|
||||
"pool", pool.Name,
|
||||
@ -132,9 +136,9 @@ func validateInferencePoolEndpointPickerRef(krtctx krt.HandlerContext, pool *inf
|
||||
kind := epr.Kind
|
||||
if kind == "" {
|
||||
// InferencePool defaults this field to Service.
|
||||
kind = inf.Kind(wellknown.ServiceKind)
|
||||
kind = wellknown.ServiceKind
|
||||
}
|
||||
if kind != inf.Kind(wellknown.ServiceKind) {
|
||||
if kind != wellknown.ServiceKind {
|
||||
errs = append(errs, fmt.Sprintf("endpointPickerRef.kind must be %q, got %q", wellknown.ServiceKind, kind))
|
||||
}
|
||||
|
||||
@ -187,13 +191,10 @@ func inferencePoolValidationError(errs []string) error {
|
||||
|
||||
func inferencePoolAttachedGateways(
|
||||
krtctx krt.HandlerContext,
|
||||
ancestors krt.IndexCollection[utils.TypedNamespacedName, *utils.AncestorBackend],
|
||||
references ReferenceIndex,
|
||||
pool *inf.InferencePool,
|
||||
) map[types.NamespacedName]struct{} {
|
||||
gateways := make(map[types.NamespacedName]struct{})
|
||||
if ancestors == nil {
|
||||
return gateways
|
||||
}
|
||||
|
||||
targetRef := utils.TypedNamespacedName{
|
||||
NamespacedName: types.NamespacedName{
|
||||
@ -203,11 +204,8 @@ func inferencePoolAttachedGateways(
|
||||
Kind: wellknown.InferencePoolKind,
|
||||
}
|
||||
|
||||
ancestorBackends := krt.Fetch(krtctx, ancestors, krt.FilterKey(targetRef.String()))
|
||||
for _, gwl := range ancestorBackends {
|
||||
for _, i := range gwl.Objects {
|
||||
gateways[i.Gateway] = struct{}{}
|
||||
}
|
||||
for gateway := range references.LookupGatewaysForBackend(krtctx, targetRef) {
|
||||
gateways[gateway] = struct{}{}
|
||||
}
|
||||
return gateways
|
||||
}
|
||||
@ -256,8 +254,8 @@ func desiredInferencePoolParentRefs(attachedGateways map[types.NamespacedName]st
|
||||
return []inf.ParentReference{}
|
||||
}
|
||||
return []inf.ParentReference{{
|
||||
Kind: inf.Kind(defaultInferencePoolStatusKind),
|
||||
Name: inf.ObjectName(defaultInferencePoolStatusName),
|
||||
Kind: defaultInferencePoolStatusKind,
|
||||
Name: defaultInferencePoolStatusName,
|
||||
}}
|
||||
}
|
||||
|
||||
@ -276,7 +274,7 @@ func desiredInferencePoolParentRefs(attachedGateways map[types.NamespacedName]st
|
||||
for _, g := range gateways {
|
||||
refs = append(refs, inf.ParentReference{
|
||||
Group: ptr.Of(inf.Group(wellknown.GatewayGroup)),
|
||||
Kind: inf.Kind(wellknown.GatewayKind),
|
||||
Kind: wellknown.GatewayKind,
|
||||
Namespace: inf.Namespace(g.Namespace),
|
||||
Name: inf.ObjectName(g.Name),
|
||||
})
|
||||
|
||||
@ -1,70 +1,64 @@
|
||||
package plugins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sort"
|
||||
|
||||
"istio.io/istio/pilot/pkg/util/protoconv"
|
||||
"istio.io/istio/pkg/config"
|
||||
"istio.io/istio/pkg/kube/controllers"
|
||||
"istio.io/istio/pkg/kube/krt"
|
||||
"istio.io/istio/pkg/ptr"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
||||
"github.com/agentgateway/agentgateway/api"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/agentgateway/ir"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/agentgateway/utils"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/apiclient"
|
||||
)
|
||||
|
||||
// AgwResourceStatusSyncHandler defines a function that handles status syncing for a specific resource type in AgentGateway
|
||||
type AgwResourceStatusSyncHandler func(ctx context.Context, client apiclient.Client, namespacedName types.NamespacedName, status any) error
|
||||
|
||||
type PolicyPluginInput struct {
|
||||
Ancestors krt.IndexCollection[utils.TypedNamespacedName, *utils.AncestorBackend]
|
||||
References ReferenceIndex
|
||||
}
|
||||
|
||||
type BackendPlugin struct {
|
||||
Build func(PolicyPluginInput) (krt.StatusCollection[controllers.Object, any], krt.Collection[ir.AgwResource])
|
||||
BuildReferences func() krt.Collection[*PolicyAttachment]
|
||||
}
|
||||
|
||||
type PolicyPlugin struct {
|
||||
Build func(PolicyPluginInput) (krt.StatusCollection[controllers.Object, any], krt.Collection[AgwPolicy])
|
||||
Build func(PolicyPluginInput) (krt.StatusCollection[controllers.Object, any], krt.Collection[AgwPolicy])
|
||||
BuildReferences func(input PolicyPluginInput) krt.Collection[*PolicyAttachment]
|
||||
}
|
||||
|
||||
// ApplyPolicies extracts all policies from the collection
|
||||
func (p *PolicyPlugin) ApplyPolicies(inputs PolicyPluginInput) (krt.Collection[AgwPolicy], krt.StatusCollection[controllers.Object, any]) {
|
||||
func (p *PolicyPlugin) ApplyPolicies(inputs PolicyPluginInput) (krt.Collection[AgwPolicy], krt.StatusCollection[controllers.Object, any], krt.Collection[*PolicyAttachment]) {
|
||||
status, col := p.Build(inputs)
|
||||
return col, status
|
||||
var refs krt.Collection[*PolicyAttachment]
|
||||
if p.BuildReferences != nil {
|
||||
refs = p.BuildReferences(inputs)
|
||||
}
|
||||
return col, status, refs
|
||||
}
|
||||
|
||||
// AgwPolicy wraps an Agw policy for collection handling
|
||||
type AgwPolicy struct {
|
||||
Policy *api.Policy
|
||||
Gateway *types.NamespacedName
|
||||
Policy *api.Policy
|
||||
// TODO: track errors per policy
|
||||
}
|
||||
|
||||
func (p AgwPolicy) Equals(in AgwPolicy) bool {
|
||||
return protoconv.Equals(p.Policy, in.Policy)
|
||||
return ptr.Equal(p.Gateway, in.Gateway) && protoconv.Equals(p.Policy, in.Policy)
|
||||
}
|
||||
|
||||
func (p AgwPolicy) ResourceName() string {
|
||||
return p.Policy.Key
|
||||
return p.Gateway.String() + "/" + p.Policy.Key
|
||||
}
|
||||
|
||||
type AddResourcesPlugin struct {
|
||||
Binds krt.Collection[ir.AgwResource]
|
||||
Listeners krt.Collection[ir.AgwResource]
|
||||
Routes krt.Collection[ir.AgwResource]
|
||||
}
|
||||
|
||||
// AddBinds extracts all bind resources from the collection
|
||||
func (p *AddResourcesPlugin) AddBinds() krt.Collection[ir.AgwResource] {
|
||||
return p.Binds
|
||||
}
|
||||
|
||||
// AddListeners extracts all routes resources from the collection
|
||||
func (p *AddResourcesPlugin) AddListeners() krt.Collection[ir.AgwResource] {
|
||||
return p.Listeners
|
||||
}
|
||||
|
||||
// AddRoutes extracts all routes resources from the collection
|
||||
func (p *AddResourcesPlugin) AddRoutes() krt.Collection[ir.AgwResource] {
|
||||
return p.Routes
|
||||
Binds krt.Collection[ir.AgwResource]
|
||||
Listeners krt.Collection[ir.AgwResource]
|
||||
Routes krt.Collection[ir.AgwResource]
|
||||
AncestorBackends krt.Collection[*utils.AncestorBackend]
|
||||
}
|
||||
|
||||
func ResourceName[T config.Namer](o T) *api.ResourceName {
|
||||
@ -89,3 +83,16 @@ func TypedResourceFromName(typ string, o types.NamespacedName) *api.TypedResourc
|
||||
Name: o.Name,
|
||||
}
|
||||
}
|
||||
|
||||
func appendPolicyForGateways(policies []AgwPolicy, gatewayTargets []types.NamespacedName, policy *api.Policy) []AgwPolicy {
|
||||
sort.Slice(gatewayTargets, func(i, j int) bool {
|
||||
return gatewayTargets[i].String() < gatewayTargets[j].String()
|
||||
})
|
||||
for _, gatewayTarget := range gatewayTargets {
|
||||
policies = append(policies, AgwPolicy{
|
||||
Gateway: ptr.Of(gatewayTarget),
|
||||
Policy: policy,
|
||||
})
|
||||
}
|
||||
return policies
|
||||
}
|
||||
|
||||
326
controller/pkg/agentgateway/plugins/reference_indexes.go
Normal file
326
controller/pkg/agentgateway/plugins/reference_indexes.go
Normal file
@ -0,0 +1,326 @@
|
||||
package plugins
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"istio.io/istio/pkg/kube/krt"
|
||||
"istio.io/istio/pkg/ptr"
|
||||
"istio.io/istio/pkg/util/sets"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
gwv1 "sigs.k8s.io/gateway-api/apis/v1"
|
||||
|
||||
"github.com/agentgateway/agentgateway/api"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/agentgateway/utils"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/pluginsdk/krtutil"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/utils/kubeutils"
|
||||
"github.com/agentgateway/agentgateway/controller/pkg/wellknown"
|
||||
)
|
||||
|
||||
type ReferenceTypes struct {
|
||||
PolicyTargets func(krtctx krt.HandlerContext, namespace string, name gwv1.ObjectName, gk schema.GroupKind, sectionName *gwv1.SectionName) ([]*api.PolicyTarget, bool)
|
||||
PolicyBackend func(krtctx krt.HandlerContext, defaultNamespace string, gk schema.GroupKind, name gwv1.ObjectName, namespace *gwv1.Namespace, port *gwv1.PortNumber) (*api.BackendReference, error)
|
||||
RouteBackend func(krtctx krt.HandlerContext, defaultNamespace string, gk schema.GroupKind, name gwv1.ObjectName, namespace *gwv1.Namespace, port *gwv1.PortNumber) (*api.BackendReference, error)
|
||||
}
|
||||
|
||||
type BackendReferenceErrorReason string
|
||||
|
||||
const (
|
||||
BackendReferenceErrorReasonBackendNotFound BackendReferenceErrorReason = "BackendNotFound"
|
||||
BackendReferenceErrorReasonInvalidKind BackendReferenceErrorReason = "InvalidKind"
|
||||
BackendReferenceErrorReasonUnsupportedValue BackendReferenceErrorReason = "UnsupportedValue"
|
||||
)
|
||||
|
||||
type BackendReferenceError struct {
|
||||
Reason BackendReferenceErrorReason
|
||||
Message string
|
||||
}
|
||||
|
||||
func (e *BackendReferenceError) Error() string {
|
||||
return e.Message
|
||||
}
|
||||
|
||||
func DefaultReferenceTypes(agw *AgwCollections) ReferenceTypes {
|
||||
return ReferenceTypes{
|
||||
// AgentgatewayPolicy targets
|
||||
PolicyTargets: func(krtctx krt.HandlerContext, namespace string, name gwv1.ObjectName, gk schema.GroupKind, sectionName *gwv1.SectionName) ([]*api.PolicyTarget, bool) {
|
||||
key := namespace + "/" + string(name)
|
||||
switch gk {
|
||||
case wellknown.GatewayGVK.GroupKind():
|
||||
return []*api.PolicyTarget{{
|
||||
Kind: utils.GatewayTarget(namespace, string(name), sectionName),
|
||||
}}, ptr.Flatten(krt.FetchOne(krtctx, agw.Gateways, krt.FilterKey(key))) != nil
|
||||
case wellknown.HTTPRouteGVK.GroupKind():
|
||||
return []*api.PolicyTarget{{
|
||||
Kind: utils.RouteTarget(namespace, string(name), wellknown.HTTPRouteGVK.Kind, sectionName),
|
||||
}}, ptr.Flatten(krt.FetchOne(krtctx, agw.HTTPRoutes, krt.FilterKey(key))) != nil
|
||||
case wellknown.GRPCRouteGVK.GroupKind():
|
||||
return []*api.PolicyTarget{{
|
||||
Kind: utils.RouteTarget(namespace, string(name), wellknown.GRPCRouteGVK.Kind, sectionName),
|
||||
}}, ptr.Flatten(krt.FetchOne(krtctx, agw.GRPCRoutes, krt.FilterKey(key))) != nil
|
||||
case wellknown.AgentgatewayBackendGVK.GroupKind():
|
||||
return []*api.PolicyTarget{{
|
||||
Kind: utils.BackendTarget(namespace, string(name), sectionName),
|
||||
}}, ptr.Flatten(krt.FetchOne(krtctx, agw.Backends, krt.FilterKey(key))) != nil
|
||||
case wellknown.ServiceGVK.GroupKind():
|
||||
return []*api.PolicyTarget{{
|
||||
Kind: utils.ServiceTarget(namespace, string(name), sectionName),
|
||||
}}, ptr.Flatten(krt.FetchOne(krtctx, agw.Services, krt.FilterKey(key))) != nil
|
||||
}
|
||||
return nil, false
|
||||
},
|
||||
// AgentgatewayPolicy targets to backends (for things like ext_authz, etc)
|
||||
PolicyBackend: func(krtctx krt.HandlerContext, defaultNamespace string, gk schema.GroupKind, name gwv1.ObjectName, namespace *gwv1.Namespace, port *gwv1.PortNumber) (*api.BackendReference, error) {
|
||||
ns := string(ptr.OrDefault(namespace, gwv1.Namespace(defaultNamespace)))
|
||||
switch gk {
|
||||
case wellknown.ServiceGVK.GroupKind():
|
||||
if strings.Contains(string(name), ".") {
|
||||
return nil, &BackendReferenceError{
|
||||
Reason: BackendReferenceErrorReasonUnsupportedValue,
|
||||
Message: "service name invalid; the name of the Service, not the hostname",
|
||||
}
|
||||
}
|
||||
key := ns + "/" + string(name)
|
||||
svc := ptr.Flatten(krt.FetchOne(krtctx, agw.Services, krt.FilterKey(key)))
|
||||
if svc == nil {
|
||||
return nil, &BackendReferenceError{
|
||||
Reason: BackendReferenceErrorReasonBackendNotFound,
|
||||
Message: fmt.Sprintf("unable to find the Service %v", key),
|
||||
}
|
||||
}
|
||||
if port == nil {
|
||||
return nil, &BackendReferenceError{
|
||||
Reason: BackendReferenceErrorReasonUnsupportedValue,
|
||||
Message: "port is required for Service targets",
|
||||
}
|
||||
}
|
||||
return &api.BackendReference{
|
||||
Kind: &api.BackendReference_Service_{
|
||||
Service: &api.BackendReference_Service{
|
||||
Hostname: kubeutils.GetServiceHostname(string(name), ns),
|
||||
Namespace: ns,
|
||||
},
|
||||
},
|
||||
Port: uint32(*port), //nolint:gosec // G115: validated 1-65535
|
||||
}, nil
|
||||
case wellknown.AgentgatewayBackendGVK.GroupKind():
|
||||
key := ns + "/" + string(name)
|
||||
be := ptr.Flatten(krt.FetchOne(krtctx, agw.Backends, krt.FilterKey(key)))
|
||||
if be == nil {
|
||||
return nil, &BackendReferenceError{
|
||||
Reason: BackendReferenceErrorReasonBackendNotFound,
|
||||
Message: fmt.Sprintf("unable to find the Backend %v", key),
|
||||
}
|
||||
}
|
||||
return &api.BackendReference{
|
||||
Kind: &api.BackendReference_Backend{
|
||||
Backend: key,
|
||||
},
|
||||
}, nil
|
||||
default:
|
||||
return nil, &BackendReferenceError{
|
||||
Reason: BackendReferenceErrorReasonInvalidKind,
|
||||
Message: fmt.Sprintf("unsupported backend %v", gk),
|
||||
}
|
||||
}
|
||||
},
|
||||
RouteBackend: func(krtctx krt.HandlerContext, defaultNamespace string, gk schema.GroupKind, name gwv1.ObjectName, namespace *gwv1.Namespace, port *gwv1.PortNumber) (*api.BackendReference, error) {
|
||||
return DefaultRouteBackend(krtctx, agw, defaultNamespace, gk, name, namespace, port)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func DefaultRouteBackend(krtctx krt.HandlerContext, agw *AgwCollections, defaultNamespace string, gk schema.GroupKind, name gwv1.ObjectName, namespace *gwv1.Namespace, port *gwv1.PortNumber) (*api.BackendReference, error) {
|
||||
ns := string(ptr.OrDefault(namespace, gwv1.Namespace(defaultNamespace)))
|
||||
// All MUST return a BackendReference. We may not be able to fully populate it, though; this will get replaced with 'invalid'
|
||||
ref := &api.BackendReference{}
|
||||
switch gk {
|
||||
case wellknown.InferencePoolGVK.GroupKind():
|
||||
if strings.Contains(string(name), ".") {
|
||||
return ref, &BackendReferenceError{
|
||||
Reason: BackendReferenceErrorReasonUnsupportedValue,
|
||||
Message: "InferencePool name invalid; the name of the InferencePool must be used, not the hostname.",
|
||||
}
|
||||
}
|
||||
key := ns + "/" + string(name)
|
||||
svc := ptr.Flatten(krt.FetchOne(krtctx, agw.InferencePools, krt.FilterKey(key)))
|
||||
if svc == nil {
|
||||
return ref, &BackendReferenceError{
|
||||
Reason: BackendReferenceErrorReasonBackendNotFound,
|
||||
Message: fmt.Sprintf("backendRef %s not found", key),
|
||||
}
|
||||
}
|
||||
ref.Kind = &api.BackendReference_Service_{
|
||||
Service: &api.BackendReference_Service{
|
||||
Hostname: kubeutils.GetInferenceServiceHostname(string(name), ns),
|
||||
Namespace: ns,
|
||||
},
|
||||
}
|
||||
ref.Port = uint32(svc.Spec.TargetPorts[0].Number) //nolint:gosec // G115: validated 1-65535
|
||||
case wellknown.ServiceGVK.GroupKind():
|
||||
if strings.Contains(string(name), ".") {
|
||||
return ref, &BackendReferenceError{
|
||||
Reason: BackendReferenceErrorReasonUnsupportedValue,
|
||||
Message: "service name invalid; the name of the Service must be used, not the hostname.",
|
||||
}
|
||||
}
|
||||
if port == nil { // Validated by CEL so shouldn't happen
|
||||
return ref, &BackendReferenceError{
|
||||
Reason: BackendReferenceErrorReasonUnsupportedValue,
|
||||
Message: "port is required in Service backendRef",
|
||||
}
|
||||
}
|
||||
// Populate resp now, so even if the service doesn't exist we can return a better error (Service not found vs invalid)
|
||||
ref.Kind = &api.BackendReference_Service_{
|
||||
Service: &api.BackendReference_Service{
|
||||
Hostname: kubeutils.GetServiceHostname(string(name), ns),
|
||||
Namespace: ns,
|
||||
}}
|
||||
ref.Port = uint32(*port) //nolint:gosec // G115: validated 1-65535
|
||||
key := ns + "/" + string(name)
|
||||
svc := ptr.Flatten(krt.FetchOne(krtctx, agw.Services, krt.FilterKey(key)))
|
||||
if svc == nil {
|
||||
return ref, &BackendReferenceError{
|
||||
Reason: BackendReferenceErrorReasonBackendNotFound,
|
||||
Message: fmt.Sprintf("backend(%s) not found", kubeutils.GetServiceHostname(string(name), ns)),
|
||||
}
|
||||
}
|
||||
case wellknown.AgentgatewayBackendGVK.GroupKind():
|
||||
key := ns + "/" + string(name)
|
||||
ref.Kind = &api.BackendReference_Backend{Backend: key}
|
||||
// Populate resp now, so even if the service doesn't exist we can return a better error (Service not found vs invalid)
|
||||
be := ptr.Flatten(krt.FetchOne(krtctx, agw.Backends, krt.FilterKey(key)))
|
||||
if be == nil {
|
||||
return ref, &BackendReferenceError{
|
||||
Reason: BackendReferenceErrorReasonBackendNotFound,
|
||||
Message: fmt.Sprintf("Backend not found: %s", key),
|
||||
}
|
||||
}
|
||||
default:
|
||||
return ref, &BackendReferenceError{
|
||||
Reason: BackendReferenceErrorReasonInvalidKind,
|
||||
Message: fmt.Sprintf("referencing unsupported backendRef: group %q kind %q", gk.Group, gk.Kind),
|
||||
}
|
||||
}
|
||||
return ref, nil
|
||||
}
|
||||
|
||||
type RouteAttachment struct {
|
||||
// Route
|
||||
From utils.TypedNamespacedName
|
||||
// Immediate parent (Gateway or ListenerSet)
|
||||
To utils.TypedNamespacedName
|
||||
ListenerName string
|
||||
// Eventual parent (always Gateway)
|
||||
Gateway types.NamespacedName
|
||||
}
|
||||
|
||||
func (r RouteAttachment) ResourceName() string {
|
||||
to := r.To.String()
|
||||
if r.To.Kind != wellknown.GatewayGVK.Kind {
|
||||
to += "/" + r.Gateway.String()
|
||||
}
|
||||
return r.From.Kind + "/" + r.From.NamespacedName.String() + "->" + to + "/" + r.ListenerName
|
||||
}
|
||||
|
||||
func (r RouteAttachment) Equals(other RouteAttachment) bool {
|
||||
return r.From == other.From && r.To == other.To && r.ListenerName == other.ListenerName && r.Gateway == other.Gateway
|
||||
}
|
||||
|
||||
// BuildReferenceIndex builds a set of indexes that can lookup objects through various means.
|
||||
// For example, lookup associated Gateways for a Backend.
|
||||
func BuildReferenceIndex(
|
||||
ancestors krt.IndexCollection[utils.TypedNamespacedName, *utils.AncestorBackend],
|
||||
attachments krt.IndexCollection[utils.TypedNamespacedName, *RouteAttachment],
|
||||
referenceTypes ReferenceTypes,
|
||||
) ReferenceIndex {
|
||||
return ReferenceIndex{
|
||||
Ancestors: ancestors,
|
||||
attachments: attachments,
|
||||
explicitReferences: referenceTypes,
|
||||
}
|
||||
}
|
||||
|
||||
type PolicyAttachment struct {
|
||||
Target utils.TypedNamespacedName
|
||||
Backend utils.TypedNamespacedName
|
||||
Source utils.TypedNamespacedName
|
||||
}
|
||||
|
||||
func (a PolicyAttachment) Equals(other PolicyAttachment) bool {
|
||||
return a.Target == other.Target && a.Backend == other.Backend && a.Source == other.Source
|
||||
}
|
||||
|
||||
func (a PolicyAttachment) ResourceName() string {
|
||||
return a.Source.String() + "/" + a.Target.String() + "/" + a.Backend.String()
|
||||
}
|
||||
|
||||
type ReferenceIndex struct {
|
||||
// Backend --> Gateway via Route
|
||||
Ancestors krt.IndexCollection[utils.TypedNamespacedName, *utils.AncestorBackend]
|
||||
// Backend --> Target via Policy
|
||||
PolicyAttachments krt.IndexCollection[utils.TypedNamespacedName, *PolicyAttachment]
|
||||
// Route --> Gateway
|
||||
attachments krt.IndexCollection[utils.TypedNamespacedName, *RouteAttachment]
|
||||
// Gateway --> Gateway: trivial, no collection needed
|
||||
// ListenerSet --> Gateway: NOT present; ListenerSet attachment not implemented (but really should be!) in AgentgatewayPolicy anyways
|
||||
|
||||
explicitReferences ReferenceTypes
|
||||
}
|
||||
|
||||
func (p ReferenceIndex) LookupGatewaysForTarget(ctx krt.HandlerContext, object utils.TypedNamespacedName) sets.Set[types.NamespacedName] {
|
||||
switch object.Kind {
|
||||
case wellknown.GatewayGVK.Kind:
|
||||
// Trivial case
|
||||
return sets.New(object.NamespacedName)
|
||||
case wellknown.HTTPRouteGVK.Kind, wellknown.GRPCRouteGVK.Kind, wellknown.TCPRouteGVK.Kind, wellknown.TLSRouteGVK.Kind:
|
||||
gateways := sets.New[types.NamespacedName]()
|
||||
for _, ancestor := range krtutil.FetchIndexObjects(ctx, p.attachments, object) {
|
||||
gateways.Insert(ancestor.Gateway)
|
||||
}
|
||||
return gateways
|
||||
default:
|
||||
gateways := sets.New[types.NamespacedName]()
|
||||
for _, ancestor := range krtutil.FetchIndexObjects(ctx, p.Ancestors, object) {
|
||||
gateways.Insert(ancestor.Gateway)
|
||||
}
|
||||
return gateways
|
||||
}
|
||||
}
|
||||
|
||||
func (p ReferenceIndex) LookupGatewaysForBackend(ctx krt.HandlerContext, object utils.TypedNamespacedName) sets.Set[types.NamespacedName] {
|
||||
return p.lookupGatewaysForBackend(ctx, object, sets.New[utils.TypedNamespacedName]())
|
||||
}
|
||||
|
||||
func (p ReferenceIndex) lookupGatewaysForBackend(ctx krt.HandlerContext, object utils.TypedNamespacedName, seen sets.Set[utils.TypedNamespacedName]) sets.Set[types.NamespacedName] {
|
||||
if seen.InsertContains(object) {
|
||||
return sets.New[types.NamespacedName]()
|
||||
}
|
||||
|
||||
base := p.LookupGatewaysForTarget(ctx, object)
|
||||
if p.PolicyAttachments == nil {
|
||||
return base
|
||||
}
|
||||
for _, pref := range krtutil.FetchIndexObjects(ctx, p.PolicyAttachments, object) {
|
||||
base = base.Union(p.lookupGatewaysForBackend(ctx, pref.Target, seen))
|
||||
}
|
||||
return base
|
||||
}
|
||||
|
||||
func (p ReferenceIndex) WithPolicyAttachments(references krt.IndexCollection[utils.TypedNamespacedName, *PolicyAttachment]) ReferenceIndex {
|
||||
p.PolicyAttachments = references
|
||||
return p
|
||||
}
|
||||
|
||||
func (p ReferenceIndex) PolicyTarget(krtctx krt.HandlerContext, namespace string, name gwv1.ObjectName, gk schema.GroupKind, sectionName *gwv1.SectionName) ([]*api.PolicyTarget, bool) {
|
||||
return p.explicitReferences.PolicyTargets(krtctx, namespace, name, gk, sectionName)
|
||||
}
|
||||
|
||||
func (p ReferenceIndex) PolicyBackend(krtctx krt.HandlerContext, defaultNamespace string, gk schema.GroupKind, name gwv1.ObjectName, namespace *gwv1.Namespace, port *gwv1.PortNumber) (*api.BackendReference, error) {
|
||||
return p.explicitReferences.PolicyBackend(krtctx, defaultNamespace, gk, name, namespace, port)
|
||||
}
|
||||
|
||||
func (p ReferenceIndex) RouteBackend(krtctx krt.HandlerContext, defaultNamespace string, gk schema.GroupKind, name gwv1.ObjectName, namespace *gwv1.Namespace, port *gwv1.PortNumber) (*api.BackendReference, error) {
|
||||
return p.explicitReferences.RouteBackend(krtctx, defaultNamespace, gk, name, namespace, port)
|
||||
}
|
||||
@ -9,15 +9,18 @@ import (
|
||||
type AgwPlugin struct {
|
||||
AddResourceExtension *AddResourcesPlugin
|
||||
ContributesPolicies map[schema.GroupKind]PolicyPlugin
|
||||
ContributesBackends map[schema.GroupKind]BackendPlugin
|
||||
}
|
||||
|
||||
func MergePlugins(plug ...AgwPlugin) AgwPlugin {
|
||||
ret := AgwPlugin{
|
||||
ContributesPolicies: make(map[schema.GroupKind]PolicyPlugin),
|
||||
ContributesBackends: make(map[schema.GroupKind]BackendPlugin),
|
||||
}
|
||||
for _, p := range plug {
|
||||
// Merge contributed policies
|
||||
maps.Copy(ret.ContributesPolicies, p.ContributesPolicies)
|
||||
maps.Copy(ret.ContributesBackends, p.ContributesBackends)
|
||||
if p.AddResourceExtension != nil {
|
||||
if ret.AddResourceExtension == nil {
|
||||
ret.AddResourceExtension = &AddResourcesPlugin{}
|
||||
@ -31,17 +34,10 @@ func MergePlugins(plug ...AgwPlugin) AgwPlugin {
|
||||
if p.AddResourceExtension.Routes != nil {
|
||||
ret.AddResourceExtension.Routes = p.AddResourceExtension.Routes
|
||||
}
|
||||
if p.AddResourceExtension.AncestorBackends != nil {
|
||||
ret.AddResourceExtension.AncestorBackends = p.AddResourceExtension.AncestorBackends
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
// Plugins registers all built-in policy plugins
|
||||
func Plugins(agw *AgwCollections) []AgwPlugin {
|
||||
return []AgwPlugin{
|
||||
NewAgentPlugin(agw),
|
||||
NewInferencePlugin(agw),
|
||||
NewA2APlugin(agw),
|
||||
NewBackendTLSPlugin(agw),
|
||||
}
|
||||
}
|
||||
|
||||
21
controller/pkg/agentgateway/plugins/registry_test.go
Normal file
21
controller/pkg/agentgateway/plugins/registry_test.go
Normal file
@ -0,0 +1,21 @@
|
||||
package plugins
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
func TestMergePluginsMergesBackendContributions(t *testing.T) {
|
||||
backendGK := schema.GroupKind{Group: "enterpriseagentgateway.solo.io", Kind: "EnterpriseAgentgatewayBackend"}
|
||||
|
||||
merged := MergePlugins(AgwPlugin{
|
||||
ContributesBackends: map[schema.GroupKind]BackendPlugin{
|
||||
backendGK: {},
|
||||
},
|
||||
})
|
||||
|
||||
if _, ok := merged.ContributesBackends[backendGK]; !ok {
|
||||
t.Fatalf("expected backend contribution %v to be preserved", backendGK)
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,11 @@
|
||||
apiVersion: gateway.networking.k8s.io/v1
|
||||
kind: GatewayClass
|
||||
metadata:
|
||||
name: agentgateway
|
||||
spec:
|
||||
controllerName: agentgateway.dev/agentgateway
|
||||
---
|
||||
apiVersion: gateway.networking.k8s.io/v1
|
||||
kind: Gateway
|
||||
metadata:
|
||||
name: test
|
||||
@ -24,6 +31,9 @@ spec:
|
||||
- backendRefs:
|
||||
- name: reviews
|
||||
port: 8080
|
||||
- name: be
|
||||
group: agentgateway.dev
|
||||
kind: AgentgatewayBackend
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user