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

218
Views
Vanilla JS ERR_NAME_NOT_RESOLVED en el clúster de minikube

Tengo una aplicación web mínima ejecutándose en un clúster minikube local. El backend expone una API en /be/test/hi y el nombre del servicio también es be. Cuando envío una solicitud GET de frontend a backend, obtengo:

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

Si ejecuto nslookup be desde el POD frontend, obtengo la resolución dns correcta, y ejecuto curl be/be/test/hi , obtengo la respuesta correcta del backend (una cadena simple de 'Hola mundo')

¿Qué me estoy perdiendo?

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

principal.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 (imagen de kubefe):

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

EDITAR: he resuelto mis problemas, pero creo que la pregunta real aún no ha sido respondida.

Para resolver esto, simplemente eliminé el protocolo y el host de mi URL y configuré las reglas de proxy en /etc/httpd/conf.d/default-site.conf

predeterminado-sitio.conf

 <VirtualHost *:8080> ProxyPreserveHost Off ProxyRequests Off ProxyPass /be/ http://be/be/ </VirtualHost>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Su código de interfaz (javascript) se está ejecutando en su navegador, no dentro del clúster de kubernetes (pod de nginx)

Tienes 3 opciones aquí,

  1. Cree un servicio NodePort para su interfaz
  2. Confíe en kubeproxy para realizar un reenvío de puertos
  3. Crear una entrada
about 4 years ago · Juan Pablo Isaza 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!