我对k8s相对来说是个新手,为了熟悉它,我跟随了tutorial。有一个通过ingress暴露kubernetes-dashboard的例子,我尝试了一下。
通过运行以下命令配置kubernetes-dashboard。根据documentation。kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.6.1/aio/deploy/recommended.yaml
但与教程kubernetes不同的是--dashboard是通过端口443暴露的
service/dashboard-metrics-scraper ClusterIP 10.108.119.138 <none> 8000/TCP 50m
service/kubernetes-dashboard ClusterIP 10.100.58.17 <none> 443/TCP 50m
因此我相应地更改了入口配置yaml。
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
name: ingress-dashboard
namespace: kubernetes-dashboard
spec:
rules:
- host: k8s-dashboard.com
http:
paths:
- pathType: Prefix
path: /
backend:
service:
name: kubernetes-dashboard
port:
number: 443
然后,我描述了入口并获取IP,并在/etc/hosts中为其添加了一个条目
kubectl describe ingress ingress-dashboard -n kubernetes-dashboard
Name: ingress-dashboard
Labels: <none>
Namespace: kubernetes-dashboard
Address: 192.168.49.2
Ingress Class: <none>
Default backend: <default>
Rules:
Host Path Backends
---- ---- --------
k8s-dashboard.com
/ kubernetes-dashboard:443 (172.17.0.6:8443)
Annotations: kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/backend-protocol: HTTPS
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Sync 24m (x2 over 25m) nginx-ingress-controller Scheduled for sync
/etc/hosts更改
192.168.49.2 k8s-dashbaord.com
当试图访问k8s-dashbaord.com时。404 Not Found从nginx找不到因此,它看起来像ingress正在运行,但它无法到达服务。
Map到ingress规则的ip似乎是错误的。(172.17.0.6:8443)。因为这不是服务的IP。
我做错了什么?
P.S.
如果我只是一个代理(kubectl代理)和访问 Jmeter 板,它工作得很好。
1条答案
按热度按时间vqlkdk9b1#
不要忘记在你的URL调用结尾的“/”。我的入口工作很好: