aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/controller/pod/pod_controller.go
diff options
context:
space:
mode:
authorKuralamudhan Ramakrishnan <kuralamudhan.ramakrishnan@intel.com>2020-07-06 16:10:19 -0700
committerKuralamudhan Ramakrishnan <kuralamudhan.ramakrishnan@intel.com>2020-09-17 16:25:10 -0700
commitce14abc0128d4c55a7805c52ea199e2ce6159428 (patch)
tree569f74510b497ed44814e931a4667de73d133ab0 /pkg/controller/pod/pod_controller.go
parent3de63ee756f9d7c0a4524b40a89e92b918a9249f (diff)
Adding node interface, SNAT and OVN Node switch port
- Adding nfn proto for node interface MAC and IP address - Adding node switch ports in NFN Operator - Adding grpc client in nfn agent to get mac and IP address for node interface - Adding feature to create Node interface with OVS internal port - Make sure pod controller requeue the pod request for empty node field in pod spec - Unique node interface name using SHA and maintain 15 charactor for OVS switch port - Adding SNAT for default interface in each node - Adding iptables modules for SNAT rules Signed-off-by: Kuralamudhan Ramakrishnan <kuralamudhan.ramakrishnan@intel.com> Change-Id: I6cfa36e45007e796eb651345f9f0751329defcf7
Diffstat (limited to 'pkg/controller/pod/pod_controller.go')
-rw-r--r--pkg/controller/pod/pod_controller.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/pkg/controller/pod/pod_controller.go b/pkg/controller/pod/pod_controller.go
index d195782..1f1aa1b 100644
--- a/pkg/controller/pod/pod_controller.go
+++ b/pkg/controller/pod/pod_controller.go
@@ -4,11 +4,12 @@ import (
"context"
"encoding/json"
"fmt"
+ "ovn4nfv-k8s-plugin/internal/pkg/ovn"
+
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
- "ovn4nfv-k8s-plugin/internal/pkg/ovn"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/event"
@@ -32,6 +33,7 @@ type nfnNetwork struct {
}
var enableOvnDefaultIntf bool = true
+
// Add creates a new Pod Controller and adds it to the Manager. The Manager will set fields on the Controller
// and Start it when the Manager is Started.
func Add(mgr manager.Manager) error {
@@ -137,6 +139,12 @@ func (r *ReconcilePod) Reconcile(request reconcile.Request) (reconcile.Result, e
return reconcile.Result{}, nil
}
+ if instance.Spec.NodeName == "" {
+ return reconcile.Result{
+ Requeue: true,
+ }, nil
+ }
+
err = r.addLogicalPorts(instance)
if err != nil && err.Error() == "Failed to add ports" {
// Requeue the object
@@ -163,7 +171,7 @@ func (r *ReconcilePod) addLogicalPorts(pod *corev1.Pod) error {
nfn, err := r.readPodAnnotation(pod)
if err != nil {
// No annotation for multiple interfaces
- nfn = &nfnNetwork {Interface: nil}
+ nfn = &nfnNetwork{Interface: nil}
if enableOvnDefaultIntf == true {
nfn.Type = "ovn4nfv"
} else {
@@ -177,7 +185,7 @@ func (r *ReconcilePod) addLogicalPorts(pod *corev1.Pod) error {
if err != nil {
return err
}
- if _, ok := pod.Annotations[ovn.Ovn4nfvAnnotationTag]; ok {
+ if _, ok := pod.Annotations[ovn.Ovn4nfvAnnotationTag]; ok {
return fmt.Errorf("Pod annotation found")
}
key, value := ovnCtl.AddLogicalPorts(pod, nfn.Interface)
@@ -187,7 +195,7 @@ func (r *ReconcilePod) addLogicalPorts(pod *corev1.Pod) error {
return fmt.Errorf("Failed to add ports")
default:
return fmt.Errorf("Unsupported Networking type %s", nfn.Type)
- // Add other types here
+ // Add other types here
}
}