本文介绍了Kubernetes Ingress服务无法加载静态文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在minikube(1.8.0)上为某些服务创建了入口:
I have created ingress for some services on minikube (1.8.0):
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: gateway-ingress
namespace: kube-system
annotations:
ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- backend:
serviceName: api-service
servicePort: 80
path: /api
paths:
- backend:
serviceName: kubernetes-dashboard
servicePort: 80
path: /ui
当我访问MINIKUBE_IP/ui时,仪表板的静态文件不起作用.以下是错误:
When I access MINIKUBE_IP/ui, the static files of dashboard not work. Below are errors:
192.168.99.100/:1 GET https://192.168.99.100/ui/static/vendor.4f4b705f.css net::ERR_ABORTED
192.168.99.100/:5 GET https://192.168.99.100/ui/static/app.8a6b8127.js net::ERR_ABORTED
VM1524:1 GET https://192.168.99.100/ui/api/v1/thirdpartyresource 404 ()
...
谢谢,请帮助我解决此错误.
Please help me to fix this error, thanks.
推荐答案
我遇到了同样的问题.您可以通过在Ingress资源中定义新路径来解决此问题.
I had the same issue.You can solve it by defining new paths in the Ingress resource.
rules:
- http:
paths:
- path: /ui
backend:
serviceName: kubernetes-dashboard
servicePort: 80
- path: /*
backend:
serviceName: kubernetes-dashboard
servicePort: 80
"/*"将允许您访问静态文件.
The "/*" will allow you to access the static files.
其他资源:
- https://github.com/kubernetes/ingress-nginx/issues/333
- https://github.com/kubernetes/contrib/issues/2238
- https://github.com/kubernetes/ingress-nginx/issues/333
- https://github.com/kubernetes/contrib/issues/2238
这篇关于Kubernetes Ingress服务无法加载静态文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!