Skip to content

Commit

Permalink
adding a needed label on the Namespace when using UDN primary network
Browse files Browse the repository at this point in the history
  • Loading branch information
capolrik committed Jan 29, 2025
1 parent 747be21 commit 2d866e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/k8s-netperf/k8s-netperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ var rootCmd = &cobra.Command{
}

// Build the namespace and create the sa account
err = k8s.BuildInfra(client)
err = k8s.BuildInfra(client, udn)
if err != nil {
log.Error(err)
os.Exit(1)
Expand Down
9 changes: 7 additions & 2 deletions pkg/k8s/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,18 @@ const k8sNetperfImage = "quay.io/cloud-bulldozer/k8s-netperf:latest"
const udnName = "udn-l2-primary"

// BuildInfra will create the infra for the SUT
func BuildInfra(client *kubernetes.Clientset) error {
func BuildInfra(client *kubernetes.Clientset, udn bool) error {
_, err := client.CoreV1().Namespaces().Get(context.TODO(), namespace, metav1.GetOptions{})
if err == nil {
log.Infof("♻️ Namespace already exists, reusing it")
} else {
log.Infof("🔨 Creating namespace: %s", namespace)
_, err := client.CoreV1().Namespaces().Create(context.TODO(), &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: namespace}}, metav1.CreateOptions{})
if udn {
_, err = client.CoreV1().Namespaces().Create(context.TODO(), &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: namespace,
Labels: map[string]string{"k8s.ovn.org/primary-user-defined-network": ""}}}, metav1.CreateOptions{})
} else {
_, err = client.CoreV1().Namespaces().Create(context.TODO(), &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: namespace}}, metav1.CreateOptions{})
}
if err != nil {
return fmt.Errorf("😥 Unable to create namespace: %v", err)
}
Expand Down

0 comments on commit 2d866e7

Please sign in to comment.