Skip to content

Commit 145e7a8

Browse files
committed
kind-sriov: Allow to use DRA
In order to allow using DRA driver, export KUBEVIRT_USE_DRA=true. It will skip installing the DP and CNI, and install DRA driver instead. We still create VFs, and unbind them. It suits vfio driver of DRA. Manifest was generated with helm template sriov-dra \ ./deployments/helm/dra-driver-sriov/ \ --set image.tag=$(git rev-parse --short=7 HEAD) \ -n dra-driver-sriov | \ sed '/helm.sh\/chart:/d' | \ sed '/app.kubernetes.io\/version:/d' | \ sed '/app.kubernetes.io\/managed-by: Helm/d' Signed-off-by: Or Shoval <[email protected]>
1 parent 7b98e8b commit 145e7a8

File tree

3 files changed

+317
-3
lines changed

3 files changed

+317
-3
lines changed

cluster-up/cluster/kind-sriov/config_sriov_cluster.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ set -xe
66

77
PF_COUNT_PER_NODE=${PF_COUNT_PER_NODE:-1}
88
[ $PF_COUNT_PER_NODE -le 0 ] && echo "FATAL: PF_COUNT_PER_NODE must be a positive integer" >&2 && exit 1
9+
KUBEVIRT_USE_DRA=${KUBEVIRT_USE_DRA:-false}
910

1011
SCRIPT_PATH=$(dirname "$(realpath "$0")")
1112

@@ -59,14 +60,20 @@ node::configure_sriov_vfs "${worker_nodes[*]}" "$VFS_DRIVER" "$VFS_DRIVER_KMODUL
5960

6061
## Deploy Multus and SRIOV components
6162
sriov_components::deploy_multus
62-
sriov_components::deploy \
63+
64+
if [[ "$KUBEVIRT_USE_DRA" != "true" ]]; then
65+
sriov_components::deploy \
6366
"$PFS_IN_USE" \
6467
"$VFS_DRIVER" \
6568
"$SRIOVDP_RESOURCE_PREFIX" "$SRIOVDP_RESOURCE_NAME" \
6669
"$SRIOV_NODE_LABEL_KEY" "$SRIOV_NODE_LABEL_VALUE"
6770

68-
# Verify that each sriov capable node has sriov VFs allocatable resource
69-
validate_nodes_sriov_allocatable_resource
71+
# Verify that each sriov capable node has sriov VFs allocatable resource
72+
validate_nodes_sriov_allocatable_resource
73+
else
74+
sriov_components::deploy_dra
75+
fi
76+
7077
sriov_components::wait_pods_ready
7178

