【发布时间】:2019-05-03 05:37:56
【问题描述】:
我无法从外部访问我的服务。 首先,这是我的 conf yaml 文件:
nginx-pod.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-nginx
namespace: development
spec:
selector:
matchLabels:
app: my-nginx
replicas: 2
template:
metadata:
labels:
app: my-nginx
spec:
containers:
- name: my-nginx
image: nginx:1.7.9
ports:
- containerPort: 80
nginx-service.yaml
apiVersion: v1
kind: Service
metadata:
name: nginx-service
namespace: development
spec:
type: LoadBalancer
selector:
app: my-nginx
ports:
- name: http
port: 80
targetPort: 80
protocol: TCP
metallb-config.yaml
apiVersion: v1
kind: ConfigMap
metadata:
namespace: metallb-system
name: config
data:
config: |
address-pools:
- name: default
protocol: layer2
addresses:
- 51.15.41.227-51.15.41.227
然后我创建了集群。命令kubectl get all -o wide 打印:
Everythink 没问题,还有kubectl describe service/nginx-service 打印:
Name: nginx-service
Namespace: development
Labels:
Annotations:
Selector: app=my-nginx
Type: LoadBalancer
IP: 10.100.63.177
LoadBalancer Ingress: 51.15.41.227
Port: http 80/TCP
TargetPort: 80/TCP
NodePort: http 30883/TCP
Endpoints: 10.244.0.16:80,10.244.1.4:80
Session Affinity: None
External Traffic Policy: Cluster
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal IPAllocated 56m metallb-controller Assigned IP "51.15.41.227"
主服务器curl 51.15.41.227 中的Curl 命令打印Welcome to nginx blablabla。接下来我尝试从另一个网络打开,它不起作用,但是我添加了它工作的节点端口 curl 51.15.41.227:30883。这一切都是我在裸机上完成的。我预计来自外部主机的curl 51.15.41.227 应该会达到结果。
我做错了什么?
【问题讨论】:
标签: docker nginx kubernetes