diff --git a/K8s/interfaces_definitions/vhost1.yaml b/K8s/interfaces_definitions/vhost1.yaml index 22675e54fafbe46d4e16be4b2ed28ceec9001d39..3f603cfbfe4a3d71fbad932cd85de76bc5903667 100644 --- a/K8s/interfaces_definitions/vhost1.yaml +++ b/K8s/interfaces_definitions/vhost1.yaml @@ -2,10 +2,10 @@ apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: - name: vhost1 + name: veth1 spec: config: '{ "cniVersion": "0.3.0", - "type": "host-device", - "device": "vhost1" + "type": "bridge", + "device": "veth1" }' diff --git a/K8s/interfaces_definitions/vhost10.yaml b/K8s/interfaces_definitions/vhost10.yaml index 1808449ca8c6e6c970c61852c8f259a091b48d9c..9975699dcea91fcb1048ec0b7d305973aac5ddaa 100644 --- a/K8s/interfaces_definitions/vhost10.yaml +++ b/K8s/interfaces_definitions/vhost10.yaml @@ -2,10 +2,10 @@ apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: - name: vhost10 + name: veth10 spec: config: '{ "cniVersion": "0.3.0", - "type": "host-device", - "device": "vhost10" + "type": "bridge", + "device": "veth10" }' diff --git a/K8s/interfaces_definitions/vhost2.yaml b/K8s/interfaces_definitions/vhost2.yaml index b155818d1a53c65ec41973b1264f49055e3e68e5..c99a91cb7df73ccd99aa100532353e9f038d0df4 100644 --- a/K8s/interfaces_definitions/vhost2.yaml +++ b/K8s/interfaces_definitions/vhost2.yaml @@ -2,10 +2,10 @@ apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: - name: vhost2 + name: veth2 spec: config: '{ "cniVersion": "0.3.0", - "type": "host-device", - "device": "vhost2" + "type": "bridge", + "device": "veth2" }' diff --git a/K8s/interfaces_definitions/vhost3.yaml b/K8s/interfaces_definitions/vhost3.yaml index 64e3fad24e78ee58cb6aa00c8a6c7d2203979126..c05f175fb6e39c3bdcb54cb66886aec003d0d630 100644 --- a/K8s/interfaces_definitions/vhost3.yaml +++ b/K8s/interfaces_definitions/vhost3.yaml @@ -2,10 +2,10 @@ apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: - name: vhost3 + name: veth3 spec: config: '{ "cniVersion": "0.3.0", - "type": "host-device", - "device": "vhost3" + "type": "bridge", + "device": "veth3" }' diff --git a/K8s/interfaces_definitions/vhost4.yaml b/K8s/interfaces_definitions/vhost4.yaml index 618369f46aecfacd7e10735a145cf48ff2b35738..a1496cde83851bb1cd9eca90cef96fbbf3f61004 100644 --- a/K8s/interfaces_definitions/vhost4.yaml +++ b/K8s/interfaces_definitions/vhost4.yaml @@ -2,10 +2,10 @@ apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: - name: vhost4 + name: veth4 spec: config: '{ "cniVersion": "0.3.0", - "type": "host-device", - "device": "vhost4" + "type": "bridge", + "device": "veth4" }' diff --git a/K8s/interfaces_definitions/vhost5.yaml b/K8s/interfaces_definitions/vhost5.yaml index d1adb864f6f50f8468f23aed8afa0d524d8b1f0d..81caf02d9008aa1c6e71295b20749d45a8e07c4a 100644 --- a/K8s/interfaces_definitions/vhost5.yaml +++ b/K8s/interfaces_definitions/vhost5.yaml @@ -2,10 +2,10 @@ apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: - name: vhost5 + name: veth5 spec: config: '{ "cniVersion": "0.3.0", - "type": "host-device", - "device": "vhost5" + "type": "bridge", + "device": "veth5" }' diff --git a/K8s/interfaces_definitions/vhost6.yaml b/K8s/interfaces_definitions/vhost6.yaml index 51ea0fd57575fa623445a973afba73d609267bc1..44250108d7a5865631b65b9b293bf72f911d2f2f 100644 --- a/K8s/interfaces_definitions/vhost6.yaml +++ b/K8s/interfaces_definitions/vhost6.yaml @@ -2,10 +2,10 @@ apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: - name: vhost6 + name: veth6 spec: config: '{ "cniVersion": "0.3.0", - "type": "host-device", - "device": "vhost6" + "type": "bridge", + "device": "veth6" }' diff --git a/K8s/interfaces_definitions/vhost7.yaml b/K8s/interfaces_definitions/vhost7.yaml index 12abac872700306ea83acb3f109fe567570a813e..2bcf5b6cfbb935e19e30e3b18acfc89c38d3adbf 100644 --- a/K8s/interfaces_definitions/vhost7.yaml +++ b/K8s/interfaces_definitions/vhost7.yaml @@ -2,10 +2,10 @@ apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: - name: vhost7 + name: veth7 spec: config: '{ "cniVersion": "0.3.0", - "type": "host-device", - "device": "vhost7" + "type": "bridge", + "device": "veth7" }' diff --git a/K8s/interfaces_definitions/vhost8.yaml b/K8s/interfaces_definitions/vhost8.yaml index 13df98013386c22123119611a1ba4859dcde5c32..2749e314fd0ce0ca727c500b7b15cf48f25169d8 100644 --- a/K8s/interfaces_definitions/vhost8.yaml +++ b/K8s/interfaces_definitions/vhost8.yaml @@ -2,10 +2,10 @@ apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: - name: vhost8 + name: veth8 spec: config: '{ "cniVersion": "0.3.0", - "type": "host-device", - "device": "vhost8" + "type": "bridge", + "device": "veth8" }' diff --git a/K8s/interfaces_definitions/vhost9.yaml b/K8s/interfaces_definitions/vhost9.yaml index 0ea4af0595782f01cd3e837896fa169d2fd14a8d..58944e8ce7b13bc6d6f5cfa304c43918b7908f3a 100644 --- a/K8s/interfaces_definitions/vhost9.yaml +++ b/K8s/interfaces_definitions/vhost9.yaml @@ -2,10 +2,10 @@ apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: - name: vhost9 + name: veth9 spec: config: '{ "cniVersion": "0.3.0", - "type": "host-device", - "device": "vhost9" + "type": "bridge", + "device": "veth9" }' diff --git a/K8s/interfaces_definitions/vpod1.yaml b/K8s/interfaces_definitions/vpod1.yaml deleted file mode 100644 index af8a907392691a157e6df25e4413e5d34a9a722c..0000000000000000000000000000000000000000 --- a/K8s/interfaces_definitions/vpod1.yaml +++ /dev/null @@ -1,11 +0,0 @@ - -apiVersion: "k8s.cni.cncf.io/v1" -kind: NetworkAttachmentDefinition -metadata: - name: vpod1 -spec: - config: '{ - "cniVersion": "0.3.0", - "type": "host-device", - "device": "vpod1" - }' diff --git a/K8s/interfaces_definitions/vpod10.yaml b/K8s/interfaces_definitions/vpod10.yaml deleted file mode 100644 index 14ef5f75fd7777b87872fbbafc25fae768364c7e..0000000000000000000000000000000000000000 --- a/K8s/interfaces_definitions/vpod10.yaml +++ /dev/null @@ -1,11 +0,0 @@ - -apiVersion: "k8s.cni.cncf.io/v1" -kind: NetworkAttachmentDefinition -metadata: - name: vpod10 -spec: - config: '{ - "cniVersion": "0.3.0", - "type": "host-device", - "device": "vpod10" - }' diff --git a/K8s/interfaces_definitions/vpod2.yaml b/K8s/interfaces_definitions/vpod2.yaml deleted file mode 100644 index 1aee3a4a7c545aef95d7543a6cf2f27e7ab314a3..0000000000000000000000000000000000000000 --- a/K8s/interfaces_definitions/vpod2.yaml +++ /dev/null @@ -1,11 +0,0 @@ - -apiVersion: "k8s.cni.cncf.io/v1" -kind: NetworkAttachmentDefinition -metadata: - name: vpod2 -spec: - config: '{ - "cniVersion": "0.3.0", - "type": "host-device", - "device": "vpod2" - }' diff --git a/K8s/interfaces_definitions/vpod3.yaml b/K8s/interfaces_definitions/vpod3.yaml deleted file mode 100644 index af8246bcf0ab6b4443bedaec8999cfa9a481fb2b..0000000000000000000000000000000000000000 --- a/K8s/interfaces_definitions/vpod3.yaml +++ /dev/null @@ -1,11 +0,0 @@ - -apiVersion: "k8s.cni.cncf.io/v1" -kind: NetworkAttachmentDefinition -metadata: - name: vpod3 -spec: - config: '{ - "cniVersion": "0.3.0", - "type": "host-device", - "device": "vpod3" - }' diff --git a/K8s/interfaces_definitions/vpod4.yaml b/K8s/interfaces_definitions/vpod4.yaml deleted file mode 100644 index 2fe22d6e2a7094c517ee43c12934e32969333954..0000000000000000000000000000000000000000 --- a/K8s/interfaces_definitions/vpod4.yaml +++ /dev/null @@ -1,11 +0,0 @@ - -apiVersion: "k8s.cni.cncf.io/v1" -kind: NetworkAttachmentDefinition -metadata: - name: vpod4 -spec: - config: '{ - "cniVersion": "0.3.0", - "type": "host-device", - "device": "vpod4" - }' diff --git a/K8s/interfaces_definitions/vpod5.yaml b/K8s/interfaces_definitions/vpod5.yaml deleted file mode 100644 index 2d078669c90914c163b0e10d466a2c3cda1d7fa2..0000000000000000000000000000000000000000 --- a/K8s/interfaces_definitions/vpod5.yaml +++ /dev/null @@ -1,11 +0,0 @@ - -apiVersion: "k8s.cni.cncf.io/v1" -kind: NetworkAttachmentDefinition -metadata: - name: vpod5 -spec: - config: '{ - "cniVersion": "0.3.0", - "type": "host-device", - "device": "vpod5" - }' diff --git a/K8s/interfaces_definitions/vpod6.yaml b/K8s/interfaces_definitions/vpod6.yaml deleted file mode 100644 index 993fd5810138393a4c150edd6d82d17d8c334124..0000000000000000000000000000000000000000 --- a/K8s/interfaces_definitions/vpod6.yaml +++ /dev/null @@ -1,11 +0,0 @@ - -apiVersion: "k8s.cni.cncf.io/v1" -kind: NetworkAttachmentDefinition -metadata: - name: vpod6 -spec: - config: '{ - "cniVersion": "0.3.0", - "type": "host-device", - "device": "vpod6" - }' diff --git a/K8s/interfaces_definitions/vpod7.yaml b/K8s/interfaces_definitions/vpod7.yaml deleted file mode 100644 index 18e4a376e3916813e22ea5015bce7557a0ae767e..0000000000000000000000000000000000000000 --- a/K8s/interfaces_definitions/vpod7.yaml +++ /dev/null @@ -1,11 +0,0 @@ - -apiVersion: "k8s.cni.cncf.io/v1" -kind: NetworkAttachmentDefinition -metadata: - name: vpod7 -spec: - config: '{ - "cniVersion": "0.3.0", - "type": "host-device", - "device": "vpod7" - }' diff --git a/K8s/interfaces_definitions/vpod8.yaml b/K8s/interfaces_definitions/vpod8.yaml deleted file mode 100644 index 152f3315540be4e3cc2ecfbb45a21a39e0ad802b..0000000000000000000000000000000000000000 --- a/K8s/interfaces_definitions/vpod8.yaml +++ /dev/null @@ -1,11 +0,0 @@ - -apiVersion: "k8s.cni.cncf.io/v1" -kind: NetworkAttachmentDefinition -metadata: - name: vpod8 -spec: - config: '{ - "cniVersion": "0.3.0", - "type": "host-device", - "device": "vpod8" - }' diff --git a/K8s/interfaces_definitions/vpod9.yaml b/K8s/interfaces_definitions/vpod9.yaml deleted file mode 100644 index b7459c2fc2c210ccefffc4e89bcf45ce7fc931a4..0000000000000000000000000000000000000000 --- a/K8s/interfaces_definitions/vpod9.yaml +++ /dev/null @@ -1,11 +0,0 @@ - -apiVersion: "k8s.cni.cncf.io/v1" -kind: NetworkAttachmentDefinition -metadata: - name: vpod9 -spec: - config: '{ - "cniVersion": "0.3.0", - "type": "host-device", - "device": "vpod9" - }' diff --git a/operator/daemonset/l2sm-switch-amd64.yaml b/operator/daemonset/l2sm-switch-amd64.yaml index 75f94797bfee051fd3b23efeadbfe17c7bc52580..039dad11f064ee529e06ef48c9ce81ffc1777f84 100644 --- a/operator/daemonset/l2sm-switch-amd64.yaml +++ b/operator/daemonset/l2sm-switch-amd64.yaml @@ -14,7 +14,7 @@ spec: labels: l2sm-component: l2sm-switch annotations: - k8s.v1.cni.cncf.io/networks: vhost1@vhost1, vhost2@vhost2, vhost3@vhost3, vhost4@vhost4, vhost5@vhost5, vhost6@vhost6, vhost7@vhost7, vhost8@vhost8, vhost9@vhost9, vhost10@vhost10 + k8s.v1.cni.cncf.io/networks: veth1, veth2, veth3, veth4, veth5, veth6, veth7, veth8, veth9, veth10 spec: tolerations: # this toleration is to have the daemonset runnable on master nodes @@ -24,21 +24,21 @@ spec: effect: NoSchedule containers: - name: l2sm-switch - image: alexdecb/l2sm-ovs:test + image: alexdecb/l2sm-switch:2.1 command: ["sleep","infinity"] + #args: ["setup_switch.sh && sleep infinity"] env: - name: NODENAME valueFrom: fieldRef: fieldPath: spec.nodeName - - name: NVPODS + - name: NVETHS value: "10" - name: CONTROLLERIP value: "l2sm-controller-service" - - imagePullPolicy: Always securityContext: capabilities: add: ["NET_ADMIN"] nodeSelector: kubernetes.io/arch: amd64 + diff --git a/operator/deploy/controller/deployController.yaml b/operator/deploy/controller/deployController.yaml index 596091ce275630a3e348aec43544bc3d459e7c7c..6a4277679bd389251648397d7162b08b77724d49 100644 --- a/operator/deploy/controller/deployController.yaml +++ b/operator/deploy/controller/deployController.yaml @@ -15,6 +15,10 @@ spec: containers: - name: l2sm-controller image: alexdecb/l2sm-controller:latest + # readinessProbe: + # httpGet: + # path: /onos/v1/l2sm/networks/status + # port: 8181 ports: - containerPort: 6633 - containerPort: 8181 diff --git a/operator/deploy/deployOperator.yaml b/operator/deploy/deployOperator.yaml index 7afe40d099ae3235cdc846f902d4e0b0145fc7e2..6a69f522114cbd6afd6e4bd11ded09eef8d85c09 100644 --- a/operator/deploy/deployOperator.yaml +++ b/operator/deploy/deployOperator.yaml @@ -18,6 +18,7 @@ spec: containers: - image: alexdecb/l2sm-operator:latest name: l2sm-opt-pod + imagePullPolicy: Always env: - name: CONTROLLER_IP value: l2sm-controller-service diff --git a/operator/src/operator/Dockerfile b/operator/src/operator/Dockerfile index 20b735d9f6c5eadee9a69e9142d6b10b0284ca07..e816270762863ac6d4037ca8e2665df36ee42b7d 100644 --- a/operator/src/operator/Dockerfile +++ b/operator/src/operator/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.7 +FROM python:3.11.6 RUN pip install kopf kubernetes PyMySQL cryptography requests COPY l2sm-operator.py /l2sm-operator.py CMD kopf run --standalone --all-namespaces /l2sm-operator.py diff --git a/operator/src/operator/l2sm-operator.py b/operator/src/operator/l2sm-operator.py index b8eef082c26e4ca51e3fcf8043de029b7ffe41fb..3f75af80cf2072b0b6b93b092942993aee2b99c4 100644 --- a/operator/src/operator/l2sm-operator.py +++ b/operator/src/operator/l2sm-operator.py @@ -87,7 +87,7 @@ def build_db(body, logger, annotations, **kwargs): #MODIFY THE END VALUE TO ADD MORE INTERFACES values = [] for i in range(1,11): - values.append(['vpod'+str(i), body['spec']['nodeName'], '-1', '']) + values.append(['veth'+str(i), body['spec']['nodeName'], '-1', '']) sqlInterfaces = "INSERT INTO interfaces (interface, node, network, pod) VALUES (%s, %s, %s, %s)" cur.executemany(sqlInterfaces, values) db.commit() @@ -212,13 +212,13 @@ def pod_vn(body, name, namespace, logger, annotations, **kwargs): # networkN = retrieve[0].strip() # break - switchId = getSwitchId(cur, node) + switchId = getSwitchId(cur, node) # TODO: diferenciar caso en el que es un veth el conectado y el de que es una red de vdd. if switchId is None: logger.info(f"The l2sm switch is not connected to controller. Not connecting the pod") return - vpodPattern = re.compile(r'\d+$') - portNumbers = [int(vpodPattern.search(interface).group()) for interface in interface_to_attach] + vethPattern = re.compile(r'\d+$') + portNumbers = [int(vethPattern.search(interface).group()) for interface in interface_to_attach] for m in range(len(network)): sql = "UPDATE interfaces SET network = '%s', pod = '%s' WHERE interface = '%s' AND node = '%s'" % (network_array[m], name, interface_to_attach[m], node) diff --git a/operator/src/switch/main.go b/operator/src/switch/main.go index c999b42345351ad68b3d45833071b5caaa3320da..aec906af66b9a0b9be1fbfbd1fc0c7e3e53957c4 100644 --- a/operator/src/switch/main.go +++ b/operator/src/switch/main.go @@ -23,7 +23,7 @@ type Node struct { // the second one is the path to the configuration file, in reference to the code. func main() { - configDir, vhostNumber, nodeName, controllerIP, err := takeArguments() + configDir, vethNumber, nodeName, controllerIP, err := takeArguments() if err != nil { fmt.Println("Error with the arguments. Error:", err) @@ -41,13 +41,13 @@ func main() { fmt.Println("Switch initialized and connected to the controller.") // Set all virtual interfaces up, and connect them to the tunnel bridge: - for i := 1; i <= vhostNumber; i++ { - vhost := fmt.Sprintf("vhost%d", i) - cmd := exec.Command("ip", "link", "set", vhost, "up") // i.e: ip link set vhost1 up + for i := 1; i <= vethNumber; i++ { + veth := fmt.Sprintf("net%d", i) + cmd := exec.Command("ip", "link", "set", veth, "up") // i.e: ip link set veth1 up if err := cmd.Run(); err != nil { fmt.Println("Error:", err) } - exec.Command("ovs-vsctl", "add-port", "brtun", vhost).Run() // i.e: ovs-vsctl add-port brtun vhost1 + exec.Command("ovs-vsctl", "add-port", "brtun", veth).Run() // i.e: ovs-vsctl add-port brtun veth1 } err = createVxlans(configDir, nodeName) @@ -61,7 +61,7 @@ func main() { func takeArguments() (string, int, string, string, error) { configDir := os.Args[len(os.Args)-1] - vhostNumber := flag.Int("n_vpods", 0, "number of pod interfaces that are going to be attached to the switch") + vethNumber := flag.Int("n_veths", 0, "number of pod interfaces that are going to be attached to the switch") nodeName := flag.String("node_name", "", "name of the node the script is executed in. Required.") controllerIP := flag.String("controller_ip", "", "ip where the SDN controller is listening using the OpenFlow13 protocol. Required") @@ -76,7 +76,7 @@ func takeArguments() (string, int, string, string, error) { return "", 0, "", "", errors.New("Controller IP is not defined") } - return configDir, *vhostNumber, *nodeName, *controllerIP, nil + return configDir, *vethNumber, *nodeName, *controllerIP, nil } func initializeSwitch(controllerIP string) error { diff --git a/operator/src/switch/setup_switch.sh b/operator/src/switch/setup_switch.sh index c0c43324b489c973451d208ea021296b0c08f362..996e62f37e85ad0926e1281047fb864ab6eb2599 100644 --- a/operator/src/switch/setup_switch.sh +++ b/operator/src/switch/setup_switch.sh @@ -6,4 +6,4 @@ ovs-vsctl --db=unix:/var/run/openvswitch/db.sock --no-wait init ovs-vswitchd --pidfile=/var/run/openvswitch/ovs-vswitchd.pid --detach -l2sm-br --n_vpods=$NVPODS --node_name=$NODENAME --controller_ip=$CONTROLLERIP /etc/l2sm/switchConfig.json +l2sm-br --n_veths=$NVETHS --node_name=$NODENAME --controller_ip=$CONTROLLERIP /etc/l2sm/switchConfig.json