istio - using externalservice
External service provide an alias to a service that is located externally, elsewhere andd out of the cluster. For exampe, let's say we wanna provide an alias for httpbin.org and we want to call it, httpbin-local - then we can do that using external name.
Lets quickly spin up an example.
istioctl install --set profile=demo
kubectl label namespace default istio-injection=enabled
kubectl apply -f httpbin-gateway.yaml
kubectl apply -f sleep.yaml
Let's create a httpbin external service
apiVersion: v1
kind: Service
metadata:
name: externalbin
spec:
type: ExternalName
externalName: httpbin.org
ports:
- port: 80
# important to set protocol name
name: http
So we are creating external service to httpbin.org which we will use "externalbin" to reference it.
kubectl exec -it sleep-868c754c4b-z8djr -c sleep -- /bin/sh
Then when we run curl, we will get the following output.
curl http://externalbin/headers
Istio Egress supports only HTTP/HTTPS - that means all HTTP/HTTPS traffic route through envoy.
Unless you say otherwise by using annotation - "traffic.sidecar.istio.io/includeOutboundIPRanges: "10.0.0.1/24"".
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: httpbin
spec:
replicas: 1
selector:
matchLabels:
app: httpbin
version: v1
template:
metadata:
labels:
app: httpbin
version: v1
annotations:
traffic.sidecar.istio.io/includeOutboundIPRanges: "10.0.0.1/24"
sidecar.istio.io/inject: "false"
spec:
serviceAccountName: httpbin
containers:
- image: docker.io/mccutchen/go-httpbin:v2.15.0
imagePullPolicy: IfNotPresent
name: httpbin
ports:
- containerPort: 8080
More details about annotation can be found here:-
https://istio.io/latest/docs/reference/config/annotations/
Comments