hostPort not working in cluster created via kubeadm
mikedanese opened this issue · 3 comments
From @linfan on October 30, 2016 16:26
Is this a request for help? (If yes, you should use our troubleshooting guide and community support channels, see http://kubernetes.io/docs/troubleshooting/.): No
What keywords did you search in Kubernetes issues before filing this one? (If you have found any duplicates, you should instead reply there.): nodePort, kubeadm
Is this a BUG REPORT or FEATURE REQUEST? (choose one): BUG REPORT
Kubernetes version (use kubectl version):
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"4", GitVersion:"v1.4.3", GitCommit:"4957b090e9a4f6a68b4a40375408fdc74a212260", GitTreeState:"clean", BuildDate:"2016-10-16T06:36:33Z", GoVersion:"go1.6.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"4", GitVersion:"v1.4.5", GitCommit:"5a0a696437ad35c133c0c8493f7e9d22b0f9b81b", GitTreeState:"clean", BuildDate:"2016-10-29T01:32:42Z", GoVersion:"go1.6.3", Compiler:"gc", Platform:"linux/amd64"}
Environment:
- Cloud provider or hardware configuration: AWS
- OS (e.g. from ca): Ubuntu 16.04.1 LTS
- Kernel (e.g.
uname -a): 4.4.0-31-generic x86_64 GNU/Linux - Install tools: kubeadm
- Others: single node cluster, with calico network plugin
What happened:
nodePort attribute in pod does not map container port to host.
What you expected to happen:
Yaml file like:
ports:
- containerPort: 80
hostPort: 80
should expose the container port 80 to host port 80.
How to reproduce it (as minimally and precisely as possible):
Create a pod use below yaml file:
apiVersion: v1
kind: Pod
metadata:
name: demo
spec:
containers:
- name: nginx-demo
image: nginx
ports:
- containerPort: 80
hostPort: 80
Then use curl <node-ip>:80 try access it, will get Connection refused error.
Check the docker container via docker inspect <container-id>, the container port is actually not exposed:
"HostConfig": {
"PortBindings": null
}
"Config": {
"ExposedPorts": {
"443/tcp": {},
"80/tcp": {}
}
}
"NetworkSettings": {
"Ports": null,
}
Anything else do we need to know:
Issue was found originally because the rc-default.yaml file in ingress example require nodePort.
Copied from original issue: kubernetes/kubernetes#35875
From @luxas on October 30, 2016 19:21
This is a known issue, but I agree we should document it.
See: kubernetes/kubernetes#31307
We're using cni networking.
Do you want to make the change in the docs or should I take it?
This is documented both on the kubeadm page and on the network plugin page