7279
_kubectl get nodes
Lines changed: 297 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,297 @@
1+
---
2+
# Source: dra-driver-sriov-chart/templates/serviceaccount.yaml
3+
apiVersion: v1
4+
kind: ServiceAccount
5+
metadata:
6+
name: sriov-dra-dra-driver-sriov-chart-service-account
7+
namespace: dra-driver-sriov
8+
labels:
9+
app.kubernetes.io/name: dra-driver-sriov-chart
10+
app.kubernetes.io/instance: sriov-dra
11+
---
12+
# Source: dra-driver-sriov-chart/templates/sriovnetwork.k8snetworkplumbingwg.io_sriovresourcefilters.yaml
13+
apiVersion: apiextensions.k8s.io/v1
14+
kind: CustomResourceDefinition
15+
metadata:
16+
annotations:
17+
controller-gen.kubebuilder.io/version: v0.14.0
18+
name: sriovresourcefilters.sriovnetwork.k8snetworkplumbingwg.io
19+
spec:
20+
group: sriovnetwork.k8snetworkplumbingwg.io
21+
names:
22+
kind: SriovResourceFilter
23+
listKind: SriovResourceFilterList
24+
plural: sriovresourcefilters
25+
singular: sriovresourcefilter
26+
scope: Namespaced
27+
versions:
28+
- name: v1alpha1
29+
schema:
30+
openAPIV3Schema:
31+
description: SriovResourceFilter is a filter for SR-IOV resources
32+
properties:
33+
apiVersion:
34+
description: |-
35+
APIVersion defines the versioned schema of this representation of an object.
36+
Servers should convert recognized schemas to the latest internal value, and
37+
may reject unrecognized values.
38+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
39+
type: string
40+
kind:
41+
description: |-
42+
Kind is a string value representing the REST resource this object represents.
43+
Servers may infer this from the endpoint the client submits requests to.
44+
Cannot be updated.
45+
In CamelCase.
46+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
47+
type: string
48+
metadata:
49+
type: object
50+
spec:
51+
description: SriovResourceFilterSpec is the spec for a SriovResourceFilter
52+
properties:
53+
configs:
54+
items:
55+
properties:
56+
resourceFilters:
57+
items:
58+
description: ResourceFilter is a filter for a resource
59+
properties:
60+
devices:
61+
items:
62+
type: string
63+
type: array
64+
drivers:
65+
items:
66+
type: string
67+
type: array
68+
numaNodes:
69+
items:
70+
type: string
71+
type: array
72+
pciAddresses:
73+
items:
74+
type: string
75+
type: array
76+
pfNames:
77+
items:
78+
type: string
79+
type: array
80+
rootDevices:
81+
items:
82+
type: string
83+
type: array
84+
vendors:
85+
items:
86+
type: string
87+
type: array
88+
type: object
89+
type: array
90+
resourceName:
91+
type: string
92+
type: object
93+
type: array
94+
nodeSelector:
95+
additionalProperties:
96+
type: string
97+
type: object
98+
type: object
99+
required:
100+
- spec
101+
type: object
102+
served: true
103+
storage: true
104+
---
105+
# Source: dra-driver-sriov-chart/templates/clusterrole.yaml
106+
apiVersion: rbac.authorization.k8s.io/v1
107+
kind: ClusterRole
108+
metadata:
109+
name: sriov-dra-dra-driver-sriov-chart-role
110+
namespace: dra-driver-sriov
111+
rules:
112+
- apiGroups: ["resource.k8s.io"]
113+
resources: ["resourceclaims"]
114+
verbs: ["get"]
115+
- apiGroups: ["resource.k8s.io"]
116+
resources: ["resourceclaims/status"]
117+
verbs: ["get","list","update","patch"]
118+
- apiGroups: [""]
119+
resources: ["nodes"]
120+
verbs: ["get", "list", "watch"] # Cluster-scoped resource, needs cluster permissions
121+
- apiGroups: ["resource.k8s.io"]
122+
resources: ["resourceslices"]
123+
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
124+
- apiGroups: ["k8s.cni.cncf.io"]
125+
resources: ["network-attachment-definitions"]
126+
verbs: ["get"]
127+
- apiGroups: ["sriovnetwork.k8snetworkplumbingwg.io"]
128+
resources: ["sriovresourcefilters"]
129+
verbs: ["get", "list", "watch"] # SriovResourceFilter resources
130+
---
131+
# Source: dra-driver-sriov-chart/templates/clusterrolebinding.yaml
132+
apiVersion: rbac.authorization.k8s.io/v1
133+
kind: ClusterRoleBinding
134+
metadata:
135+
name: sriov-dra-dra-driver-sriov-chart-role-binding
136+
namespace: dra-driver-sriov
137+
subjects:
138+
- kind: ServiceAccount
139+
name: sriov-dra-dra-driver-sriov-chart-service-account
140+
namespace: dra-driver-sriov
141+
roleRef:
142+
kind: ClusterRole
143+
name: sriov-dra-dra-driver-sriov-chart-role
144+
apiGroup: rbac.authorization.k8s.io
145+
---
146+
# Source: dra-driver-sriov-chart/templates/dra-driver.yaml
147+
apiVersion: apps/v1
148+
kind: DaemonSet
149+
metadata:
150+
name: sriov-dra-dra-driver-sriov-chart-kubeletplugin
151+
namespace: dra-driver-sriov
152+
labels:
153+
app.kubernetes.io/name: dra-driver-sriov-chart
154+
app.kubernetes.io/instance: sriov-dra
155+
app.kubernetes.io/component: kubeletplugin
156+
spec:
157+
selector:
158+
matchLabels:
159+
app.kubernetes.io/name: dra-driver-sriov-chart
160+
app.kubernetes.io/instance: sriov-dra
161+
app.kubernetes.io/component: kubeletplugin
162+
updateStrategy:
163+
type: RollingUpdate
164+
template:
165+
metadata:
166+
labels:
167+
app.kubernetes.io/name: dra-driver-sriov-chart
168+
app.kubernetes.io/instance: sriov-dra
169+
app.kubernetes.io/component: kubeletplugin
170+
spec:
171+
terminationGracePeriodSeconds: 30
172+
hostNetwork: true
173+
hostPID: true
174+
priorityClassName: system-node-critical
175+
serviceAccountName: sriov-dra-dra-driver-sriov-chart-service-account
176+
securityContext:
177+
{}
178+
initContainers:
179+
- args:
180+
- --no-sleep
181+
image: ghcr.io/k8snetworkplumbingwg/sriov-cni:v2.10.0
182+
imagePullPolicy: IfNotPresent
183+
name: sriov-cni
184+
resources:
185+
requests:
186+
cpu: 10m
187+
memory: 10Mi
188+
securityContext:
189+
privileged: true
190+
terminationMessagePath: /dev/termination-log
191+
terminationMessagePolicy: File
192+
volumeMounts:
193+
- mountPath: /host/opt/cni/bin
194+
name: cni-bin
195+
- mountPath: /host/etc/os-release
196+
name: os-release
197+
readOnly: true
198+
containers:
199+
- name: plugin
200+
securityContext:
201+
privileged: true
202+
image: ghcr.io/k8snetworkplumbingwg/dra-driver-sriov:4889196
203+
imagePullPolicy: Always
204+
command:
205+
# - dlv
206+
# - --listen=:2345
207+
# - --headless=true
208+
# - --api-version=2
209+
# - --accept-multiclient
210+
# - exec
211+
- /usr/bin/dra-driver-sriov
212+
resources:
213+
{}
214+
215+
env:
216+
- name: CDI_ROOT
217+
value: /var/run/cdi
218+
- name: KUBELET_REGISTRAR_DIRECTORY_PATH
219+
value: "/var/lib/kubelet/plugins_registry"
220+
- name: KUBELET_PLUGINS_DIRECTORY_PATH
221+
value: "/var/lib/kubelet/plugins"
222+
- name: NRI_PLUGIN_NAME
223+
value: "dra-driver-sriov"
224+
- name: NRI_PLUGIN_IDX
225+
value: "42"
226+
- name: DEFAULT_INTERFACE_PREFIX
227+
value: "vfnet"
228+
- name: NODE_NAME
229+
valueFrom:
230+
fieldRef:
231+
fieldPath: spec.nodeName
232+
- name: NAMESPACE
233+
valueFrom:
234+
fieldRef:
235+
fieldPath: metadata.namespace
236+
- name: HEALTHCHECK_PORT
237+
value: "-1"
238+
# Logging configuration
239+
- name: V
240+
value: "3"
241+
- name: LOG_FORMAT
242+
value: "text"
243+
- name: ALSOLOGTOSTDERR
244+
value: "true"
245+
volumeMounts:
246+
- name: plugins-registry
247+
mountPath: "/var/lib/kubelet/plugins_registry"
248+
- name: plugins
249+
mountPath: "/var/lib/kubelet/plugins"
250+
- name: cdi
251+
mountPath: /var/run/cdi
252+
- name: cri-socket
253+
mountPath: /var/run/nri/nri.sock
254+
- name: netns
255+
mountPath: /var/run/netns
256+
mountPropagation: HostToContainer
257+
- name: cni-results
258+
mountPath: /var/lib/cni/
259+
- name: cni-bin
260+
mountPath: /opt/cni/bin
261+
volumes:
262+
- name: cni-results
263+
hostPath:
264+
path: /var/lib/cni/
265+
- name: netns
266+
hostPath:
267+
path: /var/run/netns
268+
- name: cri-socket
269+
hostPath:
270+
path: /var/run/nri/nri.sock
271+
type: Socket
272+
- name: plugins-registry
273+
hostPath:
274+
path: "/var/lib/kubelet/plugins_registry"
275+
- name: plugins
276+
hostPath:
277+
path: "/var/lib/kubelet/plugins"
278+
- name: cdi
279+
hostPath:
280+
path: /var/run/cdi
281+
- hostPath:
282+
path: /opt/cni/bin
283+
name: cni-bin
284+
- hostPath:
285+
path: /etc/os-release
286+
type: File
287+
name: os-release
288+
---
289+
# Source: dra-driver-sriov-chart/templates/deviceclass.yaml
290+
apiVersion: resource.k8s.io/v1
291+
kind: DeviceClass
292+
metadata:
293+
name: sriovnetwork.k8snetworkplumbingwg.io
294+
spec:
295+
selectors:
296+
- cel:
297+
expression: "device.driver == 'sriovnetwork.k8snetworkplumbingwg.io'"

