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

891
Views
How to access hosts in my network from microk8s deployment pods

I am trying to access a host that sits in another server (but on my network) from inside the pod of deployment and I am using microk8s.

The thing is that on the server where I have microk8s installed I can easily ping it by ping my-network-host.qa.local. But when I go inside the pod with microk8s kubectl exec -it pod_name -- /bin/bash and I do ping my-network-host.qa.local it says: Name or service not known.

And when I connect to a VPN on my computer to be on that network and I deploy it locally using docker-desktop kubernetes I can ping that host from within the pod. So I think the problem sits in microk8s which is not letting my pod use my network.

Is there any way to tell microk8s to use my hosts from my network?

p.s. I can ping the ip of that server from the pod, but I am not being able to ping the host from the pod

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Based on another answer that I found on StackOverflow, i managed to fixed it.

There were 2 changes needed to make it work:

Update kubelet configuration to use resolv-conf:

sudo echo "--resolv-conf=/run/systemd/resolve/resolv.conf" >> /var/snap/microk8s/current/args/kubelet

Restart kubelet service:

sudo service snap.microk8s.daemon-kubelet restart

Then change the CoreDNS forward to point to your nameserver:

First open coredns config map so you can edit it

sudo microk8s.kubectl edit configmap coredns -n kube-system

and update the file at

forward . 8.8.8.8 8.8.4.4 #REMOVE THIS LINE
forward . xxx.xxx.xxx.xxx #ADD THIS WITH YOUR IP

You can get eth0 DNS address:

nmcli dev show 2>/dev/null | grep DNS | sed 's/^.*:\s*//'

On my case I already had the ip as nameserver on /run/systemd/resolve/resolv.conf.

Now just save the changes, and go inside your pods so you will be able to access them.

There is a comment in another post that suggest adding

forward . /etc/resolv.conf

But that didnt work on my case.

over 4 years ago · Santiago Trujillo Report

0

When you create a k8s network, k8s creates a LAN for the network and each pod gets an IP address and a hostname within the network, that k8s network communicates with your local LAN via the my-network-host.qa.local provided for the k8s network.

So when you are on bashinside the pod, you don’t see thatmy-network-host.qa.local , you see the k8s LAN with all the pods connected and each pod will have a specific IP address and a hostname in the k8s network IP space.

So instead of using the IP on your LAN you should use an IP from the k8s LAN or a hostname to get to a specific pod from within the k8s network.

If your pods needs to a access service on a different network then that network needs to be reachable from within the k8s network. Also you could create a k8s headless-service

Let’s say you want to connect to Mongolen on your localhost. In this case, we can create a [headless service][1] and Endpoint for it inside the cluster... the mongodb-service.yaml file should look something like this:

apiVersion: v1
kind: Service
metadata:
   name: mongodb-service
spec:
   clusterIP: None
   ports:
   - protocol: TCP
     port: the-port 
     targetPort: the-port 
   selector:  
     name:  example
   type: ClusterIP
---
apiVersion: v1
kind: Endpoints
metadata:
  name: mongodb-service
subsets:
  - addresses:
    - ip: the-kluster-ip 
    ports:
      - port: the-port

After creating service and endpoint you can use mongodb-service name and port inside any pod of this cluster as a destination point.

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!