kubescape / helm-charts

Kubescape can run as a set of microservices inside a Kubernetes cluster. This allows you to continually monitor the status of a cluster, including for compliance and vulnerability management
Apache License 2.0
29 stars 41 forks source link

Node Agent svc use wrong label selector #500

Open pierreblais opened 4 weeks ago

pierreblais commented 4 weeks ago

Description

The Node Agent svc used a wrong label selector so there are no pods exposed.

Environment

Kubescape-operator helm chart: 1.21.2

Expected behavior

I'm expecting the node-agent SVC to expose Node Agent DaemonSet pods.

Actual Behavior

The SVC expose no pods

Additional context

charts/kubescape-operator/templates/node-agent/daemonset.yaml

spec:
  template:
    metadata:
... SCOPE...

      labels:
        {{- include "kubescape-operator.labels" (dict "Chart" .Chart "Release" .Release "Values" .Values "app" .Values.nodeAgent.name "tier" .Values.global.namespaceTier) | nindent 8 }}
        kubescape.io/tier: "core"

...SCOPE...

And the kubescape-operator.labels are:

charts/kubescape-operator/templates/_helpers.tpl

{{- define "kubescape-operator.labels" -}}
helm.sh/chart: {{ include "kubescape-operator.chart" . }}
{{ include "kubescape-operator.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app: {{ .app }}
tier: {{ .tier }}
kubescape.io/ignore: "true"
{{- end }}
...
{{/*
Selector labels
*/}}
{{- define "kubescape-operator.selectorLabels" -}}
app.kubernetes.io/name: {{ include "kubescape-operator.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: {{ .app }}
{{- end }}

charts/kubescape-operator/templates/node-agent/service.yaml

...SCOPE...

  selector:
    app.kubernetes.io/name: {{ .Values.nodeAgent.name }}

...SCOPE...

I think label selector should be app: {{ .Values.nodeAgent.name }}.

matthyx commented 6 days ago

Correct, do you want to work on this too?