Implement VRF/L3VNI Infrahub Transforms #21

Closed
opened 2026-02-27 12:19:31 +00:00 by Damien · 1 comment
Owner

Description

Create Infrahub Transforms for VRF configuration including L3VNI mapping for symmetric IRB in EVPN-VXLAN.

Context

VRFs provide Layer 3 multi-tenancy in the fabric. Each VRF is associated with an L3VNI for inter-VXLAN routing (Type-5 routes). Infrahub schema will store VRF intent with relationships to VNIs and interfaces.

Tasks

  • Define Infrahub schema for VRF objects (or leverage schema-library)
    • VRF instance (name, RD, route-targets)
    • L3VNI mapping
    • VRF-aware interfaces
  • Create GraphQL queries for VRF intent
    • vrf_instance_intent.gql - VRF config with L3VNI
    • vrf_interfaces_intent.gql - SVIs in VRF
    • vrf_bgp_intent.gql - BGP VRF address-family
  • Create Jinja2 transforms for YANG generation
    • vrf_instance_yang.j2 - VRF creation
    • vrf_vxlan_yang.j2 - VRF-to-VNI mapping
    • vrf_bgp_yang.j2 - BGP VRF config with RTs
  • Handle VRF-aware SVI with anycast gateway
  • Support symmetric IRB routing model

VRF Configuration Scope

# VRF Instance
vrf instance gold

# Enable routing in VRF
ip routing vrf gold

# VXLAN VRF-to-VNI mapping
interface Vxlan1
  vxlan vrf gold vni 100001

# BGP VRF configuration
router bgp 65002
  vrf gold
    rd 10.0.250.13:1
    route-target import evpn 1:100001
    route-target export evpn 1:100001
    redistribute connected

# VRF-aware SVI
interface Vlan34
  vrf gold
  ip address 10.34.34.2/24
  ip virtual-router address 10.34.34.1

Infrahub Schema (proposed)

# InfraVRF
- name: InfraVRF
  namespace: Infra
  attributes:
    - name: name
      kind: Text
    - name: rd
      kind: Text
      description: "Route Distinguisher"
    - name: l3vni
      kind: Number
      description: "L3 VNI for symmetric IRB"
  relationships:
    - name: import_targets
      peer: InfraRouteTarget
      cardinality: many
    - name: export_targets
      peer: InfraRouteTarget
      cardinality: many
    - name: interfaces
      peer: InfraInterface
      cardinality: many

Example Implementation

GraphQL Query (vrf_instance_intent.gql)

query VrfInstanceIntent($device: String!) {
  InfraVRF(devices__name__value: $device) {
    edges {
      node {
        name { value }
        rd { value }
        l3vni { value }
        import_targets { edges { node { target { value } } } }
        export_targets { edges { node { target { value } } } }
      }
    }
  }
}

Jinja2 Transform (vrf_instance_yang.j2)

{% for vrf in data.InfraVRF.edges %}
{% set v = vrf.node %}
{
  "path": "/network-instances/network-instance[name={{ v.name.value }}]",
  "value": {
    "config": {
      "name": "{{ v.name.value }}",
      "type": "L3VRF",
      "enabled": true
    }
  }
}{% if not loop.last %},{% endif %}
{% endfor %}

Jinja2 Transform (vrf_vxlan_yang.j2)

{% for vrf in data.InfraVRF.edges %}
{% set v = vrf.node %}
{% if v.l3vni %}
{
  "path": "/interfaces/interface[name=Vxlan1]/arista-exp-eos-vxlan:arista-vxlan/config/vrf-to-vni-v2/vrf-to-vni[vrf={{ v.name.value }}]",
  "value": {
    "vrf": "{{ v.name.value }}",
    "vni": {{ v.l3vni.value }}
  }
}{% if not loop.last %},{% endif %}
{% endif %}
{% endfor %}

.infrahub.yml Addition

