Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions charts/kubescape-operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,15 @@ app.kubernetes.io/name: {{ include "kubescape-operator.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: {{ .app }}
{{- end }}

{{/*
Resolve priorityClassName for a component with customScheduling fallback.
Usage: {{ include "kubescape-operator.priorityClassName" (dict "component" .Values.<component> "global" .Values.customScheduling) }}
*/}}
{{- define "kubescape-operator.priorityClassName" -}}
{{- if .component.priorityClassName }}
priorityClassName: {{ .component.priorityClassName }}
{{- else if .global.priorityClassName }}
priorityClassName: {{ .global.priorityClassName }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,5 @@ spec:
{{- else if .Values.customScheduling.tolerations }}
{{- toYaml .Values.customScheduling.tolerations | nindent 12 }}
{{- end }}
{{- include "kubescape-operator.priorityClassName" (dict "component" .Values.helmReleaseUpgrader "global" .Values.customScheduling) | nindent 10 }}
{{ end }}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ spec:
{{- else if .Values.customScheduling.tolerations }}
{{- toYaml .Values.customScheduling.tolerations | nindent 12 }}
{{- end }}
{{- include "kubescape-operator.priorityClassName" (dict "component" .Values.grypeOfflineDB "global" .Values.customScheduling) | nindent 10 }}
{{- if .Values.volumes }}
{{ toYaml .Values.volumes | indent 10 }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ spec:
{{- else if .Values.customScheduling.tolerations }}
{{- toYaml .Values.customScheduling.tolerations | nindent 12 }}
{{- end }}
{{- include "kubescape-operator.priorityClassName" (dict "component" .Values.kubescapeScheduler "global" .Values.customScheduling) | nindent 10 }}
volumes:
- name: {{ .Values.kubescapeScheduler.name }}
configMap:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,4 +407,5 @@ spec:
{{- else if .Values.customScheduling.tolerations }}
{{- toYaml .Values.customScheduling.tolerations | nindent 8 }}
{{- end }}
{{- include "kubescape-operator.priorityClassName" (dict "component" .Values.kubescape "global" .Values.customScheduling) | nindent 6 }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ spec:
{{- else if .Values.customScheduling.tolerations }}
{{- toYaml .Values.customScheduling.tolerations | nindent 12 }}
{{- end }}
{{- include "kubescape-operator.priorityClassName" (dict "component" .Values.kubevulnScheduler "global" .Values.customScheduling) | nindent 10 }}
volumes:
- name: {{ .Values.kubevulnScheduler.name }}
configMap:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,5 @@ spec:
{{- else if .Values.customScheduling.tolerations }}
{{- toYaml .Values.customScheduling.tolerations | nindent 8 }}
{{- end }}
{{- include "kubescape-operator.priorityClassName" (dict "component" .Values.kubevuln "global" .Values.customScheduling) | nindent 6 }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,12 @@ imagePullSecrets:
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.configurations.priorityClass.enabled }}
{{- if .Values.nodeAgent.priorityClassName }}
priorityClassName: {{ .Values.nodeAgent.priorityClassName }}
{{- else if .Values.configurations.priorityClass.enabled }}
priorityClassName: kubescape-critical
{{- else if .Values.customScheduling.priorityClassName }}
priorityClassName: {{ .Values.customScheduling.priorityClassName }}
Comment on lines +446 to +451
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Global fallback is effectively masked for node-agent.

At Line 448, configurations.priorityClass.enabled takes precedence over customScheduling.priorityClassName, so global scheduling won’t apply to node-agent under default settings. This is inconsistent with the component→global fallback model used elsewhere.

💡 Suggested precedence fix
 {{- if .Values.nodeAgent.priorityClassName }}
 priorityClassName: {{ .Values.nodeAgent.priorityClassName }}
-{{- else if .Values.configurations.priorityClass.enabled }}
-priorityClassName: kubescape-critical
 {{- else if .Values.customScheduling.priorityClassName }}
 priorityClassName: {{ .Values.customScheduling.priorityClassName }}
+{{- else if .Values.configurations.priorityClass.enabled }}
+priorityClassName: kubescape-critical
 {{- end }}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{{- if .Values.nodeAgent.priorityClassName }}
priorityClassName: {{ .Values.nodeAgent.priorityClassName }}
{{- else if .Values.configurations.priorityClass.enabled }}
priorityClassName: kubescape-critical
{{- else if .Values.customScheduling.priorityClassName }}
priorityClassName: {{ .Values.customScheduling.priorityClassName }}
{{- if .Values.nodeAgent.priorityClassName }}
priorityClassName: {{ .Values.nodeAgent.priorityClassName }}
{{- else if .Values.customScheduling.priorityClassName }}
priorityClassName: {{ .Values.customScheduling.priorityClassName }}
{{- else if .Values.configurations.priorityClass.enabled }}
priorityClassName: kubescape-critical
{{- end }}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@charts/kubescape-operator/templates/node-agent/_node-agent.tpl` around lines
446 - 451, The current precedence in the node-agent template uses
.Values.configurations.priorityClass.enabled before
.Values.customScheduling.priorityClassName, which prevents the global fallback
(kubescape-critical) from being masked correctly; update the condition order in
the priorityClassName block so it checks .Values.nodeAgent.priorityClassName
first, then .Values.customScheduling.priorityClassName, and only then
.Values.configurations.priorityClass.enabled to emit "priorityClassName:
kubescape-critical" — adjust the conditional sequence around the
priorityClassName lines to reflect this corrected precedence.

{{- end }}
serviceAccountName: {{ .Values.nodeAgent.name }}
automountServiceAccountToken: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,5 @@ spec:
{{- else if .Values.customScheduling.tolerations }}
{{- toYaml .Values.customScheduling.tolerations | nindent 8 }}
{{- end }}
{{- include "kubescape-operator.priorityClassName" (dict "component" .Values.operator "global" .Values.customScheduling) | nindent 6 }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,5 @@ spec:
{{- else if .Values.customScheduling.tolerations }}
{{- toYaml .Values.customScheduling.tolerations | nindent 8 }}
{{- end }}
{{- include "kubescape-operator.priorityClassName" (dict "component" .Values.prometheusExporter "global" .Values.customScheduling) | nindent 6 }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ spec:
{{- else if .Values.customScheduling.tolerations }}
{{- toYaml .Values.customScheduling.tolerations | nindent 8 }}
{{- end }}
{{- include "kubescape-operator.priorityClassName" (dict "component" .Values.storage "global" .Values.customScheduling) | nindent 6 }}
volumes:
- name: "data"
{{- if eq .Values.configurations.persistence "enable" }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,5 @@ spec:
{{- else if .Values.customScheduling.tolerations }}
{{- toYaml .Values.customScheduling.tolerations | nindent 8 }}
{{- end }}
{{- include "kubescape-operator.priorityClassName" (dict "component" .Values.synchronizer "global" .Values.customScheduling) | nindent 6 }}
{{- end }}
Loading
Loading