// Steps for Google Cloud are missing
// Prerequisite. Update later.
Install VirtualBox
https://virtualbox.org/wiki/Downloads
Get Kubectl
https://virtualbox.org/wiki/Downloads
Get Mini
https://github.com/kubernetes/minikube/releases
//
Start minikube
minikube start --memory 6144
Check minikube running
minikube ip # 192.168.99.101
kubectl get nodes
Install Istio 1.0.0 // Note: 1.0.6 is not wokring for this tutorial.
ref: https://archive.istio.io/v1.0/docs/setup/kubernetes/quick-start/
curl -L https://git.io/getLatestIstio | ISTIO_VERSION=1.0.0 sh -
cd ./istio-*
export PATH=$PWD/bin:$PATH
kubectl apply -f install/kubernetes/helm/istio/templates/crds.yaml
sleep 5
# Option 1: Install Istio without mutual TLS authentication between sidecars
kubectl apply -f install/kubernetes/istio-demo.yaml
kubectl apply -f install/kubernetes/istio-demo-auth.yaml
kubectl get pods -n istio-system
Check BookInfo App
cat samples/bookinfo/platform/kube/bookinfo.yaml
Inject Istio to BookInfo using Istioctl
istioctl kube-inject -f samples/bookinfo/platform/kube/bookinfo.yaml
kubectl apply -f <(istioctl kube-inject -f samples/bookinfo/platform/kube/bookinfo.yaml)
// Do not execute below, if above is executed.
Alternative, setting up Istio in Namespace
kubectl label namespace default istio-injection=enabled
kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
Check BookInfo deployed.
kubectl get services
kubectl get pods
Setup Gateway (Ingress) to BookInfo
kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
export GATEWAY_URL=$(minikube ip):$(kubectl get svc istio-ingressgateway -n istio-system -o 'jsonpath={.spec.ports[0].nodePort}')
kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
Validate BookInfo Running
curl -o /dev/null -s -w "%{http_code}\n" http://${GATEWAY_URL}/productpage
Output should be
200
# If you get 000 or 503, check pods or running.
check solution here:
https://haanmo.blogspot.com/2019/05/productpage-cannot-be-accessed-and_22.html
View BookInfo App
echo "Site page for your browser: http://${GATEWAY_URL}/productpage"
Output should be like,
Site page for your browser: http://192.168.99.100:31380/productpage
Apply default destination rules
Option 1: If you selected option 1
kubectl apply -f samples/bookinfo/networking/destination-rule-all.yaml
Option 2: If you selected option 2
kubectl create -f samples/bookinfo/networking/destination-rule-all-mtls.yaml
kubectl get destinationrules -o yaml
istioctl get destinationrules
kubectl create -f samples/bookinfo/networking/virtual-service-all-v1.yaml
less samples/bookinfo/networking/virtual-service-all-v1.yaml
kubectl get virtualservice -o yaml
check BookInfo App
http://$GATEWAY_URL/productpage
Dynamic Routing
kubectl apply -f samples/bookinfo/networking/virtual-service-reviews-test-v2.yaml
less samples/bookinfo/networking/virtual-service-reviews-test-v2.yaml
kubectl get virtualservice reviews -o yaml
Check BookInfo App again
http://$GATEWAY_URL/productpage
Dynamic Routing with Weights
kubectl apply -f samples/bookinfo/networking/virtual-service-reviews-50-v3.yaml
less samples/bookinfo/networking/virtual-service-reviews-50-v3.yaml
kubectl edit virtualservice reviews
kubectl apply -f samples/bookinfo/networking/virtual-service-reviews-v3.yaml
Collect Metrics
https://istio.io/docs/tasks/telemetry/metrics/collecting-metrics/
# save below as new_metrics.yaml
# Configuration for metric instances
apiVersion: "config.istio.io/v1alpha2"
kind: metric
metadata:
name: doublerequestcount
namespace: istio-system
spec:
value: "2" # count each request twice
dimensions:
reporter: conditional((context.reporter.kind | "inbound") == "outbound", "client", "server")
source: source.workload.name | "unknown"
destination: destination.workload.name | "unknown"
message: '"twice the fun!"'
monitored_resource_type: '"UNSPECIFIED"'
---
# Configuration for a Prometheus handler
apiVersion: "config.istio.io/v1alpha2"
kind: prometheus
metadata:
name: doublehandler
namespace: istio-system
spec:
metrics:
- name: double_request_count # Prometheus metric name
instance_name: doublerequestcount.metric.istio-system # Mixer instance name (fully-qualified)
kind: COUNTER
label_names:
- reporter
- source
- destination
- message
---
# Rule to send metric instances to a Prometheus handler
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
name: doubleprom
namespace: istio-system
spec:
actions:
- handler: doublehandler.prometheus
instances:
- doublerequestcount.metric
---
# Configuration for logentry instances
apiVersion: "config.istio.io/v1alpha2"
kind: logentry
metadata:
name: newlog
namespace: istio-system
spec:
severity: '"warning"'
timestamp: request.time
variables:
source: source.labels["app"] | source.workload.name | "unknown"
user: source.user | "unknown"
destination: destination.labels["app"] | destination.workload.name | "unknown"
responseCode: response.code | 0
responseSize: response.size | 0
latency: response.duration | "0ms"
monitored_resource_type: '"UNSPECIFIED"'
---
# Configuration for a stdio handler
apiVersion: "config.istio.io/v1alpha2"
kind: stdio
metadata:
name: newhandler
namespace: istio-system
spec:
severity_levels:
warning: 1 # Params.Level.WARNING
outputAsJson: true
---
# Rule to send logentry instances to a stdio handler
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
name: newlogstdio
namespace: istio-system
spec:
match: "true" # match for all requests
actions:
- handler: newhandler.stdio
instances:
- newlog.logentry
---
then:
kubectl apply -f new_metrics.yaml
curl http://$GATEWAY_URL/productpage
http://localhost:9090/graph#%5B%7B%22range_input%22%3A%221h%22%2C%22expr%22%3A%22istio_double_request_count%22%2C%22tab%22%3A1%7D%5D
Collect Logs
https://archive.istio.io/v1.0/docs/tasks/telemetry/metrics-logs/
kubectl -n istio-system logs $(kubectl -n istio-system get pods -l istio-mixer-type=telemetry -o jsonpath='{.items[0].metadata.name}') -c mixer | grep \"instance\":\"newlog.logentry.istio-system\"
# Injecting Faults
https://archive.istio.io/v1.0/docs/tasks/traffic-management/fault-injection/
kubectl apply -f samples/bookinfo/networking/virtual-service-all-v1.yaml
kubectl apply -f samples/bookinfo/networking/virtual-service-reviews-test-v2.yaml
# 1. Injecting an Http Delay Fault
kubectl apply -f samples/bookinfo/networking/virtual-service-ratings-test-delay.yaml
kubectl get virtualservice ratings -o yaml
Reload BookInfo web app and login to user "jason"
You have to see
"Error fetching product reviews!
Sorry, product reviews are currently unavailable for this book."
# 2. Injecting an HTTP Abort Fault
kubectl apply -f samples/bookinfo/networking/virtual-service-ratings-test-abort.yaml
kubectl get virtualservice ratings -o yaml
Reload BookInfo web app and login to user "jason"
You have to see
"product ratings not available message appears."
kubectl delete svc reviews
Cleanup Environment
# Uninstall Istio
kubectl delete -f samples/bookinfo/platform/kube/bookinfo.yaml
kubectl delete -f install/kubernetes/istio-demo-auth.yaml
# Uninstall Minikube
minikube delete
# temporal
1. routing to one version
kubectl apply -f samples/bookinfo/networking/virtual-service-reviews-v3.yaml
2. routing to two versions with weights
kubectl apply -f samples/bookinfo/networking/virtual-service-reviews-50-v3.yaml
3. routing for jason
kubectl apply -f samples/bookinfo/networking/virtual-service-reviews-test-v2.yaml
댓글 없음:
댓글 쓰기