Skip to content

Commit

Permalink
Helm chart changes to support OpenShift deployments (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
ebeaty-cisco authored Dec 19, 2024
1 parent bf56a60 commit a975b84
Show file tree
Hide file tree
Showing 22 changed files with 728 additions and 200 deletions.
15 changes: 15 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
### Summary

*Main description goes here.*


### Checklist

- [ ] Version incremented
<!-- The Helm charts in this repo use semantic versioning and the version must be increased for any change. -->
- [ ] Changelog updated
<!-- The changelog must be updated for any version change. -->
- [ ] Version compatibility matrix updated (or not required)
<!-- The version compatibility matrix must be updated for any major or minor version change. -->
- [ ] Static analysis and tests passing
- See `tests/README.md` for details.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Changelog

## XRd vRouter

### v2 (active)

The v2 release supports Cisco IOS-XR release version 24.4.1 and above.

#### v2.0.0

- Change `cpu.hyperThreadingMode` options, adding `auto` and removing `off`.

### v1

The v1 release supports Cisco IOS-XR release versions from 7.7.1 to 24.3.1.

## XRd Control Plane

### v1 (active)

The v1 release supports Cisco IOS-XR release versions 7.7.1 and above.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ There are two application charts provided in this repository:
There is also a library chart provided, xrd-common, that is used by both
of the application charts.

See [CHANGELOG.md](./CHANGELOG.md) for a record of changes that have been made.

See [version-compatibility.md](./version-compatibility.md) for the compatibility statement across versions.

## Usage

[Helm](https://helm.sh) must be installed to use the charts. Please refer to
Expand Down
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.0.4
version: 1.1.0
11 changes: 11 additions & 0 deletions charts/xrd-common/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,15 @@ Convert a k8s resource specification of Mi or Gi into MiB for XR env vars.
{{- $out = "true" }}
{{- end -}}
{{ $out }}
{{- end -}}

{{- /*
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" -}}
{{- if and (include "xrd.interfaces.anySRIOVData" .) (eq .Chart.Name "xrd-vrouter") }}
1
{{- end }}
{{- end -}}
74 changes: 60 additions & 14 deletions charts/xrd-common/templates/_interfaces.tpl
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
{{- /* Helper templates */ -}}
{{- define "xrd.interfaces.multusCount" -}}
{{- $c := 0 }}
{{- range . }}
{{- if eq .type "multus" }}
{{- $c = add1 $c }}
{{- end }}
{{- end }}
{{- $c }}
{{- end -}}

{{- define "xrd.interfaces.anyMultus" -}}
{{- /*
Expand All @@ -22,6 +13,40 @@ or an empty string otherwise.
{{- end }}
{{- end -}}

{{- define "xrd.interfaces.anySRIOV" -}}
{{- /*
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 }}
{{- if eq .type "sriov" }}
1
{{- end }}
{{- end }}
{{- end -}}

{{- define "xrd.interfaces.cniCount" -}}
{{- $c := 0 }}
{{- range .Values.interfaces }}
{{- if or (eq .type "sriov") (eq .type "multus") }}
{{- $c = add1 $c }}
{{- end }}
{{- end }}
{{- $c }}
{{- end -}}

{{- define "xrd.interfaces.checkDefaultCniCount" -}}
{{- $c := 0 }}
{{- range .Values.interfaces }}
Expand All @@ -41,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 @@ -69,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 All @@ -86,16 +111,37 @@ or an empty string otherwise.
{{- join "," $flags }}
{{- end -}}

{{- define "xrd.interfaces.sriovflags" -}}
{{- $flags := list }}
{{- $base := list "type" "config" "resource" }}
{{- range $k, $v := . -}}
{{- if not (has $k $base) }}
{{- fail (printf "%s may not be specified for sriov interfaces" $k) }}
{{- end }}
{{- end }}
{{- join "," $flags }}
{{- end -}}

{{- define "xrd.podNetworkAnnotations" -}}
{{- $nets := list }}
{{- range $idx, $intf := concat .Values.interfaces .Values.mgmtInterfaces }}
{{- $cniIndex := 0}}
{{- range $intf := concat .Values.interfaces .Values.mgmtInterfaces }}
{{- if eq $intf.type "multus" }}
{{- $netname := printf "%s-%d" (include "xrd.fullname" $) $idx }}
{{- $entry := dict "name" $netname }}
{{- $netname := printf "%s-%d" (include "xrd.fullname" $) $cniIndex }}
{{- $intfname := printf "net%d" $cniIndex }}
{{- $entry := dict "name" $netname "interface" $intfname}}
{{- if $intf.attachmentConfig }}
{{- $entry = merge $entry $intf.attachmentConfig }}
{{- end }}
{{- $nets = append $nets $entry }}
{{- $cniIndex = add1 $cniIndex }}
{{- end }}
{{- if eq $intf.type "sriov" }}
{{- $netname := printf "%s-%d" (include "xrd.fullname" $) $cniIndex }}
{{- $intfname := printf "net%d" $cniIndex }}
{{- $entry := dict "name" $netname "interface" $intfname}}
{{- $nets = append $nets $entry }}
{{- $cniIndex = add1 $cniIndex }}
{{- end }}
{{- end }}
{{- toPrettyJson $nets }}
Expand Down
18 changes: 13 additions & 5 deletions charts/xrd-common/templates/_network-attachments.tpl
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
{{- define "xrd.network-attachments" -}}
{{- range $idx, $intf := concat .Values.interfaces .Values.mgmtInterfaces }}
{{- if eq $intf.type "multus" }}
{{- $cniIndex := 0 }}
{{- range $intf := concat .Values.interfaces .Values.mgmtInterfaces }}
{{- if or (eq $intf.type "multus") (eq $intf.type "sriov") }}
---
apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
name: {{ include "xrd.fullname" $ }}-{{ $idx }}
name: {{ include "xrd.fullname" $ }}-{{ $cniIndex }}
namespace: {{ $.Release.Namespace }}
{{- if gt (len (include "xrd.commonAnnotations" $ | fromYaml)) 0 }}
{{- if or (gt (len (include "xrd.commonAnnotations" $ | fromYaml)) 0) (eq $intf.type "sriov") }}
annotations:
{{- include "xrd.commonAnnotations" $ | nindent 4 }}
{{- if eq $intf.type "sriov" }}
k8s.v1.cni.cncf.io/resourceName: {{ $intf.resource }}
{{- end }}
{{- if gt (len (include "xrd.commonAnnotations" $ | fromYaml)) 0 }}
{{- include "xrd.commonAnnotations" $ | nindent 4 }}
{{- end }}
{{- end }}
labels:
{{- include "xrd.commonLabels" $ | nindent 4 }}
spec:
config: |-
{
"cniVersion": "0.3.1",
"name": "{{ include "xrd.fullname" $ }}-{{ $cniIndex }}",
"plugins": [
{{- $intf.config | toPrettyJson | nindent 8 }}
]
}
...
{{- $cniIndex = add1 $cniIndex}}
{{- end }}
{{- end -}}
{{- end -}}
20 changes: 19 additions & 1 deletion charts/xrd-common/templates/_statefulset.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
{{- if gt (len (include "xrd.commonAnnotations" . | fromYaml)) 0}}
{{- include "xrd.commonAnnotations" . | nindent 8 }}
{{- end }}
{{- if (include "xrd.interfaces.anyMultus" .) }}
{{- if or (include "xrd.interfaces.anyMultus" .) (include "xrd.interfaces.anySRIOV" .) }}
k8s.v1.cni.cncf.io/networks: |-
{{- include "xrd.podNetworkAnnotations" . | nindent 10 }}
{{- end }}
Expand All @@ -53,6 +53,12 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- if .Values.serviceAccountName }}
serviceAccountName: {{ .Values.serviceAccountName }}
{{- end }}
{{- if .Values.runtimeClassName }}
runtimeClassName: {{ .Values.runtimeClassName }}
{{- end }}
{{- if .Values.hostNetwork }}
hostNetwork: true
{{- end }}
Expand Down Expand Up @@ -91,6 +97,14 @@ spec:
type: Directory
{{- end }}
{{- end }}
{{- if (include "xrd.mountNetworkStatusAnnotation" .) }}
- downwardAPI:
items:
- fieldRef:
fieldPath: metadata.annotations['k8s.v1.cni.cncf.io/network-status']
path: "network-status-annotation"
name: "network-status-annotation"
{{- end }}
{{- if .Values.extraVolumes }}
{{- toYaml .Values.extraVolumes | nindent 6 }}
{{- end }}
Expand All @@ -117,6 +131,10 @@ spec:
name: config
readOnly: true
{{- end }}
{{- if (include "xrd.mountNetworkStatusAnnotation" .) }}
- mountPath: "/etc/xrd/network-status"
name: "network-status-annotation"
{{- end }}
{{- if .Values.persistence.enabled }}
- mountPath: /xr-storage
name: xr-storage
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.0.4
version: 1.1.0
dependencies:
- name: xrd-common
version: 1.0.4
version: 1.1.0
repository: "file://../xrd-common"
39 changes: 34 additions & 5 deletions charts/xrd-control-plane/templates/_interfaces.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,33 @@
{{- 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" }}
{{- $cniIndex = add1 $cniIndex }}
{{- 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 }}
{{- $interfaces = append $interfaces (printf "linux:net%d" $cniIndex) }}
{{- end }}
{{- $cniIndex = add1 $cniIndex }}
{{- else }}
{{- fail (printf "Invalid interface type %s" .type) }}
{{- end }}
Expand All @@ -34,24 +47,40 @@
{{- define "xrd-cp.mgmtInterfaces" -}}
{{- /* Generate the XR_MGMT_INTERFACES environment variable content */ -}}
{{- $interfaces := list }}
{{- $cniIndex := atoi (include "xrd.interfaces.multusCount" .Values.interfaces) }}
{{- $cniIndex := atoi (include "xrd.interfaces.cniCount" .) }}
{{- 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" }}
{{- $cniIndex = add1 $cniIndex }}
{{- 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 }}
{{- $interfaces = append $interfaces (printf "linux:net%d" $cniIndex) }}
{{- end }}
{{- $cniIndex = add1 $cniIndex }}
{{- else }}
{{- fail (printf "Invalid mgmt interface type %s" .type) }}
{{- end }}
Expand Down
Loading

0 comments on commit a975b84

Please sign in to comment.