istio 命名空间bookinfo部署

1、创建命名空间
kubectl create ns bookinfo

2、添加label,开启自动注入proxy
kubectl label ns bookinfo istio-injection=enabled
查看lable
kubectl describe ns bookinfo

3、部署 bookinfo
kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml -n bookinfo

4、获取 pods
kubectl get pod -n bookinfo

5、确认app是否正常
kubectl exec -it $(kubectl get pod -n bookinfo -l app=ratings -o jsonpath=’{.items[0].metadata.name}’) -n bookinfo -c ratings – curl productpage:9080/productpage | grep -o “.*

6、确认集群是否支持 负载均衡
kubectl get svc istio-ingressgateway -n istio-system
如果 EXTERNAL-IP 有值(IP 地址或主机名),则说明您的环境具有可用于 Ingress 网关的外部负载均衡器。如果 EXTERNAL-IP 值是 (或一直是 ),则说明可能您的环境并没有为 Ingress 网关提供外部负载均衡器的功能。在这种情况下,您可以使用 Service 的 node port 方式访问网关
由于使测试环境用的本地k8s集群肯定不支持,本次使用nodeport 方式访问网关,在公有云部署的可以忽略此步骤

7、设置 istio-ingressgateway service 为 node port
kubectl patch service istio-ingressgateway -n istio-system -p ‘{“spec”:{“type”:“NodePort”}}’

8、查看service:
kubectl get svc istio-ingressgateway -n istio-system

9、部署 istio gateway
kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml -n bookinfo

10、查看 gateway:
kubectl get gateway -n bookinfo

11、设置 INGRESS_PORT:
export INGRESS_PORT= ( k u b e c t l − n i s t i o − s y s t e m g e t s e r v i c e i s t i o − i n g r e s s g a t e w a y − o j s o n p a t h = ′ . s p e c . p o r t s [ ? ( @ . n a m e = = " h t t p 2 " ) ] . n o d e P o r t ′ ) e x p o r t I N G R E S S H O S T = (kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}') export INGRESS_HOST= (kubectlnistiosystemgetserviceistioingressgatewayojsonpath=.spec.ports[?(@.name=="http2")].nodePort)exportINGRESSHOST=(kubectl get po -l istio=ingressgateway -n istio-system -o jsonpath=’{.items[0].status.hostIP}’)
export GATEWAY_URL= I N G R E S S H O S T : INGRESS_HOST: INGRESSHOST:INGRESS_PORT

12、查看访问地址
echo $GATEWAY_URL

13、验证可以外网访问
curl -s http://${GATEWAY_URL}/productpage | grep -o “.*
#返回

Simple Bookstore App

14、应用缺省目标规则
#不使用TLS(默认是轮询负载均衡)
kubectl apply -f samples/bookinfo/networking/destination-rule-all.yaml -n bookinfo
#使用TLS
kubectl apply -f samples/bookinfo/networking/destination-rule-all-mtls.yaml -n bookinfo
#reviews设置随机访问策略
kubectl apply -f samples/bookinfo/networking/destination-rule-reviews.yaml -n bookinfo

15、在做完实验,官方例子还提供了清理功能,删除bookinfo的路由规则和应用pod
samples/bookinfo/platform/kube/cleanup.sh

16、确认所有bookinfo涉及的都被删掉
kubectl get virtualservices #-- there should be no virtual services
kubectl get destinationrules #-- there should be no destination rules
kubectl get gateway #-- there should be no gateway
kubectl get pods #-- the Bookinfo pods should be deleted

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值