我在我的3個virtualbox虛擬機上安裝了kubernetes集羣。 3 vms全部運行Ubuntu14.04並禁用ufw。 Kubernetes versin是1.6。這裏是我的配置文件,用於創建pod和服務。Kubernetes節點端口無法成功公開
波德pod.yaml
:
apiVersion: v1
kind: ReplicationController
metadata:
name: frontend
labels:
name: frontend
spec:
replicas: 3
selector:
name: frontend
template:
metadata:
labels:
name: frontend
spec:
imagePullSecrets:
- name: regsecret
containers:
- name: frontend
image: hub.allinmoney.com/kubeguide/guestbook-php-frontend
env:
- name: GET_HOSTS_FROM
value: env
ports:
- containerPort: 80
服務service.yaml
:
apiVersion: v1
kind: Service
metadata:
name: frontend
labels:
name: frontend
spec:
type: NodePort
ports:
- port: 80
targetPort: 31000
nodePort: 31000
selector:
name: frontend
我創建NodePort
類型的服務。當我運行命令kubectl create -f service.yaml
,它輸出像下面,我無法找到任何KUBE節點暴露的端口31000:
You have exposed your service on an external port on all nodes in your
cluster. If you want to expose this service to the external internet, you may
need to set up firewall rules for the service port(s) (tcp:31000) to serve traffic.
See http://releases.k8s.io/release-1.3/docs/user-guide/services-firewalls.md for more details.
誰能告訴如何解決這個或者給我任何提示?
嘗試將targetPort設置爲80 – JazzCat
kube-system是否在節點上運行?你可以發佈'iptables-save'的輸出嗎? –