Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

182
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda