idk i brought Istio and some other things
This commit is contained in:
1
Istio/NetworkPolicies/README.md
Normal file
1
Istio/NetworkPolicies/README.md
Normal file
@ -0,0 +1 @@
|
||||
https://istio.io/latest/blog/2017/0.1-using-network-policy/#examples
|
1
Istio/bookshelf/README.md
Normal file
1
Istio/bookshelf/README.md
Normal file
@ -0,0 +1 @@
|
||||
# Example from istio, using it for testing purposes
|
52
Istio/bookshelf/bookinfo-gateway.yaml
Normal file
52
Istio/bookshelf/bookinfo-gateway.yaml
Normal file
@ -0,0 +1,52 @@
|
||||
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: Gateway
|
||||
metadata:
|
||||
name: bookinfo-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: bookinfo
|
||||
spec:
|
||||
hosts:
|
||||
- "*"
|
||||
gateways:
|
||||
- bookinfo-gateway
|
||||
http:
|
||||
- match:
|
||||
- uri:
|
||||
exact: /productpage
|
||||
- uri:
|
||||
prefix: /static
|
||||
- uri:
|
||||
exact: /login
|
||||
- uri:
|
||||
exact: /logout
|
||||
- uri:
|
||||
prefix: /api/v1/products
|
||||
route:
|
||||
- destination:
|
||||
host: productpage
|
||||
port:
|
||||
number: 9080
|
||||
- match:
|
||||
- uri:
|
||||
exact: /helloworld
|
||||
route:
|
||||
- destination:
|
||||
host: productpage
|
||||
port:
|
||||
number: 9080
|
||||
rewrite:
|
||||
uri: "/productpage"
|
343
Istio/bookshelf/bookinfo.yaml
Normal file
343
Istio/bookshelf/bookinfo.yaml
Normal file
@ -0,0 +1,343 @@
|
||||
# Copyright Istio 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
|
||||
#
|
||||
# http://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.
|
||||
|
||||
##################################################################################################
|
||||
# This file defines the services, service accounts, and deployments for the Bookinfo sample.
|
||||
#
|
||||
# To apply all 4 Bookinfo services, their corresponding service accounts, and deployments:
|
||||
#
|
||||
# kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
|
||||
#
|
||||
# Alternatively, you can deploy any resource separately:
|
||||
#
|
||||
# kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml -l service=reviews # reviews Service
|
||||
# kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml -l account=reviews # reviews ServiceAccount
|
||||
# kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml -l app=reviews,version=v3 # reviews-v3 Deployment
|
||||
##################################################################################################
|
||||
|
||||
##################################################################################################
|
||||
# Details service
|
||||
##################################################################################################
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: details
|
||||
labels:
|
||||
app: details
|
||||
service: details
|
||||
spec:
|
||||
ports:
|
||||
- port: 9080
|
||||
name: http
|
||||
selector:
|
||||
app: details
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: bookinfo-details
|
||||
labels:
|
||||
account: details
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: details-v1
|
||||
labels:
|
||||
app: details
|
||||
version: v1
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: details
|
||||
version: v1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: details
|
||||
version: v1
|
||||
spec:
|
||||
serviceAccountName: bookinfo-details
|
||||
containers:
|
||||
- name: details
|
||||
image: docker.io/istio/examples-bookinfo-details-v1:1.17.0
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 9080
|
||||
securityContext:
|
||||
runAsUser: 1000
|
||||
---
|
||||
##################################################################################################
|
||||
# Ratings service
|
||||
##################################################################################################
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: ratings
|
||||
labels:
|
||||
app: ratings
|
||||
service: ratings
|
||||
spec:
|
||||
ports:
|
||||
- port: 9080
|
||||
name: http
|
||||
selector:
|
||||
app: ratings
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: bookinfo-ratings
|
||||
labels:
|
||||
account: ratings
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: ratings-v1
|
||||
labels:
|
||||
app: ratings
|
||||
version: v1
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: ratings
|
||||
version: v1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: ratings
|
||||
version: v1
|
||||
spec:
|
||||
serviceAccountName: bookinfo-ratings
|
||||
containers:
|
||||
- name: ratings
|
||||
image: docker.io/istio/examples-bookinfo-ratings-v1:1.17.0
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 9080
|
||||
securityContext:
|
||||
runAsUser: 1000
|
||||
---
|
||||
##################################################################################################
|
||||
# Reviews service
|
||||
##################################################################################################
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: reviews
|
||||
labels:
|
||||
app: reviews
|
||||
service: reviews
|
||||
spec:
|
||||
ports:
|
||||
- port: 9080
|
||||
name: http
|
||||
selector:
|
||||
app: reviews
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: bookinfo-reviews
|
||||
labels:
|
||||
account: reviews
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: reviews-v1
|
||||
labels:
|
||||
app: reviews
|
||||
version: v1
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: reviews
|
||||
version: v1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: reviews
|
||||
version: v1
|
||||
spec:
|
||||
serviceAccountName: bookinfo-reviews
|
||||
containers:
|
||||
- name: reviews
|
||||
image: docker.io/istio/examples-bookinfo-reviews-v1:1.17.0
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: LOG_DIR
|
||||
value: "/tmp/logs"
|
||||
ports:
|
||||
- containerPort: 9080
|
||||
volumeMounts:
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
- name: wlp-output
|
||||
mountPath: /opt/ibm/wlp/output
|
||||
securityContext:
|
||||
runAsUser: 1000
|
||||
volumes:
|
||||
- name: wlp-output
|
||||
emptyDir: {}
|
||||
- name: tmp
|
||||
emptyDir: {}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: reviews-v2
|
||||
labels:
|
||||
app: reviews
|
||||
version: v2
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: reviews
|
||||
version: v2
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: reviews
|
||||
version: v2
|
||||
spec:
|
||||
serviceAccountName: bookinfo-reviews
|
||||
containers:
|
||||
- name: reviews
|
||||
image: docker.io/istio/examples-bookinfo-reviews-v2:1.17.0
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: LOG_DIR
|
||||
value: "/tmp/logs"
|
||||
ports:
|
||||
- containerPort: 9080
|
||||
volumeMounts:
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
- name: wlp-output
|
||||
mountPath: /opt/ibm/wlp/output
|
||||
securityContext:
|
||||
runAsUser: 1000
|
||||
volumes:
|
||||
- name: wlp-output
|
||||
emptyDir: {}
|
||||
- name: tmp
|
||||
emptyDir: {}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: reviews-v3
|
||||
labels:
|
||||
app: reviews
|
||||
version: v3
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: reviews
|
||||
version: v3
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: reviews
|
||||
version: v3
|
||||
spec:
|
||||
serviceAccountName: bookinfo-reviews
|
||||
containers:
|
||||
- name: reviews
|
||||
image: docker.io/istio/examples-bookinfo-reviews-v3:1.17.0
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: LOG_DIR
|
||||
value: "/tmp/logs"
|
||||
ports:
|
||||
- containerPort: 9080
|
||||
volumeMounts:
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
- name: wlp-output
|
||||
mountPath: /opt/ibm/wlp/output
|
||||
securityContext:
|
||||
runAsUser: 1000
|
||||
volumes:
|
||||
- name: wlp-output
|
||||
emptyDir: {}
|
||||
- name: tmp
|
||||
emptyDir: {}
|
||||
---
|
||||
##################################################################################################
|
||||
# Productpage services
|
||||
##################################################################################################
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: productpage
|
||||
labels:
|
||||
app: productpage
|
||||
service: productpage
|
||||
spec:
|
||||
ports:
|
||||
- port: 9080
|
||||
name: http
|
||||
selector:
|
||||
app: productpage
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: bookinfo-productpage
|
||||
labels:
|
||||
account: productpage
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: productpage-v1
|
||||
labels:
|
||||
app: productpage
|
||||
version: v1
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: productpage
|
||||
version: v1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: productpage
|
||||
version: v1
|
||||
spec:
|
||||
serviceAccountName: bookinfo-productpage
|
||||
containers:
|
||||
- name: productpage
|
||||
image: docker.io/istio/examples-bookinfo-productpage-v1:1.17.0
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 9080
|
||||
volumeMounts:
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
securityContext:
|
||||
runAsUser: 1000
|
||||
volumes:
|
||||
- name: tmp
|
||||
emptyDir: {}
|
||||
---
|
15
Istio/ingress.yaml
Normal file
15
Istio/ingress.yaml
Normal file
@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: istio-ingress
|
||||
labels:
|
||||
istio: ingress
|
||||
spec:
|
||||
type: LoadBalancer
|
||||
ports:
|
||||
- port: 80
|
||||
name: http
|
||||
- port: 443
|
||||
name: https
|
||||
selector:
|
||||
istio: ingress
|
6
Istio/simple/README.md
Normal file
6
Istio/simple/README.md
Normal file
@ -0,0 +1,6 @@
|
||||
# Simple examples
|
||||
|
||||
|
||||
# Traffic path
|
||||
|
||||
## Istio Ingress Controller ---> Gateway -> Virtual Service (-> Destination Route) -> Ingress -> Deployment
|
102
Istio/simple/hello_world_1_service_1_deployment/README.md
Normal file
102
Istio/simple/hello_world_1_service_1_deployment/README.md
Normal file
@ -0,0 +1,102 @@
|
||||
##### https://github.com/istio/istio/tree/master/samples/helloworld
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
Relies in automatic sidecar injection.
|
||||
|
||||
|
||||
> 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: "*"
|
||||
uri: "/helloworld"
|
||||
```
|
||||
|
||||
# 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 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-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 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 "<title>.*</title>" ✔
|
||||
<title>Welcome to nginx!</title>
|
||||
```
|
@ -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
|
36
Istio/simple/hello_world_1_service_1_deployment/gateway.yaml
Normal file
36
Istio/simple/hello_world_1_service_1_deployment/gateway.yaml
Normal 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: "/"
|
@ -0,0 +1,182 @@
|
||||
##### 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
|
||||
|
||||
|
||||
Relies in automatic sidecar injection.
|
||||
|
||||
|
||||
> 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
|
||||
|
||||
|
||||
## 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: "25%"
|
||||
v2:
|
||||
weight: "75%"
|
||||
```
|
||||
|
||||
#### Destination Rule
|
||||
|
||||
###### Configuration
|
||||
|
||||
```yaml
|
||||
|
||||
```
|
||||
|
||||
|
||||
# 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 ✔ kubernetes-admin@kubernetes ⎈
|
||||
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>
|
||||
```
|
@ -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,61 @@
|
||||
# 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
|
||||
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,139 @@
|
||||
##### 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)
|
||||
|
||||
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
|
||||
|
||||
|
||||
Relies in automatic sidecar injection.
|
||||
|
||||
|
||||
> Contains service account configurations, yet they are commented as not "necessary".
|
||||
|
||||
|
||||
## 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"
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# 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 ✔ kubernetes-admin@kubernetes ⎈
|
||||
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>
|
||||
```
|
@ -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
|
||||
---
|
@ -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: "/"
|
63
Istio/tmp/ingress.yaml
Normal file
63
Istio/tmp/ingress.yaml
Normal file
@ -0,0 +1,63 @@
|
||||
## https://istio.io/latest/docs/setup/additional-setup/gateway/#deploying-a-gateway
|
||||
#apiVersion: v1
|
||||
#kind: Service
|
||||
#metadata:
|
||||
# name: istio-ingressgateway2
|
||||
# namespace: istio-ingress
|
||||
#spec:
|
||||
# type: LoadBalancer
|
||||
# selector:
|
||||
# istio: ingressgateway
|
||||
# ports:
|
||||
# - port: 80
|
||||
# name: http
|
||||
# - port: 443
|
||||
# name: https
|
||||
#---
|
||||
#apiVersion: apps/v1
|
||||
#kind: Deployment
|
||||
#metadata:
|
||||
# name: istio-ingressgateway2
|
||||
# namespace: istio-ingress
|
||||
#spec:
|
||||
# selector:
|
||||
# matchLabels:
|
||||
# istio: ingressgateway
|
||||
# template:
|
||||
# metadata:
|
||||
# annotations:
|
||||
# # Select the gateway injection template (rather than the default sidecar template)
|
||||
# inject.istio.io/templates: gateway
|
||||
# labels:
|
||||
# # Set a unique label for the gateway. This is required to ensure Gateways can select this workload
|
||||
# istio: ingressgateway
|
||||
# # Enable gateway injection. If connecting to a revisioned control plane, replace with "istio.io/rev: revision-name"
|
||||
# sidecar.istio.io/inject: "true"
|
||||
# spec:
|
||||
# containers:
|
||||
# - name: istio-proxy
|
||||
# image: auto # The image will automatically update each time the pod starts.
|
||||
#---
|
||||
## Set up roles to allow reading credentials for TLS
|
||||
#apiVersion: rbac.authorization.k8s.io/v1
|
||||
#kind: Role
|
||||
#metadata:
|
||||
# name: istio-ingressgateway2-sds
|
||||
# namespace: istio-ingress
|
||||
#rules:
|
||||
# - apiGroups: [""]
|
||||
# resources: ["secrets"]
|
||||
# verbs: ["get", "watch", "list"]
|
||||
#---
|
||||
#apiVersion: rbac.authorization.k8s.io/v1
|
||||
#kind: RoleBinding
|
||||
#metadata:
|
||||
# name: istio-ingressgateway2-sds
|
||||
# namespace: istio-ingress
|
||||
#roleRef:
|
||||
# apiGroup: rbac.authorization.k8s.io
|
||||
# kind: Role
|
||||
# name: istio-ingressgateway2-sds
|
||||
#subjects:
|
||||
# - kind: ServiceAccount
|
||||
# name: default
|
29
Istio/tmp/tmp.txt
Normal file
29
Istio/tmp/tmp.txt
Normal file
@ -0,0 +1,29 @@
|
||||
https://medium.com/@dinup24/expose-apps-on-private-network-through-istio-ingress-gateway-7dcb8a16d5bc
|
||||
|
||||
|
||||
cat << EOF > istio-operator.yaml
|
||||
apiVersion: install.istio.io/v1alpha1
|
||||
kind: IstioOperator
|
||||
metadata:
|
||||
namespace: istio-system
|
||||
name: istio-operator
|
||||
spec:
|
||||
profile: default
|
||||
components:
|
||||
ingressGateways:
|
||||
- name: istio-ingressgateway
|
||||
enabled: true
|
||||
- namespace: istio-system
|
||||
name: istio-ingressgateway-private
|
||||
enabled: true
|
||||
k8s:
|
||||
serviceAnnotations:
|
||||
service.kubernetes.io/ibm-load-balancer-cloud-provider-ip-type: "private"
|
||||
values:
|
||||
gateways:
|
||||
istio-ingressgateway:
|
||||
sds:
|
||||
enabled: true
|
||||
EOF
|
||||
|
||||
istioctl manifest apply -f istio-operator.yaml
|
Reference in New Issue
Block a user