TL; DR;
如何通过Hyper-V从主机连接到我的kubernetes集群,并连接到Kubernetes代理(kube-proxy)。
因此,我使用两个Ubuntu 18.04.1 LTS服务器进行了Hyper-v设置。完全相同的设置。
一个是大师
OS Image: Ubuntu 18.04.1 LTS
Operating System: linux
Architecture: amd64
Container Runtime Version: docker://18.6.0
Kubelet Version: v1.11.1
Kube-Proxy Version: v1.11.1
另一个节点:
OS Image: Ubuntu 18.04.1 LTS
Operating System: linux
Architecture: amd64
Container Runtime Version: docker://18.6.0
Kubelet Version: v1.11.1
Kube-Proxy Version: v1.11.1
默认情况下,这些Pod正在运行:
kube-system coredns-78fcdf6894-6ld8l 1/1 Running 1 4h
kube-system coredns-78fcdf6894-ncp79 1/1 Running 1 4h
kube-system etcd-node1 1/1 Running 1 4h
kube-system kube-apiserver-node1 1/1 Running 1 4h
kube-system kube-controller-manager-node1 1/1 Running 1 4h
kube-system kube-proxy-942xh 1/1 Running 1 4h
kube-system kube-proxy-k6jl4 1/1 Running 1 4h
kube-system kube-scheduler-node1 1/1 Running 1 4h
kube-system kubernetes-dashboard-6948bdb78-9fbv8 1/1 Running 0 25m
kube-system weave-net-fzj8h 2/2 Running 2 3h
kube-system weave-net-s648g 2/2 Running 3 3h
这两个节点通过两个IP地址暴露给我的局域网:
192.168.1.116
192.168.1.115
我已经公开了部署:
service.yml
:
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
type: NodePort # internal cluster management
ports:
- port: 80 # container port
nodePort: 30001 # outside port
protocol: TCP
targetPort: http
selector:
app: my-api
tier: backend
列出:
$ kubectl get svc -o wide
my-service NodePort 10.105.166.48 <none> 80:30001/TCP 50m app=my-api,tier=backend
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 4h <none>
如果我坐在主节点上并卷曲豆荚
$ kubectl get pods -o wide
my-api-86db46fc95-2d6wf 1/1 Running 0 22m 10.32.0.7 node2
$ curl 10.32.0.7:80/api/health
{"success": true}
我的api很明显在豆荚里。
当我查询服务IP
$ curl 10.105.166.48:80/api/health
OR
$ curl 10.105.166.48:30001/api/health
只是超时
我的主服务器的网络配置:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.116 netmask 255.255.255.0 broadcast 192.168.1.255
weave: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1376
inet 10.40.0.0 netmask 255.240.0.0 broadcast 10.47.255.255
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
我的iptables只是将所有内容都列为source anywhere
destination anywhere
,其中包含大量的KUBE和DOCKER引用。
我什至尝试将dashboard设置为无效...
访问网址:
https://192.168.1.116:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/
执行nslookup
不会显示主机名:
$ nslookup my-service
Server: 127.0.0.53
Address: 127.0.0.53#53
** server can't find eyemenu-api-service: SERVFAIL
答案 0 :(得分:1)
要访问节点端口30001,您需要使用节点的ip。
curl nodeip:30001 / api / health
群集中的Pod不知道节点端口30001。
nodePort会将端口公开给kubernetes集群的所有工作节点,因此您可以使用以下任何一种方式:
卷曲node1:30001 / api / health或 卷曲node2:30001 / api / health