azure - 如何使用 Istio Ingress 在 AKS 中公开服务?
问题描述
我曾经使用 Type: LoadBalancer 通过反向代理公开我的服务。没有 Istio,一切正常。但是,当我将 Istio 应用到集群时发生了错误。
我尝试使用 Istio Ingress 在 Kubernetes 中公开我的服务,但我认为在使用 Istio 路由服务时我误解了一些东西。
我在同一个命名空间中有 2 个部署(见下图):
1:应用程序(Bus-id)
2:应用程序的反向代理(Bus-Proxy):将HTTP翻译成gRPC
https://drive.google.com/file/d/1tby9_taJb9WMHi0ssO9Os7MQAWRMga6k/view?usp=sharing
版本:
Kubernetes 版本(启用 RBAC 的 AKS):
客户端版本:v1.15.0
服务器版本:v1.12.8
Istio 版本:1.1.3(AKS 说他们在 1.1.3 上测试过)
舵:
客户端:&version.Version{SemVer:"v2.13.0", GitCommit:"79d07943b03aea2b76c12644b4b54733bc5958d6", GitTreeState:"clean"}
服务器:&version.Version{SemVer:"v2.14.1", GitCommit:"5270352a09c7e8b6e8c9593002a73535276507c0", GitTreeState:"clean"}
我在Istio ( https://istio.io/docs/examples/bookinfo/ ) 中尝试了BookInfo示例,它成功了。
但是,我尝试了AKS中的投票示例(https://docs.microsoft.com/en-us/azure/aks/istio-scenario-routing),我无法使用外部负载均衡器的 IP 访问示例,它重新调整“超时” "
部署文件:
1.bus-id.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: bus-id
namespace: smart-id
labels:
k8s-app: bus-id
spec:
selector:
matchLabels:
k8s-app: bus-id
template:
metadata:
name: bus-id
labels:
k8s-app: bus-id
spec:
containers:
- name: bus-id
image: mydockerhub/mydockerhub:bus-id
ports:
- containerPort: 50001
env:
- name: APP_NAME
value: bus-id
---
apiVersion: v1
kind: Service
metadata:
name: bus-id
namespace: smart-id
labels:
service: bus-id
spec:
ports:
- name: http
port: 50001
targetPort: 50001
protocol: TCP
selector:
k8s-app: bus-id
2. 总线代理.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
k8s-app: bus-proxy
name: bus-proxy
namespace: smart-id
spec:
selector:
matchLabels:
k8s-app: bus-proxy
replicas: 1
template:
metadata:
labels:
k8s-app: bus-proxy
spec:
imagePullSecrets:
- name: duynd
containers:
- image: mydockerhub/mydockerhub:bus-proxy
name: bus-proxy
ports:
- containerPort: 40001
name: http
env:
- name: APP_NAME
value: bus-proxy
---
apiVersion: v1
kind: Service
metadata:
name: bus-proxy
namespace: smart-id
labels:
service: bus-proxy
spec:
ports:
- port: 8080
targetPort: 40001
protocol: TCP
selector:
k8s-app: bus-proxy
3.入口.yaml
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: smartid-gateway
namespace: smart-id
spec:
selector:
istio: ingressgateway # use istio default controller
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: smartid
namespace: smart-id
spec:
hosts:
- "*"
gateways:
- smart-id/smartid-gateway
http:
- match:
- uri:
prefix: /api
route:
- destination:
host: bus-proxy.smart-id.svc.cluster.local
port:
number: 8080
我希望它适用于 ingress-ip:ingress-port/api/my-function (方法 POST)。但是,它返回错误 500,bus-proxy的 POD 也打印日志(我认为请求成功到达bus-proxy,但可以通过bus-id)。
- 我还在 github 上发布了 issue ( https://github.com/istio/istio/issues/16069 )
解决方案
首先,如果您使用 Istio 在 AKS 中运行所有应用程序,我建议您按照 AKS在 Azure Kubernetes Service (AKS) 中安装和使用 Istio 中提供的步骤安装 Istio 。
现在,查看此处提供的 AKS 示例,您需要了解以下内容:
Istio 本身就有代理。因此,您需要选择使用哪个代理或同时使用两个代理,但您需要确保它支持两个代理。
如果您使用 Istio 的代理,那么您还需要为istio-injection
您的应用程序的命名空间启用 ,就像示例一样:
kubectl label namespace voting istio-injection=enabled
此标签指示 Istio 自动将 istio-proxy 作为 sidecar 注入此命名空间中的所有 pod。您应该在 ingress.yaml 中为您的虚拟服务使用正确的网关。
推荐阅读
- typescript - 在 TypeScript 中声明数组类型的最佳方法?
- javascript - 从查询字符串中删除关联数组
- java - 在骆驼中找到错误的路线
- visual-studio-code - 使用 WSL 在 VS 代码中禁用 Git 扩展
- javascript - 如何为也可以包含视频的 wordpress 帖子制作滑块?
- esbuild - esbuild:如何使用 `loader: { '.css': 'text' }` 结合 `minify: true` 将缩小的 CSS 作为嵌入文本?
- c# - 在 EF Core 中为一对一关系定义具有特定列名的实体
- jquery - jQuery日期选择器没有输出
- python - 使用 Python 在 Bot Framework 中使用中间件获取 Bot 响应
- python - MlFlow:找不到使用 api 的运行