kubernetes-ingress - 如何设置INGRESS_HOST和INGRESS_PORT并访问GATEWAY_URL
问题描述
如何为使用自动边车注入创建其 istio 文件的示例 yaml 文件设置 INGRESS_HOST 和 INGRESS_PORT
我正在使用窗口 10 - Docker - kubernetes -Istio 配置。分别安装了 kubectl、istioctl 版本
apiVersion: v1
kind: Service
metadata:
name: helloworld
labels:
app: helloworld
spec:
ports:
- port: 5000
name: http
selector:
app: helloworld
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: helloworld-v1
labels:
version: v1
spec:
replicas: 1
template:
metadata:
labels:
app: helloworld
version: v1
spec:
containers:
- name: helloworld
image: istio/examples-helloworld-v1
resources:
requests:
cpu: "100m"
imagePullPolicy: Never
ports:
- containerPort: 5000
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: helloworld-v2
labels:
version: v2
spec:
replicas: 1
template:
metadata:
labels:
app: helloworld
version: v2
spec:
containers:
- name: helloworld
image: istio/examples-helloworld-v2
resources:
requests:
cpu: "100m"
imagePullPolicy: Never
ports:
- containerPort: 5000
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: helloworld-gateway
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: helloworld
spec:
hosts:
- "*"
gateways:
- helloworld-gateway
http:
- match:
- uri:
exact: /hello
route:
- destination:
host: helloworld
port:
number: 5
010
尝试访问我创建的示例服务时出现 503 服务暂时不可用
解决方案
请首先验证您的选择器标签是否完美,并且您的服务已连接到部署 [POD]。
您在部署选择器中有“版本:v1”和“版本:v2”,但它不在服务中。这就是服务导致输出 503 不可用的原因。如果 pod 或服务中的问题,那么我将给出 502 bad gateway 或其他东西。
Istio 流量工作就像
ingress-gateway -> virtual-service -> destination-rule [optional] -> service
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: helloworld
spec:
hosts:
- "*"
gateways:
- helloworld-gateway
http:
- match:
- uri:
exact: /hello
route:
- destination:
host: helloworld
port:
number: 5000 <--- change
推荐阅读
- python - 绘制对数似然函数作为 theta1 和 theta2 的函数
- laravel - whereHas 和 whereDoesntHave 在 laravel eloquent 中没有按预期工作
- tensorflow - 不允许迭代 `tf.Tensor`:AutoGraph 确实转换了这个函数。这可能表明您正在尝试使用不受支持的功能
- rust - 如何在 Rust 中保存子图像?
- doctrine-orm - Symfony 4 - 如何订购但 DISTINCT 和第二次订购 - Createquerybuilder?
- assembly - 为什么将 init_task 结构地址保存到 arm64 引导代码 __primary_switched 中的 sp_el0?
- python - 如何执行独特的随机函数
- javascript - 我们如何在 ANT D 列中获取/重新呈现异步数据
- spring - 在 Spring Security 中注销后重定向到外部身份验证时出现 Cors 问题
- python - 如何使用 Discord.py 发送消息