https://rancher.com/ logo
Title
c

chilly-telephone-51989

08/20/2022, 8:22 PM
I'm trying to make the database service available inside kubernetes for which I created the following service along with the endpoint
apiVersion: v1
kind: Service
metadata:
  name: postgres
  namespace: xp
  labels:
    service: postgres
    type: database
spec:
  type: ClusterIP
  selector:
    service: postgres
    type: database
  ports:
    - name: client
      protocol: TCP
      port: 5432
      targetPort: 5432
---
apiVersion: v1
kind: Endpoints
metadata:
  name: postgres
  namespace: xp
  labels:
    service: postgres
    type: database
subsets:
  - addresses:
      - ip: 172.19.0.2
    ports:
      - name: client
        port: 5432
        protocol: TCP
I tried verifying the service using busybox but nslookup and ping both fail for postgres.xp however pinging the IP 172.19.0.2 runs just fine. how do I expose the IP of an external service inside?
s

sticky-summer-13450

08/23/2022, 2:18 PM
Is the database inside kubernetes or outside kubernetes? For a database outside of kubernetes and being accessed from a deployment inside kubernetes you only need a simple service or type
ExternalName
.
apiVersion: v1
kind: Service
metadata:
  name: mysql
spec:
  type: ExternalName
  externalName: mysql001.lan
c

chilly-telephone-51989

08/23/2022, 2:42 PM
it's outside, just running on docker
it's working now. but I'm still not able to ping the k8s cluster ip from inside k3s. however the actual address replies ping correctly When the pod access db, it does it at a slow pace.
s

sticky-summer-13450

08/26/2022, 1:39 PM
When the pod access db, it does it at a slow pace.
That is interesting. I had recently added an
Ingress
, using Traefik in my K3s (v1.23.8+k3s1) cluster, which was to a
Service
that was just an
ExternalName
to a web server I have elsewhere in a private subnet - this was just to add TLS security to this web service and publicly expose it. The public end runs terribly slowly, often with 10 second pauses between HTTPS calls. I haven't had time to investigate further, but it is an interesting coincidence that you are experiencing slow access to external systems using an
ExternalName
type of
Service
.
c

chilly-telephone-51989

08/26/2022, 3:44 PM
so my case is not the only one! all the external services are slow. can't ping them. but they are 🥱 😴 working. my colleague decided to try setup the same using microk8s to see if the result is similar or different