Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

180
Views
Can an `ExternalName` service point to the host machine?

I'm working locally (within Docker for Mac) on a Kubernetes cluster that will eventually be deployed to the cloud. We plan to use a database service in that environment. To simulate that, I'd like to have the services in the cluster connect to a database running outside the cluster on my laptop.

Can I do that? Here's what I thought I'd try.

  • Define a Service with type: ExternalName and externalName: somedb.local
  • Add 127.0.0.1 somedb.local to /etc/hosts on the laptop

Is that correct? Is there a better way?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

After talking with some colleagues, I found a solution.

In Docker for Mac, host.docker.internal points to the host machine, and that lets me connect to the db running there, even from containers running in the K8s cluster.

over 4 years ago · Santiago Trujillo Report

0

You may have a Service pointing to an address out of your SDN, by creating an Endpoint object with matching name.

----
apiVersion: v1
kind: Service
metadata:
  name: external-db
  namespace: my-namespace
spec:
  ports:
  - name: exporter-3306
    port: 3306
  selector:
    name: external-db
---
apiVersion: v1
kind: Endpoints
metadata:
  name: external-db
  namespace: my-namespace
subsets:
- addresses:
  - ip: 10.42.253.110
  ports:
  - name: exporter-3306
    port: 3306

You may add hosts overrides in your Deployment definition:

apiVersion: apps/v1
kind: Deployment
spec:
  template:
    spec:
      containers:
      ...
      hostAliases:
      - ip: 10.42.253.110
        hostnames:
        - external-db
over 4 years ago · Santiago Trujillo Report

0

It seems the Kubernetes docs provide an instruction on how to achieve this. https://kubernetes.io/docs/concepts/services-networking/service/#services-without-selectors

A note says endpoint IPs must not be: loopback (127.0.0.0/8 for IPv4, ::1/128 for IPv6), or link-local (169.254.0.0/16 and 224.0.0.0/24 for IPv4, fe80::/64 for IPv6).

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!