Multi-Homed Pod with Static IP
Define Network
Define a network attachment for additional interface via CRD.
You can define multiple ones on demand.
DEF_NIC=$(ip r get 1 | head -n1 | awk '{ print $5 }') # double check the default NIC echo $DEF_NIC # the type is macvlan and use static for ip management # change the ADDRESS and GATEWAY accordingly ADDRESS=10.67.108.35/23 GATEWAY=10.67.108.1 cat <<EOF > macvlan-static-net.yaml apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: name: macvlan-static spec: config: '{ "cniVersion": "0.3.1", "type": "macvlan", "master": "$DEF_NIC", "mode": "bridge", "ipam": { "type": "static", "addresses": [ { "address": "$ADDRESS", "gateway": "$GATEWAY" } ] } }' EOF kubectl create -f macvlan-static-net.yaml