jinja2_transforms:
  - name: vrf_instance_yang_transform
    description: "Generate YANG payload for VRF instances"
    query: vrf_instance_intent
    template_path: transforms/vrf_instance_yang.j2

  - name: vrf_vxlan_yang_transform
    description: "Generate YANG payload for VRF-to-VNI mapping"
    query: vrf_instance_intent
    template_path: transforms/vrf_vxlan_yang.j2

  - name: vrf_bgp_yang_transform
    description: "Generate YANG payload for BGP VRF config"
    query: vrf_bgp_intent
    template_path: transforms/vrf_bgp_yang.j2

queries:
  - name: vrf_instance_intent
    file_path: queries/vrf_instance_intent.gql
  - name: vrf_interfaces_intent
    file_path: queries/vrf_interfaces_intent.gql
  - name: vrf_bgp_intent
    file_path: queries/vrf_bgp_intent.gql

Output Files

transforms/
├── vrf_instance_yang.j2
├── vrf_vxlan_yang.j2
└── vrf_bgp_yang.j2
queries/
├── vrf_instance_intent.gql
├── vrf_interfaces_intent.gql
└── vrf_bgp_intent.gql
tests/
├── vrf_instance_transform_test.yml
├── vrf_vxlan_transform_test.yml
└── vrf_bgp_transform_test.yml

Acceptance Criteria

  • Transforms create VRF instances with proper type
  • L3VNI correctly mapped to VRF
  • Route-targets for EVPN import/export handled
  • VRF-aware SVIs with anycast gateway supported
  • Unit tests cover symmetric IRB scenarios

Migration Notes (from NetBox)

