Skip to content

Commit 85879aa

Browse files
committed
Adapting the documentation, and the official examples in preparation for the upcoming DANM 4.0 release.
Also adding extra demo materials showcasing the usage of the new APIs. Changing two little validation mistakes discovered during document update: - max allowed NID shall be 11, not 12 - host_device should not be allowed together with device_pool for non-SR-IOV networks as well
1 parent ac3daf6 commit 85879aa

23 files changed

+490
-80
lines changed

Diff for: README.md

+246-79
Large diffs are not rendered by default.

Diff for: example/4_0_examples/0_wrong_tconf.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: danm.k8s.io/v1
2+
kind: TenantConfig
3+
metadata:
4+
name: wrong-tconf
5+
hostDevices:
6+
- name: ens4
7+
vniType: vlan
8+
networkIds:
9+
flannel: flannel

Diff for: example/4_0_examples/10_good_deployment.yaml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apiVersion: apps/v1beta1
2+
kind: Deployment
3+
metadata:
4+
name: test-deployment
5+
namespace: default
6+
spec:
7+
replicas: 1
8+
template:
9+
metadata:
10+
labels:
11+
app: test-deployment
12+
annotations:
13+
danm.k8s.io/interfaces: |
14+
[
15+
{"tenantNetwork":"management", "ip":"dynamic"},
16+
{"clusterNetwork":"external", "ip":"dynamic"},
17+
{"tenantNetwork":"internal", "ip":"dynamic"}
18+
]
19+
spec:
20+
containers:
21+
- name: busybox
22+
image: busybox:latest
23+
args:
24+
- sleep
25+
- "1000"

Diff for: example/4_0_examples/11_allowed_default.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: apps/v1beta1
2+
kind: Deployment
3+
metadata:
4+
name: test-deployment
5+
namespace: default
6+
spec:
7+
replicas: 1
8+
template:
9+
metadata:
10+
labels:
11+
app: test-deployment
12+
spec:
13+
containers:
14+
- name: busybox
15+
image: busybox:latest
16+
args:
17+
- sleep
18+
- "1000"

Diff for: example/4_0_examples/12_not_allowed_default.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: apps/v1beta1
2+
kind: Deployment
3+
metadata:
4+
name: test-deployment
5+
namespace: kube-system
6+
spec:
7+
replicas: 1
8+
template:
9+
metadata:
10+
labels:
11+
app: test-deployment
12+
spec:
13+
containers:
14+
- name: busybox
15+
image: busybox:latest
16+
args:
17+
- sleep
18+
- "1000"

Diff for: example/4_0_examples/1_good_tconf.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: danm.k8s.io/v1
2+
kind: TenantConfig
3+
metadata:
4+
name: tconf
5+
hostDevices:
6+
- name: ens4
7+
vniType: vlan
8+
vniRange: 1000-2000
9+
- name: ens5
10+
vniType: vlan
11+
vniRange: 2000-3000
12+
networkIds:
13+
flannel: flannel

Diff for: example/4_0_examples/2_tnet_with_vlan.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: danm.k8s.io/v1
2+
kind: TenantNetwork
3+
metadata:
4+
name: internal
5+
namespace: default
6+
spec:
7+
NetworkID: internal
8+
NetworkType: ipvlan
9+
Options:
10+
host_device: ens4
11+
container_prefix: int
12+
rt_tables: 200
13+
vlan: 700
14+
cidr: 10.240.1.0/24
15+
allocation_pool:
16+
start: 10.240.1.100
17+
end: 10.240.1.200

Diff for: example/4_0_examples/3_chosen_device.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: danm.k8s.io/v1
2+
kind: TenantNetwork
3+
metadata:
4+
name: internal
5+
namespace: default
6+
spec:
7+
NetworkID: internal
8+
NetworkType: ipvlan
9+
Options:
10+
host_device: ens4
11+
container_prefix: int
12+
rt_tables: 200
13+
cidr: 10.240.1.0/24
14+
allocation_pool:
15+
start: 10.240.1.100
16+
end: 10.240.1.200

Diff for: example/4_0_examples/4_random_device.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: danm.k8s.io/v1
2+
kind: TenantNetwork
3+
metadata:
4+
name: internal2
5+
namespace: default
6+
spec:
7+
NetworkID: internal2
8+
NetworkType: ipvlan
9+
Options:
10+
container_prefix: int2
11+
rt_tables: 200
12+
cidr: 10.250.1.0/24
13+
allocation_pool:
14+
start: 10.250.1.100
15+
end: 10.250.1.200

Diff for: example/4_0_examples/5_wrong_device.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: danm.k8s.io/v1
2+
kind: TenantNetwork
3+
metadata:
4+
name: internal3
5+
namespace: default
6+
spec:
7+
NetworkID: internal3
8+
NetworkType: ipvlan
9+
Options:
10+
host_device: ens6
11+
container_prefix: int
12+
rt_tables: 200
13+
cidr: 10.251.1.0/24
14+
allocation_pool:
15+
start: 10.251.1.100
16+
end: 10.251.1.200

