wordpress 作品集网站,怎么做淘宝客网站推广,网站维护更新,台州行app官网下载1. Istio Gateway发布服务
在集群中部署一个 tomcat 应用程序。然后将部署一个 Gateway 资源和一个与 Gateway 绑定的 VirtualService#xff0c;以便在外部 IP 地址上公开该应用程序。
1.1 部署 Gateway 资源
vim ingressgateway.yaml
---
apiVersion: networking.istio.…1. Istio Gateway发布服务
在集群中部署一个 tomcat 应用程序。然后将部署一个 Gateway 资源和一个与 Gateway 绑定的 VirtualService以便在外部 IP 地址上公开该应用程序。
1.1 部署 Gateway 资源
vim ingressgateway.yaml
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:name: ingressgateway80
spec:selector:istio: ingressgatewayservers:- port:number: 80name: httpprotocol: HTTPhosts:- * 把 hosts 字段设置为 *可以直接从外部 IP 地址访问入口网关。 1.2 部署Tomcat 应用
拉取所需的镜像
docker pull tomcat:latest
docker save tomcat:latest -o tomcat-latest.img
docker load tomcat-latest.img部署tomcat vim tomcat.yaml
---
apiVersion: apps/v1
kind: Deployment
metadata:creationTimestamp: nulllabels:app: tomcatname: tomcat
spec:replicas: 1selector:matchLabels:app: tomcatstrategy: {}template:metadata:creationTimestamp: nulllabels:app: tomcatspec:containers:- image: tomcat:latestimagePullPolicy: IfNotPresentname: tomcatports:- containerPort: 8080resources: {}
status: {}kubectl apply -f tomcat.yamldeployment创建成功并且有两个容器在运行。一个是 Envoy sidecar 代理第二个是应用程序tomcat。如下
1.3 部署Tomcat service
vim tomcat.yaml
---
apiVersion: v1
kind: Service
metadata:creationTimestamp: nulllabels:app: tomcatname: tomcat
spec:ports:- port: 80name: tcpprotocol: TCPtargetPort: 8080selector:app: tomcat
status:loadBalancer: {}创建service
kubectl apply -f service.yaml1.4 部署VirtualService
为 tomcat 服务创建一个 VirtualService并将其绑定到 Gateway 资源上 vim virtualservice.yaml
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:name: virtualservice
spec:hosts:- *gateways:- ingressgatewayhttp:- route:- destination:host: tomcat.default.svc.cluster.localport:number: 80
创建virtualservice
kubectl apply -f virtualservice.yaml在 hosts 字段中使用 *就像我们在 Gateway 中做的那样。我们还将之前创建的 Gateway 资源gateway添加到 gateways 数组中。最后我们指定了一个目的地为 Kubernetes 服务 tomcat.default.svc.cluster.local 的单一路由。 kubectl get svc -l istioingressgateway -n istio-system如果 EXTERNAL-IP 有值IP 地址或主机名则说明环境具有可用于 Ingress 网关的外部负载均衡器。如果 EXTERNAL-IP 值是 或一直是 则说明的环境并没有为 Ingress 网关提供外部负载均衡器的功能。 可以通过以下方法添加外部IP
kubectl edit service istio-ingressgateway -n istio-system添加externalIPs此处填在为master的IP地址 重新查看有地址了 对 GATEWAY_URL 运行 cURL 或在浏览器中打开它我们将得到 tomcat 的响应如下 另外注意到 server 头设置为 istio-envoy告诉我们该请求通过了 Envoy 代理。 1.4 清理资源
删除 Deployment、Service、VirtualService 和 Gateway
kubectl delete deployments tomcat
kubectl delete service tomcat
kubectl delete virtualservice virtualservice
kubectl delete gateways ingressgateway2. 参考文献
https://www.cnblogs.com/renshengdezheli/p/16838966.html https://blog.csdn.net/weixin_41709748/article/details/122695478 https://developer.aliyun.com/article/886726 https://www.bookstack.cn/read/istio-handbook/best-practices-how-to-implement-ingress-gateway.md https://www.cnblogs.com/boshen-hzb/p/10679863.html https://istio.io/latest/zh/docs/tasks/traffic-management/ingress/ingress-control/