Build customers-api REST layer (Layer 3), mirroring catalog-api

8 routes over Customer + orders/payments sub-resources, proxying to
classic-models-api. openid-connect with RFC 8693 token exchange to
classic-models-api audience, rate-limiting, proxy-cache, audit-log —
same plugin set and structure as catalog-api's REST surface.

Not deployed: dev/gitrepository.yaml points at a gitea repo that
doesn't exist yet (kong-customers-api.git, 404). No MCP layer yet
either, unlike catalog-api.
This commit is contained in:
Stéphane Tailland
2026-08-23 14:34:47 +02:00
parent 7ab1cbb569
commit 66565367f1
17 changed files with 775 additions and 9 deletions
@@ -0,0 +1,35 @@
apiVersion: configuration.konghq.com/v1alpha1
kind: KongPluginBinding
metadata:
name: ${NAME}-customers-api-audit-capture-request-binding
namespace: ${NAMESPACE}
spec:
controlPlaneRef:
type: konnectNamespacedRef
konnectNamespacedRef:
name: ${CONTROL_PLANE_REF_NAME}
pluginRef:
name: ${NAME}-customers-api-audit-capture-request
targets:
serviceRef:
group: configuration.konghq.com
kind: KongService
name: ${NAME}-customers-api
---
apiVersion: configuration.konghq.com/v1alpha1
kind: KongPluginBinding
metadata:
name: ${NAME}-customers-api-audit-capture-response-binding
namespace: ${NAMESPACE}
spec:
controlPlaneRef:
type: konnectNamespacedRef
konnectNamespacedRef:
name: ${CONTROL_PLANE_REF_NAME}
pluginRef:
name: ${NAME}-customers-api-audit-capture-response
targets:
serviceRef:
group: configuration.konghq.com
kind: KongService
name: ${NAME}-customers-api
+27
View File
@@ -0,0 +1,27 @@
# dev only: captures raw request/response bodies into kong.ctx.shared for
# audit-log.yaml's custom_fields_by_lua to read back in the log phase.
# Drop this file (and its bindings) to stop body capture without touching
# audit-log.yaml itself — it degrades gracefully to metadata-only logging.
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: ${NAME}-customers-api-audit-capture-request
namespace: ${NAMESPACE}
plugin: pre-function
config:
access:
- "kong.ctx.shared.audit_request_body = kong.request.get_raw_body()"
---
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: ${NAME}-customers-api-audit-capture-response
namespace: ${NAMESPACE}
plugin: post-function
config:
body_filter:
- |
local chunk = ngx.arg[1]
if chunk then
kong.ctx.shared.audit_response_body = (kong.ctx.shared.audit_response_body or "") .. chunk
end
+17
View File
@@ -0,0 +1,17 @@
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: ${NAME}-customers-api-audit-log
namespace: ${NAMESPACE}
plugin: http-log
# dev only: the raw Authorization (JWT) header is captured in clear text,
# not acceptable as-is for a non-dev environment. request_body/response_body
# below read from kong.ctx.shared, populated by audit-log-body-capture.yaml
# — nil (and silently omitted) if that file isn't applied.
config:
http_endpoint: ${AUDIT_LOG_ENDPOINT}
method: POST
content_type: application/json
custom_fields_by_lua:
request_body: "return kong.ctx.shared.audit_request_body"
response_body: "return kong.ctx.shared.audit_response_body"
+30
View File
@@ -0,0 +1,30 @@
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: ${NAME}-customers-api-openid-connect
namespace: ${NAMESPACE}
plugin: openid-connect
config:
issuer: ${OIDC_ISSUER}
audience_required: ${BACKEND_AUDIENCE}
auth_methods:
- bearer
display_errors: false
ssl_verify: true
consumer_claims:
- - sub
consumer_by:
- custom_id
- username
consumer_optional: true
client_id:
- ${TOKEN_EXCHANGE_CLIENT_ID}
client_secret:
- ${TOKEN_EXCHANGE_CLIENT_SECRET}
token_exchange:
subject_token_issuers:
- issuer: ${OIDC_ISSUER}
conditions: {}
request:
audience: ${BACKEND_AUDIENCE}
scopes: ${BACKEND_SCOPES}
+143
View File
@@ -0,0 +1,143 @@
apiVersion: configuration.konghq.com/v1alpha1
kind: KongPluginBinding
metadata:
name: ${NAME}-customers-api-rewrite-listcustomers-binding
namespace: ${NAMESPACE}
spec:
controlPlaneRef:
type: konnectNamespacedRef
konnectNamespacedRef:
name: ${CONTROL_PLANE_REF_NAME}
pluginRef:
name: ${NAME}-customers-api-rewrite-listcustomers
targets:
routeRef:
group: configuration.konghq.com
kind: KongRoute
name: ${NAME}-customers-api-listcustomers
---
apiVersion: configuration.konghq.com/v1alpha1
kind: KongPluginBinding
metadata:
name: ${NAME}-customers-api-rewrite-createcustomer-binding
namespace: ${NAMESPACE}
spec:
controlPlaneRef:
type: konnectNamespacedRef
konnectNamespacedRef:
name: ${CONTROL_PLANE_REF_NAME}
pluginRef:
name: ${NAME}-customers-api-rewrite-createcustomer
targets:
routeRef:
group: configuration.konghq.com
kind: KongRoute
name: ${NAME}-customers-api-createcustomer
---
apiVersion: configuration.konghq.com/v1alpha1
kind: KongPluginBinding
metadata:
name: ${NAME}-customers-api-rewrite-getcustomer-binding
namespace: ${NAMESPACE}
spec:
controlPlaneRef:
type: konnectNamespacedRef
konnectNamespacedRef:
name: ${CONTROL_PLANE_REF_NAME}
pluginRef:
name: ${NAME}-customers-api-rewrite-getcustomer
targets:
routeRef:
group: configuration.konghq.com
kind: KongRoute
name: ${NAME}-customers-api-getcustomer
---
apiVersion: configuration.konghq.com/v1alpha1
kind: KongPluginBinding
metadata:
name: ${NAME}-customers-api-rewrite-updatecustomer-binding
namespace: ${NAMESPACE}
spec:
controlPlaneRef:
type: konnectNamespacedRef
konnectNamespacedRef:
name: ${CONTROL_PLANE_REF_NAME}
pluginRef:
name: ${NAME}-customers-api-rewrite-updatecustomer
targets:
routeRef:
group: configuration.konghq.com
kind: KongRoute
name: ${NAME}-customers-api-updatecustomer
---
apiVersion: configuration.konghq.com/v1alpha1
kind: KongPluginBinding
metadata:
name: ${NAME}-customers-api-rewrite-patchcustomer-binding
namespace: ${NAMESPACE}
spec:
controlPlaneRef:
type: konnectNamespacedRef
konnectNamespacedRef:
name: ${CONTROL_PLANE_REF_NAME}
pluginRef:
name: ${NAME}-customers-api-rewrite-patchcustomer
targets:
routeRef:
group: configuration.konghq.com
kind: KongRoute
name: ${NAME}-customers-api-patchcustomer
---
apiVersion: configuration.konghq.com/v1alpha1
kind: KongPluginBinding
metadata:
name: ${NAME}-customers-api-rewrite-deletecustomer-binding
namespace: ${NAMESPACE}
spec:
controlPlaneRef:
type: konnectNamespacedRef
konnectNamespacedRef:
name: ${CONTROL_PLANE_REF_NAME}
pluginRef:
name: ${NAME}-customers-api-rewrite-deletecustomer
targets:
routeRef:
group: configuration.konghq.com
kind: KongRoute
name: ${NAME}-customers-api-deletecustomer
---
apiVersion: configuration.konghq.com/v1alpha1
kind: KongPluginBinding
metadata:
name: ${NAME}-customers-api-rewrite-getcustomerorders-binding
namespace: ${NAMESPACE}
spec:
controlPlaneRef:
type: konnectNamespacedRef
konnectNamespacedRef:
name: ${CONTROL_PLANE_REF_NAME}
pluginRef:
name: ${NAME}-customers-api-rewrite-getcustomerorders
targets:
routeRef:
group: configuration.konghq.com
kind: KongRoute
name: ${NAME}-customers-api-getcustomerorders
---
apiVersion: configuration.konghq.com/v1alpha1
kind: KongPluginBinding
metadata:
name: ${NAME}-customers-api-rewrite-getcustomerpayments-binding
namespace: ${NAMESPACE}
spec:
controlPlaneRef:
type: konnectNamespacedRef
konnectNamespacedRef:
name: ${CONTROL_PLANE_REF_NAME}
pluginRef:
name: ${NAME}-customers-api-rewrite-getcustomerpayments
targets:
routeRef:
group: configuration.konghq.com
kind: KongRoute
name: ${NAME}-customers-api-getcustomerpayments
+79
View File
@@ -0,0 +1,79 @@
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: ${NAME}-customers-api-rewrite-listcustomers
namespace: ${NAMESPACE}
plugin: request-transformer-advanced
config:
replace:
uri: /classic-models/api/v1/customers/
---
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: ${NAME}-customers-api-rewrite-createcustomer
namespace: ${NAMESPACE}
plugin: request-transformer-advanced
config:
replace:
uri: /classic-models/api/v1/customers/
---
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: ${NAME}-customers-api-rewrite-getcustomer
namespace: ${NAMESPACE}
plugin: request-transformer-advanced
config:
replace:
uri: /classic-models/api/v1/customers/$(uri_captures.customernumber)/
---
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: ${NAME}-customers-api-rewrite-updatecustomer
namespace: ${NAMESPACE}
plugin: request-transformer-advanced
config:
replace:
uri: /classic-models/api/v1/customers/$(uri_captures.customernumber)/
---
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: ${NAME}-customers-api-rewrite-patchcustomer
namespace: ${NAMESPACE}
plugin: request-transformer-advanced
config:
replace:
uri: /classic-models/api/v1/customers/$(uri_captures.customernumber)/
---
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: ${NAME}-customers-api-rewrite-deletecustomer
namespace: ${NAMESPACE}
plugin: request-transformer-advanced
config:
replace:
uri: /classic-models/api/v1/customers/$(uri_captures.customernumber)/
---
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: ${NAME}-customers-api-rewrite-getcustomerorders
namespace: ${NAMESPACE}
plugin: request-transformer-advanced
config:
replace:
uri: /classic-models/api/v1/customers/$(uri_captures.customernumber)/orders/
---
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: ${NAME}-customers-api-rewrite-getcustomerpayments
namespace: ${NAMESPACE}
plugin: request-transformer-advanced
config:
replace:
uri: /classic-models/api/v1/customers/$(uri_captures.customernumber)/payments/
+71
View File
@@ -0,0 +1,71 @@
apiVersion: configuration.konghq.com/v1alpha1
kind: KongPluginBinding
metadata:
name: ${NAME}-customers-api-openid-connect-binding
namespace: ${NAMESPACE}
spec:
controlPlaneRef:
type: konnectNamespacedRef
konnectNamespacedRef:
name: ${CONTROL_PLANE_REF_NAME}
pluginRef:
name: ${NAME}-customers-api-openid-connect
targets:
serviceRef:
group: configuration.konghq.com
kind: KongService
name: ${NAME}-customers-api
---
apiVersion: configuration.konghq.com/v1alpha1
kind: KongPluginBinding
metadata:
name: ${NAME}-customers-api-rate-limiting-binding
namespace: ${NAMESPACE}
spec:
controlPlaneRef:
type: konnectNamespacedRef
konnectNamespacedRef:
name: ${CONTROL_PLANE_REF_NAME}
pluginRef:
name: ${NAME}-customers-api-rate-limiting
targets:
serviceRef:
group: configuration.konghq.com
kind: KongService
name: ${NAME}-customers-api
---
apiVersion: configuration.konghq.com/v1alpha1
kind: KongPluginBinding
metadata:
name: ${NAME}-customers-api-proxy-cache-binding
namespace: ${NAMESPACE}
spec:
controlPlaneRef:
type: konnectNamespacedRef
konnectNamespacedRef:
name: ${CONTROL_PLANE_REF_NAME}
pluginRef:
name: ${NAME}-customers-api-proxy-cache
targets:
serviceRef:
group: configuration.konghq.com
kind: KongService
name: ${NAME}-customers-api
---
apiVersion: configuration.konghq.com/v1alpha1
kind: KongPluginBinding
metadata:
name: ${NAME}-customers-api-audit-log-binding
namespace: ${NAMESPACE}
spec:
controlPlaneRef:
type: konnectNamespacedRef
konnectNamespacedRef:
name: ${CONTROL_PLANE_REF_NAME}
pluginRef:
name: ${NAME}-customers-api-audit-log
targets:
serviceRef:
group: configuration.konghq.com
kind: KongService
name: ${NAME}-customers-api
+16
View File
@@ -0,0 +1,16 @@
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: ${NAME}-customers-api-proxy-cache
namespace: ${NAMESPACE}
plugin: proxy-cache-advanced
config:
strategy: memory
request_method:
- GET
- HEAD
response_code:
- 200
content_type:
- application/json
cache_ttl: 60
+14
View File
@@ -0,0 +1,14 @@
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: ${NAME}-customers-api-rate-limiting
namespace: ${NAMESPACE}
plugin: rate-limiting-advanced
config:
limit:
- ${API_RATE_LIMIT_MINUTE}
window_size:
- 60
identifier: consumer
sync_rate: -1
strategy: local
+159
View File
@@ -0,0 +1,159 @@
apiVersion: configuration.konghq.com/v1alpha1
kind: KongRoute
metadata:
name: ${NAME}-customers-api-listcustomers
namespace: ${NAMESPACE}
spec:
serviceRef:
type: namespacedRef
namespacedRef:
name: ${NAME}-customers-api
name: customers-api_listcustomers
methods:
- GET
- OPTIONS
paths:
- /customers/v1/customers/
strip_path: false
tags:
- customers
---
apiVersion: configuration.konghq.com/v1alpha1
kind: KongRoute
metadata:
name: ${NAME}-customers-api-createcustomer
namespace: ${NAMESPACE}
spec:
serviceRef:
type: namespacedRef
namespacedRef:
name: ${NAME}-customers-api
name: customers-api_createcustomer
methods:
- POST
- OPTIONS
paths:
- /customers/v1/customers/
strip_path: false
tags:
- customers
---
apiVersion: configuration.konghq.com/v1alpha1
kind: KongRoute
metadata:
name: ${NAME}-customers-api-getcustomer
namespace: ${NAMESPACE}
spec:
serviceRef:
type: namespacedRef
namespacedRef:
name: ${NAME}-customers-api
name: customers-api_getcustomer
methods:
- GET
- OPTIONS
paths:
- ~/customers/v1/customers/(?<customernumber>[^#?/]+)/$
strip_path: false
tags:
- customers
---
apiVersion: configuration.konghq.com/v1alpha1
kind: KongRoute
metadata:
name: ${NAME}-customers-api-updatecustomer
namespace: ${NAMESPACE}
spec:
serviceRef:
type: namespacedRef
namespacedRef:
name: ${NAME}-customers-api
name: customers-api_updatecustomer
methods:
- PUT
- OPTIONS
paths:
- ~/customers/v1/customers/(?<customernumber>[^#?/]+)/$
strip_path: false
tags:
- customers
---
apiVersion: configuration.konghq.com/v1alpha1
kind: KongRoute
metadata:
name: ${NAME}-customers-api-patchcustomer
namespace: ${NAMESPACE}
spec:
serviceRef:
type: namespacedRef
namespacedRef:
name: ${NAME}-customers-api
name: customers-api_patchcustomer
methods:
- PATCH
- OPTIONS
paths:
- ~/customers/v1/customers/(?<customernumber>[^#?/]+)/$
strip_path: false
tags:
- customers
---
apiVersion: configuration.konghq.com/v1alpha1
kind: KongRoute
metadata:
name: ${NAME}-customers-api-deletecustomer
namespace: ${NAMESPACE}
spec:
serviceRef:
type: namespacedRef
namespacedRef:
name: ${NAME}-customers-api
name: customers-api_deletecustomer
methods:
- DELETE
- OPTIONS
paths:
- ~/customers/v1/customers/(?<customernumber>[^#?/]+)/$
strip_path: false
tags:
- customers
---
apiVersion: configuration.konghq.com/v1alpha1
kind: KongRoute
metadata:
name: ${NAME}-customers-api-getcustomerorders
namespace: ${NAMESPACE}
spec:
serviceRef:
type: namespacedRef
namespacedRef:
name: ${NAME}-customers-api
name: customers-api_getcustomerorders
methods:
- GET
- OPTIONS
paths:
- ~/customers/v1/customers/(?<customernumber>[^#?/]+)/orders/$
strip_path: false
tags:
- customers
---
apiVersion: configuration.konghq.com/v1alpha1
kind: KongRoute
metadata:
name: ${NAME}-customers-api-getcustomerpayments
namespace: ${NAMESPACE}
spec:
serviceRef:
type: namespacedRef
namespacedRef:
name: ${NAME}-customers-api
name: customers-api_getcustomerpayments
methods:
- GET
- OPTIONS
paths:
- ~/customers/v1/customers/(?<customernumber>[^#?/]+)/payments/$
strip_path: false
tags:
- customers
+17
View File
@@ -0,0 +1,17 @@
apiVersion: configuration.konghq.com/v1alpha1
kind: KongService
metadata:
name: ${NAME}-customers-api
namespace: ${NAMESPACE}
spec:
controlPlaneRef:
type: konnectNamespacedRef
konnectNamespacedRef:
name: ${CONTROL_PLANE_REF_NAME}
name: customers-api
host: ${BACKEND_HOST}
port: 8000
protocol: http
path: /
tags:
- customers