Skip to content

Commit a975b84

Browse files
authored
Helm chart changes to support OpenShift deployments (#16)
1 parent bf56a60 commit a975b84

File tree

22 files changed

+728
-200
lines changed

22 files changed

+728
-200
lines changed

.github/pull_request_template.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
### Summary
2+
3+
*Main description goes here.*
4+
5+
6+
### Checklist
7+
8+
- [ ] Version incremented
9+
<!-- The Helm charts in this repo use semantic versioning and the version must be increased for any change. -->
10+
- [ ] Changelog updated
11+
<!-- The changelog must be updated for any version change. -->
12+
- [ ] Version compatibility matrix updated (or not required)
13+
<!-- The version compatibility matrix must be updated for any major or minor version change. -->
14+
- [ ] Static analysis and tests passing
15+
- See `tests/README.md` for details.

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Changelog
2+
3+
## XRd vRouter
4+
5+
### v2 (active)
6+
7+
The v2 release supports Cisco IOS-XR release version 24.4.1 and above.
8+
9+
#### v2.0.0
10+
11+
- Change `cpu.hyperThreadingMode` options, adding `auto` and removing `off`.
12+
13+
### v1
14+
15+
The v1 release supports Cisco IOS-XR release versions from 7.7.1 to 24.3.1.
16+
17+
## XRd Control Plane
18+
19+
### v1 (active)
20+
21+
The v1 release supports Cisco IOS-XR release versions 7.7.1 and above.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ There are two application charts provided in this repository:
1010
There is also a library chart provided, xrd-common, that is used by both
1111
of the application charts.
1212

13+
See [CHANGELOG.md](./CHANGELOG.md) for a record of changes that have been made.
14+
15+
See [version-compatibility.md](./version-compatibility.md) for the compatibility statement across versions.
16+
1317
## Usage
1418

1519
[Helm](https://helm.sh) must be installed to use the charts. Please refer to

charts/xrd-common/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ keywords:
88
- xrd
99
sources:
1010
- https://github.com/ios-xr/xrd-helm
11-
version: 1.0.4
11+
version: 1.1.0

charts/xrd-common/templates/_helpers.tpl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,15 @@ Convert a k8s resource specification of Mi or Gi into MiB for XR env vars.
106106
{{- $out = "true" }}
107107
{{- end -}}
108108
{{ $out }}
109+
{{- end -}}
110+
111+
{{- /*
112+
Should the NetworkStatusAnnotation be mounted?
113+
Returns a string equivalent to boolean true if there are any sriov data
114+
interfaces on vRouter, or an empty string otherwise.
115+
*/ -}}
116+
{{- define "xrd.mountNetworkStatusAnnotation" -}}
117+
{{- if and (include "xrd.interfaces.anySRIOVData" .) (eq .Chart.Name "xrd-vrouter") }}
118+
1
119+
{{- end }}
109120
{{- end -}}

charts/xrd-common/templates/_interfaces.tpl

Lines changed: 60 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
11
{{- /* Helper templates */ -}}
2-
{{- define "xrd.interfaces.multusCount" -}}
3-
{{- $c := 0 }}
4-
{{- range . }}
5-
{{- if eq .type "multus" }}
6-
{{- $c = add1 $c }}
7-
{{- end }}
8-
{{- end }}
9-
{{- $c }}
10-
{{- end -}}
112

123
{{- define "xrd.interfaces.anyMultus" -}}
134
{{- /*
@@ -22,6 +13,40 @@ or an empty string otherwise.
2213
{{- end }}
2314
{{- end -}}
2415

16+
{{- define "xrd.interfaces.anySRIOV" -}}
17+
{{- /*
18+
Returns a string equivalent to boolean true if there are any sriov interfaces,
19+
or an empty string otherwise.
20+
*/ -}}
21+
{{- range (concat .Values.interfaces .Values.mgmtInterfaces) }}
22+
{{- if eq .type "sriov" }}
23+
1
24+
{{- end }}
25+
{{- end }}
26+
{{- end -}}
27+
28+
{{- define "xrd.interfaces.anySRIOVData" -}}
29+
{{- /*
30+
Returns a string equivalent to boolean true if there are any sriov data interfaces,
31+
or an empty string otherwise.
32+
*/ -}}
33+
{{- range .Values.interfaces }}
34+
{{- if eq .type "sriov" }}
35+
1
36+
{{- end }}
37+
{{- end }}
38+
{{- end -}}
39+
40+
{{- define "xrd.interfaces.cniCount" -}}
41+
{{- $c := 0 }}
42+
{{- range .Values.interfaces }}
43+
{{- if or (eq .type "sriov") (eq .type "multus") }}
44+
{{- $c = add1 $c }}
45+
{{- end }}
46+
{{- end }}
47+
{{- $c }}
48+
{{- end -}}
49+
2550
{{- define "xrd.interfaces.checkDefaultCniCount" -}}
2651
{{- $c := 0 }}
2752
{{- range .Values.interfaces }}
@@ -41,7 +66,7 @@ or an empty string otherwise.
4166

4267
{{- define "xrd.interfaces.linuxflags" -}}
4368
{{- $flags := list }}
44-
{{- $base := list "type" "config" "attachmentConfig" }}
69+
{{- $base := list "type" "config" "attachmentConfig" "resource" }}
4570
{{- range $k, $v := . -}}
4671
{{- if eq $k "snoopIpv4Address" }}
4772
{{- if $v }}
@@ -69,7 +94,7 @@ or an empty string otherwise.
6994
{{- end }}
7095
{{- $flags = append $flags (printf "xr_name=%s" $v) }}
7196
{{- else if not (has $k $base) }}
72-
{{- fail (printf "%s may not be specified for defaultCni or multus interfaces" $k) }}
97+
{{- fail (printf "%s may not be specified for defaultCni, multus or sriov interfaces" $k) }}
7398
{{- end }}
7499
{{- end }}
75100
{{- join "," $flags }}
@@ -86,16 +111,37 @@ or an empty string otherwise.
86111
{{- join "," $flags }}
87112
{{- end -}}
88113

114+
{{- define "xrd.interfaces.sriovflags" -}}
115+
{{- $flags := list }}
116+
{{- $base := list "type" "config" "resource" }}
117+
{{- range $k, $v := . -}}
118+
{{- if not (has $k $base) }}
119+
{{- fail (printf "%s may not be specified for sriov interfaces" $k) }}
120+
{{- end }}
121+
{{- end }}
122+
{{- join "," $flags }}
123+
{{- end -}}
124+
89125
{{- define "xrd.podNetworkAnnotations" -}}
90126
{{- $nets := list }}
91-
{{- range $idx, $intf := concat .Values.interfaces .Values.mgmtInterfaces }}
127+
{{- $cniIndex := 0}}
128+
{{- range $intf := concat .Values.interfaces .Values.mgmtInterfaces }}
92129
{{- if eq $intf.type "multus" }}
93-
{{- $netname := printf "%s-%d" (include "xrd.fullname" $) $idx }}
94-
{{- $entry := dict "name" $netname }}
130+
{{- $netname := printf "%s-%d" (include "xrd.fullname" $) $cniIndex }}
131+
{{- $intfname := printf "net%d" $cniIndex }}
132+
{{- $entry := dict "name" $netname "interface" $intfname}}
95133
{{- if $intf.attachmentConfig }}
96134
{{- $entry = merge $entry $intf.attachmentConfig }}
97135
{{- end }}
98136
{{- $nets = append $nets $entry }}
137+
{{- $cniIndex = add1 $cniIndex }}
138+
{{- end }}
139+
{{- if eq $intf.type "sriov" }}
140+
{{- $netname := printf "%s-%d" (include "xrd.fullname" $) $cniIndex }}
141+
{{- $intfname := printf "net%d" $cniIndex }}
142+
{{- $entry := dict "name" $netname "interface" $intfname}}
143+
{{- $nets = append $nets $entry }}
144+
{{- $cniIndex = add1 $cniIndex }}
99145
{{- end }}
100146
{{- end }}
101147
{{- toPrettyJson $nets }}
Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,35 @@
11
{{- define "xrd.network-attachments" -}}
2-
{{- range $idx, $intf := concat .Values.interfaces .Values.mgmtInterfaces }}
3-
{{- if eq $intf.type "multus" }}
2+
{{- $cniIndex := 0 }}
3+
{{- range $intf := concat .Values.interfaces .Values.mgmtInterfaces }}
4+
{{- if or (eq $intf.type "multus") (eq $intf.type "sriov") }}
45
---
56
apiVersion: k8s.cni.cncf.io/v1
67
kind: NetworkAttachmentDefinition
78
metadata:
8-
name: {{ include "xrd.fullname" $ }}-{{ $idx }}
9+
name: {{ include "xrd.fullname" $ }}-{{ $cniIndex }}
910
namespace: {{ $.Release.Namespace }}
10-
{{- if gt (len (include "xrd.commonAnnotations" $ | fromYaml)) 0 }}
11+
{{- if or (gt (len (include "xrd.commonAnnotations" $ | fromYaml)) 0) (eq $intf.type "sriov") }}
1112
annotations:
12-
{{- include "xrd.commonAnnotations" $ | nindent 4 }}
13+
{{- if eq $intf.type "sriov" }}
14+
k8s.v1.cni.cncf.io/resourceName: {{ $intf.resource }}
15+
{{- end }}
16+
{{- if gt (len (include "xrd.commonAnnotations" $ | fromYaml)) 0 }}
17+
{{- include "xrd.commonAnnotations" $ | nindent 4 }}
18+
{{- end }}
1319
{{- end }}
1420
labels:
1521
{{- include "xrd.commonLabels" $ | nindent 4 }}
1622
spec:
1723
config: |-
1824
{
1925
"cniVersion": "0.3.1",
26+
"name": "{{ include "xrd.fullname" $ }}-{{ $cniIndex }}",
2027
"plugins": [
2128
{{- $intf.config | toPrettyJson | nindent 8 }}
2229
]
2330
}
2431
...
32+
{{- $cniIndex = add1 $cniIndex}}
2533
{{- end }}
2634
{{- end -}}
2735
{{- end -}}

charts/xrd-common/templates/_statefulset.tpl

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ spec:
4040
{{- if gt (len (include "xrd.commonAnnotations" . | fromYaml)) 0}}
4141
{{- include "xrd.commonAnnotations" . | nindent 8 }}
4242
{{- end }}
43-
{{- if (include "xrd.interfaces.anyMultus" .) }}
43+
{{- if or (include "xrd.interfaces.anyMultus" .) (include "xrd.interfaces.anySRIOV" .) }}
4444
k8s.v1.cni.cncf.io/networks: |-
4545
{{- include "xrd.podNetworkAnnotations" . | nindent 10 }}
4646
{{- end }}
@@ -53,6 +53,12 @@ spec:
5353
{{- toYaml . | nindent 8 }}
5454
{{- end }}
5555
spec:
56+
{{- if .Values.serviceAccountName }}
57+
serviceAccountName: {{ .Values.serviceAccountName }}
58+
{{- end }}
59+
{{- if .Values.runtimeClassName }}
60+
runtimeClassName: {{ .Values.runtimeClassName }}
61+
{{- end }}
5662
{{- if .Values.hostNetwork }}
5763
hostNetwork: true
5864
{{- end }}
@@ -91,6 +97,14 @@ spec:
9197
type: Directory
9298
{{- end }}
9399
{{- end }}
100+
{{- if (include "xrd.mountNetworkStatusAnnotation" .) }}
101+
- downwardAPI:
102+
items:
103+
- fieldRef:
104+
fieldPath: metadata.annotations['k8s.v1.cni.cncf.io/network-status']
105+
path: "network-status-annotation"
106+
name: "network-status-annotation"
107+
{{- end }}
94108
{{- if .Values.extraVolumes }}
95109
{{- toYaml .Values.extraVolumes | nindent 6 }}
96110
{{- end }}
@@ -117,6 +131,10 @@ spec:
117131
name: config
118132
readOnly: true
119133
{{- end }}
134+
{{- if (include "xrd.mountNetworkStatusAnnotation" .) }}
135+
- mountPath: "/etc/xrd/network-status"
136+
name: "network-status-annotation"
137+
{{- end }}
120138
{{- if .Values.persistence.enabled }}
121139
- mountPath: /xr-storage
122140
name: xr-storage

charts/xrd-control-plane/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ keywords:
88
- xrd
99
sources:
1010
- https://github.com/ios-xr/xrd-helm
11-
version: 1.0.4
11+
version: 1.1.0
1212
dependencies:
1313
- name: xrd-common
14-
version: 1.0.4
14+
version: 1.1.0
1515
repository: "file://../xrd-common"

charts/xrd-control-plane/templates/_interfaces.tpl

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,33 @@
1010
{{- if hasKey . "attachmentConfig" }}
1111
{{- fail "attachmentConfig may not be specified for defaultCni interfaces" }}
1212
{{- end }}
13+
{{- if hasKey . "resource" }}
14+
{{- fail "resource may not be specified for defaultCni interface types" }}
15+
{{- end }}
1316
{{- $flags := include "xrd.interfaces.linuxflags" . }}
1417
{{- if $flags }}
1518
{{- $interfaces = append $interfaces (printf "linux:eth0,%s" $flags) }}
1619
{{- else }}
1720
{{- $interfaces = append $interfaces "linux:eth0" }}
1821
{{- end }}
19-
{{- else if eq .type "multus" }}
20-
{{- $cniIndex = add1 $cniIndex }}
22+
{{- else if or (eq .type "multus") (eq .type "sriov") }}
2123
{{- $flags := include "xrd.interfaces.linuxflags" . }}
24+
{{- if eq .type "sriov" }}
25+
{{- if hasKey . "attachmentConfig" }}
26+
{{- fail "attachmentConfig may not be specified for sriov interface types" }}
27+
{{- end }}
28+
{{- if not (hasKey . "resource") }}
29+
{{- fail "Resource must be specified for sriov interface types" }}
30+
{{- end }}
31+
{{- else if hasKey . "resource" }}
32+
{{- fail "resource may not be specified for multus interface types" }}
33+
{{- end }}
2234
{{- if $flags }}
2335
{{- $interfaces = append $interfaces (printf "linux:net%d,%s" $cniIndex $flags) }}
2436
{{- else }}
2537
{{- $interfaces = append $interfaces (printf "linux:net%d" $cniIndex) }}
2638
{{- end }}
39+
{{- $cniIndex = add1 $cniIndex }}
2740
{{- else }}
2841
{{- fail (printf "Invalid interface type %s" .type) }}
2942
{{- end }}
@@ -34,24 +47,40 @@
3447
{{- define "xrd-cp.mgmtInterfaces" -}}
3548
{{- /* Generate the XR_MGMT_INTERFACES environment variable content */ -}}
3649
{{- $interfaces := list }}
37-
{{- $cniIndex := atoi (include "xrd.interfaces.multusCount" .Values.interfaces) }}
50+
{{- $cniIndex := atoi (include "xrd.interfaces.cniCount" .) }}
3851
{{- include "xrd.interfaces.checkDefaultCniCount" . -}}
3952
{{- range .Values.mgmtInterfaces }}
4053
{{- if eq .type "defaultCni" }}
54+
{{- if hasKey . "attachmentConfig" }}
55+
{{- fail "attachmentConfig may not be specified for defaultCni mgmt interfaces" }}
56+
{{- end }}
57+
{{- if hasKey . "resource" }}
58+
{{- fail "resource may not be specified for defaultCni mgmt interface types" }}
59+
{{- end }}
4160
{{- $flags := include "xrd.interfaces.linuxflags" . }}
4261
{{- if $flags }}
4362
{{- $interfaces = append $interfaces (printf "linux:eth0,%s" $flags) }}
4463
{{- else }}
4564
{{- $interfaces = append $interfaces "linux:eth0" }}
4665
{{- end }}
47-
{{- else if eq .type "multus" }}
48-
{{- $cniIndex = add1 $cniIndex }}
66+
{{- else if or (eq .type "multus") (eq .type "sriov") }}
4967
{{- $flags := include "xrd.interfaces.linuxflags" . }}
68+
{{- if eq .type "sriov" }}
69+
{{- if hasKey . "attachmentConfig" }}
70+
{{- fail "attachmentConfig may not be specified for sriov mgmt interface types" }}
71+
{{- end }}
72+
{{- if not (hasKey . "resource") }}
73+
{{- fail "Resource must be specified for sriov mgmt interface types" }}
74+
{{- end }}
75+
{{- else if hasKey . "resource" }}
76+
{{- fail "resource may not be specified for multus mgmt interface types" }}
77+
{{- end }}
5078
{{- if $flags }}
5179
{{- $interfaces = append $interfaces (printf "linux:net%d,%s" $cniIndex $flags) }}
5280
{{- else }}
5381
{{- $interfaces = append $interfaces (printf "linux:net%d" $cniIndex) }}
5482
{{- end }}
83+
{{- $cniIndex = add1 $cniIndex }}
5584
{{- else }}
5685
{{- fail (printf "Invalid mgmt interface type %s" .type) }}
5786
{{- end }}

0 commit comments

Comments
 (0)