Diff for: example/4_0_examples/6_static_tnet.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: danm.k8s.io/v1
2+
kind: TenantNetwork
3+
metadata:
4+
name: management
5+
namespace: default
6+
spec:
7+
NetworkID: iknowitbetter
8+
NetworkType: flannel

Diff for: example/4_0_examples/7_default_cnet.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: danm.k8s.io/v1
2+
kind: ClusterNetwork
3+
metadata:
4+
name: default
5+
spec:
6+
NetworkID: flannel
7+
NetworkType: flannel
8+
AllowedTenants:
9+
- default

Diff for: example/4_0_examples/8_external_cnet.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: danm.k8s.io/v1
2+
kind: ClusterNetwork
3+
metadata:
4+
name: external
5+
spec:
6+
NetworkID: external
7+
NetworkType: ipvlan
8+
Options:
9+
host_device: ens4
10+
vlan: 500
11+
container_prefix: ext
12+
rt_tables: 100
13+
cidr: 10.100.1.0/24
14+
allocation_pool:
15+
start: 10.100.1.100
16+
end: 10.100.1.200

Diff for: example/4_0_examples/9_wrong_deployment.yaml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: apps/v1beta1
2+
kind: Deployment
3+
metadata:
4+
name: test-deployment
5+
namespace: default
6+
spec:
7+
replicas: 1
8+
template:
9+
metadata:
10+
labels:
11+
app: test-deployment
12+
annotations:
13+
danm.k8s.io/interfaces: |
14+
[
15+
{"tenantNetwork":"management", "clusterNetwork":"external", "ip":"dynamic"}
16+
]
17+
spec:
18+
containers:
19+
- name: busybox
20+
image: busybox:latest
21+
args:
22+
- sleep
23+
- "1000"
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: danm.k8s.io/v1
2+
kind: DanmNet
3+
metadata:
4+
name: flannel
5+
namespace: kube-system
6+
spec:
7+
NetworkID: flannel
8+
NetworkType: flannel
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: danm.k8s.io/v1
2+
kind: TenantNetwork
3+
metadata:
4+
name: flannel
5+
namespace: kube-system
6+
spec:
7+
NetworkID: flannel
8+
NetworkType: flannel
File renamed without changes.

Diff for: integration/crds/DanmNet.yaml renamed to integration/crds/lightweight/DanmNet.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ spec:
5454
rt_tables:
5555
type: integer
5656
format: int32
57+
minimum: 0
58+
maximum: 255
5759
net6:
5860
type: string
5961
pattern: '^s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*(\/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8]))$'

Diff for: integration/crds/ClusterNetwork.yaml renamed to integration/crds/production/ClusterNetwork.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ spec:
5858
rt_tables:
5959
type: integer
6060
format: int32
61+
minimum: 0
62+
maximum: 255
6163
net6:
6264
type: string
6365
pattern: '^s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*(\/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8]))$'

Diff for: integration/crds/production/DanmEp.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: apiextensions.k8s.io/v1beta1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
name: danmeps.danm.k8s.io
5+
spec:
6+
scope: Namespaced
7+
group: danm.k8s.io
8+
version: v1
9+
names:
10+
kind: DanmEp
11+
plural: danmeps
12+
singular: danmep
13+
shortNames:
14+
- de
15+
- dep
File renamed without changes.

Diff for: integration/crds/TenantNetwork.yaml renamed to integration/crds/production/TenantNetwork.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ spec:
5454
rt_tables:
5555
type: integer
5656
format: int32
57+
minimum: 0
58+
maximum: 255
5759
net6:
5860
type: string
5961
pattern: '^s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*(\/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8]))$'

Diff for: pkg/admit/validators.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
const (
15-
MaxNidLength = 12
15+
MaxNidLength = 11
1616
)
1717

1818
var (
@@ -127,6 +127,7 @@ func validateTenantNetRules(oldManifest, newManifest *danmtypes.DanmNet, opType
127127
}
128128
if opType == admissionv1.Update &&
129129
(newManifest.Spec.Options.Device != oldManifest.Spec.Options.Device ||
130+
newManifest.Spec.Options.DevicePool != oldManifest.Spec.Options.DevicePool ||
130131
newManifest.Spec.Options.Vxlan != oldManifest.Spec.Options.Vxlan ||
131132
newManifest.Spec.Options.Vlan != oldManifest.Spec.Options.Vlan) {
132133
return errors.New("Manually changing any one of host_device, vlan, or vxlan attributes is not allowed for TenantNetworks!")
@@ -189,6 +190,8 @@ func validateNeType(oldManifest, newManifest *danmtypes.DanmNet, opType admissio
189190
if newManifest.Spec.Options.DevicePool == "" || newManifest.Spec.Options.Device != "" {
190191
return errors.New("DevicePool must, and host_device cannot be provided for SR-IOV networks!")
191192
}
193+
} else if newManifest.Spec.Options.Device != "" && newManifest.Spec.Options.DevicePool != "" {
194+
return errors.New("DevicePool and host_device cannot be provided together!")
192195
}
193196
return nil
194197
}

0 commit comments

Comments
 (0)