Attribute a static public ip for a pod in kubernetes and specify in service
As per Link , we can create pods with multiples networks , if the application opens port with non-default network (eth2,3 etc) How can we expose it as service? In service yaml i do not find any way to expose the service other than default.
Multus allows you to attach network devices to your Pods, though we should note these interfaces are not part of our Kubernetes cluster SDN.
With Multus based devices: you would allocate IPs to your Pods, either using DHCP, static IPs, ... up to you. Bearing in mind those addresses are independent from your Kubernetes SDN.
If other containers in that cluster need to connect those endpoints, then their traffic would to leave your SDN, going through their usual default gateway, which in turn should have some knowledge of (route to) your Multus addresses subnet(s).
However, you may still create Services, designating addresses out of your SDN. This would be done by creating an Endpoints object, alongside your Service, such as:
---
apiVersion: v1
kind: Endpoints
metadata:
name: svc-out-sdn
namespace: ns
subsets:
- addresses:
- ip: 10.0.0.1
ports:
- name: tcp-80
port: 80
protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
name: svc-out-sdn
namespace: ns
spec:
clusterIP: None
ports:
- name: tcp-80
port: 80