Deploy a Nokia SR-Linux MC-LAG Lab in Seconds with Containerlab

The revolution in network labs is real! A few years ago, setting up and testing a network architecture required purchasing physical devices, cabling them together, and enduring the noise of spinning fans, all just to run a few commands and experiment.

Times have changed. With the growing popularity of virtual machines running network operating systems (NOSes), we can now create virtual network topologies on our laptops. However, this approach has drawbacks: large topologies demand significant resources, and the deployment process can be time-consuming.

Thankfully, there’s a modern alternative: containers. In this article, we’ll show how to deploy a Nokia SR-Linux-based data center with MC-LAG in seconds, using containers.

Why Containers?

Containers offer a lightweight alternative to virtual machines. While both have their pros and cons, containers are a perfect fit for our use case.

However, before we jump into the deployment, we need a way to manage these containers. The best tool for the job? Containerlab.

Containerlab

Containerlab is a powerful tool designed for network engineers. Developed by Nokia (with significant contributions from Roman Dodin), it allows for rapid deployment of container-based network topologies.

As the name suggests, Containerlab leverages container runtimes like Docker to build network topologies. In our case, we’ll use Docker to run pre-configured SR-Linux nodes, meaning the entire topology will be up and fully operational after a single command.

Before we dive into the deployment, let’s install Containerlab.

Installation

Multiple installation methods are available, all well-documented in the official guide.

Docker Image

To deploy SR-Linux nodes, we need a Docker image. Fortunately, Nokia provides it for free via the GitHub Container Registry.

Topology

Our topology consists of:

  • 2 spine switches
  • 3 leaf switches
  • 2 clients

Even the client devices are SR-Linux containers, designed to simulate typical end-host scenarios:

  • Client1: uses LACP bonding with VLAN tagging
  • Client2: uses a classic L3 interface configuration

You can find a detailed breakdown of this setup in our previous article.

Let’s now explore the topology definition from the perspective of Containerlab.

Files and Repository

All topology files referenced in this article are available in this GitHub repository.

Definition

Containerlab uses a main YAML file to define the topology. Ours is called topology.yaml.clab. Let’s walk through its main sections.

name: sr-linux-mclag
topology:
  kinds:
    nokia_srlinux:
      image: ghcr.io/nokia/srlinux
  nodes:
    leaf1:
      kind: nokia_srlinux
      startup-config: configs/leaf1.cfg
    leaf2:
      kind: nokia_srlinux
      startup-config: configs/leaf2.cfg
    leaf3:
      kind: nokia_srlinux
      startup-config: configs/leaf3.cfg
  
    spine1:
      kind: nokia_srlinux
      type: ixrd3
      startup-config: configs/spine1.cfg
    spine2:
      kind: nokia_srlinux
      type: ixrd3
      startup-config: configs/spine2.cfg

    client1:
      kind: nokia_srlinux
      startup-config: configs/client1.cfg
    client2:
      kind: nokia_srlinux
      startup-config: configs/client2.cfg

  links:
    # leaf to spine links POD1
    - endpoints: ["leaf1:e1-1", "spine1:e1-1"]
    - endpoints: ["leaf1:e1-2", "spine2:e1-1"]
    - endpoints: ["leaf2:e1-1", "spine1:e1-2"]
    - endpoints: ["leaf2:e1-2", "spine2:e1-2"]

    # leaf to spine links POD2
    - endpoints: ["leaf3:e1-1", "spine1:e1-3"]
    - endpoints: ["leaf3:e1-2", "spine2:e1-3"]

    # client connection links
    - endpoints: ["client1:e1-1", "leaf1:e1-3"]
    - endpoints: ["client1:e1-2", "leaf2:e1-3"]
    - endpoints: ["client2:e1-1", "leaf3:e1-3"]

Kinds

This section lets us define common attributes for each device type used in the topology. Since all our nodes use the nokia_srlinux kind and the same container image, we define the image once here. Containerlab will apply it to all nodes of that kind automatically.

Nodes

Here we define each container to be deployed. Each node has:

  • A unique hostname as the key
  • A kind, referencing the device type
  • A startup-config parameter, pointing to a config file that will be applied at boot

Because the image is already defined in the kinds section, we don’t need to repeat it here.

Links

This section defines point-to-point connections between containers. Each entry describes a pair of endpoints, which makes wiring up the entire network simple.

Configs

Each node has its own configuration file. These files include the CLI commands that will be executed immediately after the container boots.

Let’s take a quick look at part of the configuration for spine1.

set / interface ethernet-1/1 admin-state enable
set / interface ethernet-1/1 mtu 9412
set / interface ethernet-1/1 ethernet port-speed 10G
set / interface ethernet-1/1 subinterface 0 admin-state enable
set / interface ethernet-1/1 subinterface 0 ip-mtu 9398
set / interface ethernet-1/1 subinterface 0 ipv4 admin-state enable
set / interface ethernet-1/1 subinterface 0 ipv4 address 192.0.2.0/31

