kubernetes pod second interface

3/26/2016

How can one create a second network interface for a pod.

In particular, I actually have a use case where second network interface should be ideally shared network interface to the host('s 2nd network interface) because the host has second network domain?

The external service (on a separate subnet as the host) is not controlled within the same cluster(and controlled by some other vendoring). It is limiting its access by whitelisting client ips.

Please advice.

Thanks.

-- user642318
interface
kubernetes
networking

1 Answer

4/25/2016

To share network interfaces between pod and host. You need to start the pod with host mode, which means pod will share the same network namespace with the host node.

In the pod configuration file, you need to specify "hostNetwork: true".

And for Kubernetes version before 1.1, you need to use --host-network-sources="*" option when start kubelet.

Following is the example pod configuration file:

apiVersion: v1
kind: Pod
metadata:
  name: test
spec:
  hostNetwork: true
  restartPolicy: Never
  containers:
  - name: test
    image: ubuntu
    command: ["bash", "sleep 1000"]

Following is the example kublet command:

kubelet --api_servers=http://$MASTER_IP:8080 --address=0.0.0.0 --cluster_dns=10.0.0.10 --cluster_domain="kubernetes.local" --host-network-sources="*" --pod-infra-container-image="kiwenlau/pause:0.8.0

References:

kubernetes specified host networking, but is disallowed? kubernetes network performance issue: moving service from physical machine to kubernetes get half rps drop

-- KiwenLau
Source: StackOverflow