Small cleanup
This commit is contained in:
120
01-Simple/01-hello_world_1_service_1_deployment/README.md
Executable file
120
01-Simple/01-hello_world_1_service_1_deployment/README.md
Executable file
@ -0,0 +1,120 @@
|
||||
##### https://github.com/istio/istio/tree/master/samples/helloworld
|
||||
|
||||
### Base simple template
|
||||
|
||||
# Simple Hello World
|
||||
|
||||
- 1 Service
|
||||
- 1 Deployment
|
||||
|
||||
I think that by default uses `RANDOM`.
|
||||
|
||||
https://istio.io/latest/docs/reference/config/networking/destination-rule/#TrafficPolicy-PortTrafficPolicy
|
||||
|
||||
https://istio.io/latest/docs/reference/config/networking/destination-rule/#LoadBalancerSettings
|
||||
|
||||
> Contains service account configurations, yet they are commented as not "necessary".
|
||||
|
||||
|
||||
## Files
|
||||
|
||||
- deployment.yaml
|
||||
- gateway.yaml
|
||||
|
||||
## deployment.yaml
|
||||
|
||||
### Creates
|
||||
|
||||
#### Service
|
||||
|
||||
- helloworld
|
||||
|
||||
#### Deployments
|
||||
|
||||
- helloworld-nginx (Nginx container)
|
||||
|
||||
## gateway.yaml
|
||||
|
||||
### Creates
|
||||
|
||||
#### Gateway
|
||||
|
||||
##### helloworld-gateway
|
||||
|
||||
###### Configuration
|
||||
|
||||
```yml
|
||||
port: 80
|
||||
istio-ingress: ingressgateway
|
||||
hosts: "*"
|
||||
```
|
||||
|
||||
#### VirtualService
|
||||
|
||||
##### helloworld-vs
|
||||
|
||||
###### Configuration
|
||||
|
||||
|
||||
|
||||
```yaml
|
||||
hosts:
|
||||
- "*"
|
||||
gateways:
|
||||
- helloworld-gateway
|
||||
http:
|
||||
- match:
|
||||
- uri:
|
||||
exact: /helloworld
|
||||
route:
|
||||
- destination:
|
||||
host: helloworld
|
||||
port:
|
||||
number: 80
|
||||
rewrite:
|
||||
uri: "/"
|
||||
```
|
||||
- Allows the traffic that have as a destination any domain.
|
||||
|
||||
- Only allows traffic that has as a destination the directory/path `/helloworld`.
|
||||
|
||||
- `rewrite.uri` allows to redirect the traffic towards the root directory of the service, as the service(s) used don't have any directory named `helloworld` but are configured to work at the root base level.
|
||||
|
||||
- Traffic request is sent to the service named `helloworld`, to the service port 80.
|
||||
|
||||
# Run example
|
||||
|
||||
## Deploy resources
|
||||
|
||||
```shell
|
||||
$ kubectl apply -f ./
|
||||
service/helloworld created
|
||||
deployment.apps/helloworld-nginx created
|
||||
gateway.networking.istio.io/helloworld-gateway created
|
||||
virtualservice.networking.istio.io/helloworld-vs created
|
||||
```
|
||||
|
||||
## Wait for the deployment to be ready
|
||||
|
||||
```shell
|
||||
$ kubectl get deployment helloworld-nginx -w
|
||||
NAME READY UP-TO-DATE AVAILABLE AGE
|
||||
helloworld-nginx 1/1 1 1 44s
|
||||
```
|
||||
|
||||
## Test the service
|
||||
|
||||
### Get LB IP
|
||||
|
||||
```shell
|
||||
$ kubectl get svc -l istio=ingressgateway -A
|
||||
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
|
||||
istio-ingressgateway LoadBalancer 10.97.47.216 192.168.1.50 15021:31316/TCP,80:32012/TCP,443:32486/TCP 39h
|
||||
```
|
||||
|
||||
### Curl
|
||||
|
||||
```shell
|
||||
$ curl 192.168.1.50/helloworld -s | grep "<title>.*</title>" ✔
|
||||
<title>Welcome to nginx!</title>
|
||||
```
|
48
01-Simple/01-hello_world_1_service_1_deployment/deployment.yaml
Executable file
48
01-Simple/01-hello_world_1_service_1_deployment/deployment.yaml
Executable file
@ -0,0 +1,48 @@
|
||||
# https://github.com/istio/istio/blob/master/samples/helloworld/helloworld.yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: helloworld
|
||||
labels:
|
||||
app: helloworld
|
||||
service: helloworld
|
||||
spec:
|
||||
ports:
|
||||
- port: 80
|
||||
name: http
|
||||
selector:
|
||||
app: helloworld
|
||||
---
|
||||
#apiVersion: v1
|
||||
#kind: ServiceAccount
|
||||
#metadata:
|
||||
# name: istio-helloworld
|
||||
# labels:
|
||||
# account:
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: helloworld-nginx
|
||||
labels:
|
||||
app: helloworld
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: helloworld
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: helloworld
|
||||
spec:
|
||||
# serviceAccountName: istio-helloworld
|
||||
containers:
|
||||
- name: helloworld
|
||||
image: nginx
|
||||
resources:
|
||||
requests:
|
||||
cpu: "100m"
|
||||
imagePullPolicy: IfNotPresent #Always
|
||||
ports:
|
||||
- containerPort: 80
|
35
01-Simple/01-hello_world_1_service_1_deployment/gateway.yaml
Executable file
35
01-Simple/01-hello_world_1_service_1_deployment/gateway.yaml
Executable file
@ -0,0 +1,35 @@
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: Gateway
|
||||
metadata:
|
||||
name: helloworld-gateway
|
||||
spec:
|
||||
selector:
|
||||
istio: ingressgateway # use istio default controller
|
||||
servers:
|
||||
- port:
|
||||
number: 80
|
||||
name: http
|
||||
protocol: HTTP
|
||||
hosts:
|
||||
- "*"
|
||||
---
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: helloworld-vs
|
||||
spec:
|
||||
hosts:
|
||||
- "*"
|
||||
gateways:
|
||||
- helloworld-gateway
|
||||
http:
|
||||
- match:
|
||||
- uri:
|
||||
exact: /helloworld
|
||||
route:
|
||||
- destination:
|
||||
host: helloworld
|
||||
port:
|
||||
number: 80
|
||||
rewrite:
|
||||
uri: "/"
|
142
01-Simple/02-hello_world_1_service_2_deployments_unmanaged/README.md
Executable file
142
01-Simple/02-hello_world_1_service_2_deployments_unmanaged/README.md
Executable file
@ -0,0 +1,142 @@
|
||||
##### https://github.com/istio/istio/tree/master/samples/helloworld
|
||||
|
||||
# Simple Hello World
|
||||
|
||||
- 1 Service
|
||||
- 2 Versions
|
||||
|
||||
Iterates between the versions without any specific policy. (actually doesn't use the version for anything)
|
||||
|
||||
By default uses `Round Robin`
|
||||
|
||||
https://istio.io/latest/docs/concepts/traffic-management/#load-balancing-options
|
||||
|
||||
> Contains service account configurations, yet they are commented as not "necessary".
|
||||
|
||||
|
||||
# Changes
|
||||
|
||||
## File
|
||||
|
||||
- deployment.yaml
|
||||
- gateway.yaml
|
||||
|
||||
> Files used maintains from the last version
|
||||
|
||||
## deployment.yaml
|
||||
|
||||
### Creates
|
||||
|
||||
#### Service
|
||||
|
||||
- helloworld
|
||||
|
||||
> Service used maintains from the last version
|
||||
|
||||
#### Deployments
|
||||
|
||||
- helloworld-v1 (Nginx)
|
||||
- helloworld-v2 (Apache)
|
||||
|
||||
> Renamed the old deployment from `helloworld-nginx` to `helloworld-v1`.\
|
||||
> Created a secondary deployment using apache named `helloworld-v2`.
|
||||
|
||||
## gateway.yaml
|
||||
|
||||
### Creates
|
||||
|
||||
#### Gateway
|
||||
|
||||
##### helloworld-gateway
|
||||
|
||||
###### Configuration
|
||||
|
||||
```yml
|
||||
port: 80
|
||||
istio-ingress: ingressgateway
|
||||
hosts: "*"
|
||||
```
|
||||
|
||||
#### VirtualService
|
||||
|
||||
##### helloworld-vs
|
||||
|
||||
###### Configuration
|
||||
|
||||
```yaml
|
||||
hosts: "*"
|
||||
uri: "/helloworld"
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Run example
|
||||
|
||||
## Deploy resources
|
||||
|
||||
```shell
|
||||
$ kubectl apply -f ./
|
||||
service/helloworld created
|
||||
deployment.apps/helloworld-v1 created
|
||||
deployment.apps/helloworld-v2 created
|
||||
deployment.apps/helloworld-v2 unchanged
|
||||
gateway.networking.istio.io/helloworld-gateway created
|
||||
virtualservice.networking.istio.io/helloworld-vs created
|
||||
```
|
||||
|
||||
## Wait for the pods to be ready
|
||||
|
||||
(I think it deploys 2 pods as there is the Envoy Proxy pod besides the Nginx deployment)
|
||||
|
||||
```shell
|
||||
$ kubectl get deployment helloworld-v{1..2} -w
|
||||
NAME READY UP-TO-DATE AVAILABLE AGE
|
||||
helloworld-v1 1/1 1 1 4m1s
|
||||
helloworld-v2 1/1 1 1 4m1s
|
||||
```
|
||||
|
||||
## Test the service
|
||||
|
||||
### Get LB IP
|
||||
|
||||
```shell
|
||||
$ kubectl get svc istio-ingressgateway -n istio-system
|
||||
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
|
||||
istio-ingressgateway LoadBalancer 10.97.47.216 192.168.1.50 15021:31316/TCP,80:32012/TCP,443:32486/TCP 39h
|
||||
```
|
||||
|
||||
### Curl
|
||||
|
||||
Iterates randomly between Nginx and Apache
|
||||
|
||||
```shell
|
||||
$ curl 192.168.1.50/helloworld -s | grep "<h1>.*</h1>"
|
||||
<h1>Welcome to nginx!</h1>
|
||||
|
||||
$ curl 192.168.1.50/helloworld -s | grep "<h1>.*</h1>"
|
||||
<html><body><h1>It works!</h1></body></html>
|
||||
|
||||
$ curl 192.168.1.50/helloworld -s | grep "<h1>.*</h1>"
|
||||
<h1>Welcome to nginx!</h1>
|
||||
|
||||
$ curl 192.168.1.50/helloworld -s | grep "<h1>.*</h1>"
|
||||
<html><body><h1>It works!</h1></body></html>
|
||||
|
||||
$ curl 192.168.1.50/helloworld -s | grep "<h1>.*</h1>"
|
||||
<h1>Welcome to nginx!</h1>
|
||||
|
||||
$ curl 192.168.1.50/helloworld -s | grep "<h1>.*</h1>"
|
||||
<html><body><h1>It works!</h1></body></html>
|
||||
|
||||
$ curl 192.168.1.50/helloworld -s | grep "<h1>.*</h1>"
|
||||
<h1>Welcome to nginx!</h1>
|
||||
|
||||
$ curl 192.168.1.50/helloworld -s | grep "<h1>.*</h1>"
|
||||
<h1>Welcome to nginx!</h1>
|
||||
|
||||
$ curl 192.168.1.50/helloworld -s | grep "<h1>.*</h1>"
|
||||
<html><body><h1>It works!</h1></body></html>
|
||||
```
|
76
01-Simple/02-hello_world_1_service_2_deployments_unmanaged/deployment.yaml
Executable file
76
01-Simple/02-hello_world_1_service_2_deployments_unmanaged/deployment.yaml
Executable file
@ -0,0 +1,76 @@
|
||||
# https://github.com/istio/istio/blob/master/samples/helloworld/helloworld.yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: helloworld
|
||||
labels:
|
||||
app: helloworld
|
||||
service: helloworld
|
||||
spec:
|
||||
ports:
|
||||
- port: 80
|
||||
name: http
|
||||
selector:
|
||||
app: helloworld
|
||||
---
|
||||
#apiVersion: v1
|
||||
#kind: ServiceAccount
|
||||
#metadata:
|
||||
# name: istio-helloworld
|
||||
# labels:
|
||||
# account:
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: helloworld-v1
|
||||
labels:
|
||||
app: helloworld
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: helloworld
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: helloworld
|
||||
spec:
|
||||
# serviceAccountName: istio-helloworld
|
||||
containers:
|
||||
- name: helloworld
|
||||
image: nginx
|
||||
resources:
|
||||
requests:
|
||||
cpu: "100m"
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 80
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: helloworld-v2
|
||||
labels:
|
||||
app: helloworld
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: helloworld
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: helloworld
|
||||
spec:
|
||||
# serviceAccountName: istio-helloworld
|
||||
containers:
|
||||
- name: helloworld
|
||||
image: httpd
|
||||
resources:
|
||||
requests:
|
||||
cpu: "100m"
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 80
|
||||
---
|
36
01-Simple/02-hello_world_1_service_2_deployments_unmanaged/gateway.yaml
Executable file
36
01-Simple/02-hello_world_1_service_2_deployments_unmanaged/gateway.yaml
Executable file
@ -0,0 +1,36 @@
|
||||
# https://github.com/istio/istio/blob/master/samples/helloworld/helloworld-gateway.yaml
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: Gateway
|
||||
metadata:
|
||||
name: helloworld-gateway
|
||||
spec:
|
||||
selector:
|
||||
istio: ingressgateway # use istio default controller
|
||||
servers:
|
||||
- port:
|
||||
number: 80
|
||||
name: http
|
||||
protocol: HTTP
|
||||
hosts:
|
||||
- "*"
|
||||
---
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: helloworld-vs
|
||||
spec:
|
||||
hosts:
|
||||
- "*"
|
||||
gateways:
|
||||
- helloworld-gateway
|
||||
http:
|
||||
- match:
|
||||
- uri:
|
||||
exact: /helloworld
|
||||
route:
|
||||
- destination:
|
||||
host: helloworld
|
||||
port:
|
||||
number: 80
|
||||
rewrite:
|
||||
uri: "/"
|
261
01-Simple/03-hello_world_1_service_2_deployments_managed_version/README.md
Executable file
261
01-Simple/03-hello_world_1_service_2_deployments_managed_version/README.md
Executable file
@ -0,0 +1,261 @@
|
||||
##### https://github.com/istio/istio/tree/master/samples/helloworld
|
||||
|
||||
https://istio.io/latest/blog/2017/0.1-canary/
|
||||
|
||||
|
||||
# Continues from
|
||||
|
||||
- 01-hello_world_1_service_1_deployment
|
||||
|
||||
# Simple Hello World
|
||||
|
||||
- 1 Service
|
||||
- 2 Versions
|
||||
|
||||
Iterates between the versions without any specific policy. (actually doesn't use the version for anything)
|
||||
|
||||
|
||||
> Contains service account configurations, yet they are commented as not "necessary".
|
||||
|
||||
## Quick note
|
||||
|
||||
On this version I have "started" to use the full service name instead of the shorten version, aka:
|
||||
|
||||
```yaml
|
||||
route:
|
||||
- destination:
|
||||
host: helloworld
|
||||
```
|
||||
|
||||
Will be:
|
||||
|
||||
```yaml
|
||||
route:
|
||||
- destination:
|
||||
host: helloworld.default.svc.cluster.local
|
||||
```
|
||||
|
||||
It's overall a good practice to have, so not much of a reason to not do it.
|
||||
|
||||
https://istio.io/latest/docs/reference/config/networking/destination-rule/#DestinationRule
|
||||
|
||||
|
||||
# Changes
|
||||
|
||||
## File
|
||||
|
||||
- deployment.yaml
|
||||
- gateway.yaml
|
||||
|
||||
> Files used maintains from the last version
|
||||
|
||||
## deployment.yaml
|
||||
|
||||
### Creates
|
||||
|
||||
#### Service
|
||||
|
||||
- helloworld
|
||||
|
||||
> Service used maintains from the last version
|
||||
|
||||
#### Deployments
|
||||
|
||||
- helloworld-v1 (Nginx)
|
||||
- helloworld-v2 (Apache)
|
||||
|
||||
> Renamed the old deployment from `helloworld-nginx` to `helloworld-v1`.\
|
||||
> Created a secondary deployment using apache named `helloworld-v2`.
|
||||
|
||||
## gateway.yaml
|
||||
|
||||
#### VirtualService
|
||||
|
||||
##### helloworld-vs
|
||||
|
||||
###### Configuration
|
||||
|
||||
|
||||
|
||||
```yaml
|
||||
...
|
||||
http:
|
||||
- match:
|
||||
- uri:
|
||||
exact: /helloworld
|
||||
route:
|
||||
- destination:
|
||||
host: helloworld.default.svc.cluster.local
|
||||
port:
|
||||
number: 80
|
||||
subset: v1
|
||||
weight: 20
|
||||
- destination:
|
||||
host: helloworld.default.svc.cluster.local
|
||||
port:
|
||||
number: 80
|
||||
subset: v2
|
||||
weight: 80
|
||||
...
|
||||
```
|
||||
|
||||
> Distributed the traffic between 2 versions (`subsets`), setting a `25%` to the subset `v1` and a `75%` to the subset `v2`.
|
||||
|
||||
> As previously mentioned, the section `http.route.host` points to `helloworld.default.svc.cluster.local`, which is the service we created, on the `default` namespace.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Destination Rule
|
||||
|
||||
###### Declaration configuration
|
||||
|
||||
```yaml
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: DestinationRule
|
||||
metadata:
|
||||
name: helloworld.default.svc.cluster.local # Destination that will "interject"
|
||||
```
|
||||
|
||||
> Here we need to put the `path/destination/service` that we want this rule to interject and manage.
|
||||
|
||||
###### Traffic Configuration
|
||||
|
||||
```yaml
|
||||
host: helloworld.default.svc.cluster.local
|
||||
subsets:
|
||||
- name: v1
|
||||
labels:
|
||||
version: v1
|
||||
- name: v2
|
||||
labels:
|
||||
version: v2
|
||||
```
|
||||
|
||||
> On the `Destination Rule` declared the subsets. Each subset has different labels. This will be used to select the deployments within the destination service.
|
||||
|
||||
# Run example
|
||||
|
||||
## Deploy resources
|
||||
|
||||
```shell
|
||||
$ kubectl apply -f ./
|
||||
service/helloworld created
|
||||
deployment.apps/helloworld-v1 created
|
||||
deployment.apps/helloworld-v2 created
|
||||
gateway.networking.istio.io/helloworld-gateway created
|
||||
virtualservice.networking.istio.io/helloworld-vs created
|
||||
destinationrule.networking.istio.io/helloworld-destinationrule created
|
||||
```
|
||||
|
||||
## Wait for the pods to be ready
|
||||
|
||||
(I think it deploys 2 pods as there is the Envoy Proxy pod besides the Nginx deployment)
|
||||
|
||||
```shell
|
||||
$ kubectl get deployment helloworld-v{1..2} -w
|
||||
NAME READY UP-TO-DATE AVAILABLE AGE
|
||||
helloworld-v1 1/1 1 1 4m1s
|
||||
helloworld-v2 1/1 1 1 4m1s
|
||||
```
|
||||
|
||||
## Test the service
|
||||
|
||||
### Get LB IP
|
||||
|
||||
```shell
|
||||
$ kubectl get svc istio-ingressgateway -n istio-system
|
||||
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
|
||||
istio-ingressgateway LoadBalancer 10.97.47.216 192.168.1.50 15021:31316/TCP,80:32012/TCP,443:32486/TCP 39h
|
||||
```
|
||||
|
||||
### Curl
|
||||
|
||||
Iterates between Nginx and Apache. Somwhat close to the ratio configured.
|
||||
|
||||
> Nginx instances (v1): 2 \
|
||||
> Apache instances (v2): 9
|
||||
|
||||
```shell
|
||||
$ curl 192.168.1.50/helloworld -s | grep "<h1>.*</h1>"
|
||||
<html><body><h1>It works!</h1></body></html>
|
||||
|
||||
$ curl 192.168.1.50/helloworld -s | grep "<h1>.*</h1>"
|
||||
<html><body><h1>It works!</h1></body></html>
|
||||
|
||||
$ curl 192.168.1.50/helloworld -s | grep "<h1>.*</h1>"
|
||||
<html><body><h1>It works!</h1></body></html>
|
||||
|
||||
$ curl 192.168.1.50/helloworld -s | grep "<h1>.*</h1>"
|
||||
<html><body><h1>It works!</h1></body></html>
|
||||
|
||||
$ curl 192.168.1.50/helloworld -s | grep "<h1>.*</h1>"
|
||||
<html><body><h1>It works!</h1></body></html>
|
||||
|
||||
$ curl 192.168.1.50/helloworld -s | grep "<h1>.*</h1>"
|
||||
<html><body><h1>It works!</h1></body></html>
|
||||
|
||||
$ curl 192.168.1.50/helloworld -s | grep "<h1>.*</h1>"
|
||||
<html><body><h1>It works!</h1></body></html>
|
||||
|
||||
$ curl 192.168.1.50/helloworld -s | grep "<h1>.*</h1>"
|
||||
<html><body><h1>It works!</h1></body></html>
|
||||
|
||||
$ curl 192.168.1.50/helloworld -s | grep "<h1>.*</h1>"
|
||||
<h1>Welcome to nginx!</h1>
|
||||
|
||||
$ curl 192.168.1.50/helloworld -s | grep "<h1>.*</h1>"
|
||||
<html><body><h1>It works!</h1></body></html>
|
||||
|
||||
$ curl 192.168.1.50/helloworld -s | grep "<h1>.*</h1>"
|
||||
<h1>Welcome to nginx!</h1>
|
||||
```
|
||||
|
||||
## Check istio configs
|
||||
|
||||
```sh
|
||||
$ istioctl x describe pod `kubectl get pod -l app=helloworld,version=v1 -o jsonpath='{.items[0].metadata.name}'`
|
||||
Pod: helloworld-v1-7454b56b86-4cksf
|
||||
Pod Revision: default
|
||||
Pod Ports: 80 (helloworld), 15090 (istio-proxy)
|
||||
--------------------
|
||||
Service: helloworld
|
||||
Port: http 80/HTTP targets pod port 80
|
||||
DestinationRule: helloworld for "helloworld.default.svc.cluster.local"
|
||||
Matching subsets: v1
|
||||
(Non-matching subsets v2)
|
||||
No Traffic Policy
|
||||
--------------------
|
||||
Effective PeerAuthentication:
|
||||
Workload mTLS mode: PERMISSIVE
|
||||
|
||||
|
||||
Exposed on Ingress Gateway http://192.168.1.50
|
||||
VirtualService: helloworld-vs
|
||||
Weight 20%
|
||||
/helloworld
|
||||
```
|
||||
|
||||
|
||||
```shell
|
||||
$ istioctl x describe pod `kubectl get pod -l app=helloworld,version=v2 -o jsonpath='{.items[0].metadata.name
|
||||
Pod: helloworld-v2-64b5656d99-5bwgr
|
||||
Pod Revision: default
|
||||
Pod Ports: 80 (helloworld), 15090 (istio-proxy)
|
||||
--------------------
|
||||
Service: helloworld
|
||||
Port: http 80/HTTP targets pod port 80
|
||||
DestinationRule: helloworld for "helloworld.default.svc.cluster.local"
|
||||
Matching subsets: v2
|
||||
(Non-matching subsets v1)
|
||||
No Traffic Policy
|
||||
--------------------
|
||||
Effective PeerAuthentication:
|
||||
Workload mTLS mode: PERMISSIVE
|
||||
|
||||
|
||||
Exposed on Ingress Gateway http://192.168.1.50
|
||||
VirtualService: helloworld-vs
|
||||
Weight 80%
|
||||
/helloworld
|
||||
```
|
@ -0,0 +1,82 @@
|
||||
# https://github.com/istio/istio/blob/master/samples/helloworld/helloworld.yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: helloworld
|
||||
labels:
|
||||
app: helloworld
|
||||
service: helloworld
|
||||
spec:
|
||||
ports:
|
||||
- port: 80
|
||||
name: http
|
||||
selector:
|
||||
app: helloworld
|
||||
---
|
||||
#apiVersion: v1
|
||||
#kind: ServiceAccount
|
||||
#metadata:
|
||||
# name: istio-helloworld
|
||||
# labels:
|
||||
# account:
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: helloworld-v1
|
||||
labels:
|
||||
app: helloworld
|
||||
version: v1
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: helloworld
|
||||
version: v1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: helloworld
|
||||
version: v1
|
||||
spec:
|
||||
# serviceAccountName: istio-helloworld
|
||||
containers:
|
||||
- name: helloworld
|
||||
image: nginx
|
||||
resources:
|
||||
requests:
|
||||
cpu: "100m"
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 80
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: helloworld-v2
|
||||
labels:
|
||||
app: helloworld
|
||||
version: v2
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: helloworld
|
||||
version: v2
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: helloworld
|
||||
version: v2
|
||||
spec:
|
||||
# serviceAccountName: istio-helloworld
|
||||
containers:
|
||||
- name: helloworld
|
||||
image: httpd
|
||||
resources:
|
||||
requests:
|
||||
cpu: "100m"
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 80
|
||||
---
|
@ -0,0 +1,62 @@
|
||||
# https://github.com/istio/istio/blob/master/samples/helloworld/helloworld-gateway.yaml
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: Gateway
|
||||
metadata:
|
||||
name: helloworld-gateway
|
||||
spec:
|
||||
selector:
|
||||
istio: ingressgateway # use istio default controller
|
||||
servers:
|
||||
- port:
|
||||
number: 80
|
||||
name: http
|
||||
protocol: HTTP
|
||||
hosts:
|
||||
- "*"
|
||||
---
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: helloworld-vs
|
||||
spec:
|
||||
hosts:
|
||||
- "*"
|
||||
gateways:
|
||||
- helloworld-gateway
|
||||
http:
|
||||
- match:
|
||||
- uri:
|
||||
exact: /helloworld
|
||||
route:
|
||||
- destination:
|
||||
host: helloworld.default.svc.cluster.local
|
||||
# host: helloworld
|
||||
port:
|
||||
number: 80
|
||||
subset: v1
|
||||
weight: 20
|
||||
- destination:
|
||||
# host: helloworld
|
||||
host: helloworld.default.svc.cluster.local
|
||||
port:
|
||||
number: 80
|
||||
subset: v2
|
||||
weight: 80
|
||||
rewrite:
|
||||
uri: "/"
|
||||
---
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: DestinationRule
|
||||
metadata:
|
||||
# name: helloworld
|
||||
name: helloworld.default.svc.cluster.local # Destination that will "interject"
|
||||
spec:
|
||||
# host: helloworld # destination service
|
||||
host: helloworld.default.svc.cluster.local # Full destination service, lil better for consistency
|
||||
subsets:
|
||||
- name: v1
|
||||
labels:
|
||||
version: v1
|
||||
- name: v2
|
||||
labels:
|
||||
version: v2
|
@ -0,0 +1,8 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: defaultnt
|
||||
labels:
|
||||
istio-injection: "false"
|
||||
# istio-injection: "enabled"
|
||||
---
|
@ -0,0 +1,123 @@
|
||||
##### https://github.com/istio/istio/tree/master/samples/helloworld
|
||||
|
||||
https://istio.io/latest/blog/2017/0.1-canary/
|
||||
|
||||
|
||||
# Simple Hello World
|
||||
|
||||
- 1 Service
|
||||
- 2 Versions
|
||||
|
||||
Iterates between the versions without any specific policy. (actually doesn't use the version for anything)
|
||||
|
||||
I think that by default uses `RANDOM`.
|
||||
|
||||
https://istio.io/latest/docs/reference/config/networking/destination-rule/#TrafficPolicy-PortTrafficPolicy
|
||||
|
||||
https://istio.io/latest/docs/reference/config/networking/destination-rule/#LoadBalancerSettings
|
||||
|
||||
|
||||
Manually allows the sidecar injection through the label in the pod
|
||||
|
||||
|
||||
https://istio.io/latest/docs/setup/additional-setup/sidecar-injection/#controlling-the-injection-policy
|
||||
|
||||
## Files
|
||||
|
||||
- deployment.yaml
|
||||
- gateway.yaml
|
||||
|
||||
## deployment.yaml
|
||||
|
||||
### Creates
|
||||
|
||||
#### Service
|
||||
|
||||
- helloworld
|
||||
|
||||
#### Deployments
|
||||
|
||||
- helloworld-v1 (Nginx)
|
||||
- helloworld-v2 (Apache)
|
||||
|
||||
## gateway.yaml
|
||||
|
||||
### Creates
|
||||
|
||||
#### Gateway
|
||||
|
||||
##### helloworld-gateway
|
||||
|
||||
###### Configuration
|
||||
|
||||
```yml
|
||||
port: 80
|
||||
istio-ingress: ingressgateway
|
||||
hosts: "*"
|
||||
```
|
||||
|
||||
#### VirtualService
|
||||
|
||||
##### helloworld-vs
|
||||
|
||||
###### Configuration
|
||||
|
||||
```yaml
|
||||
hosts: "*"
|
||||
uri: "/helloworld"
|
||||
versions:
|
||||
v1:
|
||||
weight: "50%"
|
||||
v2:
|
||||
weight: "50%"
|
||||
```
|
||||
|
||||
#### Destination Rule
|
||||
|
||||
###### Configuration
|
||||
|
||||
```yaml
|
||||
host: helloworld.defaultnt.svc.cluster.local # Full destination service, lil better for consistency
|
||||
subsets:
|
||||
- name: v1
|
||||
labels:
|
||||
version: v1
|
||||
- name: v2
|
||||
labels:
|
||||
version: v2
|
||||
```
|
||||
|
||||
|
||||
# Run example
|
||||
|
||||
## Deploy resources
|
||||
|
||||
```shell
|
||||
$
|
||||
```
|
||||
|
||||
## Wait for the pods to be ready
|
||||
|
||||
(I think it deploys 2 pods as there is the Envoy Proxy pod besides the Nginx deployment)
|
||||
|
||||
```shell
|
||||
|
||||
```
|
||||
|
||||
## Test the service
|
||||
|
||||
### Get LB IP
|
||||
|
||||
```shell
|
||||
$ kubectl get svc istio-ingressgateway -n istio-system
|
||||
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
|
||||
istio-ingressgateway LoadBalancer 10.97.47.216 192.168.1.50 15021:31316/TCP,80:32012/TCP,443:32486/TCP 39h
|
||||
```
|
||||
|
||||
### Curl
|
||||
|
||||
|
||||
```shell
|
||||
$ curl 192.168.1.50/helloworld -s | grep "<h1>.*</h1>"
|
||||
<html><body><h1>It works!</h1></body></html>
|
||||
```
|
@ -0,0 +1,86 @@
|
||||
# https://github.com/istio/istio/blob/master/samples/helloworld/helloworld.yaml
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: helloworld
|
||||
namespace: defaultnt
|
||||
labels:
|
||||
app: helloworldll
|
||||
service: helloworld
|
||||
sidecar.istio.io/inject: "false"
|
||||
spec:
|
||||
ports:
|
||||
- port: 80
|
||||
name: http
|
||||
selector:
|
||||
app: helloworld
|
||||
---
|
||||
#apiVersion: v1
|
||||
#kind: ServiceAccount
|
||||
#metadata:
|
||||
# name: istio-helloworld
|
||||
# labels:
|
||||
# account:
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: helloworld-v1
|
||||
namespace: defaultnt
|
||||
labels:
|
||||
app: helloworld
|
||||
version: v1
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: helloworld
|
||||
version: v1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: helloworld
|
||||
version: v1
|
||||
spec:
|
||||
containers:
|
||||
- name: helloworld
|
||||
image: nginx
|
||||
resources:
|
||||
requests:
|
||||
cpu: "100m"
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 80
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: helloworld-v2
|
||||
namespace: defaultnt
|
||||
labels:
|
||||
app: helloworld
|
||||
version: v2
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: helloworld
|
||||
version: v2
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: helloworld
|
||||
version: v2
|
||||
spec:
|
||||
containers:
|
||||
- name: helloworld
|
||||
image: httpd
|
||||
resources:
|
||||
requests:
|
||||
cpu: "100m"
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 80
|
||||
---
|
@ -0,0 +1,61 @@
|
||||
# https://github.com/istio/istio/blob/master/samples/helloworld/helloworld-gateway.yaml
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: Gateway
|
||||
metadata:
|
||||
name: helloworld-gateway
|
||||
namespace: defaultnt
|
||||
spec:
|
||||
selector:
|
||||
istio: istio-ingress # use istio default controller
|
||||
servers:
|
||||
- port:
|
||||
number: 80
|
||||
name: http
|
||||
protocol: HTTP
|
||||
hosts:
|
||||
- "*"
|
||||
---
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: helloworld-vs
|
||||
namespace: defaultnt
|
||||
spec:
|
||||
hosts:
|
||||
- "*"
|
||||
gateways:
|
||||
- helloworld-gateway
|
||||
http:
|
||||
- match:
|
||||
- uri:
|
||||
exact: /helloworld
|
||||
route:
|
||||
- destination:
|
||||
host: helloworld.defaultnt.svc.cluster.local
|
||||
port:
|
||||
number: 80
|
||||
subset: v1
|
||||
weight: 50
|
||||
- destination:
|
||||
host: helloworld.defaultnt.svc.cluster.local
|
||||
port:
|
||||
number: 80
|
||||
subset: v2
|
||||
weight: 50
|
||||
rewrite:
|
||||
uri: "/"
|
||||
---
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: DestinationRule
|
||||
metadata:
|
||||
name: helloworld
|
||||
namespace: defaultnt
|
||||
spec:
|
||||
host: helloworld.defaultnt.svc.cluster.local # Full destination service, lil better for consistency
|
||||
subsets:
|
||||
- name: v1
|
||||
labels:
|
||||
version: v1
|
||||
- name: v2
|
||||
labels:
|
||||
version: v2
|
204
01-Simple/05-hello_world_1_Service_Entry/README.md
Executable file
204
01-Simple/05-hello_world_1_Service_Entry/README.md
Executable file
@ -0,0 +1,204 @@
|
||||
# Description
|
||||
|
||||
This example uses a resource `ServiceEntry` to "integrate" external resources into our `Istio Service Mesh`.
|
||||
|
||||
It also explores the different behaviors between specifying the destination URL on the headers or not.
|
||||
|
||||
The following page has been used for testing purposes:
|
||||
|
||||
- info.cern.ch
|
||||
|
||||
> **Quick disclaimer**:\
|
||||
> I have no relation with that page.
|
||||
|
||||
# Configuration
|
||||
|
||||
## ServiceEntry
|
||||
|
||||
This `ServiceEntry` resource, defines as a destination the URL `info.cern.ch`.
|
||||
|
||||
Note that location is set to `MESH_EXTERNAL` and that the resolution is set to `DNS`, this means that the resource is external to ou `Istio Service Mesh`, and the URL will be resolved through `DNS`
|
||||
|
||||
Bear in mind that when Istio is communicating with resources externals to the mesh, `mTLS` is disabled.
|
||||
|
||||
Also, policy enforcement is performed in the client side instead of the server side.
|
||||
|
||||
> **Note:**/
|
||||
> For more information regarding the `resolution` field or the `location` field, refer to the following official Istio documentations:
|
||||
> [ServiceEntry.Location](https://istio.io/latest/docs/reference/config/networking/service-entry/#ServiceEntry-Location)
|
||||
> [ServiceEntry.Resolution](https://istio.io/latest/docs/reference/config/networking/service-entry/#ServiceEntry-Resolution)
|
||||
|
||||
```yaml
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: ServiceEntry
|
||||
metadata:
|
||||
name: external-cern-service
|
||||
spec:
|
||||
hosts:
|
||||
- info.cern.ch
|
||||
ports:
|
||||
- number: 80
|
||||
name: http
|
||||
protocol: HTTP
|
||||
resolution: DNS
|
||||
location: MESH_EXTERNAL
|
||||
```
|
||||
|
||||
## Gateway
|
||||
|
||||
Listens for `HTTP` traffic at the port `80` without limiting to any host.
|
||||
|
||||
```yaml
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: Gateway
|
||||
metadata:
|
||||
name: helloworld-gateway
|
||||
spec:
|
||||
selector:
|
||||
istio: ingressgateway # use istio default controller
|
||||
servers:
|
||||
- port:
|
||||
number: 80
|
||||
name: http
|
||||
protocol: HTTP
|
||||
hosts:
|
||||
- "*"
|
||||
```
|
||||
|
||||
|
||||
## VirtualService
|
||||
|
||||
There has been configured 2 paths:
|
||||
|
||||
- "/external"
|
||||
- "/external-noh"
|
||||
|
||||
Both routes will forward the request towards the destination URL `info.cern.ch`.
|
||||
|
||||
Highlight that the destination is `info.cern.ch`, which is the same as the contents set on the field `host` from the [ServiceEntry resource configured above](#serviceentry).
|
||||
|
||||
The difference between `/external` and `/external-noh` is that the first path will contain a header named `HOST`, with the contents set to `info.cern.ch`, it being the URL from the external service.
|
||||
|
||||
On the [Walkthrough](#walkthrough) section we will observe the different behaviors of these paths, being the only difference the header attributed.
|
||||
|
||||
Also, we have set a timeout of 3 seconds towards the external services.
|
||||
|
||||
```yaml
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: helloworld-vs
|
||||
spec:
|
||||
hosts:
|
||||
- "*"
|
||||
gateways:
|
||||
- helloworld-gateway
|
||||
http:
|
||||
- name: http-external-service
|
||||
timeout: 3s
|
||||
match:
|
||||
- uri:
|
||||
exact: "/external"
|
||||
route:
|
||||
- destination:
|
||||
host: info.cern.ch
|
||||
port:
|
||||
number: 80
|
||||
rewrite:
|
||||
uri: "/"
|
||||
headers:
|
||||
request:
|
||||
set:
|
||||
HOST: "info.cern.ch"
|
||||
|
||||
- name: https-external-service-without-headers
|
||||
timeout: 3s
|
||||
match:
|
||||
- uri:
|
||||
exact: "/external-noh"
|
||||
route:
|
||||
- destination:
|
||||
host: info.cern.ch
|
||||
port:
|
||||
number: 80
|
||||
rewrite:
|
||||
uri: "/"
|
||||
```
|
||||
|
||||
# Walkthrough
|
||||
|
||||
## Deploy the resources
|
||||
|
||||
```shell
|
||||
kubectl apply -f ./
|
||||
```
|
||||
```text
|
||||
serviceentry.networking.istio.io/external-cern-service created
|
||||
gateway.networking.istio.io/helloworld-gateway created
|
||||
virtualservice.networking.istio.io/helloworld-vs created
|
||||
```
|
||||
|
||||
## Test the service
|
||||
|
||||
### Get LB IP
|
||||
|
||||
```shell
|
||||
$ kubectl get svc -l istio=ingressgateway -A
|
||||
```
|
||||
```text
|
||||
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
|
||||
istio-ingressgateway LoadBalancer 10.97.47.216 192.168.1.50 15021:31316/TCP,80:32012/TCP,443:32486/TCP 39h
|
||||
```
|
||||
|
||||
### /external
|
||||
|
||||
We can visualize the page contents without issues, nothing to highlight.
|
||||
|
||||
```shell
|
||||
curl 192.168.1.50/external
|
||||
```
|
||||
```text
|
||||
<html><head></head><body><header>
|
||||
<title>http://info.cern.ch</title>
|
||||
</header>
|
||||
|
||||
<h1>http://info.cern.ch - home of the first website</h1>
|
||||
<p>From here you can:</p>
|
||||
<ul>
|
||||
<li><a href="http://info.cern.ch/hypertext/WWW/TheProject.html">Browse the first website</a></li>
|
||||
<li><a href="http://line-mode.cern.ch/www/hypertext/WWW/TheProject.html">Browse the first website using the line-mode browser simulator</a></li>
|
||||
<li><a href="http://home.web.cern.ch/topics/birth-web">Learn about the birth of the web</a></li>
|
||||
<li><a href="http://home.web.cern.ch/about">Learn about CERN, the physics laboratory where the web was born</a></li>
|
||||
</ul>
|
||||
</body></html>
|
||||
```
|
||||
|
||||
### /external-noh
|
||||
|
||||
We don't receive any output.
|
||||
|
||||
This could be due, even if we resolve the destination IP for the URL `info.cern.ch`, the destination might have a Reverse Proxy or any other ingress resource that could condition handling this request.
|
||||
|
||||
Due to the `HOST` field not being modified after we set the request, it might not be able to pass the filtering set, weather it is security wise, for example, requiring such field to allow the request; or it being a routing condition, which due not having this field specified, it's not able to route the request towards the destination desired.
|
||||
|
||||
```shell
|
||||
curl 192.168.1.50/external-noh
|
||||
```
|
||||
```text
|
||||
```
|
||||
|
||||
## Cleanup
|
||||
|
||||
```shell
|
||||
kubectl delete -f ./
|
||||
```
|
||||
```text
|
||||
serviceentry.networking.istio.io "external-cern-service" deleted
|
||||
gateway.networking.istio.io "helloworld-gateway" deleted
|
||||
virtualservice.networking.istio.io "helloworld-vs" deleted
|
||||
```
|
||||
|
||||
# Links of interest:
|
||||
|
||||
- https://istio.io/latest/docs/reference/config/networking/service-entry/#ServiceEntry-Location
|
||||
|
13
01-Simple/05-hello_world_1_Service_Entry/ServiceEntry.yaml
Normal file
13
01-Simple/05-hello_world_1_Service_Entry/ServiceEntry.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: ServiceEntry
|
||||
metadata:
|
||||
name: external-cern-service
|
||||
spec:
|
||||
hosts:
|
||||
- info.cern.ch
|
||||
ports:
|
||||
- number: 80
|
||||
name: http
|
||||
protocol: HTTP
|
||||
resolution: DNS
|
||||
location: MESH_EXTERNAL
|
54
01-Simple/05-hello_world_1_Service_Entry/gateway.yaml
Executable file
54
01-Simple/05-hello_world_1_Service_Entry/gateway.yaml
Executable file
@ -0,0 +1,54 @@
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: Gateway
|
||||
metadata:
|
||||
name: helloworld-gateway
|
||||
spec:
|
||||
selector:
|
||||
istio: ingressgateway # use istio default controller
|
||||
servers:
|
||||
- port:
|
||||
number: 80
|
||||
name: http
|
||||
protocol: HTTP
|
||||
hosts:
|
||||
- "*"
|
||||
---
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: helloworld-vs
|
||||
spec:
|
||||
hosts:
|
||||
- "*"
|
||||
gateways:
|
||||
- helloworld-gateway
|
||||
http:
|
||||
- name: http-external-service
|
||||
timeout: 3s
|
||||
match:
|
||||
- uri:
|
||||
exact: "/external"
|
||||
route:
|
||||
- destination:
|
||||
host: info.cern.ch
|
||||
port:
|
||||
number: 80
|
||||
rewrite:
|
||||
uri: "/"
|
||||
headers:
|
||||
request:
|
||||
set:
|
||||
HOST: "info.cern.ch"
|
||||
|
||||
- name: https-external-service-without-headers
|
||||
timeout: 3s
|
||||
match:
|
||||
- uri:
|
||||
exact: "/external-noh"
|
||||
route:
|
||||
- destination:
|
||||
host: info.cern.ch
|
||||
port:
|
||||
number: 80
|
||||
rewrite:
|
||||
uri: "/"
|
188
01-Simple/06-hello_world_1_HTTPS-Service_Entry/README.md
Executable file
188
01-Simple/06-hello_world_1_HTTPS-Service_Entry/README.md
Executable file
@ -0,0 +1,188 @@
|
||||
# Description
|
||||
|
||||
This example configures an `ServiceEntry` service pointing to a URL external to our `Istio Service Mesh`.
|
||||
|
||||
The main difference with the previous example, is that on this example the resource selected requires `HTTPS` communication.
|
||||
|
||||
The page used as a destination is my own [GitHub page](https://github.com/).
|
||||
|
||||
# Based on
|
||||
|
||||
- [05-hello_world_1_Service_Entry](../05-hello_world_1_Service_Entry)
|
||||
|
||||
# Configuration
|
||||
|
||||
## ServiceEntry
|
||||
|
||||
This `ServiceEntry` resource, defines as a destination the URL `github.com`.
|
||||
|
||||
Note that location is set to `MESH_EXTERNAL` and that the resolution is set to `DNS`, this means that the resource is external to ou `Istio Service Mesh`, and the URL will be resolved through `DNS`
|
||||
|
||||
This resource listens for the port `8443`, and will connect to its destination with the port `443`, intending to handle `HTTPS` protocol traffic.
|
||||
|
||||
Bear in mind that when Istio is communicating with resources externals to the mesh, `mTLS` is disabled.
|
||||
|
||||
Also, policy enforcement is performed in the client side instead of the server side.
|
||||
|
||||
> **Note:**/
|
||||
> For more information regarding the `resolution` field or the `location` field, refer to the following official Istio documentations:
|
||||
> [ServiceEntry.Location](https://istio.io/latest/docs/reference/config/networking/service-entry/#ServiceEntry-Location)
|
||||
> [ServiceEntry.Resolution](https://istio.io/latest/docs/reference/config/networking/service-entry/#ServiceEntry-Resolution)
|
||||
|
||||
```yaml
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: ServiceEntry
|
||||
metadata:
|
||||
name: external-github-service
|
||||
spec:
|
||||
hosts:
|
||||
- github.com
|
||||
ports:
|
||||
- number: 8443
|
||||
name: https
|
||||
protocol: HTTPS
|
||||
targetPort: 443
|
||||
resolution: DNS
|
||||
location: MESH_EXTERNAL
|
||||
```
|
||||
|
||||
## Gateway
|
||||
|
||||
Listens for `HTTP` traffic at the port `80` without limiting to any host.
|
||||
|
||||
```yaml
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: Gateway
|
||||
metadata:
|
||||
name: helloworld-gateway
|
||||
spec:
|
||||
selector:
|
||||
istio: ingressgateway # use istio default controller
|
||||
servers:
|
||||
- port:
|
||||
number: 80
|
||||
name: http
|
||||
protocol: HTTP
|
||||
hosts:
|
||||
- "*"
|
||||
```
|
||||
|
||||
|
||||
## VirtualService
|
||||
|
||||
The path `/external` will forward the request towards the destination URL `github.com`, and path `/OriolFilter`.
|
||||
|
||||
|
||||
Highlight that the destination is `github.com`, which is the same as the contents set on the field `host` from the [ServiceEntry resource configured above](#serviceentry).
|
||||
|
||||
As seen [in the previous example, where the host that didn't have the `HOST` header wasn't able to receive a response by the destination](../05-hello_world_1_Service_Entry/#external-noh), we configured the `HOST` header to match the URL from the external service.
|
||||
|
||||
```yaml
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: helloworld-vs
|
||||
spec:
|
||||
hosts:
|
||||
- "*"
|
||||
gateways:
|
||||
- helloworld-gateway
|
||||
http:
|
||||
- name: https-external-service
|
||||
timeout: 3s
|
||||
match:
|
||||
- uri:
|
||||
exact: "/external"
|
||||
route:
|
||||
- destination:
|
||||
host: "github.com"
|
||||
port:
|
||||
number: 8443
|
||||
rewrite:
|
||||
uri: "/OriolFilter/"
|
||||
headers:
|
||||
request:
|
||||
set:
|
||||
HOST: "github.com"
|
||||
```
|
||||
|
||||
## DestinationRule
|
||||
|
||||
As seen in the example [02-Traffic_management/09-HTTPS-backend](../../02-Traffic_management/09-HTTPS-backend), where we configure Istio to use an `HTTPS` backend, the same configuration is applied on this case (yes, I am aware that a `ServiceEntry` is also a backend).
|
||||
|
||||
For such, we deploy a `DestinationRule` setting to expect to terminate the TLS traffic, for the traffic with resource destination `github.com`, and port `8443`, which matches the settings set in our [ServiceEntry](#serviceentry) deployed.
|
||||
|
||||
```yaml
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: DestinationRule
|
||||
metadata:
|
||||
name: github.com
|
||||
namespace: default
|
||||
spec:
|
||||
host: github.com
|
||||
trafficPolicy:
|
||||
portLevelSettings:
|
||||
- port:
|
||||
number: 8443
|
||||
tls:
|
||||
mode: SIMPLE
|
||||
```
|
||||
|
||||
# Walkthrough
|
||||
|
||||
## Deploy the resources
|
||||
|
||||
```shell
|
||||
kubectl apply -f ./
|
||||
```
|
||||
```text
|
||||
serviceentry.networking.istio.io/external-github-service created
|
||||
gateway.networking.istio.io/helloworld-gateway created
|
||||
virtualservice.networking.istio.io/helloworld-vs created
|
||||
destinationrule.networking.istio.io/github.com created
|
||||
```
|
||||
|
||||
## Test the service
|
||||
|
||||
### Get LB IP
|
||||
|
||||
```shell
|
||||
$ kubectl get svc -l istio=ingressgateway -A
|
||||
```
|
||||
```text
|
||||
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
|
||||
istio-ingressgateway LoadBalancer 10.97.47.216 192.168.1.50 15021:31316/TCP,80:32012/TCP,443:32486/TCP 39h
|
||||
```
|
||||
|
||||
### /external
|
||||
|
||||
We can visualize the page contents without issues, nothing to highlight.
|
||||
|
||||
```shell
|
||||
curl 192.168.1.50/external
|
||||
```
|
||||
```text
|
||||
...
|
||||
I mean, we can use curl but it's certainly quite an ugly output, it works tho.
|
||||
...
|
||||
```
|
||||
|
||||
As performing the test through `curl` is ugly, here is a screenshot of the setting working correctly.
|
||||
|
||||

|
||||
|
||||
## Cleanup
|
||||
|
||||
```shell
|
||||
kubectl delete -f ./
|
||||
```
|
||||
```text
|
||||
serviceentry.networking.istio.io "external-github-service" deleted
|
||||
gateway.networking.istio.io "helloworld-gateway" deleted
|
||||
virtualservice.networking.istio.io "helloworld-vs" deleted
|
||||
destinationrule.networking.istio.io "github.com" deleted
|
||||
```
|
||||
|
||||
# Links of interest:
|
||||
|
||||
- https://istio.io/latest/docs/reference/config/networking/service-entry/#ServiceEntry-Location
|
@ -0,0 +1,14 @@
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: ServiceEntry
|
||||
metadata:
|
||||
name: external-github-service
|
||||
spec:
|
||||
hosts:
|
||||
- github.com
|
||||
ports:
|
||||
- number: 8443
|
||||
name: https
|
||||
protocol: HTTPS
|
||||
targetPort: 443
|
||||
resolution: DNS
|
||||
location: MESH_EXTERNAL
|
55
01-Simple/06-hello_world_1_HTTPS-Service_Entry/gateway.yaml
Executable file
55
01-Simple/06-hello_world_1_HTTPS-Service_Entry/gateway.yaml
Executable file
@ -0,0 +1,55 @@
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: Gateway
|
||||
metadata:
|
||||
name: helloworld-gateway
|
||||
spec:
|
||||
selector:
|
||||
istio: ingressgateway # use istio default controller
|
||||
servers:
|
||||
- port:
|
||||
number: 80
|
||||
name: http
|
||||
protocol: HTTP
|
||||
hosts:
|
||||
- "*"
|
||||
---
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: helloworld-vs
|
||||
spec:
|
||||
hosts:
|
||||
- "*"
|
||||
gateways:
|
||||
- helloworld-gateway
|
||||
http:
|
||||
- name: https-external-service
|
||||
timeout: 3s
|
||||
match:
|
||||
- uri:
|
||||
exact: "/external"
|
||||
route:
|
||||
- destination:
|
||||
host: "github.com"
|
||||
port:
|
||||
number: 8443
|
||||
rewrite:
|
||||
uri: "/OriolFilter/"
|
||||
headers:
|
||||
request:
|
||||
set:
|
||||
HOST: "github.com"
|
||||
---
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: DestinationRule
|
||||
metadata:
|
||||
name: github.com
|
||||
namespace: default
|
||||
spec:
|
||||
host: github.com
|
||||
trafficPolicy:
|
||||
portLevelSettings:
|
||||
- port:
|
||||
number: 8443
|
||||
tls:
|
||||
mode: SIMPLE
|
Binary file not shown.
After Width: | Height: | Size: 113 KiB |
38
01-Simple/README.md
Executable file
38
01-Simple/README.md
Executable file
@ -0,0 +1,38 @@
|
||||
# Simple examples
|
||||
|
||||
|
||||
# Traffic path
|
||||
|
||||
## Istio Ingress Controller ---> Gateway -> Virtual Service (-> Destination Route) -> Ingress -> Deployment
|
||||
|
||||
|
||||
# Examples
|
||||
|
||||
ALL NEEDS DOCUMENTATION
|
||||
|
||||
- 01-hello_world_1_service_1_deployment
|
||||
|
||||
- 02-hello_world_1_service_2_deployments_unmanaged
|
||||
|
||||
- 03-hello_world_1_service_2_deployments_managed_version
|
||||
|
||||
- 04-hello_world_1_service_2_deployments_managed_version_defaultnt_namespace
|
||||
|
||||
- 05-hello_world_1_Service_Entry
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# TODO
|
||||
|
||||
do HTTPS ingress
|
||||
|
||||
tcp ingress to minecraft/factorio/zomboid
|
||||
|
||||
Service Entry with outbound policy set to `REGISTRY_ONLY`
|
||||
istioctl install --set profile=default -y --set meshConfig.accessLogFile=/dev/stdout --set meshConfig.outboundTrafficPolicy.mode=REGISTRY_ONLY
|
||||
(no funca)
|
Reference in New Issue
Block a user