With this setup, there’s no need to configure devices manually after deployment, because Containerlab handles it all.

Deployment

To deploy the entire topology, simply run the sudo containerlab deploy command inside the topology directory.

You can also use built-in alias clab instead of containerlab.

lukrad@SiedliskoZua:~/Documents/sr-linux-mclag/topology$ sudo clab deploy
INFO[0000] Containerlab v0.60.1 started                 
INFO[0000] Parsing & checking topology file: topology.clab.yaml 
INFO[0000] Creating docker network: Name="clab", IPv4Subnet="172.20.20.0/24", IPv6Subnet="3fff:172:20:20::/64", MTU=1500 
INFO[0000] Creating lab directory: /home/lukrad/Documents/sr-linux-mclag/topology/clab-sr-linux-mclag 
INFO[0000] Creating container: "client2"                
INFO[0000] Creating container: "spine1"                 
INFO[0000] Creating container: "leaf3"                  
INFO[0000] Creating container: "client1"                
INFO[0000] Creating container: "leaf1"                  
INFO[0000] Creating container: "leaf2"                  
INFO[0000] Running postdeploy actions for Nokia SR Linux 'client2' node 
INFO[0001] Created link: client2:e1-1 <--> leaf3:e1-3   
INFO[0001] Running postdeploy actions for Nokia SR Linux 'leaf3' node 
INFO[0001] Running postdeploy actions for Nokia SR Linux 'leaf1' node 
INFO[0001] Running postdeploy actions for Nokia SR Linux 'leaf2' node 
INFO[0001] Created link: client1:e1-1 <--> leaf1:e1-3   
INFO[0001] Created link: client1:e1-2 <--> leaf2:e1-3   
INFO[0001] Running postdeploy actions for Nokia SR Linux 'client1' node 
INFO[0001] Created link: leaf1:e1-1 <--> spine1:e1-1    
INFO[0001] Created link: leaf2:e1-1 <--> spine1:e1-2    
INFO[0001] Created link: leaf3:e1-1 <--> spine1:e1-3    
INFO[0001] Running postdeploy actions for Nokia SR Linux 'spine1' node 
INFO[0034] Creating container: "spine2"                 
INFO[0035] Created link: leaf1:e1-2 <--> spine2:e1-1    
INFO[0035] Created link: leaf2:e1-2 <--> spine2:e1-2    
INFO[0035] Created link: leaf3:e1-2 <--> spine2:e1-3    
INFO[0035] Running postdeploy actions for Nokia SR Linux 'spine2' node 
INFO[0055] Adding containerlab host entries to /etc/hosts file 
INFO[0055] Adding ssh config for containerlab nodes     
INFO[0055] 🎉 New containerlab version 0.68.0 is available! Release notes: https://containerlab.dev/rn/0.68/
Run 'containerlab version upgrade' to upgrade or go check other installation options at https://containerlab.dev/install/ 
╭─────────────────────────────┬───────────────────────┬─────────┬───────────────────╮
│             Name            │       Kind/Image      │  State  │   IPv4/6 Address  │
├─────────────────────────────┼───────────────────────┼─────────┼───────────────────┤
│ clab-sr-linux-mclag-client1 │ nokia_srlinux         │ running │ 172.20.20.6       │
│                             │ ghcr.io/nokia/srlinux │         │ 3fff:172:20:20::6 │
├─────────────────────────────┼───────────────────────┼─────────┼───────────────────┤
│ clab-sr-linux-mclag-client2 │ nokia_srlinux         │ running │ 172.20.20.2       │
│                             │ ghcr.io/nokia/srlinux │         │ 3fff:172:20:20::2 │
├─────────────────────────────┼───────────────────────┼─────────┼───────────────────┤
│ clab-sr-linux-mclag-leaf1   │ nokia_srlinux         │ running │ 172.20.20.3       │
│                             │ ghcr.io/nokia/srlinux │         │ 3fff:172:20:20::3 │
├─────────────────────────────┼───────────────────────┼─────────┼───────────────────┤
│ clab-sr-linux-mclag-leaf2   │ nokia_srlinux         │ running │ 172.20.20.5       │
│                             │ ghcr.io/nokia/srlinux │         │ 3fff:172:20:20::5 │
├─────────────────────────────┼───────────────────────┼─────────┼───────────────────┤
│ clab-sr-linux-mclag-leaf3   │ nokia_srlinux         │ running │ 172.20.20.4       │
│                             │ ghcr.io/nokia/srlinux │         │ 3fff:172:20:20::4 │
├─────────────────────────────┼───────────────────────┼─────────┼───────────────────┤
│ clab-sr-linux-mclag-spine1  │ nokia_srlinux         │ running │ 172.20.20.7       │
│                             │ ghcr.io/nokia/srlinux │         │ 3fff:172:20:20::7 │
├─────────────────────────────┼───────────────────────┼─────────┼───────────────────┤
│ clab-sr-linux-mclag-spine2  │ nokia_srlinux         │ running │ 172.20.20.8       │
│                             │ ghcr.io/nokia/srlinux │         │ 3fff:172:20:20::8 │
╰─────────────────────────────┴───────────────────────┴─────────┴───────────────────╯

