1

I have Ubuntu server 20.04 running as a guest vm. On it I have installed Rancher within a docker container, and mapped port 443 to 9091 to have access to the Rancher UI at 192.168.0.50:9091. Within Rancher I have deployed a nextcloud instance on the local cluster and forwarded the nextcloud port 443 to port 9700 using HostPort. The link generated for the pod is taking me to 172.17.0.2:9700, which I am assuming is the internal Ip for the local node within the cluster.

How can I access the nextcloud container with a browser?

Currently I cannot access it if I simply navigate to the :9700. Is there a way to access the node with the IP I use for my vm?

enter image description here

Thanks

  • you will need to create nodePort service for that deployed nextcloud pod. Add some screenshot related to service config – avadhut007 Jan 19 '21 at 05:10
  • @avadhut007 is there any way to do it via hostPort? Or is it because the node is local-node that a service has to be created? – TheOriginalXman Jan 19 '21 at 06:18
  • What error do you receive when trying to reach that nextcloud pod? In the UI you published the container port as 443 but AFAIK the nextcloud image does not listen on that port. The nextcloud-apache listen on 80 and nextcloud-fpm listen on 9000. – acid_fuji Jan 19 '21 at 09:05
  • in k8s if you want to access App outside the cluster, you need to create the service. Checkout the NodePort Service – avadhut007 Jan 19 '21 at 09:49
  • @avadhut007 This is not entirely right. Please don`t forget that OP is using rancher which provides a [way of exposing](https://rancher.com/blog/2018/2018-08-14-expose-and-monitor-workloads/) using hostPort as well. – acid_fuji Jan 20 '21 at 08:55

1 Answers1

0

The publish the container port field in the Port Mapping is the one where you specify the the port that container listen to.

It relates directly to containerPort in kubernetes yaml file. Exposing a port in this field gives the system additional information about the network connections a container uses but this field is primarily informational. Not specyfing a port here does not prevent that port from being expose. Any port which is listening on the default "0.0.0.0" address inside a container will be accessible from the network.

I checked the nextcloud image specs and it looks like it the apache-image is listening on port 80 and fpm-image uses 9000.

For more reading please visit rancher document how to expose workloads.

acid_fuji
  • 6,287
  • 7
  • 22