I’m trying to assign a static IP address to a Kubevirt VM pod. My goal is to be able to access the pod using the static IP over the network outside of Kubernetes. Here’s my config:
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
name: testvm
spec:
running: false
template:
metadata:
labels:
kubevirt.io/size: small
kubevirt.io/domain: testvm
spec:
domain:
devices:
disks:
- name: containerdisk
disk:
bus: virtio
- name: cloudinitdisk
disk:
bus: virtio
interfaces:
- name: default
bridge: {}
resources:
requests:
memory: 512M
networks:
- name: default
multus:
default: true
networkName: bridge-test
volumes:
- name: containerdisk
containerDisk:
image: quay.io/kubevirt/cirros-container-disk-demo
- name: cloudinitdisk
cloudInitNoCloud:
userDataBase64: SGkuXG4=
---
apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
name: bridge-test
spec:
config: '{
"cniVersion": "0.3.1",
"name": "bridge-test",
"type": "bridge",
"master": "kvbr0",
"mode": "bridge",
"ipam": {
"type": "static",
"addresses": [
{
"address": "10.120.224.45/23",
"gateway": "10.120.225.1"
}
]
}
}'
On the host I have bridge kvbr0
that is also in the 10.120.224.0/23
network.
This applies successfully. After I start the VM using virtctl start testvm
, running virtctl console testvm
shows nothing. kubectl get vmi
shows testvm
in phase Scheduling
.
1