有人能解释一下如何在“前端”服务上设置外部Ip吗?我知道Vagrant不支持“类型: LoadBalancer”,而我不知道如何向我的主机公开一个Ip地址。谢谢
发布于 2016-03-11 07:09:53
首先,您应该在guestbook服务定义中更改您的服务类型:
diff --git a/guestbook-service.json b/guestbook-service.json
index cc7640e..fadef78 100644
--- a/guestbook-service.json
+++ b/guestbook-service.json
@@ -17,6 +17,6 @@
"selector":{
"app":"guestbook"
},
- "type": "LoadBalancer"
+ "type": "NodePort"
}
}然后使用以下命令停止并重新启动服务:
kubectl delete -f guestbook-service.json
kubectl create -f guestbook-service.json使用以下命令查看您的节点IP地址:
kubectl get nodes例如,对我来说,结果是:
$ kubectl get nodes
NAME LABELS STATUS AGE
172.17.4.99 kubernetes.io/hostname=172.17.4.99 Ready 3h最后,您可以使用以下命令找到您的服务节点报告:
kubectl describe services guestbook例如,对我来说,结果是:
$ kubectl describe services guestbook
Name: guestbook
Namespace: default
Labels: app=guestbook
Selector: app=guestbook
Type: NodePort
IP: 10.3.0.47
Port: <unnamed> 3000/TCP
NodePort: <unnamed> 32757/TCP
Endpoints: 10.2.76.12:3000,10.2.76.8:3000,10.2.76.9:3000
Session Affinity: None
No events.此时,使用您之前获得的节点IP和您刚刚找到的NodePort,您应该能够连接:
$ curl 172.17.4.99:32757
<!DOCTYPE html>
<html lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta charset="utf-8">
<meta content="width=device-width" name="viewport">
<link href="/style.css" rel="stylesheet">
<title>Guestbook</title>
[...]注意: NodePort通常是从配置了标志的范围分配的,默认是30000-32767。
发布于 2016-02-02 12:15:46
尝试键入"NodePort“:
https://github.com/kubernetes/kubernetes/blob/master/docs/user-guide/services.md#type-nodeport
然后在分配的端口上使用您的流浪虚拟机的IP地址。
https://stackoverflow.com/questions/34352085
复制相似问题