Skip to content
Snippets Groups Projects
Commit d6165ce8 authored by Alex ubuntu vm's avatar Alex ubuntu vm
Browse files

Merge branch 'main' into release-2.0

parents 5c618ae4 c0fbd1ff
No related branches found
No related tags found
1 merge request!2repo: added new directory where utils scripts will be
# L2S-M Ping Pong example
This section of L2S-M documentation provides an example that you can use in order to learn how to create virtual networks and attach pods to them. To do so, we are going to deploy a simple ping-pong application, where we will deploy two pods attached into a virtual network and test their connectivity.
This section of L2S-M documentation provides an example that you can use in order to learn how to create virtual networks and attach pods to them. To do so, we are going to deploy a simple ping-pong application, where we will deploy two pods attached to a virtual network and test their connectivity.
All the neccessary descriptors can be found in the *'./L2S-M/descriptors'* directory of this repository.
All the necessary descriptors can be found in the *'./descriptors'* directory of this repository.
This guide will assume that all commands are executed within the L2S-M directory.
### Creating our first virtual network
......@@ -26,31 +28,31 @@ As you can see, L2S-M virtual networks are a [NetworkAttachmentDefinition](https
To create the virtual network in your cluster, use the appropriate *kubectl* command as if you were building any other K8s resource:
```bash
kubectl create -f ./L2S-M/descriptors/
kubectl create -f ./descriptors/networks/myfirstnetwork.yaml
```
Et voilá! You have succcesfully created your first virtual network in your K8s cluster.
Et voilá! You have successfully created your first virtual network in your K8s cluster.
### Deploying our application in the cluster
After creating our first virtual network, it is time to attach some pods to it. To do so, it is as simple as adding an annotation to your deployment/pod file, just like you would do when attaching into a multus NetworkAttachmentDefinition.
For example, to add a deployment to my-first-network, introduce in your descriptor the following annotation in its metadata:
For example, to add one deployment to my-first-network, enter the following annotation in your descriptor in its metadata:
```yaml
annotations:
k8s.v1.cni.cncf.io/networks: my-first-network
```
If you want to add your own Multus annotations, you are free to do so! L2S-M will not interfere with the standard Multus behaviour, so feel free to add your addittional annotations if you need them.
If you want to add your own Multus annotations, you are free to do so! L2S-M will not interfere with the standard Multus behavior, so feel free to add your additional annotations if you need them.
To assist you with the dpeloyment of your first application with L2S-M, you can use the deployments available in this repository. To deploy both "ping-pong" pods (which are simple Ubuntu alpine containers), use the following command:
To assist you with the deployment of your first application with L2S-M, you can use the deployments available in this repository. To deploy both "ping-pong" pods (which are simple Ubuntu alpine containers), use the following command:
```bash
kubectl create -f ./L2S-M/descriptors/deployments/
kubectl create -f ./descriptors/deployments/
```
After a bit of time, check that both deployments were succesfully instantiated in your cluster.
After a bit of time, check that both deployments were successfully instantiated in your cluster.
### Testing the connectivity
......@@ -91,7 +93,7 @@ See if they can ping each using the ping command (e.g., in the "pong" pod):
ping 192.168.12.1
```
If you have ping betwen them, congratulations! You are now able to deploy your applications attached to the virtual network "my-fist-network" at your K8s cluster. You will notice that the *ttl* of these packets is 64: this is the case because they see each other as if they were in the same broadcast domain (i.e., in the same LAN). You can further test this fact by installing and using the *traceroute* command:
If you have ping between them, congratulations! You are now able to deploy your applications attached to the virtual network "my-fist-network" at your K8s cluster. You will notice that the *ttl* of these packets is 64: this is the case because they see each other as if they were in the same broadcast domain (i.e., in the same LAN). You can further test this fact by installing and using the *traceroute* command:
```bash
apk update
......
apiVersion: apps/v1
kind: Deployment
apiVersion: v1
kind: Pod
metadata:
name: ping-l2sm
name: ping
labels:
app: test2
annotations:
k8s.v1.cni.cncf.io/networks: first-network
spec:
replicas: 1
selector:
matchLabels:
app: ping-pong
template:
metadata:
labels:
app: ping-pong
annotations:
k8s.v1.cni.cncf.io/networks: my-first-network
spec:
containers:
- name: ping
command: ["/bin/ash", "-c", "trap : TERM INT; sleep infinity & wait"]
image: alpine:latest
securityContext:
capabilities:
add: ["NET_ADMIN"]
# Use this parameter if you want to place the pod in a specific node
# nodeName:
containers:
- name: router
command: ["/bin/ash", "-c", "trap : TERM INT; sleep infinity & wait"]
image: alpine:latest
securityContext:
capabilities:
add: ["NET_ADMIN"]
# Use this parameter if you want to place the pod in a specific node
nodeName: l2sm1
apiVersion: apps/v1
kind: Deployment
apiVersion: v1
kind: Pod
metadata:
name: pong-l2sm
name: pong
labels:
app: test2
annotations:
k8s.v1.cni.cncf.io/networks: first-network
spec:
replicas: 1
selector:
matchLabels:
app: ping-pong
template:
metadata:
labels:
app: ping-pong
annotations:
k8s.v1.cni.cncf.io/networks: my-first-network
spec:
containers:
- name: pong
command: ["/bin/ash", "-c", "trap : TERM INT; sleep infinity & wait"]
image: alpine:latest
securityContext:
capabilities:
add: ["NET_ADMIN"]
# Use this parameter if you want to place the pod in a specific node
# nodeName:
containers:
- name: router
command: ["/bin/ash", "-c", "trap : TERM INT; sleep infinity & wait"]
image: alpine:latest
securityContext:
capabilities:
add: ["NET_ADMIN"]
# Use this parameter if you want to place the pod in a specific node
nodeName: l2sm2
......@@ -4,7 +4,7 @@ This guide details the necessary steps to install the L2S-M Kubernetes operator
# Prerequisites
1. Clone the L2S-M repository in your host. This guide will assume that all commands are executed insideo the L2S-M directory.
1. Clone the L2S-M repository in your host. This guide will assume that all commands are executed within the L2S-M directory.
2. As a prerequisite to start with the installation of L2S-M, it is necessary to set up an IP tunnel overlay among the nodes of your k8s cluster (see [how L2S works](https://github.com/Networks-it-uc3m/L2S-M/tree/main/K8s). To do so, **the installation needs 10 vEth pairs in order to support the attachment of pods to virtual networks.**
......@@ -118,8 +118,27 @@ In order to connect the switches between themselves, an additional configuarion
```
In this example we have two nodes: l2sm1 and l2sm2, with two switches, with IP addresses 10.1.14.58 and 10.1.72.111.
We want to connect them directly, so we modify the reference file, ./operator/src/switch/sampleFile.json:
```json
[
{
"name": "<NODE_SWITCH_1>",
"nodeIP": "<IP_SWITCH_1>",
"neighborNodes": ["<NODE_SWITCH_2>"]
},
{
"name": "<NODE_SWITCH_2>",
"nodeIP": "<IP_SWITCH_2>",
"neighborNodes": ["<NODE_SWITCH_1>"]
}
]
```
Note: The parameters to be changed are shown in the NODE and IP columns of the table above.
Example of how it looks:
```json
[
{
"name": "l2sm1",
......@@ -141,12 +160,12 @@ Once this file is created, we inject it to each node using the kubectl cp comman
```bash
kubectl cp ./operator/src/switch/sampleFile.json <pod-name>:/etc/l2sm/switchConfig.json
```
And then executing the script in the pod:
And then executing the script in the switch-pod:
```bash
kubectl exec -it <pod-name> -- setup_switch.sh
kubectl exec -it <switch-pod-name> -- setup_switch.sh
```
This must be done in each pod. In the provided example, using two nodes, l2sm1 and l2sm2, we have to do it twice, in l2-ps-8p5td and l2-ps-xdkvz.
This must be done in each switch-pod. In the provided example, using two nodes, l2sm1 and l2sm2, we have to do it twice, in l2-ps-8p5td and l2-ps-xdkvz.
When the exec command is done, we should see an output like this:
```bash
......
[
{
"name": "l2sm1",
"nodeIP": "10.1.14.50",
"neighborNodes": ["l2sm2"]
"name": "<NODE_SWITCH_1>",
"nodeIP": "<IP_SWITCH_1>",
"neighborNodes": ["<NODE_SWITCH_2>"]
},
{
"name": "l2sm2",
"nodeIP": "10.1.72.69",
"neighborNodes": ["l2sm1"]
"name": "<NODE_SWITCH_2>",
"nodeIP": "<IP_SWITCH_2>",
"neighborNodes": ["<NODE_SWITCH_1>"]
}
]
\ No newline at end of file
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment