Skip to content

Commit

Permalink
Add support for using SR-IOV resource bundles for CP interfaces and C…
Browse files Browse the repository at this point in the history
…P and vRouter MGMT interfaces (#21)

* Add additional cpuset options (#13)

* Fix cpu count env var error (#14)

* just change password to secret (#15)

* added sriov for cp interfaces

* added tests that XR_NETWORK_STATUS_ANNOTATION_PATH is not present

* added sriov for cp mgmt interfaces

* sriov mgmt interfaces added for vrouter

* fixed anySRIOV bug

* small ut fix

* markups

---------

Co-authored-by: ebeaty-cisco <[email protected]>
  • Loading branch information
2 people authored and GitHub Enterprise committed Oct 23, 2024
1 parent e906001 commit f0ccb8a
Show file tree
Hide file tree
Showing 15 changed files with 265 additions and 47 deletions.
2 changes: 1 addition & 1 deletion charts/xrd-common/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ keywords:
- xrd
sources:
- https://github.com/ios-xr/xrd-helm
version: 1.1.0-beta.3
version: 1.1.0-beta.4
6 changes: 5 additions & 1 deletion charts/xrd-common/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ Convert a k8s resource specification of Mi or Gi into MiB for XR env vars.

{{- /*
Should the NetworkStatusAnnotation be mounted?
Returns a string equivalent to boolean true if there are any sriov data
interfaces on vRouter, or an empty string otherwise.
*/ -}}
{{- define "xrd.mountNetworkStatusAnnotation" -}}
{{- include "xrd.interfaces.anySRIOV" . -}}
{{- if and (include "xrd.interfaces.anySRIOVData" .) (eq .Chart.Name "xrd-vrouter") }}
1
{{- end }}
{{- end -}}
18 changes: 15 additions & 3 deletions charts/xrd-common/templates/_interfaces.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,19 @@ or an empty string otherwise.

{{- define "xrd.interfaces.anySRIOV" -}}
{{- /*
Returns a string equivalent to boolean true if there are any sriov network interfaces,
Returns a string equivalent to boolean true if there are any sriov interfaces,
or an empty string otherwise.
*/ -}}
{{- range (concat .Values.interfaces .Values.mgmtInterfaces) }}
{{- if eq .type "sriov" }}
1
{{- end }}
{{- end }}
{{- end -}}

{{- define "xrd.interfaces.anySRIOVData" -}}
{{- /*
Returns a string equivalent to boolean true if there are any sriov data interfaces,
or an empty string otherwise.
*/ -}}
{{- range .Values.interfaces }}
Expand Down Expand Up @@ -54,7 +66,7 @@ or an empty string otherwise.

{{- define "xrd.interfaces.linuxflags" -}}
{{- $flags := list }}
{{- $base := list "type" "config" "attachmentConfig" }}
{{- $base := list "type" "config" "attachmentConfig" "resource" }}
{{- range $k, $v := . -}}
{{- if eq $k "snoopIpv4Address" }}
{{- if $v }}
Expand Down Expand Up @@ -82,7 +94,7 @@ or an empty string otherwise.
{{- end }}
{{- $flags = append $flags (printf "xr_name=%s" $v) }}
{{- else if not (has $k $base) }}
{{- fail (printf "%s may not be specified for defaultCni or multus interfaces" $k) }}
{{- fail (printf "%s may not be specified for defaultCni, multus or sriov interfaces" $k) }}
{{- end }}
{{- end }}
{{- join "," $flags }}
Expand Down
4 changes: 2 additions & 2 deletions charts/xrd-control-plane/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ keywords:
- xrd
sources:
- https://github.com/ios-xr/xrd-helm
version: 1.1.0-beta.3
version: 1.1.0-beta.4
dependencies:
- name: xrd-common
version: 1.1.0-beta.3
version: 1.1.0-beta.4
repository: "file://../xrd-common"
33 changes: 31 additions & 2 deletions charts/xrd-control-plane/templates/_interfaces.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,27 @@
{{- if hasKey . "attachmentConfig" }}
{{- fail "attachmentConfig may not be specified for defaultCni interfaces" }}
{{- end }}
{{- if hasKey . "resource" }}
{{- fail "resource may not be specified for defaultCni interface types" }}
{{- end }}
{{- $flags := include "xrd.interfaces.linuxflags" . }}
{{- if $flags }}
{{- $interfaces = append $interfaces (printf "linux:eth0,%s" $flags) }}
{{- else }}
{{- $interfaces = append $interfaces "linux:eth0" }}
{{- end }}
{{- else if eq .type "multus" }}
{{- else if or (eq .type "multus") (eq .type "sriov") }}
{{- $flags := include "xrd.interfaces.linuxflags" . }}
{{- if eq .type "sriov" }}
{{- if hasKey . "attachmentConfig" }}
{{- fail "attachmentConfig may not be specified for sriov interface types" }}
{{- end }}
{{- if not (hasKey . "resource") }}
{{- fail "Resource must be specified for sriov interface types" }}
{{- end }}
{{- else if hasKey . "resource" }}
{{- fail "resource may not be specified for multus interface types" }}
{{- end }}
{{- if $flags }}
{{- $interfaces = append $interfaces (printf "linux:net%d,%s" $cniIndex $flags) }}
{{- else }}
Expand All @@ -38,14 +51,30 @@
{{- include "xrd.interfaces.checkDefaultCniCount" . -}}
{{- range .Values.mgmtInterfaces }}
{{- if eq .type "defaultCni" }}
{{- if hasKey . "attachmentConfig" }}
{{- fail "attachmentConfig may not be specified for defaultCni mgmt interfaces" }}
{{- end }}
{{- if hasKey . "resource" }}
{{- fail "resource may not be specified for defaultCni mgmt interface types" }}
{{- end }}
{{- $flags := include "xrd.interfaces.linuxflags" . }}
{{- if $flags }}
{{- $interfaces = append $interfaces (printf "linux:eth0,%s" $flags) }}
{{- else }}
{{- $interfaces = append $interfaces "linux:eth0" }}
{{- end }}
{{- else if eq .type "multus" }}
{{- else if or (eq .type "multus") (eq .type "sriov") }}
{{- $flags := include "xrd.interfaces.linuxflags" . }}
{{- if eq .type "sriov" }}
{{- if hasKey . "attachmentConfig" }}
{{- fail "attachmentConfig may not be specified for sriov mgmt interface types" }}
{{- end }}
{{- if not (hasKey . "resource") }}
{{- fail "Resource must be specified for sriov mgmt interface types" }}
{{- end }}
{{- else if hasKey . "resource" }}
{{- fail "resource may not be specified for multus mgmt interface types" }}
{{- end }}
{{- if $flags }}
{{- $interfaces = append $interfaces (printf "linux:net%d,%s" $cniIndex $flags) }}
{{- else }}
Expand Down
18 changes: 14 additions & 4 deletions charts/xrd-control-plane/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,12 @@
"type": "object",
"properties": {
"type": {
"description": "Underying interface type. One of: 'defaultCni' or 'multus'",
"description": "Underlying interface type. One of: 'defaultCni', 'multus' or 'sriov'",
"type": "string",
"enum": [
"defaultCni",
"multus"
"multus",
"sriov"
]
},
"config": {
Expand All @@ -273,6 +274,10 @@
"description": "Network attachment annotation configuration, for multus-type interfaces only",
"type": "object"
},
"resource": {
"description": "SR-IOV resource-pool name, for sriov-type interfaces only",
"type": "string"
},
"snoopIpv4Address": {
"description": "Indicate whether to snoop the pre-existing IPv4 address of the interface into XR config",
"type": "boolean",
Expand Down Expand Up @@ -316,11 +321,12 @@
"type": "object",
"properties": {
"type": {
"description": "Underying interface type. One of: 'defaultCni' or 'multus'",
"description": "Underlying interface type. One of: 'defaultCni', 'multus' or 'sriov'",
"type": "string",
"enum": [
"defaultCni",
"multus"
"multus",
"sriov"
]
},
"config": {
Expand All @@ -331,6 +337,10 @@
"description": "Network attachment annotation configuration, for multus-type interfaces only",
"type": "object"
},
"resource": {
"description": "SR-IOV resource-pool name, for sriov-type interfaces only",
"type": "string"
},
"snoopIpv4Address": {
"description": "Indicate whether to snoop the pre-existing IPv4 address of the interface into XR config",
"type": "boolean",
Expand Down
21 changes: 19 additions & 2 deletions charts/xrd-control-plane/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,17 @@ config:
# specified under the 'config' field for the interface.
# Any attachment annotation configuration may be specified under
# the 'attachmentConfig' field.
# - sriov: This connects an additional network allocated from an SR-IOV
# network resource pool and created using a CNI plugin, driven
# by the multus meta-CNI plugin.
# An SR-IOV resource pool must be specified under the 'resource'
# key for the interface.
# The network attachment definition configuration must be
# specified under the 'config' field for the interface. Config
# is required to specify and configure the CNI used.
#
# On 'defaultCni' and 'multus' interfaces, the following options may also
# be specified to control the interface behavior in XR:
# On 'defaultCni', 'multus' and 'sriov' interfaces, the following options may
# also be specified to control the interface behavior in XR:
# - chksum: Turn on TCP/UDP checksum calculation for ingress packets (to
# counteract checksum offload to hardware).
# - xrName: Customize the XR interface name for this interface.
Expand All @@ -204,6 +212,11 @@ interfaces: []
# type: host-device
# device: eth1
# xrName: GigabitEthernet0/0/0/3
#- type: sriov
# resource: intel.com/intel_sriov_netdevice_1
# config:
# type: sriov
# vlan: 1

# XRd management interfaces.
mgmtInterfaces: []
Expand All @@ -222,6 +235,10 @@ mgmtInterfaces: []
# attachmentConfig:
# ips:
# - "10.0.0.1/24"
#- type: sriov
# resource: intel.com/intel_sriov_netdevice_2
# config:
# type: sriov

# XRd advanced settings.
# This section contains settings not required by most users.
Expand Down
4 changes: 2 additions & 2 deletions charts/xrd-vrouter/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ keywords:
- xrd
sources:
- https://github.com/ios-xr/xrd-helm
version: 2.0.0-beta.2
version: 2.0.0-beta.3
dependencies:
- name: xrd-common
version: 1.1.0-beta.3
version: 1.1.0-beta.4
repository: "file://../xrd-common"
15 changes: 14 additions & 1 deletion charts/xrd-vrouter/templates/_interfaces.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@
{{- include "xrd.interfaces.checkDefaultCniCount" . -}}
{{- range .Values.mgmtInterfaces }}
{{- if eq .type "defaultCni" }}
{{- if hasKey . "attachmentConfig" }}
{{- fail "attachmentConfig may not be specified for defaultCni mgmt interface types" }}
{{- end }}
{{- if (hasKey . "xrName") }}
{{- fail "xrName may not be specified for interfaces on XRd vRouter" }}
{{- end }}
Expand All @@ -94,11 +97,21 @@
{{- else }}
{{- $interfaces = append $interfaces "linux:eth0" }}
{{- end }}
{{- else if eq .type "multus" }}
{{- else if or (eq .type "multus") (eq .type "sriov") }}
{{- if (hasKey . "xrName") }}
{{- fail "xrName may not be specified for interfaces on XRd vRouter" }}
{{- end }}
{{- $flags := include "xrd.interfaces.linuxflags" . }}
{{- if eq .type "sriov" }}
{{- if hasKey . "attachmentConfig" }}
{{- fail "attachmentConfig may not be specified for sriov mgmt interface types" }}
{{- end }}
{{- if not (hasKey . "resource") }}
{{- fail "Resource must be specified for sriov mgmt interface types" }}
{{- end }}
{{- else if hasKey . "resource" }}
{{- fail "resource may not be specified for multus mgmt interface types" }}
{{- end }}
{{- if $flags }}
{{- $interfaces = append $interfaces (printf "linux:net%d,%s" $cniIndex $flags) }}
{{- else }}
Expand Down
9 changes: 7 additions & 2 deletions charts/xrd-vrouter/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,12 @@
"type": "object",
"properties": {
"type": {
"description": "Underlying interface type. One of: 'defaultCni' or 'multus'",
"description": "Underlying interface type. One of: 'defaultCni', 'multus' or 'sriov'",
"type": "string",
"enum": [
"defaultCni",
"multus"
"multus",
"sriov"
]
},
"config": {
Expand All @@ -302,6 +303,10 @@
"description": "Network attachment annotation configuration, for multus-type interfaces only",
"type": "object"
},
"resource": {
"description": "SR-IOV resource-pool name, for sriov-type interfaces only",
"type": "string"
},
"snoopIpv4Address": {
"description": "Indicate whether to snoop the pre-existing IPv4 address of the interface into XR config",
"type": "boolean",
Expand Down
14 changes: 9 additions & 5 deletions charts/xrd-vrouter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,12 @@ config:
# The network attachment definition configuration must be
# specified under the 'config' field for the interface. Config
# is required to specify and configure the CNI used.
# This can be specified as a line interface only.
#
# On 'defaultCni' and 'multus' interfaces, the following options may also
# be specified to control the interface behavior in XR:
# On 'defaultCni' and 'multus' interfaces, and 'sriov' interfaces when used as
# a management interface, the following options may also be specified to
# control the interface behavior in XR:
# - chksum: Turn on TCP/UDP checksum calculation for ingress packets (to
# counteract checksum offload to hardware).
# - xrName: Customize the XR interface name for this interface.
# - snoopIpv4Address: see below.
# - snoopIpv4DefaultRoute: see below.
# - snoopIpv6Address: see below.
Expand All @@ -229,7 +228,7 @@ interfaces: []
# config:
# last: 3
#- type: sriov
# resource: intel.com/intel_sriov_netdevice
# resource: intel.com/intel_sriov_netdevice_1
# config:
# type: sriov
# vlan: 1
Expand All @@ -251,6 +250,11 @@ mgmtInterfaces: []
# attachmentConfig:
# ips:
# - "10.0.0.1/24"
#- type: sriov
# resource: intel.com/intel_sriov_netdevice_2
# config:
# type: sriov
# snoopIpv4Address: true

# Add a runtimeClassName to the XRd Pod.
# Refer to https://kubernetes.io/docs/concepts/containers/runtime-class/.
Expand Down
Loading

0 comments on commit f0ccb8a

Please sign in to comment.