Networking issues between pods & from pods to internet

development

#1

Hello, i was trying to create a 2 nodes - 2 machines cluster.
i’m using 2 centOS virtual machines (on virtualbox) on a company network, using Kubeadm
i’m also using Weave network as a network plugin.

afterward, i’ve just tried to create a simple deployment of nginx with the following yaml file:

apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 2 # tells deployment to run 2 pods matching the template
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80

The deployment went well, and i can see the following:

[root@arielKuber ~]# kubectl get pods -l run=my-nginx -o wide
NAME                        READY   STATUS    RESTARTS   AGE   IP           NODE          NOMINATED NODE
my-nginx-756f645cd7-87b54   1/1     Running   2          23h   10.32.48.3   arielkuber2   <none>
my-nginx-756f645cd7-9ts6k   1/1     Running   1          23h   10.32.48.2   arielkuber2   <none>


[root@arielKuber ~]# kubectl get nodes
NAME          STATUS   ROLES    AGE   VERSION
arielkuber    Ready    master   23h   v1.12.0
arielkuber2   Ready    <none>   23h   v1.12.0
  • Ping from master node to the pods does not work, but it does work from the slave node:

from master:

    [root@arielKuber ~]# ping 10.32.48.2
    PING 10.32.48.2 (10.32.48.2) 56(84) bytes of data.
    From 10.32.0.1 icmp_seq=1 Destination Host Unreachable
    From 10.32.0.1 icmp_seq=2 Destination Host Unreachable

from slave:

root@my-nginx-756f645cd7-87b54:/# ping 10.32.48.2
PING 10.32.48.2 (10.32.48.2) 56(84) bytes of data.
64 bytes from 10.32.48.2: icmp_seq=1 ttl=64 time=0.216 ms
64 bytes from 10.32.48.2: icmp_seq=2 ttl=64 time=0.163 ms

I’m guessing 10.32.0.1 should be k8s dns server? but it’s not reachable from master

  • another issue, that the pods are created without access to the internet, their resolv.conf file is different from as i create a plain docker container, and they don’t contain the correct DNS server of the hosts:

in the hosts:

search company.com
nameserver #IP1
nameserver #IP2

but in the containers created by the pods:

nameserver 10.96.0.10
search default.svc.cluster.local svc.cluster.local cluster.local company.com
options ndots:5

I’m a bit confused about the networking there, any assistance would be appreciated.


#2

@Ariel_B you’re missing a Kubernetes Service.

Services provides a “networking abstraction” that allows you to communicate with your pods.

Here is an example service:

apiVersion: v1
kind: Service
metadata:
  name: mysql
  labels:
    app: mysql
spec:
  ports:
    - port: 3306
  selector:
    app: mysql

I don’t fully understand what it is that you’re asking (I just took a guess) … hope that helps! :smiley: