作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下应用程序,我能够成功地在 K8S 中运行它使用类型负载均衡器的服务,非常简单的应用程序有两条路线
/
- 你应该看到“你好应用程序”/api/books
应提供 json 格式的图书列表 service
apiVersion: v1
kind: Service
metadata:
name: go-ms
labels:
app: go-ms
tier: service
spec:
type: LoadBalancer
ports:
- port: 8080
selector:
app: go-ms
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: go-ms
labels:
app: go-ms
spec:
replicas: 2
template:
metadata:
labels:
app: go-ms
tier: service
spec:
containers:
- name: go-ms
image: rayndockder/http:0.0.2
ports:
- containerPort: 8080
env:
- name: PORT
value: "8080"
resources:
requests:
memory: "64Mi"
cpu: "125m"
limits:
memory: "128Mi"
cpu: "250m"
http://b0751-1302075110.eu-central-1.elb.amazonaws.com/api/books
istio
,所以我按照指南并通过
helm
成功安装了它
istio-system
组件(例如
istio-ingressgateway
istio-pilot
等所有 8 个部署都已启动并正在运行)
LoadBalancer
更改为至
NodePort
istio
根据 istio 文档进行配置
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: http-gateway
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 8080
name: http
protocol: HTTP
hosts:
- "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: virtualservice
spec:
hosts:
- "*"
gateways:
- http-gateway
http:
- match:
- uri:
prefix: "/"
- uri:
exact: "/api/books"
route:
- destination:
port:
number: 8080
host: go-ms
kubectl label namespace books istio-injection=enabled
应用程序的部署位置,
kubectl get svc -n istio-system -l istio=ingressgateway
external-ip
中获取此信息
b0751-1302075110.eu-central-1.elb.amazonaws.com
尝试访问 URL 时
http://b0751-1302075110.eu-central-1.elb.amazonaws.com/api/books
ERR_CONNECTION_TIMED_OUT
rayndockder/http:0.0.2
通过
docker run -it -p 8080:8080 httpv2
istio
配置以查看是否缺少某些内容,或者我们是否与端口或网络策略有一些勾结?
80
(在所有 yaml 文件、应用程序和 docker 中)我能够获取根路径的数据,但不能获取“api/books”的数据
最佳答案
我在 kubernetes 和 istio 的本地 minikube 设置中将网关端口从 8080 修改为 80,这让您的配置感到厌烦。这是我使用的命令:
kubectl apply -f - <<EOF
apiVersion: v1
kind: Service
metadata:
name: go-ms
labels:
app: go-ms
tier: service
spec:
ports:
- port: 8080
selector:
app: go-ms
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: go-ms
labels:
app: go-ms
spec:
replicas: 2
template:
metadata:
labels:
app: go-ms
tier: service
spec:
containers:
- name: go-ms
image: rayndockder/http:0.0.2
ports:
- containerPort: 8080
env:
- name: PORT
value: "8080"
resources:
requests:
memory: "64Mi"
cpu: "125m"
limits:
memory: "128Mi"
cpu: "250m"
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: http-gateway
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: go-ms-virtualservice
spec:
hosts:
- "*"
gateways:
- http-gateway
http:
- match:
- uri:
prefix: /
- uri:
exact: /api/books
route:
- destination:
port:
number: 8080
host: go-ms
EOF
关于amazon-web-services - istio - 使用 vs 服务和 gw 代替负载均衡器不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56314859/
我是一名优秀的程序员,十分优秀!