Skip to content

Instantly share code, notes, and snippets.

@rvennam
Created April 23, 2024 13:45
Show Gist options
  • Save rvennam/eb49d6d10bd4b93a2da660efc090ebe9 to your computer and use it in GitHub Desktop.
Save rvennam/eb49d6d10bd4b93a2da660efc090ebe9 to your computer and use it in GitHub Desktop.
# localhost:9081 -> details:9080
#
# Need a ServiceEntry to route to details on 9081 instead of 9080
apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
name: localhost-svc
spec:
hosts:
- details.service
location: MESH_INTERNAL
ports:
- number: 9081 # NOTE
name: http
protocol: HTTP
targetPort: 9080 # NOTE
resolution: STATIC
workloadSelector:
labels:
app: details
---
# To create a listener on 9081 and send to details.service
apiVersion: networking.istio.io/v1beta1
kind: Sidecar
metadata:
name: localhost-sidecar
namespace: default
spec:
egress:
- bind: 0.0.0.0
captureMode: NONE
port:
number: 9081
protocol: HTTP
name: web
hosts:
- "./details.service"
- captureMode: IPTABLES
hosts:
- "*/*"
---
# add localhost has a host match so you don't have to specify a host header
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: localhost-details
namespace: default
spec:
workloadSelector:
labels:
app: sleep
configPatches:
- applyTo: VIRTUAL_HOST
match:
context: ANY
routeConfiguration:
name: "9081"
vhost:
name: "details.service:9081"
patch:
operation: MERGE
value:
domains:
- localhost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment