如何在istio中配置入口网关? [英] How to configure ingress gateway in istio?
问题描述
我是istio的新手,我想通过istio入口网关访问我的应用程序,但是我不知道为什么它不起作用.
这是我的kubenetes_deploy.yaml
文件内容:
I'm new to istio, and I want to access my app through istio ingress gateway, but I do not know why it does not work.
This is my kubenetes_deploy.yaml
file content:
apiVersion: v1
kind: Service
metadata:
name: batman
labels:
run: batman
spec:
#type: NodePort
ports:
- port: 8000
#nodePort: 32000
targetPort: 7000
#protocol: TCP
name: batman
selector:
run: batman
#version: v1
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: batman-v1
spec:
replicas: 1
selector:
matchLabels:
run: batman
template:
metadata:
labels:
run: batman
version: v1
spec:
containers:
- name: batman
image: leowu/batman:v1
ports:
- containerPort: 7000
env:
- name: MONGODB_URL
value: mongodb://localhost:27017/articles_demo_dev
- name: mongo
image: mongo
这是我的istio ingress_gateway.yaml
配置文件:
And here is my istio ingress_gateway.yaml
config file:
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: batman-gateway
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 15000
name: http
protocol: HTTP
hosts:
- "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: batman
spec:
hosts:
- "*"
gateways:
- batman-gateway
http:
- match:
route:
- destination:
host: batman
port:
number: 7000
我从示例创建了入口网关,看起来不错,但是当我运行kubectl get svc istio-ingressgateway -n istio-system
时,我在输出中看不到侦听端口15000
.我不知道.
I created the ingress gateway from example, and it looks well but when I run kubectl get svc istio-ingressgateway -n istio-system
I can't see the listening port 15000
in the output。I donot know way.
有没有人可以帮助我?谢谢.
Is there anyone can help me? Thanks.
推荐答案
首先,正如@Abhyudit Jain提到的那样,您需要将VirtualService中的端口更正为8000
First of all, as @Abhyudit Jain mentioned you need to correct port in VirtualService to 8000
然后您只需将另一个端口添加到您的 istio-ingressgateway 服务
And then you just add another port to your istio-ingressgateway service
kubectl edit svc istio-ingressgateway -n istio-system
添加部分:
ports:
- name: http
nodePort: 30001
port: 15000
protocol: TCP
targetPort: 80
这将接受端口 15000 上的HTTP流量,并将其路由到端口 8000
This will accept HTTP traffic on port 15000 and rout it to your destination service on port 8000
简单模式如下:
incoming traffic --> istio-gateway service --> istio-gateway --> virtual service --> service --> pod
这篇关于如何在istio中配置入口网关?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!