Rate This Document
Findability
Accuracy
Completeness
Readability

Static IP Addresses and MAC Addresses for Pods

By default, Kube-OVN allocates an IP address and a MAC address to a pod based on the subnet to which the namespace belongs. The pod is in the namespace. You can specify the IP address and MAC address by setting the ovn.kubernetes.io/ip_address and ovn.kubernetes.io/mac_address fields in the annotations section in the YAML configuration file when creating the pod.

Example:

vim Pod.yaml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
apiVersion: v1
kind: Pod
metadata:
  name: static-ip
  namespace: product
  annotations:
    ovn.kubernetes.io/ip_address: 10.16.0.15
    ovn.kubernetes.io/mac_address: 00:00:00:53:6B:B6
spec:
  containers:
  - name: static-ip
    image: nginx:alpine
kubectl create -f Pod.yaml

When specifying the IP address and MAC address for a pod, note that:

  • The specified IP addresses must be within the CIDR of the subnet to which the namespace where the pod resides belongs.
  • The specified IP address and MAC address cannot conflict with the used IP addresses and MAC addresses.
  • You can specify only an IP address or a MAC address.