Istio Bookinfo Task in Minikube


Minikube

Istio 是 service mesh 的一个解决方案,已经有部分大厂开始落地的。本文将会通过官方提供的一个 BookInfo 案例来学习 Istio 的各种操作。

准备

准备开始

安装 Minikube

# brew 直接安装
brew install minikube

export HTTP_PROXY=http://
export HTTPS_PROXY=https://
export NO_PROXY=localhost,127.0.0.1,10.96.0.0/12,192.168.99.0/24,192.168.39.0/24

设置 proxy


export HTTP_PROXY=http://192.168.64.1:7890 HTTPS_PROXY=http://192.168.64.1:7890 ALL_PROXY=socks5://192.168.64.1:7891 NO_PROXY=localhost,127.0.0.1,10.96.0.0/12,192.168.64.0/24

export HTTP_PROXY=http://192.168.64.1:7890 HTTPS_PROXY=http://192.168.64.1:7890 ALL_PROXY=socks5://192.168.64.1:7891 NO_PROXY=localhost,127.0.0.1,10.96.0.0/12,192.168.64.0/24

export SS_ADDR=192.168.64.1
export SS_HTTP_PORT=7890
export SS_SOCKET_PORT=7891

export HTTP_PROXY=http://$SS_ADDR:$SS_HTTP_PORT
export HTTPS_PROXY=http://$SS_ADDR:$SS_HTTP_PORT
export ALL_PROXY=socks5://$SS_ADDR:$SS_SOCKET_PORT
export NO_PROXY=localhost,127.0.0.1,10.0.0.0/8,192.168.0.0/16


export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7891

unset SS_ADDR
unset SS_HTTP_PORT
unset SS_SOCKET_PORT
unset HTTP_PROXY
unset HTTPS_PROXY
unset NO_PROXY

minikube docker-env HTTP_PROXY=http://$SS_ADDR:$SS_HTTP_PORT HTTPS_PROXY=http://192.168.64.1:7890 ALL_PROXY=socks5://192.168.64.1:7891 NO_PROXY=localhost,127.0.0.1,10.96.0.0/12,192.168.64.0/24

minikube docker-env HTTPS_PROXY=http://192.168.64.1:7890

minikube config set cpus 8
minikube config set memory 10000
minikube config set  disk-size 100GB

minikube delete --all
minikube start --kubernetes-version=1.16.9

minikube start --memory=16384 --cpus=8 --kubernetes-version=1.18.2

minikube start --docker-env http_proxy=http://192.168.64.1:7890 \
                 --docker-env https_proxy=https://192.168.64.1:7890

kubectl create deployment hello-minikube1 --image=k8s.gcr.io/echoserver:1.4
kubectl expose deployment hello-minikube1 --type=LoadBalancer --port=8080
kubectl expose deployment kiali --type=LoadBalancer --port=8081
kubectl expose deployment dashboard-metrics-scraper --type=LoadBalancer --port10081


kubectl expose deployment productpage-v1 --type=LoadBalancer --port=9080
minikube service

Istio

curl -L https://git.io/getLatestIstio | sh -
cd istio-1.5.4 
export PATH=$PWD/bin:$PATH
istioctl manifest apply --set profile=demo
  • 设置自动注入Sidecar.
kubectl label namespace default istio-injection=enabled
  • 部署应用
kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
  • 配置 Ingress 网关
kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml

提示如果遇到网络问题 image pull 不下来可以在本地 pull 镜像,再用 minikube 推到 kubernetes 上

Events:
  Type    Reason     Age        From               Message
  ----    ------     ----       ----               -------
  Normal  Scheduled    default-scheduler  Successfully assigned default/details-v1-6fc55d65c9-fn745 to minikube
  Normal  Pulled     63s        kubelet, minikube  Container image "docker.io/istio/proxyv2:1.5.4" already present on machine
  Normal  Created    63s        kubelet, minikube  Created container istio-init
  Normal  Started    63s        kubelet, minikube  Started container istio-init
  Normal  Pulling    62s        kubelet, minikube  Pulling image "docker.io/istio/examples-bookinfo-details-v1:1.15.0"
docker pull docker.io/istio/examples-bookinfo-details-v1:1.15.0
docker pull docker.io/istio/examples-bookinfo-productpage-v1:1.15.0
docker pull docker.io/istio/examples-bookinfo-ratings-v1:1.15.0
docker pull docker.io/istio/examples-bookinfo-ratings-v1:1.15.0
docker pull docker.io/istio/examples-bookinfo-reviews-v1:1.15.0
docker pull docker.io/istio/examples-bookinfo-reviews-v2:1.15.0
docker pull docker.io/istio/examples-bookinfo-reviews-v3:1.15.0

docker tag  istio/examples-bookinfo-details-v1 docker.io/istio/examples-bookinfo-details-v1:1.15.0

minikube cahce add docker.io/istio/examples-bookinfo-reviews-v3:1.15.0

dashboard

KUBERNETES_SERVICE_HOST and 
KUBERNETES_SERVICE_PORT must be

export KUBERNETES_SERVICE_HOST=https://192.168.64.8
export KUBERNETES_SERVICE_PORT=8443

  controlz    Open ControlZ web UI
  envoy       Open Envoy admin web UI
  grafana     Open Grafana web UI
  jaeger      Open Jaeger web UI
  kiali       Open Kiali web UI
  prometheus  Open Prometheus web UI
  zipkin      Open Zipkin web UI

配置 Istio Gateway


export INGRESS_HOST=$(minikube ip)
export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}')
export SECURE_INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="https")].nodePort}')

export GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT

echo  GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT
GATEWAY_URL=192.168.64.8:32228

boofinfo

kubectl -n default delete  deployment  --all
kubectl -n default delete  services  --all
kubectl -n default delete  secrets  --all
kubectl -n default delete  gateway  --all
kubectl -n default delete  VirtualService  --all
kubectl -n default delete  DestinationRule  --all


kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml

kubectl get services
kubectl get pods
`kubectl exec -it $(kubectl get pod -l app=ratings -o jsonpath='{.items[0].metadata.name}') -c ratings -- curl productpage:9080/productpage | grep -o "<title>.*</title>"`

kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml


sh samples/bookinfo/platform/kube/cleanup.sh

kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml


  • Benchmark
while true; do
  curl -s http://192.168.64.8:32228/productpage > /dev/null
  echo -n .;
  sleep 0.2
done

Author: Kyle Liu
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source Kyle Liu !
 Current
Istio Bookinfo Task in Minikube Istio Bookinfo Task in Minikube
Kubernetes 的安装非常复杂,本文将会介绍 Deployment YAML 名词解释。
2020-05-17
Next 
Go Modules Tutorial Go Modules Tutorial
Go modules is a officially announced project dependency solution in the Go language. Go modules (formerly known as vgo) were officially released in Go1.11. They are ready for Go1.14 and can be used for production. Go officially encourages all users to migrate from other dependency management tools to Go modules.
2020-02-29
  TOC