Skip to content

Commit

Permalink
Propagate resource requirements to the states
Browse files Browse the repository at this point in the history
Signed-off-by: amaslennikov <[email protected]>
  • Loading branch information
almaslennikov committed Dec 19, 2023
1 parent b1fb1d0 commit 7e71047
Show file tree
Hide file tree
Showing 11 changed files with 178 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,30 @@ spec:
imagePullPolicy: IfNotPresent
securityContext:
privileged: true
{{- $containerResourcesFound := false }}
{{- range .CrSpec.ContainerResources }}
{{- if eq .Name "cni-plugins" }}
resources:
{{- if .Requests }}
requests:
{{ .Requests | yaml | nindent 14}}
{{- end }}
{{- if .Limits }}
limits:
{{ .Limits | yaml | nindent 14}}
{{- end }}
{{- $containerResourcesFound = true }}
{{- end }}
{{- end }}
{{- if not $containerResourcesFound }}
resources:
requests:
cpu: "100m"
memory: "50Mi"
limits:
cpu: "100m"
memory: "50Mi"
{{- end }}
volumeMounts:
- name: cnibin
mountPath: /host/opt/cni/bin
Expand Down
17 changes: 17 additions & 0 deletions manifests/state-ib-kubernetes/0070-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,27 @@ spec:
image: {{ .CrSpec.Repository }}/{{ .CrSpec.Image }}:{{ .CrSpec.Version }}
imagePullPolicy: IfNotPresent
command: ["/usr/bin/ib-kubernetes"]
{{- $containerResourcesFound := false }}
{{- range .CrSpec.ContainerResources }}
{{- if eq .Name "ib-kubernetes" }}
resources:
{{- if .Requests }}
requests:
{{ .Requests | yaml | nindent 14}}
{{- end }}
{{- if .Limits }}
limits:
{{ .Limits | yaml | nindent 14}}
{{- end }}
{{- $containerResourcesFound = true }}
{{- end }}
{{- end }}
{{- if not $containerResourcesFound }}
resources:
requests:
cpu: 100m
memory: 300Mi
{{- end }}
env:
- name: DAEMON_SM_PLUGIN
value: "ufm"
Expand Down
17 changes: 17 additions & 0 deletions manifests/state-ipoib-cni/0050-ipoib-cni-ds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,30 @@ spec:
containers:
- name: ipoib-cni
image: {{ .CrSpec.Repository }}/{{ .CrSpec.Image }}:{{ .CrSpec.Version }}
{{- $containerResourcesFound := false }}
{{- range .CrSpec.ContainerResources }}
{{- if eq .Name "ipoib-cni" }}
resources:
{{- if .Requests }}
requests:
{{ .Requests | yaml | nindent 14}}
{{- end }}
{{- if .Limits }}
limits:
{{ .Limits | yaml | nindent 14}}
{{- end }}
{{- $containerResourcesFound = true }}
{{- end }}
{{- end }}
{{- if not $containerResourcesFound }}
resources:
requests:
cpu: "100m"
memory: "50Mi"
limits:
cpu: "100m"
memory: "50Mi"
{{- end }}
securityContext:
privileged: true
volumeMounts:
Expand Down
17 changes: 17 additions & 0 deletions manifests/state-multus-cni/0050-multus-ds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,30 @@ spec:
preStop:
exec:
command: ["/bin/sh", "-c", "rm -f /host/etc/cni/net.d/00-multus.conf"]
{{- $containerResourcesFound := false }}
{{- range .CrSpec.ContainerResources }}
{{- if eq .Name "kube-multus" }}
resources:
{{- if .Requests }}
requests:
{{ .Requests | yaml | nindent 14}}
{{- end }}
{{- if .Limits }}
limits:
{{ .Limits | yaml | nindent 14}}
{{- end }}
{{- $containerResourcesFound = true }}
{{- end }}
{{- end }}
{{- if not $containerResourcesFound }}
resources:
requests:
cpu: "100m"
memory: "50Mi"
limits:
cpu: "100m"
memory: "50Mi"
{{- end }}
securityContext:
privileged: true
volumeMounts:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,30 @@ spec:
args:
- --v=0
- --logging-format=json
{{- $containerResourcesFound := false }}
{{- range .CrSpec.ContainerResources }}
{{- if eq .Name "nic-feature-discovery" }}
resources:
{{- if .Requests }}
requests:
{{ .Requests | yaml | nindent 14}}
{{- end }}
{{- if .Limits }}
limits:
{{ .Limits | yaml | nindent 14}}
{{- end }}
{{- $containerResourcesFound = true }}
{{- end }}
{{- end }}
{{- if not $containerResourcesFound }}
resources:
requests:
cpu: "100m"
memory: "50Mi"
limits:
cpu: "300m"
memory: "150Mi"
{{- end }}
securityContext:
privileged: true
volumeMounts:
Expand Down
21 changes: 19 additions & 2 deletions manifests/state-nv-ipam-cni/040-nv-ipam-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,27 @@ spec:
port: 8081
initialDelaySeconds: 5
periodSeconds: 10
{{- $containerResourcesFound := false }}
{{- range .CrSpec.ContainerResources }}
{{- if eq .Name "nv-ipam-controller" }}
resources:
{{- if .Requests }}
requests:
cpu: 100m
memory: 300Mi
{{ .Requests | yaml | nindent 14}}
{{- end }}
{{- if .Limits }}
limits:
{{ .Limits | yaml | nindent 14}}
{{- end }}
{{- $containerResourcesFound = true }}
{{- end }}
{{- end }}
{{- if not $containerResourcesFound }}
resources:
requests:
cpu: "100m"
memory: "300Mi"
{{- end }}
volumeMounts:
{{- if .CrSpec.EnableWebhook }}
- mountPath: /tmp/k8s-webhook-server/serving-certs
Expand Down
19 changes: 18 additions & 1 deletion manifests/state-nv-ipam-cni/040-nv-ipam-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,30 @@ spec:
- --cni-log-file=/var/log/nv-ipam-cni.log
- --cni-log-level=info # log level for shim CNI
- --ippools-namespace=$(IPPOOLS_NAMESPACE)
{{- $containerResourcesFound := false }}
{{- range .CrSpec.ContainerResources }}
{{- if eq .Name "nv-ipam-node" }}
resources:
{{- if .Requests }}
requests:
{{ .Requests | yaml | nindent 14}}
{{- end }}
{{- if .Limits }}
limits:
{{ .Limits | yaml | nindent 14}}
{{- end }}
{{- $containerResourcesFound = true }}
{{- end }}
{{- end }}
{{- if not $containerResourcesFound }}
resources:
requests:
cpu: "100m"
cpu: "150m"
memory: "50Mi"
limits:
cpu: "300m"
memory: "300Mi"
{{- end }}
securityContext:
privileged: true
volumeMounts:
Expand Down
13 changes: 13 additions & 0 deletions manifests/state-ofed-driver/0050_ofed-driver-ds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,19 @@ spec:
readOnly: {{ .ReadOnly }}
{{- end }}
{{- end }}
{{- range .CrSpec.ContainerResources }}
{{- if eq .Name "mofed-container" }}
resources:
{{- if .Requests }}
requests:
{{ .Requests | yaml | nindent 14}}
{{- end }}
{{- if .Limits }}
limits:
{{ .Limits | yaml | nindent 14}}
{{- end }}
{{- end }}
{{- end }}
startupProbe:
exec:
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ spec:
- name: host-config-volume
mountPath: /host/etc/pcidp/
{{- end }}
{{- range .CrSpec.ContainerResources }}
{{- if eq .Name "rdma-shared-dp" }}
resources:
{{- if .Requests }}
requests:
{{ .Requests | yaml | nindent 12}}
{{- end }}
{{- if .Limits }}
limits:
{{ .Limits | yaml | nindent 12}}
{{- end }}
{{- end }}
{{- end }}
volumes:
- name: device-plugin
hostPath:
Expand Down
13 changes: 13 additions & 0 deletions manifests/state-sriov-device-plugin/0030-sriov-dp-daemonset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ spec:
- name: host-config-volume
mountPath: /host/etc/pcidp/
{{- end}}
{{- range .CrSpec.ContainerResources }}
{{- if eq .Name "kube-sriovdp" }}
resources:
{{- if .Requests }}
requests:
{{ .Requests | yaml | nindent 12}}
{{- end }}
{{- if .Limits }}
limits:
{{ .Limits | yaml | nindent 12}}
{{- end }}
{{- end }}
{{- end }}
volumes:
- name: devicesock
hostPath:
Expand Down
17 changes: 17 additions & 0 deletions manifests/state-whereabouts-cni/0050-whereabouts-ds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,30 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
{{- $containerResourcesFound := false }}
{{- range .CrSpec.ContainerResources }}
{{- if eq .Name "whereabouts" }}
resources:
{{- if .Requests }}
requests:
{{ .Requests | yaml | nindent 12}}
{{- end }}
{{- if .Limits }}
limits:
{{ .Limits | yaml | nindent 12}}
{{- end }}
{{- $containerResourcesFound = true }}
{{- end }}
{{- end }}
{{- if not $containerResourcesFound }}
resources:
requests:
cpu: "100m"
memory: "100Mi"
limits:
cpu: "100m"
memory: "200Mi"
{{- end }}
securityContext:
privileged: true
volumeMounts:
Expand Down

0 comments on commit 7e71047

Please sign in to comment.