Skip to content

Commit 59535ed

Browse files
committed
- update README.md
- change netns mount folder
1 parent 1daabea commit 59535ed

4 files changed

Lines changed: 63 additions & 61 deletions

File tree

README.md

Lines changed: 60 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,23 @@ This installs k8slan in the namespace `k8slan-system`. change the namespace in t
9292
apiVersion: lan.k8slan.io/v1beta1
9393
kind: LAN
9494
metadata:
95-
name: lan-test
95+
name: lan-example
9696
spec:
9797
ns: knlvrf
9898
bridge: br2
9999
vxlan: vx2
100100
vni: 222
101-
defaultVxlanDev: eth0.10
101+
defaultVxlanDev: eth0
102102
vxlanDevMap:
103103
worker1: eth1
104104
worker2: eth2
105105
spokes:
106-
- pod1
107-
- pod2
106+
- srl
107+
- vm
108108
```
109+
- `ns` specifies the net namespace dedicate for the virtual LAN, it mounts under `/run/k8slan/netns/` of each k8s worker
110+
- `bridge` specifies the local bridge interface name, lives in the LAN namespace
111+
- `vni` specifies the VNI used for the VXLAN tunnel
109112
- `vxlanDevMap` list which interface to use as vxlan interface underlying device on the specified host, key is the hostname, value is the interface name; if a host is not listed here, then `defaultVxlanDev` is used
110113
- `spokes` is a list of veth interface names, one for each connecting pod; in case of kubevirt VM, a macvtap interface is created on top of the veth interface.
111114
- following values must be unique across all LAN CRs
@@ -116,94 +119,93 @@ spec:
116119
**Note: having duplicate value for above field could cause networking issue and/or connecting pod failed to create**
117120

118121
2. k8slan will create two NetworkAttachmentDefinition for each spoke in the CR:
119-
- one is `k8slan-mac-<spoke>`
120-
- one is `k8slan-veth-<spoke>`
122+
- `k8slan-mac-<spoke>`: use by kubevirt VM to attach
123+
- `k8slan-veth-<spoke>`: use for pod to attach
121124

122-
3. create the pod attach to the LAN:
123-
- reference the NetworkAttachmentDefinition with prefix `k8slan-veth-`
124-
- reference spoke name in resource section: `macvtap.k8slan.io/k8slan-veth-pod2: 1`
125+
note: For a given spoke, only one of these two should be used, not both.
126+
127+
128+
3. create the pod/vm attach to the LAN:
129+
130+
3a. for pod
131+
- reference the NetworkAttachmentDefinition with prefix `k8slan-veth-<spoke>`
132+
- reference spoke name in resource section: `macvtap.k8slan.io/k8slan-veth-<spoke>: 1`
133+
134+
following is an example for Nokia SRL pod:
125135
```
126136
apiVersion: v1
127137
kind: Pod
128138
metadata:
129-
name: nginx
139+
name: srl-test
130140
annotations:
131-
k8s.v1.cni.cncf.io/networks: k8slan-veth-pod2
141+
k8s.v1.cni.cncf.io/networks: k8slan-veth-srl@e1-1
132142
spec:
133143
containers:
134-
- name: nginx
135-
image: nginx:1.14.2
136-
ports:
137-
- containerPort: 80
144+
- name: main
145+
image: ghcr.io/nokia/srlinux:25.7
146+
command:
147+
- /tini
148+
- --
149+
- /usr/local/bin/fixuid
150+
- -q
151+
- /entrypoint.sh
152+
- sudo
153+
- -E
154+
- bash
155+
- -c
156+
- "touch /.dockerenv && /opt/srlinux/bin/sr_linux"
157+
securityContext:
158+
privileged: true
138159
resources:
139160
limits:
140-
macvtap.k8slan.io/k8slan-veth-pod2: 1
161+
macvtap.k8slan.io/k8slan-veth-srl: 1
141162
```
142163

143-
3a. Or create a kubevirt VM connect to the LAN
164+
3b. create a kubevirt VM connect to the LAN
144165
- refer to [kubevirt macvtap guide](https://kubevirt.io/user-guide/network/net_binding_plugins/macvtap/).
145-
- reference to the NetworkAttachmentDefinition with prefix `k8slan-mac-` in the `networks` section
166+
- reference to the NetworkAttachmentDefinition with prefix `k8slan-mac-<spoke>` in the `networks` section
146167
```
147168
apiVersion: kubevirt.io/v1
148169
kind: VirtualMachine
149170
metadata:
150-
labels:
151-
kubevirt.io/vm: vm-net-binding-macvtap
152-
name: testvm-1
171+
name: testvm
153172
spec:
154173
runStrategy: Always
155174
template:
156175
metadata:
157176
labels:
158-
kubevirt.io/vm: testvm-1
177+
kubevirt.io/size: small
178+
kubevirt.io/domain: testvm
159179
spec:
160180
domain:
161181
devices:
162182
disks:
163-
- disk:
164-
bus: virtio
165-
name: containerdisk
166-
- disk:
167-
bus: virtio
168-
name: cloudinitdisk
183+
- name: containerdisk
184+
disk:
185+
bus: virtio
186+
- name: cloudinitdisk
187+
disk:
188+
bus: virtio
169189
interfaces:
170-
- name: podnet
190+
- name: default
171191
masquerade: {}
172-
ports:
173-
- name: ssh
174-
port: 22
175-
- name: hostnetwork
192+
- name: link1
176193
binding:
177194
name: macvtap
178-
rng: {}
179195
resources:
180196
requests:
181-
memory: 1024M
197+
memory: 64M
182198
networks:
183-
- name: podnet
199+
- name: default
184200
pod: {}
185-
- name: hostnetwork
201+
- name: link1
186202
multus:
187-
networkName: k8slan-mac-pod1
188-
terminationGracePeriodSeconds: 0
203+
networkName: k8slan-mac-vm
189204
volumes:
190-
- containerDisk:
191-
image: localhost/mytool:v1
192-
name: containerdisk
193-
- cloudInitNoCloud:
194-
userData: |
195-
#cloud-config
196-
ssh_pwauth: True
197-
users:
198-
- name: test
199-
shell: /bin/bash
200-
plain_text_passwd: test123
201-
lock_passwd: false
202-
sudo: ALL=(ALL) NOPASSWD:ALL
203-
networkData: |
204-
version: 2
205-
ethernets:
206-
enp1s0:
207-
dhcp4: true
208-
name: cloudinitdisk
205+
- name: containerdisk
206+
containerDisk:
207+
image: quay.io/kubevirt/cirros-container-disk-demo
208+
- name: cloudinitdisk
209+
cloudInitNoCloud:
210+
userDataBase64: SGkuXG4=
209211
```

config/daemonset/daemonset.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@ spec:
6969
type: ""
7070
name: deviceplugin
7171
- hostPath:
72-
path: /root/k8slanns
72+
path: /run/k8slan/netns
7373
type: ""
7474
name: ns

config/daemonset/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ kind: Kustomization
55
images:
66
- name: controller
77
newName: localhost/k8slan
8-
newTag: v41
8+
newTag: v42

config/manager/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ kind: Kustomization
55
images:
66
- name: controller
77
newName: localhost/k8slan
8-
newTag: v41
8+
newTag: v42

0 commit comments

Comments
 (0)