1、设置label
kubectl label namespace default istio-injection=enabled
error: 'istio-injection' already has a value (enabled), and --overwrite is false
2、部署bookinfo
kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
service/details created
deployment.extensions/details-v1 created
service/ratings created
deployment.extensions/ratings-v1 created
service/reviews created
deployment.extensions/reviews-v1 created
deployment.extensions/reviews-v2 created
deployment.extensions/reviews-v3 created
service/productpage created
deployment.extensions/productpage-v1 created
备注:手工Sidecar注入命令:
kubectl apply -f <(istioctl kube-inject -f samples/bookinfo/platform/kube/bookinfo.yaml)
3、定义gateway
kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
gateway.networking.istio.io/bookinfo-gateway created
virtualservice.networking.istio.io/bookinfo created
4、确认
kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
details ClusterIP 10.100.16.52 <none> 9080/TCP 3m
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 57m
productpage ClusterIP 10.109.131.28 <none> 9080/TCP 3m
ratings ClusterIP 10.99.51.210 <none> 9080/TCP 3m
reviews ClusterIP 10.103.39.35 <none> 9080/TCP 3m
kubectl get pods
NAME READY STATUS RESTARTS AGE
details-v1-6764bbc7f7-4xn7n 2/2 Running 0 3m
productpage-v1-54b8b9f55-zxffs 2/2 Running 0 3m
ratings-v1-7bc85949-q8lbp 2/2 Running 0 3m
reviews-v1-fdbf674bb-zgsrg 2/2 Running 0 3m
reviews-v2-5bdc5877d6-h5n6t 2/2 Running 0 3m
reviews-v3-dd846cc78-m9pwz 2/2 Running 0 3m
kubectl get gateway
NAME AGE
bookinfo-gateway 1m
5、确认Node Port时ingress 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}')
echo $INGRESS_PORT
31380
echo $SECURE_INGRESS_PORT
31390
6、设置GATEWAY_URL
export GATEWAY_URL=172.16.33.151:$INGRESS_PORT
7、确认运用正常运行中
# curl -o /dev/null -s -w "%{http_code}\n" http://${GATEWAY_URL}/productpage
200