docker 桌面上的 istio 入口 404
istio ingress 404 on docker desktop
我一直在尝试 运行 使用 Docker 桌面在 macOS 上的 kubernetes 和 istio 上的本地集群。我使用了 bookinfo 示例,一切正常 运行。
我有自己的一项服务,但我无法将其发送到 运行。我尝试使用邮递员点击它并总是得到 404。
我无法调试它,我可能只是遗漏了一些东西或做了一些愚蠢的事情。
这些是我的 yaml 文件
gateway.yaml
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: reeal-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: reeal
spec:
hosts:
- "*"
gateways:
- reeal-gateway
http:
- match:
- uri:
exact: /feed
route:
- destination:
host: feed
port:
number: 8080
service.yaml
apiVersion: v1
kind: Service
metadata:
name: feed
labels:
app: feed
service: feed
spec:
selector:
app: feed
ports:
- port: 8080
name: http
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: reeal-feed
labels:
account: feed
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: feed-deployment
labels:
app: feed
version: v1
spec:
replicas: 1
selector:
matchLabels:
app: feed
version: v1
template:
metadata:
labels:
app: feed
version: v1
spec:
serviceAccountName: reeal-feed
volumes:
- name: firestore-key
secret:
secretName: firestore-cred
containers:
- name: feed-service
image: reealadmin/feed-service:latest
imagePullPolicy: Always
ports:
- containerPort: 8080
volumeMounts:
- name: firestore-key
mountPath: /var/secrets/google
env:
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /var/secrets/google/key.json
imagePullSecrets:
- name: regcred
我已经通过使用 Nodeport 公开它来测试服务,我可以 curl 并获得相应的响应,但是我犯了一些错误,无法正确配置入口。
URL
我在下面使用 URL。组成的url是localhost/feed
export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].port}')
export SECURE_INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="https")].port}')
export INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
echo $INGRESS_HOST
echo $INGRESS_PORT
echo $SECURE_INGRESS_PORT
错误
[2020-08-22T01:01:05.088Z] "GET /feed HTTP/1.1" 404 - "-" "-" 0 19 29 22 "192.168.65.3" "PostmanRuntime/7.26.3" "e5705c53-6e70-9dbe-b831-764f9c7be63e" "localhost" "10.1.0.41:8080" outbound|8080||feed.default.svc.cluster.local 10.1.0.25:40654 10.1.0.25:8080 192.168.65.3:59050 - -
这里真的需要帮助。
如果您收到 404 错误,这意味着您的应用程序已到达但没有 /feed
页面。
您可以更改您的应用以提供该 contextPath 上的所有内容,或者重写您的 VirtualService:
http:
- match:
- uri:
exact: /feed
rewrite:
uri: /
route:
- destination:
host: feed
port:
number: 8080
我一直在尝试 运行 使用 Docker 桌面在 macOS 上的 kubernetes 和 istio 上的本地集群。我使用了 bookinfo 示例,一切正常 运行。
我有自己的一项服务,但我无法将其发送到 运行。我尝试使用邮递员点击它并总是得到 404。
我无法调试它,我可能只是遗漏了一些东西或做了一些愚蠢的事情。 这些是我的 yaml 文件
gateway.yaml
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: reeal-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: reeal
spec:
hosts:
- "*"
gateways:
- reeal-gateway
http:
- match:
- uri:
exact: /feed
route:
- destination:
host: feed
port:
number: 8080
service.yaml
apiVersion: v1
kind: Service
metadata:
name: feed
labels:
app: feed
service: feed
spec:
selector:
app: feed
ports:
- port: 8080
name: http
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: reeal-feed
labels:
account: feed
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: feed-deployment
labels:
app: feed
version: v1
spec:
replicas: 1
selector:
matchLabels:
app: feed
version: v1
template:
metadata:
labels:
app: feed
version: v1
spec:
serviceAccountName: reeal-feed
volumes:
- name: firestore-key
secret:
secretName: firestore-cred
containers:
- name: feed-service
image: reealadmin/feed-service:latest
imagePullPolicy: Always
ports:
- containerPort: 8080
volumeMounts:
- name: firestore-key
mountPath: /var/secrets/google
env:
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /var/secrets/google/key.json
imagePullSecrets:
- name: regcred
我已经通过使用 Nodeport 公开它来测试服务,我可以 curl 并获得相应的响应,但是我犯了一些错误,无法正确配置入口。
URL
我在下面使用 URL。组成的url是localhost/feed
export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].port}')
export SECURE_INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="https")].port}')
export INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
echo $INGRESS_HOST
echo $INGRESS_PORT
echo $SECURE_INGRESS_PORT
错误
[2020-08-22T01:01:05.088Z] "GET /feed HTTP/1.1" 404 - "-" "-" 0 19 29 22 "192.168.65.3" "PostmanRuntime/7.26.3" "e5705c53-6e70-9dbe-b831-764f9c7be63e" "localhost" "10.1.0.41:8080" outbound|8080||feed.default.svc.cluster.local 10.1.0.25:40654 10.1.0.25:8080 192.168.65.3:59050 - -
这里真的需要帮助。
如果您收到 404 错误,这意味着您的应用程序已到达但没有 /feed
页面。
您可以更改您的应用以提供该 contextPath 上的所有内容,或者重写您的 VirtualService:
http:
- match:
- uri:
exact: /feed
rewrite:
uri: /
route:
- destination:
host: feed
port:
number: 8080