Once deployed, Containerlab provides a table listing all active nodes. You can log in via SSH into each one using its hostname. The default credentials for Nokia SR-Linux are:

Username: admin  
Password: NokiaSrl1!
lukrad@SiedliskoZua:~/Documents/sr-linux-mclag$ ssh admin@clab-sr-linux-mclag-leaf1
Warning: Permanently added 'clab-sr-linux-mclag-leaf1' (ED25519) to the list of known hosts.
................................................................
:                  Welcome to Nokia SR Linux!                  :
:              Open Network OS for the NetOps era.             :
:                                                              :
:    This is a freely distributed official container image.    :
:                      Use it - Share it                       :
:                                                              :
: Get started: https://learn.srlinux.dev                       :
: Container:   https://go.srlinux.dev/container-image          :
: Docs:        https://doc.srlinux.dev/24-10                   :
: Rel. notes:  https://doc.srlinux.dev/rn24-10-1               :
: YANG:        https://yang.srlinux.dev/v24.10.1               :
: Discord:     https://go.srlinux.dev/discord                  :
: Contact:     https://go.srlinux.dev/contact-sales            :
................................................................

(admin@clab-sr-linux-mclag-leaf1) Password:
Using configuration file(s): ['/home/admin/.srlinuxrc']
Welcome to the srlinux CLI.
Type 'help' (and press <ENTER>) if you need any help using this.

--{ running }--[  ]--
A:leaf1#

Since those are normal Docker containers, we can display a list of running instances with the docker ps command.

lukrad@SiedliskoZua:~/Documents/sr-linux-mclag/topology$ docker ps
CONTAINER ID   IMAGE                   COMMAND                  CREATED              STATUS              PORTS     NAMES
c56fab0adacc   ghcr.io/nokia/srlinux   "/tini -- fixuid -q …"   About a minute ago   Up About a minute             clab-sr-linux-mclag-client1
5f7550d5ef26   ghcr.io/nokia/srlinux   "/tini -- fixuid -q …"   About a minute ago   Up About a minute             clab-sr-linux-mclag-leaf2
fe6315d19bc6   ghcr.io/nokia/srlinux   "/tini -- fixuid -q …"   About a minute ago   Up About a minute             clab-sr-linux-mclag-client2
da72094dd941   ghcr.io/nokia/srlinux   "/tini -- fixuid -q …"   About a minute ago   Up About a minute             clab-sr-linux-mclag-leaf3
fe1095fb3937   ghcr.io/nokia/srlinux   "/tini -- fixuid -q …"   About a minute ago   Up About a minute             clab-sr-linux-mclag-spine2
38001534b0ce   ghcr.io/nokia/srlinux   "/tini -- fixuid -q …"   About a minute ago   Up About a minute             clab-sr-linux-mclag-leaf1
c87375aac24a   ghcr.io/nokia/srlinux   "/tini -- fixuid -q …"   About a minute ago   Up About a minute             clab-sr-linux-mclag-spine1

Cleanup

We can perform a cleanup of the deployed topology by executing one command – sudo clab destroy.

lukrad@SiedliskoZua:~/Documents/sr-linux-mclag/topology$ sudo clab destroy 
INFO[0000] Parsing & checking topology file: topology.clab.yaml 
INFO[0000] Parsing & checking topology file: topology.clab.yaml 
INFO[0000] Destroying lab: sr-linux-mclag               
INFO[0001] Removed container: clab-sr-linux-mclag-client2 
INFO[0001] Removed container: clab-sr-linux-mclag-leaf3 
INFO[0001] Removed container: clab-sr-linux-mclag-spine1 
INFO[0001] Removed container: clab-sr-linux-mclag-leaf2 
INFO[0001] Removed container: clab-sr-linux-mclag-leaf1 
INFO[0001] Removed container: clab-sr-linux-mclag-client1 
INFO[0001] Removed container: clab-sr-linux-mclag-spine2 
INFO[0001] Removing containerlab host entries from /etc/hosts file 
INFO[0001] Removing ssh config for containerlab nodes   

Summary

Containerlab makes network testing incredibly efficient. In just seconds, we deployed a fully configured data center topology with MC-LAG using Nokia SR-Linux containers. Learning and experimenting have never been easier.

Curious about automating tests for your deployed topology using Python? Stay tuned for our future articles!

Authors

Share

Leave a Reply

Your email address will not be published. Required fields are marked *