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

223
Visualizações
Vanilla JS ERR_NAME_NOT_RESOLVED on minikube cluster

I have a minimal web application running on local minikube cluster. The backend is exposing an API at /be/test/hi and service name is also be. When I send a GET request from frontend to backend i get:

main.js:15 GET http://be/be/test/hi net::ERR_NAME_NOT_RESOLVED

If I run nslookup be from the frontend POD i get the correct dns resolution, and running curl be/be/test/hi I get the right response from backend (a simple 'Hello world' string)

What am I missing?

backend.yaml

apiVersion: v1
kind: Service
metadata:
  name: be
spec:
  ports:
    - port: 80
      targetPort: 8080
  selector:
    app: be
  type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: be
spec:
  replicas: 1
  selector:
    matchLabels:
      app: be
  template:
    metadata:
      labels:
        app: be
    spec:
      containers:
      - name: be
        image: kubebe
        imagePullPolicy: Never
        ports:
          - containerPort: 8080

frontend.yaml

apiVersion: v1
kind: Service
metadata:
  name: fe
spec:
  ports:
    - port: 80
      targetPort: 8080
  selector:
    app: fe
  type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: frontend
spec:
  replicas: 1
  selector:
    matchLabels:
      app: fe
  template:
    metadata:
      labels:
        app: fe
    spec:
      containers:
      - name: fe
        image: kubefe
        imagePullPolicy: Never
        ports:
          - containerPort: 8080

main.js

const URL="http://be/be/test/hi"

  function httpGetAsync(){
    var xmlHttp = new XMLHttpRequest();
    xmlHttp.onreadystatechange = function() { 
        if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
            console.log(xmlHttp.responseText);
    }
    xmlHttp.open("GET", URL, true); 
    xmlHttp.send(null);
}

frontend Dockerfile (kubefe image):

FROM centos/httpd-24-centos7:2.4
RUN mkdir -p /var/www/html/fe
COPY ./index.html ./main.js /var/www/html/fe/

EDIT: I've resolved my issues but I think the actual question is still unanswered.

To solve this I've simple removed the protocol and host from my url and set up proxy rules in /etc/httpd/conf.d/default-site.conf

default-site.conf

<VirtualHost *:8080> 
  ProxyPreserveHost Off
  ProxyRequests Off
  ProxyPass /be/ http://be/be/
</VirtualHost> 
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Your frontend code (javascript) is executing in your browser, not inside the kubernetes cluster (nginx pod)

You have 3 options here,

  1. Create a NodePort Service for your frontend
  2. Rely on kubeproxy for doing a port forward
  3. Create an ingress
about 4 years ago · Juan Pablo Isaza 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