mirror of https://github.com/knative/docs.git
102 lines
3.3 KiB
YAML
102 lines
3.3 KiB
YAML
# Copyright 2021 The Knative Authors
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# https://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
# Create a Kong request transformer plugin to rewrite the original host header
|
|
# to the host header of Search service in order to redirect requests to Search
|
|
# service.
|
|
apiVersion: configuration.konghq.com/v1
|
|
kind: KongPlugin
|
|
metadata:
|
|
name: search-service-host-rewrite
|
|
# The plugin must be created in the same namespace as the ingress.
|
|
namespace: kong
|
|
plugin: request-transformer
|
|
config:
|
|
add:
|
|
headers:
|
|
- "Host: search-service.default.example.com"
|
|
replace:
|
|
headers:
|
|
- "Host: search-service.default.example.com"
|
|
---
|
|
# Create an ingress that forwards an incoming request at example.com/search to
|
|
# "search-service.default.example.com" by updating the "Host" header to
|
|
# "search-service.default.example.com" and stripping the request path. This
|
|
# modified request is then forwarded to the Knative ingress (Kong) and routed
|
|
# to the service as usual.
|
|
apiVersion: extensions/v1beta1
|
|
kind: Ingress
|
|
metadata:
|
|
name: search-service-ingress
|
|
# The ingress must be created in the same namespace as the kong-proxy service.
|
|
namespace: kong
|
|
annotations:
|
|
kubernetes.io/ingress.class: kong
|
|
konghq.com/strip-path: "true"
|
|
konghq.com/plugins: search-service-host-rewrite
|
|
spec:
|
|
rules:
|
|
- http:
|
|
paths:
|
|
- host: example.com
|
|
path: /search
|
|
backend:
|
|
serviceName: kong-proxy
|
|
servicePort: 80
|
|
|
|
---
|
|
|
|
# Create a Kong request transformer plugin to rewrite the original host header
|
|
# to the host header of Login service in order to redirect requests to Login
|
|
# service.
|
|
apiVersion: configuration.konghq.com/v1
|
|
kind: KongPlugin
|
|
metadata:
|
|
name: login-service-host-rewrite
|
|
# The plugin must be created in the same namespace as the ingress.
|
|
namespace: kong
|
|
plugin: request-transformer
|
|
config:
|
|
add:
|
|
headers:
|
|
- "Host: login-service.default.example.com"
|
|
replace:
|
|
headers:
|
|
- "Host: login-service.default.example.com"
|
|
---
|
|
# Create an ingress that forwards an incoming request at example.com/login to
|
|
# "login-service.default.example.com" by updating the "Host" header to
|
|
# "login-service.default.example.com" and stripping the request path. This
|
|
# modified request is then forwarded to the Knative ingress (Kong) and routed
|
|
# to the service as usual.
|
|
apiVersion: extensions/v1beta1
|
|
kind: Ingress
|
|
metadata:
|
|
name: login-service-ingress
|
|
# The ingress must be created in the same namespace as the kong-proxy service.
|
|
namespace: kong
|
|
annotations:
|
|
kubernetes.io/ingress.class: kong
|
|
konghq.com/strip-path: "true"
|
|
konghq.com/plugins: login-service-host-rewrite
|
|
spec:
|
|
rules:
|
|
- http:
|
|
paths:
|
|
- host: example.com
|
|
path: /login
|
|
backend:
|
|
serviceName: kong-proxy
|
|
servicePort: 80
|