Skip to content
This repository was archived by the owner on Dec 9, 2025. It is now read-only.

Commit 97d38e5

Browse files
committed
add more documentation
Change-Id: I8c03027fc199477b3310c8225d737b7dc6103dd1
1 parent d1ac4e1 commit 97d38e5

File tree

2 files changed

+204
-0
lines changed

2 files changed

+204
-0
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
title: "Interface Status"
3+
date: 2025-05-25T11:30:40Z
4+
---
5+
6+
To configure network interfaces in DraNet, users can provide custom configurations through the parameters field of a ResourceClaim or ResourceClaimTemplate. This configuration adheres to the NetworkConfig structure, which defines the desired state for network interfaces and their associated routes.
7+
8+
### Network Configuration Overview
9+
10+
The primary structure for custom network configuration is NetworkConfig. It encompasses settings for the network interface itself and any specific routes to be applied within the Pod's network namespace.
11+
12+
```go
13+
type NetworkConfig struct {
14+
Interface InterfaceConfig `json:"interface"`
15+
Routes []RouteConfig `json:"routes"`
16+
}
17+
```
18+
19+
#### Interface Configuration
20+
21+
The InterfaceConfig structure allows you to specify details for a single network interface.
22+
23+
```go
24+
type InterfaceConfig struct {
25+
Name string `json:"name,omitempty"`
26+
Addresses []string `json:"addresses,omitempty"`
27+
MTU int32 `json:"mtu,omitempty"`
28+
HardwareAddr string `json:"hardwareAddr,omitempty"`
29+
}
30+
```
31+
32+
* **name** (string, optional): The logical name that the interface will have inside the Pod (e.g., "eth0", "enp0s3"). If not specified, DraNet will keep the original name if compliant.
33+
* **addresses** ([]string, optional): A list of IP addresses in CIDR format (e.g., "192.168.1.10/24", "2001:db8::1/64") to be assigned to the interface.
34+
* **mtu** (int32, optional): The Maximum Transmission Unit for the interface.
35+
* **hardwareAddr** (string, optional, Read-Only): The current hardware (MAC) address of the interface.
36+
37+
#### **Route Configuration (RouteConfig)**
38+
39+
The RouteConfig structure defines individual network routes to be added to the Pod's network namespace, associated with the configured interface.
40+
41+
```go
42+
type RouteConfig struct {
43+
Destination string `json:"destination,omitempty"`
44+
Gateway string `json:"gateway,omitempty"`
45+
Source string `json:"source,omitempty"`
46+
Scope uint8 `json:"scope,omitempty"`
47+
}
48+
```
49+
50+
* **destination** (string, optional): The destination network in CIDR format (e.g., "0.0.0.0/0" for a default route, "10.0.0.0/8" for a specific subnet).
51+
* **gateway** (string, optional): The IP address of the gateway for the route. This field is mandatory for routes with Universe scope (0).
52+
* **source** (string, optional): An optional source IP address for policy routing.
53+
* **scope** (uint8, optional): The scope of the route. Only Link (253) or Universe (0) are allowed.
54+
* Link (253): Routes directly to a device without a gateway (e.g., for directly connected subnets).
55+
* Universe (0): Routes to a network via a gateway.
56+
57+
### **Example: Customizing a Network Interface and Routes**
58+
59+
Below is an example of a ResourceClaim that allocates a dummy interface, renames it to "eth99", assigns a static IP address, and configures two routes: one to a subnet via a gateway and another link-scoped route.
60+
61+
62+
```yaml
63+
apiVersion: resource.k8s.io/v1beta1
64+
kind: ResourceClaim
65+
metadata:
66+
name: dummy-interface-static-ip-route
67+
spec:
68+
devices:
69+
requests:
70+
- name: req-dummy
71+
deviceClassName: dra.net
72+
selectors:
73+
- cel:
74+
expression: device.attributes["dra.net"].type == "dummy"
75+
config:
76+
- opaque:
77+
driver: dra.net
78+
parameters:
79+
interface:
80+
name: "eth99"
81+
addresses:
82+
- "169.254.169.13/32"
83+
routes:
84+
- destination: "169.254.169.0/24"
85+
gateway: "169.254.169.1"
86+
- destination: "169.254.169.1/32"
87+
scope: 253
88+
---
89+
apiVersion: v1
90+
kind: Pod
91+
metadata:
92+
name: pod3
93+
labels:
94+
app: pod
95+
spec:
96+
containers:
97+
- name: ctr1
98+
image: registry.k8s.io/e2e-test-images/agnhost:2.39
99+
resourceClaims:
100+
- name: dummy1
101+
resourceClaimName: dummy-interface-static-ip-route
102+
```
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
title: "Interface Configuration"
3+
date: 2025-05-25T11:30:40Z
4+
---
5+
6+
To configure network interfaces in DraNet, users can provide custom configurations through the parameters field of a ResourceClaim or ResourceClaimTemplate. This configuration adheres to the NetworkConfig structure, which defines the desired state for network interfaces and their associated routes.
7+
8+
### Network Configuration Overview
9+
10+
The primary structure for custom network configuration is NetworkConfig. It encompasses settings for the network interface itself and any specific routes to be applied within the Pod's network namespace.
11+
12+
```go
13+
type NetworkConfig struct {
14+
Interface InterfaceConfig `json:"interface"`
15+
Routes []RouteConfig `json:"routes"`
16+
}
17+
```
18+
19+
#### Interface Configuration
20+
21+
The InterfaceConfig structure allows you to specify details for a single network interface.
22+
23+
```go
24+
type InterfaceConfig struct {
25+
Name string `json:"name,omitempty"`
26+
Addresses []string `json:"addresses,omitempty"`
27+
MTU int32 `json:"mtu,omitempty"`
28+
HardwareAddr string `json:"hardwareAddr,omitempty"`
29+
}
30+
```
31+
32+
* **name** (string, optional): The logical name that the interface will have inside the Pod (e.g., "eth0", "enp0s3"). If not specified, DraNet will keep the original name if compliant.
33+
* **addresses** ([]string, optional): A list of IP addresses in CIDR format (e.g., "192.168.1.10/24", "2001:db8::1/64") to be assigned to the interface.
34+
* **mtu** (int32, optional): The Maximum Transmission Unit for the interface.
35+
* **hardwareAddr** (string, optional, Read-Only): The current hardware (MAC) address of the interface.
36+
37+
#### **Route Configuration (RouteConfig)**
38+
39+
The RouteConfig structure defines individual network routes to be added to the Pod's network namespace, associated with the configured interface.
40+
41+
```go
42+
type RouteConfig struct {
43+
Destination string `json:"destination,omitempty"`
44+
Gateway string `json:"gateway,omitempty"`
45+
Source string `json:"source,omitempty"`
46+
Scope uint8 `json:"scope,omitempty"`
47+
}
48+
```
49+
50+
* **destination** (string, optional): The destination network in CIDR format (e.g., "0.0.0.0/0" for a default route, "10.0.0.0/8" for a specific subnet).
51+
* **gateway** (string, optional): The IP address of the gateway for the route. This field is mandatory for routes with Universe scope (0).
52+
* **source** (string, optional): An optional source IP address for policy routing.
53+
* **scope** (uint8, optional): The scope of the route. Only Link (253) or Universe (0) are allowed.
54+
* Link (253): Routes directly to a device without a gateway (e.g., for directly connected subnets).
55+
* Universe (0): Routes to a network via a gateway.
56+
57+
### **Example: Customizing a Network Interface and Routes**
58+
59+
Below is an example of a ResourceClaim that allocates a dummy interface, renames it to "eth99", assigns a static IP address, and configures two routes: one to a subnet via a gateway and another link-scoped route.
60+
61+
62+
```yaml
63+
apiVersion: resource.k8s.io/v1beta1
64+
kind: ResourceClaim
65+
metadata:
66+
name: dummy-interface-static-ip-route
67+
spec:
68+
devices:
69+
requests:
70+
- name: req-dummy
71+
deviceClassName: dra.net
72+
selectors:
73+
- cel:
74+
expression: device.attributes["dra.net"].type == "dummy"
75+
config:
76+
- opaque:
77+
driver: dra.net
78+
parameters:
79+
interface:
80+
name: "eth99"
81+
addresses:
82+
- "169.254.169.13/32"
83+
routes:
84+
- destination: "169.254.169.0/24"
85+
gateway: "169.254.169.1"
86+
- destination: "169.254.169.1/32"
87+
scope: 253
88+
---
89+
apiVersion: v1
90+
kind: Pod
91+
metadata:
92+
name: pod3
93+
labels:
94+
app: pod
95+
spec:
96+
containers:
97+
- name: ctr1
98+
image: registry.k8s.io/e2e-test-images/agnhost:2.39
99+
resourceClaims:
100+
- name: dummy1
101+
resourceClaimName: dummy-interface-static-ip-route
102+
```

0 commit comments

Comments
 (0)