<p>The whole point of my setup is to achieve (if possible) the following:</p>
<ul>
<li>I have multiple k8s nodes</li>
<li>When I contact an IP address (from my company's network), it should be routed to one of my container/pod/service/whatever.</li>
<li>I should be able to easily setup that IP (like in my service .yml definition)</li>
</ul>
<p>I'm running a small Kubernetes cluster (built with kubeadm) in order to evaluate if I can move my Docker (old)Swarm setup to k8s. The feature I absolutely need is the ability to assign IP to containers, like I do with MacVlan.</p>
<p>In my current docker setup, I'm using MacVlan to assign IP addresses from my company's network to some containers so I can reach directly (without reverse-proxy) like if it's any physical server. I'm trying to achieve something similar with k8s.</p>
<p>I found out that:</p>
<ul>
<li>I have to use <em>Service</em></li>
<li>I can't use the <em>LoadBalancer</em> type, as it's only for compatible cloud providers (like GCE or AWS).</li>
<li>I should use <a href="https://kubernetes.io/docs/concepts/services-networking/service/#external-ips" rel="nofollow noreferrer"><em>ExternalIPs</em></a></li>
<li><em>Ingress Resources</em> are some kind of reverse proxy ?</li>
</ul>
<p>My yaml file is :</p>
<pre><code>apiVersion: apps/v1beta1
kind: Deployment
metadata:
      name: nginx-deployment
spec:
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80
      nodeSelector:
        kubernetes.io/hostname: k8s-slave-3
---
kind: Service
apiVersion: v1
metadata:
  name: nginx-service
spec:
  type: ClusterIP
  selector:
    app: nginx
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: 80
  externalIPs: 
    - A.B.C.D
</code></pre>
<p>I was hopping that my service would get the IP A.B.C.D (which is one of my company's network). My deployment is working as I can reach my nginx container from inside the k8s cluster using it's <em>ClusterIP</em>.</p>
<p>What am I missing ? Or at least, where can I find informations on my network traffic in order to see if packets are coming?</p>
<pre><code>$ kubectl get svc
NAME            CLUSTER-IP     EXTERNAL-IP       PORT(S)   AGE
kubernetes      10.96.0.1      &lt;none&gt;            443/TCP   6d
nginx-service   10.102.64.83   A.B.C.D           80/TCP    23h
</code></pre>

<p>First of all run this command: </p>

<pre><code>kubectl get -n namespace services
</code></pre>

<p>Above command will return output like this:</p>

<pre><code> NAME            TYPE       CLUSTER-IP       EXTERNAL-IP   PORT(S)         AGE
backend   NodePort   10.100.44.154         &lt;none&gt;          9400:3003/TCP   13h   
frontend        NodePort   10.107.53.39     &lt;none&gt;        3000:30017/TCP   13h
</code></pre>

<p>It is clear from the above output that External IPs are not assigned to the services yet. To assign External IPs to <em>backend</em> service run the following command.</p>

<pre><code> kubectl patch svc backend -p '{"spec":{"externalIPs":["192.168.0.194"]}}'
</code></pre>

<p>and to assign external IP to <em>frontend</em> service run this command.</p>

<pre><code> kubectl patch svc frontend -p '{"spec":{"externalIPs":["192.168.0.194"]}}'
</code></pre>

<p>Now get namespace service to check either external IPs assignment:</p>

<pre><code>kubectl get -n namespace services
</code></pre>

<p>We get an output like this:</p>

<pre><code>NAME     TYPE     CLUSTER-IP     EXTERNAL-IP    PORT(S)             AGE
backend  NodePort 10.100.44.154  192.168.0.194  9400:3003/TCP       13h
frontend NodePort 10.107.53.39   192.168.0.194  3000:30017/TCP      13h
</code></pre>

<p>Cheers!!! Kubernetes External IPs are now assigned .</p>
