Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring Kubernetes recommanded labels for Falco Sidekick #563

Closed
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
21 changes: 21 additions & 0 deletions charts/falcosidekick/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,27 @@ Return the appropriate apiVersion for ingress.
{{- end -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "falcosidekick.labels" -}}
helm.sh/chart: {{ include "falcosidekick.chart" . }}
{{ include "falcosidekick.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/part-of: {{ include "falcosidekick.name" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "falcosidekick.selectorLabels" -}}
app.kubernetes.io/name: {{ include "falcosidekick.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Return if ingress is stable.
*/}}
Expand Down
5 changes: 5 additions & 0 deletions charts/falcosidekick/templates/aadpodidentity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
apiVersion: "aadpodidentity.k8s.io/v1"
kind: AzureIdentity
metadata:
labels:
{{- include "falcosidekick.labels" . | nindent 4 }}
app.kubernetes.io/component: core
name: {{ include "falcosidekick.fullname" . }}
namespace: {{ .Release.Namespace }}
spec:
Expand All @@ -13,6 +16,8 @@ spec:
apiVersion: "aadpodidentity.k8s.io/v1"
kind: AzureIdentityBinding
metadata:
labels:
{{- include "falcosidekick.labels" . | nindent 4 }}
name: {{ include "falcosidekick.fullname" . }}
spec:
azureIdentity: {{ include "falcosidekick.fullname" . }}
Expand Down
6 changes: 2 additions & 4 deletions charts/falcosidekick/templates/certs-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ metadata:
name: {{ include "falcosidekick.fullname" . }}-certs
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "falcosidekick.name" . }}
helm.sh/chart: {{ include "falcosidekick.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "falcosidekick.labels" . | nindent 4 }}
app.kubernetes.io/component: core
type: Opaque
data:
{{ $key := .Values.config.tlsserver.serverkey }}
Expand Down
6 changes: 2 additions & 4 deletions charts/falcosidekick/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "falcosidekick.fullname" .}}
labels:
app: {{ template "falcosidekick.fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{- include "falcosidekick.labels" . | nindent 4 }}
app.kubernetes.io/component: core
rules:
- apiGroups:
- policy
Expand Down
28 changes: 12 additions & 16 deletions charts/falcosidekick/templates/deployment-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,22 @@ metadata:
name: {{ include "falcosidekick.fullname" . }}-ui
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "falcosidekick.name" . }}-ui
helm.sh/chart: {{ include "falcosidekick.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}-ui
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "falcosidekick.labels" . | nindent 4 }}
app.kubernetes.io/component: ui
spec:
replicas: {{ .Values.webui.replicaCount }}
{{- if .Values.webui.revisionHistoryLimit }}
revisionHistoryLimit: {{ .Values.webui.revisionHistoryLimit }}
{{- end }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "falcosidekick.name" . }}-ui
app.kubernetes.io/instance: {{ .Release.Name }}-ui
{{- include "falcosidekick.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: ui
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "falcosidekick.name" . }}-ui
app.kubernetes.io/instance: {{ .Release.Name }}-ui
{{- include "falcosidekick.labels" . | nindent 8 }}
app.kubernetes.io/component: ui
{{- if .Values.webui.podLabels }}
{{ toYaml .Values.webui.podLabels | indent 8 }}
{{- end }}
Expand Down Expand Up @@ -125,22 +123,20 @@ metadata:
name: {{ include "falcosidekick.fullname" . }}-ui-redis
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "falcosidekick.name" . }}-ui-redis
helm.sh/chart: {{ include "falcosidekick.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}-ui
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "falcosidekick.labels" . | nindent 4 }}
app.kubernetes.io/component: ui-redis
spec:
replicas: 1
serviceName: {{ include "falcosidekick.fullname" . }}-ui-redis
selector:
matchLabels:
app.kubernetes.io/name: {{ include "falcosidekick.name" . }}-ui-redis
app.kubernetes.io/instance: {{ .Release.Name }}-ui-redis
{{- include "falcosidekick.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: ui-redis
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "falcosidekick.name" . }}-ui-redis
app.kubernetes.io/instance: {{ .Release.Name }}-ui-redis
{{- include "falcosidekick.labels" . | nindent 8 }}
app.kubernetes.io/component: ui-redis
{{- if .Values.webui.redis.podLabels }}
{{ toYaml .Values.webui.redis.podLabels | indent 8 }}
{{- end }}
Expand Down
14 changes: 6 additions & 8 deletions charts/falcosidekick/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,22 @@ metadata:
name: {{ include "falcosidekick.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "falcosidekick.name" . }}
helm.sh/chart: {{ include "falcosidekick.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "falcosidekick.labels" . | nindent 4 }}
app.kubernetes.io/component: core
spec:
replicas: {{ .Values.replicaCount }}
{{- if .Values.revisionHistoryLimit }}
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
{{- end }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "falcosidekick.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- include "falcosidekick.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: core
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "falcosidekick.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- include "falcosidekick.labels" . | nindent 8 }}
app.kubernetes.io/component: core
{{- if and .Values.config.azure.podIdentityClientID .Values.config.azure.podIdentityName }}
aadpodidbinding: {{ include "falcosidekick.fullname" . }}
{{- end }}
Expand Down
6 changes: 2 additions & 4 deletions charts/falcosidekick/templates/ingress-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ metadata:
name: {{ $fullName }}-ui
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "falcosidekick.name" . }}-ui
helm.sh/chart: {{ include "falcosidekick.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}-ui
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "falcosidekick.labels" . | nindent 4 }}
app.kubernetes.io/component: ui
{{- with .Values.webui.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
6 changes: 2 additions & 4 deletions charts/falcosidekick/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ metadata:
name: {{ $fullName }}
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "falcosidekick.name" . }}
helm.sh/chart: {{ include "falcosidekick.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "falcosidekick.labels" . | nindent 4 }}
app.kubernetes.io/component: core
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
6 changes: 2 additions & 4 deletions charts/falcosidekick/templates/podsecuritypolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ kind: PodSecurityPolicy
metadata:
name: {{ template "falcosidekick.fullname" . }}
labels:
app: {{ template "falcosidekick.fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{- include "falcosidekick.labels" . | nindent 4 }}
app.kubernetes.io/component: core
spec:
privileged: false
allowPrivilegeEscalation: false
Expand Down
1 change: 1 addition & 0 deletions charts/falcosidekick/templates/prometheusrule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ metadata:
{{- end }}
labels:
{{- include "falcosidekick.labels" . | nindent 4 }}
app.kubernetes.io/component: core
{{- if .Values.prometheusRules.additionalLabels }}
{{- toYaml .Values.prometheusRules.additionalLabels | nindent 4 }}
{{- end }}
Expand Down
20 changes: 8 additions & 12 deletions charts/falcosidekick/templates/rbac-ui.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
{{- if .Values.webui.enabled -}}
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "falcosidekick.fullname" . }}-ui
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "falcosidekick.name" . }}-ui
helm.sh/chart: {{ include "falcosidekick.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "falcosidekick.labels" . | nindent 4 }}
app.kubernetes.io/component: ui
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "falcosidekick.fullname" . }}-ui
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "falcosidekick.name" . }}-ui
helm.sh/chart: {{ include "falcosidekick.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "falcosidekick.labels" . | nindent 4 }}
app.kubernetes.io/component: ui
rules: []
---
apiVersion: rbac.authorization.k8s.io/v1
Expand All @@ -28,14 +25,13 @@ metadata:
name: {{ include "falcosidekick.fullname" . }}-ui
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "falcosidekick.name" . }}-ui
helm.sh/chart: {{ include "falcosidekick.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "falcosidekick.labels" . | nindent 4 }}
app.kubernetes.io/component: ui
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ include "falcosidekick.fullname" . }}-ui
subjects:
- kind: ServiceAccount
name: {{ include "falcosidekick.fullname" . }}-ui
{{- end }}
30 changes: 10 additions & 20 deletions charts/falcosidekick/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,17 @@ metadata:
eks.amazonaws.com/role-arn: {{ .Values.config.aws.rolearn }}
{{- end }}
labels:
app.kubernetes.io/name: {{ include "falcosidekick.name" . }}
helm.sh/chart: {{ include "falcosidekick.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "falcosidekick.labels" . | nindent 4 }}
app.kubernetes.io/component: core
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "falcosidekick.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "falcosidekick.name" . }}
helm.sh/chart: {{ include "falcosidekick.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "falcosidekick.labels" . | nindent 4 }}
app.kubernetes.io/component: core
rules:
- apiGroups:
- ""
Expand All @@ -48,10 +44,8 @@ metadata:
name: {{ include "falcosidekick.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "falcosidekick.name" . }}
helm.sh/chart: {{ include "falcosidekick.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "falcosidekick.labels" . | nindent 4 }}
app.kubernetes.io/component: core
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
Expand All @@ -66,10 +60,8 @@ kind: ClusterRole
metadata:
name: {{ include "falcosidekick.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "falcosidekick.name" . }}
helm.sh/chart: {{ include "falcosidekick.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "falcosidekick.labels" . | nindent 4 }}
app.kubernetes.io/component: core
rules:
- apiGroups:
- "wgpolicyk8s.io"
Expand All @@ -87,10 +79,8 @@ kind: ClusterRoleBinding
metadata:
name: {{ include "falcosidekick.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "falcosidekick.name" . }}
helm.sh/chart: {{ include "falcosidekick.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "falcosidekick.labels" . | nindent 4 }}
app.kubernetes.io/component: core
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
14 changes: 6 additions & 8 deletions charts/falcosidekick/templates/secrets-ui.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if .Values.webui.enabled -}}
{{- if eq .Values.webui.existingSecret "" }}
---
apiVersion: v1
Expand All @@ -6,10 +7,8 @@ metadata:
name: {{ include "falcosidekick.fullname" . }}-ui
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "falcosidekick.name" . }}-ui
helm.sh/chart: {{ include "falcosidekick.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "falcosidekick.labels" . | nindent 4 }}
app.kubernetes.io/component: ui
type: Opaque
data:
{{- if .Values.webui.user }}
Expand All @@ -27,13 +26,12 @@ metadata:
name: {{ include "falcosidekick.fullname" . }}-ui-redis
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "falcosidekick.name" . }}-ui
helm.sh/chart: {{ include "falcosidekick.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "falcosidekick.labels" . | nindent 4 }}
app.kubernetes.io/component: ui
type: Opaque
data:
{{- if .Values.webui.redis.password }}
REDIS_ARGS: "{{ printf "--requirepass %s" .Values.webui.redis.password | b64enc}}"
{{- end }}
{{- end }}
{{- end }}
6 changes: 2 additions & 4 deletions charts/falcosidekick/templates/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ metadata:
name: {{ include "falcosidekick.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "falcosidekick.name" . }}
helm.sh/chart: {{ include "falcosidekick.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "falcosidekick.labels" . | nindent 4 }}
app.kubernetes.io/component: core
type: Opaque
data:
# Slack Output
Expand Down
Loading
Loading