-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
network/kubevirt-ipam-controller: Add new net-attach-def resource
This resource does not belong to kubevirt-ipam-controller, but is currently piggy-backing this component in order to deploy the primary user-defined-network net-attach-def [0]. This net-attach-def is deployed on default namespace, as this way it will be available to all VMs that need to consume it. Note that for CI, KubevirtIpamController will not be able to deploy without Multus (that deploys the net-attach-def CRD) alongside it, or the net-attach-def deployment will fail, with error: `could not apply (k8s.cni.cncf.io/v1, Kind=NetworkAttachmentDefinition) default/primary-user-defined-network: could not retrieve existing (k8s.cni.cncf.io/v1, Kind=NetworkAttachmentDefinition) default/primary-user-defined-network: no matches for kind "NetworkAttachmentDefinition" in version "k8s.cni.cncf.io/v1"` [0] https://kubevirt.io/user-guide/network/network_binding_plugins/#deployment Signed-off-by: Ram Lavi <[email protected]>
- Loading branch information
Showing
7 changed files
with
101 additions
and
8 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
data/kubevirt-ipam-controller/004-primary-udn-networkattachdef.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
apiVersion: "k8s.cni.cncf.io/v1" | ||
kind: NetworkAttachmentDefinition | ||
metadata: | ||
name: primary-user-defined-network | ||
namespace: default | ||
spec: | ||
config: '{ | ||
"cniVersion": "1.0.0", | ||
"name": "primary-user-defined-network", | ||
"plugins": [ | ||
{ | ||
"type": "cni-passt-binding-plugin" | ||
} | ||
] | ||
}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package network | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
|
||
osv1 "github.com/openshift/api/operator/v1" | ||
v1 "k8s.io/api/core/v1" | ||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
|
||
cnao "github.com/kubevirt/cluster-network-addons-operator/pkg/apis/networkaddonsoperator/shared" | ||
) | ||
|
||
var _ = Describe("Testing kubevirt ipam controller", func() { | ||
Context("Render KubevirtIpamController", func() { | ||
conf := &cnao.NetworkAddonsConfigSpec{ImagePullPolicy: v1.PullAlways, Multus: &cnao.Multus{}, KubevirtIpamController: &cnao.KubevirtIpamController{}, PlacementConfiguration: &cnao.PlacementConfiguration{Workloads: &cnao.Placement{}}} | ||
manifestDir := "../../data" | ||
openshiftNetworkConf := &osv1.Network{} | ||
clusterInfo := &ClusterInfo{SCCAvailable: false, OpenShift4: false} | ||
expectedGroupVersionKind := schema.GroupVersionKind{ | ||
Group: "k8s.cni.cncf.io", | ||
Version: "v1", | ||
Kind: "NetworkAttachmentDefinition", | ||
} | ||
const expectedName = "primary-user-defined-network" | ||
|
||
It("should add the primary-udn network-attach-def obj", func() { | ||
objs, err := Render(conf, manifestDir, openshiftNetworkConf, clusterInfo) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(objs).NotTo(BeEmpty()) | ||
|
||
Expect(objs).To(ContainElement( | ||
SatisfyAll( | ||
WithTransform(func(obj *unstructured.Unstructured) string { | ||
return obj.GetName() | ||
}, Equal(expectedName)), | ||
WithTransform(func(obj *unstructured.Unstructured) schema.GroupVersionKind { | ||
return obj.GetObjectKind().GroupVersionKind() | ||
}, Equal(expectedGroupVersionKind)), | ||
), | ||
)) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters