# Newbie needs help: Expose Container Port

**URL:** <https://forums.suse.com/t/newbie-needs-help-expose-container-port/18235>\
**Category:** SUSE Rancher Prime\
**Created:** [August 31, 2020, 7:57am UTC](https://forums.suse.com/t/newbie-needs-help-expose-container-port/18235 "2020-08-31T07:57:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomx1](https://avatars.discourse-cdn.com/v4/letter/t/779978/32.png) [@tomx1](https://forums.suse.com/u/tomx1)\
**Post date:** [August 31, 2020, 7:57am UTC](https://forums.suse.com/t/newbie-needs-help-expose-container-port/18235/1 "2020-08-31T07:57:50Z")

</div>

Hey,

currently I’m playing around with Rancher and Kubernetes for the first time. I have already some experience with Docker Swarm. Unfortunately I have problems with quite a simple task: Expose a Port of a single nginx container.  
My test setup constists of two servers. One is a worker node only, the other one has all roles. I have used the following Guide and added an additional worker Node: [https://rancher.com/docs/rancher/v2.x/en/installation/other-installation-methods/single-node-docker/](https://rancher.com/docs/rancher/v2.x/en/installation/other-installation-methods/single-node-docker/)

After everything got smoothly up and running, I created a new Cluster (opstest) and Project (ops) and namespace (ops-namespace). Inside that namespace I’ve created a new workload containing an nginx container with the following port mapping:

Port Mapping

| Port Name | Publish the container port | | Protocol | | As a | | On listening port | |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| ops-nginx | 80 | | TCP | | NodePort | | 30005 | |

The container/workload is up and running but the thing is, with ‘netstat -tulpen’ I don’t see - on any of my both test hosts - that this port gets exposed at port 30005 (or any other port). Of course the container/nginx is also not reachable from outside. I have used all possible settings using HostPort and so on with no success. What am I missing here? Thanks guys for helping me out! 🙂

---

<div class="post-metadata">

**Author:** ![vincent](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vincent/32/7156_2.png) [@vincent](https://forums.suse.com/u/vincent)\
**Post date:** [September 1, 2020, 7:10pm UTC](https://forums.suse.com/t/newbie-needs-help-expose-container-port/18235/2 "2020-09-01T19:10:50Z")

</div>

Port mapping is done with iptables rules, there is no process “listening” on them to see in `netstat`. Make sure there aren’t other rules dropping the request.

A HostPort is published to _one_ node, a NodePort to _every_ (worker) node.

---

<div class="post-metadata">

**Author:** ![tomx1](https://avatars.discourse-cdn.com/v4/letter/t/779978/32.png) [@tomx1](https://forums.suse.com/u/tomx1)\
**Post date:** [September 2, 2020, 7:16am UTC](https://forums.suse.com/t/newbie-needs-help-expose-container-port/18235/3 "2020-09-02T07:16:56Z")

</div>

Hi vincent,

thanks for helping me out. I forgot to mention that I also don’t see any iptables rules. I’ve created a Workload with the settings explained above. On my worker node it looks like that:

```
root@docktest2:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
28e3df45b471 nginx "/docker-entrypoint.…" About a minute ago Up About a minute k8s_nginx_nginx-8f48b45d8-j7bjz_ops-namespace_795517b7-8448-4471-b466-10ab8b8d5508_0
834c66b74515 rancher/pause:3.1 "/pause" About a minute ago Up About a minute k8s_POD_nginx-8f48b45d8-j7bjz_ops-namespace_795517b7-8448-4471-b466-10ab8b8d5508_0
ec7181bec045 4e9f801d2217 "/opt/bin/flanneld -…" 47 hours ago Up 47 hours k8s_kube-flannel_canal-94cq7_kube-system_def55ae5-64fe-4c94-91c7-9b0d22e69b96_1
...

```

Above you can see the nginx container running, but if I take a look at the iptables rules on that node I see nothing (also non with iptables-legacy):

```
root@docktest2:~# iptables -nvL |grep 30005
# Warning: iptables-legacy tables present, use iptables-legacy to see them
root@docktest2:~# iptables -t nat -L |grep 30005
# Warning: iptables-legacy tables present, use iptables-legacy to see them
```