Before (NetBox) After (Infrahub)
VRF object + custom fields InfraVRF schema with relationships
l3vni custom field l3vni attribute
VrfMapper class vrf_*_yang_transform
## Description Create Infrahub Transforms for VRF configuration including L3VNI mapping for symmetric IRB in EVPN-VXLAN. ## Context VRFs provide Layer 3 multi-tenancy in the fabric. Each VRF is associated with an L3VNI for inter-VXLAN routing (Type-5 routes). Infrahub schema will store VRF intent with relationships to VNIs and interfaces. ## Tasks - [x] Define Infrahub schema for VRF objects (or leverage schema-library) - VRF instance (name, RD, route-targets) - L3VNI mapping - VRF-aware interfaces - [x] Create GraphQL queries for VRF intent - `vrf_instance_intent.gql` - VRF config with L3VNI - `vrf_interfaces_intent.gql` - SVIs in VRF - `vrf_bgp_intent.gql` - BGP VRF address-family - [x] Create Jinja2 transforms for YANG generation - `vrf_instance_yang.j2` - VRF creation - `vrf_vxlan_yang.j2` - VRF-to-VNI mapping - `vrf_bgp_yang.j2` - BGP VRF config with RTs - [x] Handle VRF-aware SVI with anycast gateway - [x] Support symmetric IRB routing model ## VRF Configuration Scope ``` # VRF Instance vrf instance gold # Enable routing in VRF ip routing vrf gold # VXLAN VRF-to-VNI mapping interface Vxlan1 vxlan vrf gold vni 100001 # BGP VRF configuration router bgp 65002 vrf gold rd 10.0.250.13:1 route-target import evpn 1:100001 route-target export evpn 1:100001 redistribute connected # VRF-aware SVI interface Vlan34 vrf gold ip address 10.34.34.2/24 ip virtual-router address 10.34.34.1 ``` ## Infrahub Schema (proposed) ```yaml # InfraVRF - name: InfraVRF namespace: Infra attributes: - name: name kind: Text - name: rd kind: Text description: "Route Distinguisher" - name: l3vni kind: Number description: "L3 VNI for symmetric IRB" relationships: - name: import_targets peer: InfraRouteTarget cardinality: many - name: export_targets peer: InfraRouteTarget cardinality: many - name: interfaces peer: InfraInterface cardinality: many ``` ## Example Implementation ### GraphQL Query (`vrf_instance_intent.gql`) ```graphql query VrfInstanceIntent($device: String!) { InfraVRF(devices__name__value: $device) { edges { node { name { value } rd { value } l3vni { value } import_targets { edges { node { target { value } } } } export_targets { edges { node { target { value } } } } } } } } ``` ### Jinja2 Transform (`vrf_instance_yang.j2`) ```jinja2 {% for vrf in data.InfraVRF.edges %} {% set v = vrf.node %} { "path": "/network-instances/network-instance[name={{ v.name.value }}]", "value": { "config": { "name": "{{ v.name.value }}", "type": "L3VRF", "enabled": true } } }{% if not loop.last %},{% endif %} {% endfor %} ``` ### Jinja2 Transform (`vrf_vxlan_yang.j2`) ```jinja2 {% for vrf in data.InfraVRF.edges %} {% set v = vrf.node %} {% if v.l3vni %} { "path": "/interfaces/interface[name=Vxlan1]/arista-exp-eos-vxlan:arista-vxlan/config/vrf-to-vni-v2/vrf-to-vni[vrf={{ v.name.value }}]", "value": { "vrf": "{{ v.name.value }}", "vni": {{ v.l3vni.value }} } }{% if not loop.last %},{% endif %} {% endif %} {% endfor %} ``` ### `.infrahub.yml` Addition ```yaml jinja2_transforms: - name: vrf_instance_yang_transform description: "Generate YANG payload for VRF instances" query: vrf_instance_intent template_path: transforms/vrf_instance_yang.j2 - name: vrf_vxlan_yang_transform description: "Generate YANG payload for VRF-to-VNI mapping" query: vrf_instance_intent template_path: transforms/vrf_vxlan_yang.j2 - name: vrf_bgp_yang_transform description: "Generate YANG payload for BGP VRF config" query: vrf_bgp_intent template_path: transforms/vrf_bgp_yang.j2 queries: - name: vrf_instance_intent file_path: queries/vrf_instance_intent.gql - name: vrf_interfaces_intent file_path: queries/vrf_interfaces_intent.gql - name: vrf_bgp_intent file_path: queries/vrf_bgp_intent.gql ``` ## Output Files ``` transforms/ ├── vrf_instance_yang.j2 ├── vrf_vxlan_yang.j2 └── vrf_bgp_yang.j2 queries/ ├── vrf_instance_intent.gql ├── vrf_interfaces_intent.gql └── vrf_bgp_intent.gql tests/ ├── vrf_instance_transform_test.yml ├── vrf_vxlan_transform_test.yml └── vrf_bgp_transform_test.yml ``` ## Acceptance Criteria - [ ] Transforms create VRF instances with proper type - [ ] L3VNI correctly mapped to VRF - [ ] Route-targets for EVPN import/export handled - [ ] VRF-aware SVIs with anycast gateway supported - [ ] Unit tests cover symmetric IRB scenarios ## Migration Notes (from NetBox) | Before (NetBox) | After (Infrahub) | |-----------------|------------------| | VRF object + custom fields | `InfraVRF` schema with relationships | | `l3vni` custom field | `l3vni` attribute | | `VrfMapper` class | `vrf_*_yang_transform` | ## Related - **Depends on: #41** (Infrahub Schema definition) - Depends on: #30 (Base Transforms), #31 (BGP for VRF AF) - Reference: [Arista EVPN Type-5 Configuration](https://overlaid.net/2019/01/27/arista-bgp-evpn-configuration-example/#example---transporting-l3vxlan-with-evpn)
Author
Owner

Branch feat/infrahub-transforms-vrf-l3vni created from main for this issue.

Note: This branch should be rebased on feat/infrahub-transforms-vlan-interfaces-vxlan (issue #20) once that PR is merged, as it depends on the transforms infrastructure created there.

Branch `feat/infrahub-transforms-vrf-l3vni` created from `main` for this issue. Note: This branch should be rebased on `feat/infrahub-transforms-vlan-interfaces-vxlan` (issue #20) once that PR is merged, as it depends on the transforms infrastructure created there.
Damien added reference feat/infrahub-transforms-vrf-l3vni 2026-03-01 10:30:47 +00:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Damien/arista-evpn-vxlan-clab#21