cluster-up/cluster/kind-sriov/sriov-components/sriov_components.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ PATCH_NODE_SELECTOR="${CUSTOM_MANIFESTS}/patch-node-selector.yaml"
2020
KUBECONFIG="${KUBEVIRTCI_CONFIG_PATH}/$KUBEVIRT_PROVIDER/.kubeconfig"
2121
KUBECTL="${KUBEVIRTCI_CONFIG_PATH}/$KUBEVIRT_PROVIDER/.kubectl --kubeconfig=${KUBECONFIG}"
2222

23+
SRIOV_DRA_MANIFEST="${MANIFESTS_DIR}/dra/sriov_dra.yaml"
24+
SRIOV_DRA_NAMESPACE="dra-driver-sriov"
25+
2326
function _kubectl() {
2427
${KUBECTL} "$@"
2528
}
@@ -138,6 +141,13 @@ function sriov_components::deploy() {
138141
return 0
139142
}
140143

144+
function sriov_components::deploy_dra() {
145+
_kubectl create namespace "$SRIOV_DRA_NAMESPACE"
146+
_kubectl apply -f "$SRIOV_DRA_MANIFEST"
147+
148+
return 0
149+
}
150+
141151
function _create_custom_manifests_dir() {
142152
mkdir -p "$CUSTOM_MANIFESTS"
143153

0 commit comments

Comments
 (0)