【发布时间】:2021-05-16 11:38:24
【问题描述】:
我无法应用入口配置。
我需要通过它的 DNS 访问 jupyter-lab 服务
已部署到 3 节点裸机 k8s 集群
- node1.local(主)
- node2.local (worker)
- node3.local (worker)
Flannel 被安装为网络控制器
我已经为这样的裸机安装了 nginx 入口
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.44.0/deploy/static/provider/baremetal/deploy.yaml
部署时,jupyter-lab pod 位于 node2 上,NodePort 服务从 http://node2.local:30004 正确响应(见下文)
我希望 ingress-nginx 控制器会通过其 DNS 名称公开 ClusterIP 服务......这就是我所需要的,是不是错了?
这是 CIP 服务,使用对称端口 8888 定义尽可能简单(有错吗?)
---
apiVersion: v1
kind: Service
metadata:
name: jupyter-lab-cip
namespace: default
spec:
type: ClusterIP
ports:
- port: 8888
targetPort: 8888
selector:
app: jupyter-lab
-
DNS 名称
jupyter-lab.local解析为集群的 IP 地址范围,但超时无响应。Failed to connect to jupyter-lab.local port 80: No route to host -
firewall-cmd --list-all表示每个节点的80端口都是开放的
这是 http 进入集群(任何节点)端口 80 的入口定义。(错了吗?)
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: jupyter-lab-ingress
annotations:
# nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io: /
spec:
rules:
- host: jupyter-lab.local
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: jupyter-lab-cip
port:
number: 80
这是部署
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: jupyter-lab-dpt
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: jupyter-lab
template:
metadata:
labels:
app: jupyter-lab
spec:
volumes:
- name: jupyter-lab-home
persistentVolumeClaim:
claimName: jupyter-lab-pvc
containers:
- name: jupyter-lab
image: docker.io/jupyter/tensorflow-notebook
ports:
- containerPort: 8888
volumeMounts:
- name: jupyter-lab-home
mountPath: /var/jupyter-lab_home
env:
- name: "JUPYTER_ENABLE_LAB"
value: "yes"
我可以通过它的NodePort http://node2:30004 使用这个定义成功访问jupyter-lab:
---
apiVersion: v1
kind: Service
metadata:
name: jupyter-lab-nodeport
namespace: default
spec:
type: NodePort
ports:
- port: 10003
targetPort: 8888
nodePort: 30004
selector:
app: jupyter-lab
如何在http://jupyter-lab.local 访问我的 jupyter-lab ???
- 命令
kubectl get endpoints -n ingress-nginx ingress-nginx-controller-admission返回:
ingress-nginx-controller-admission 10.244.2.4:8443 15m
我是否错误配置了端口?
我的“selector:appname”定义有错吗?
我错过了一部分吗
如何调试发生了什么?
其他细节
-
应用入口
kubectl apply -f default-ingress.yml时出现此错误Error from server (InternalError): error when creating "minnimal-ingress.yml": Internal error occurred: failed calling webhook "validate.nginx.ingress.kubernetes.io": Post "https://ingress-nginx-contr oller-admission.ingress-nginx.svc:443/networking/v1beta1/ingresses?timeout=10s": context deadline exceeded这个命令
kubectl delete validatingwebhookconfigurations --all-namespaces删除了验证 webhook ...这样做有错吗? -
我已经在集群中的每个节点上打开了 8443 端口
【问题讨论】:
-
您是否检查了端口 8443 是否从当前运行入口控制器 Pod 的节点打开?
-
kubectl get endpoints -n ingress-nginx ingress-nginx-controller-admission是否在 ENDPOINTS 列中显示任何 IP 地址? -
我设法通过删除验证 webhook 取得了进展。
kubectl get validatingwebhookconfigurations --all-namespaceskubectl delete validatingwebhookconfigurations但是还是没有反应@jupyter-lab.local集群已经重置,我会试试这些建议 -
@AndD 8443 在所有节点上都打开
-
@Matt 是的,在 ENDPOINTS 列中有一个 ip 地址,(见上文)
标签: kubernetes nginx-ingress ingress-nginx