https://rancher.com/ logo
Title
f

famous-traffic-65054

08/02/2022, 6:36 PM
The same service to endpoint mapping works fine in Docker but I was wondering if there's a different way to do this in Rancher. Do I have to setup things here? Appreciate your help!
f

freezing-airplane-30363

08/03/2022, 8:27 AM
Hi, I was able to configure external nginx to act as an endpoint by following this doc https://kubernetes.io/docs/concepts/services-networking/service/#services-without-selectors ...I'm using RD on Linux
apiVersion: v1
kind: Service
metadata:
  name: external-nginx
spec:
 ports:
    - protocol: TCP
      port: 80
      targetPort: 8080
---
apiVersion: v1
kind: Endpoints
metadata:
  name: external-nginx
subsets:
  - addresses:
    - ip: 10.111.222.111 # IP reachable from cluster
    ports:
    - port: 8080
then I just ran busybox pod and
wget <http://external-nginx>
worked
f

famous-traffic-65054

08/03/2022, 5:30 PM
Thanks for the response @freezing-airplane-30363 I'll try it and let you know. The only thing missing in my service yaml is the targetPort and the protocol. I just have specified ports. It worked fine on my KIND cluster inside Docker Desktop, but may be Rancher needs that specific info. Port 5432 is specific to PostgreSQL so, I'll try your suggestion.
So @freezing-airplane-30363 I tried your suggestion and it's similar to the one I was using but my application pods are still not able to connect to my postgresql database running outside my cluster. So I'm running my rancher desktop, and my postgresql is deployed separately on my windows laptop. The same service/endpoint mapping works fine in microk8s and KIND, however, it's surprising that it's giving me issues working with rancher-desktop. Any other way to handle to this connection? I appreciate your help!
f

freezing-airplane-30363

08/11/2022, 7:49 AM
@famous-traffic-65054 Hi, thats strange, It should work. Is the postgresql-server properly configured to handle connections from foreign IPs? You may check if you have something like
host    all      all         0.0.0.0/0      trust
in /var/lib/pgsql/data/pg_hba.conf on psql server machine. Gonna try it.
also logs from psql client and server would be helpful
The external postgres does communicate over endpoint - I'd say problem is with your psql server configuration which is by default listening on localhost / lo interface only - kubernetes in RD is running in VM (on Linux and Mac, not sure about Windows) and using another network/interface so this might be the difference to microk8s and KIND.
this is how I changed default postgresql server configs to make it work with remote client (it is not secured at all):
$ cat /var/lib/pgsql/data/pg_hba.conf
...
local   all             all                                     trust
host    all             all             0.0.0.0/0               trust
...
and
$ cat /var/lib/pgsql/data/postgresql.conf
...
listen_addresses = '*'
...