Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNM WIP poc: Use multus default-network to provide ipam claim ref #4732

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion contrib/kind-common
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ install_cert_manager() {
install_kubevirt_ipam_controller() {
echo "Installing KubeVirt IPAM controller manager ..."
manifest="https://raw.githubusercontent.com/kubevirt/ipam-extensions/main/dist/install.yaml"
run_kubectl apply -f "$manifest"
curl -sL $manifest | sed 's#ghcr.io/kubevirt/ipam-controller#quay.io/oshoval/kubevirt-ipam-controller#' > ipam.yaml
run_kubectl apply -f ipam.yaml
kubectl wait -n kubevirt-ipam-controller-system deployment kubevirt-ipam-controller-manager --for condition=Available --timeout 2m
}

Expand Down Expand Up @@ -605,6 +606,24 @@ spec:
}
]
}'
EOF

cat <<EOF | oc apply -f -
---
apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
name: ovn-kubernetes
namespace: default
spec:
config: '{
"cniVersion": "0.4.0",
"name": "ovn-kubernetes",
"type": "ovn-k8s-cni-overlay",
"ipam": {},
"dns": {},
"runtimeConfig": {}
}'
EOF
}

Expand Down
9 changes: 6 additions & 3 deletions go-controller/pkg/util/multi_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -959,9 +959,12 @@ func GetPodNADToNetworkMappingWithActiveNetwork(pod *kapi.Pod, nInfo NetInfo, ac
}

if nInfo.IsPrimaryNetwork() && AllowsPersistentIPs(nInfo) {
ipamClaimName, wasPersistentIPRequested := pod.Annotations[OvnUDNIPAMClaimName]
if wasPersistentIPRequested {
networkSelections[activeNetworkNADs[0]].IPAMClaimReference = ipamClaimName
network, err := GetK8sPodDefaultNetworkSelection(pod)
if err != nil {
return false, nil, fmt.Errorf("error getting default-network's network-attachment for pod: %w", err)
}
if network != nil {
networkSelections[activeNetworkNADs[0]].IPAMClaimReference = network.IPAMClaimReference
}
}

Expand Down
22 changes: 11 additions & 11 deletions go-controller/pkg/util/multi_network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -942,16 +942,16 @@ func TestGetPodNADToNetworkMappingWithActiveNetwork(t *testing.T) {
Role: ovntypes.NetworkRolePrimary,
AllowPersistentIPs: true,
},
inputPodAnnotations: map[string]string{
nadv1.NetworkAttachmentAnnot: GetNADName(namespaceName, "another-network"),
OvnUDNIPAMClaimName: "the-one-to-the-left-of-the-pony",
},
//inputPodAnnotations: map[string]string{
// nadv1.NetworkAttachmentAnnot: GetNADName(namespaceName, "another-network"),
// OvnUDNIPAMClaimName: "the-one-to-the-left-of-the-pony",
//},
expectedIsAttachmentRequested: true,
expectedNetworkSelectionElements: map[string]*nadv1.NetworkSelectionElement{
"ns1/attachment1": {
Name: "attachment1",
Namespace: "ns1",
IPAMClaimReference: "the-one-to-the-left-of-the-pony",
Name: "attachment1",
Namespace: "ns1",
//IPAMClaimReference: "the-one-to-the-left-of-the-pony",
},
},
},
Expand Down Expand Up @@ -998,10 +998,10 @@ func TestGetPodNADToNetworkMappingWithActiveNetwork(t *testing.T) {
Role: ovntypes.NetworkRolePrimary,
AllowPersistentIPs: true,
},
inputPodAnnotations: map[string]string{
nadv1.NetworkAttachmentAnnot: GetNADName(namespaceName, "another-network"),
OvnUDNIPAMClaimName: "the-one-to-the-left-of-the-pony",
},
//inputPodAnnotations: map[string]string{
// nadv1.NetworkAttachmentAnnot: GetNADName(namespaceName, "another-network"),
// OvnUDNIPAMClaimName: "the-one-to-the-left-of-the-pony",
//},
expectedIsAttachmentRequested: true,
expectedNetworkSelectionElements: map[string]*nadv1.NetworkSelectionElement{
"ns1/attachment1": {
Expand Down
2 changes: 1 addition & 1 deletion go-controller/pkg/util/pod_annotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const (
DefNetworkAnnotation = "v1.multus-cni.io/default-network"
// OvnUDNIPAMClaimName is used for workload owners to instruct OVN-K which
// IPAMClaim will hold the allocation for the workload
OvnUDNIPAMClaimName = "k8s.ovn.org/primary-udn-ipamclaim"
//OvnUDNIPAMClaimName = "k8s.ovn.org/primary-udn-ipamclaim"
)

var ErrNoPodIPFound = errors.New("no pod IPs found")
Expand Down
Loading