一.安装k8s docker desktop版 并配置镜像源
二.安装Istio
https://zhuanlan.zhihu.com/p/506007550
1.在github中下载windows版本的istio.exe,解压后 将/bin目录放入path变量中。
2.运行cmd,检查一下 istio 环境以及版本信息:
$ istioctl version
3.开始使用 demo
配置文件进行 Istio 安装:(这一步可能需要科学上网,我设置了全局代理才下载成功)
$ istioctl install --set profile=demo
4.验证是否下载成功
$ kubectl -n istio-system get deploy
NAME READY UP-TO-DATE AVAILABLE AGE
istio-egressgateway 1/1 1 1 9m49s
istio-ingressgateway 1/1 1 1 9m49s
istiod 1/1 1 1 10m
三.部署Online Boutique 应用到k8s
1.git clone Online Boutique项目
2.先不要
kubectl apply -n microservices-demo -f kubernetes-manifests.yaml
可以在https://console.cloud.google.com/gcr/images/google-samples/global/microservices-demo
中找到docker pull命令,在github中创建Dockerfile文件(放在11个目录下),然后用阿里云登录 - 欢迎登录阿里云,安全稳定的云计算服务平台
创建镜像,参考国内顺畅下载k8s.gcr.io的镜像_上海_运维_Q先生的博客-CSDN博客_https://k8s.gcr.io/v2/
3.然后
docker pull registry.cn-hangzhou.aliyuncs.com/lusilin/checkoutservice:0.3.7
docker pull registry.cn-hangzhou.aliyuncs.com/lusilin/adservice:0.3.7
docker pull registry.cn-hangzhou.aliyuncs.com/lusilin/cartservice:0.3.7
docker pull registry.cn-hangzhou.aliyuncs.com/lusilin/currencyservice:0.3.7
docker pull registry.cn-hangzhou.aliyuncs.com/lusilin/emailservice:0.3.7
docker pull registry.cn-hangzhou.aliyuncs.com/lusilin/frontend:0.3.7
docker pull registry.cn-hangzhou.aliyuncs.com/lusilin/loadgenerator:0.3.7
docker pull registry.cn-hangzhou.aliyuncs.com/lusilin/paymentservice:0.3.7
docker pull registry.cn-hangzhou.aliyuncs.com/lusilin/productcatalogservice:0.3.7
docker pull registry.cn-hangzhou.aliyuncs.com/lusilin/recommendationservice:0.3.7
docker pull registry.cn-hangzhou.aliyuncs.com/lusilin/shippingservice:0.3.7
docker tag registry.cn-hangzhou.aliyuncs.com/lusilin/checkoutservice:0.3.7 gcr.io/google-samples/microservices-demo/checkoutservice:v0.3.7
docker tag registry.cn-hangzhou.aliyuncs.com/lusilin/adservice:0.3.7 gcr.io/google-samples/microservices-demo/adservice:v0.3.7
docker tag registry.cn-hangzhou.aliyuncs.com/lusilin/cartservice:0.3.7 gcr.io/google-samples/microservices-demo/cartservice:v0.3.7
docker tag registry.cn-hangzhou.aliyuncs.com/lusilin/currencyservice:0.3.7 gcr.io/google-samples/microservices-demo/currencyservice:v0.3.7
docker tag registry.cn-hangzhou.aliyuncs.com/lusilin/emailservice:0.3.7 gcr.io/google-samples/microservices-demo/emailservice:v0.3.7
docker tag registry.cn-hangzhou.aliyuncs.com/lusilin/frontend:0.3.7 gcr.io/google-samples/microservices-demo/frontend:v0.3.7
docker tag registry.cn-hangzhou.aliyuncs.com/lusilin/loadgenerator:0.3.7 gcr.io/google-samples/microservices-demo/loadgenerator:v0.3.7
docker tag registry.cn-hangzhou.aliyuncs.com/lusilin/paymentservice:0.3.7 gcr.io/google-samples/microservices-demo/paymentservice:v0.3.7
docker tag registry.cn-hangzhou.aliyuncs.com/lusilin/productcatalogservice:0.3.7 gcr.io/google-samples/microservices-demo/productcatalogservice:v0.3.7
docker tag registry.cn-hangzhou.aliyuncs.com/lusilin/recommendationservice:0.3.7 gcr.io/google-samples/microservices-demo/recommendationservice:v0.3.7
docker tag registry.cn-hangzhou.aliyuncs.com/lusilin/shippingservice:0.3.7 gcr.io/google-samples/microservices-demo/shippingservice:v0.3.7
4.创建namespace,并为 POD 额外注入一个 SideCar 应用,可以手动注入,也可以为整个命名空间添加 istio-injection=enabled
标签实现自动注入。
kubectl create ns microservices-demo
kubectl label ns microservices-demo istio-injection=enabled
5.在git clone 下来的目录下打开cmd,部署应用
kubectl apply -f ./release/kubernetes-manifests.yaml --namespace=microservices-demo
查看部署的pod情况 ,可以看到已经注入了SideCar。
kubectl get pod -n microservices-demo
NAME READY STATUS RESTARTS AGE
adservice-cf67f4d57-k5gp7 2/2 Running 0 99s
cartservice-659768978f-x6lh4 2/2 Running 2 (82s ago) 100s
checkoutservice-685bbcccbc-bfgxp 2/2 Running 0 100s
currencyservice-6f8b7fc7f9-2jkdl 2/2 Running 0 99s
emailservice-594db85977-fqlxm 2/2 Running 0 100s
frontend-67fbdd4fc-z9xbt 2/2 Running 0 100s
loadgenerator-557cf6649-8wfcc 2/2 Running 0 100s
paymentservice-85cc844df-dccm2 2/2 Running 0 100s
productcatalogservice-7f989bc99-4fb7m 2/2 Running 0 100s
recommendationservice-68878fdf99-nljc7 2/2 Running 0 100s
redis-cart-7667674fc7-98kvz 2/2 Running 0 99s
shippingservice-5cd69dd957-5gkh4 2/2 Running 0 99s
6.查看service,并将frontend-external pod删除。
>kubectl get svc -n microservices-demo
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
adservice ClusterIP 10.101.92.180 <none> 9555/TCP 2m23s
cartservice ClusterIP 10.108.36.16 <none> 7070/TCP 2m23s
checkoutservice ClusterIP 10.110.200.229 <none> 5050/TCP 2m23s
currencyservice ClusterIP 10.99.11.2 <none> 7000/TCP 2m23s
emailservice ClusterIP 10.106.13.19 <none> 5000/TCP 2m23s
frontend ClusterIP 10.96.232.105 <none> 80/TCP 2m23s
frontend-external LoadBalancer 10.111.167.114 <pending> 80:30370/TCP 2m23s
paymentservice ClusterIP 10.99.191.39 <none> 50051/TCP 2m23s
productcatalogservice ClusterIP 10.108.236.225 <none> 3550/TCP 2m23s
recommendationservice ClusterIP 10.111.210.14 <none> 8080/TCP 2m23s
redis-cart ClusterIP 10.107.242.161 <none> 6379/TCP 2m23s
shippingservice ClusterIP 10.98.109.70 <none> 50051/TCP 2m23s
>kubectl delete svc frontend-external -n microservices-demo
7.查看istio-manifests.yaml,可以看到它提供的tcp端口 80 文章来源:https://www.toymoban.com/news/detail-493813.html
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: frontend-gateway
spec:
selector:
istio: ingressgateway # use Istio default gateway implementation
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "*"
8.打开127.0.0.1:80,可以看到完成部署文章来源地址https://www.toymoban.com/news/detail-493813.html
到了这里,关于部署Online Boutique 项目在 Kubernetes并启用 Istio 支持的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!