Skip to content

Commit

Permalink
Push audit logs to loki-audits based on promtail-audit-logs label
Browse files Browse the repository at this point in the history
  • Loading branch information
ffilippopoulos committed Jun 11, 2024
1 parent bd17835 commit d016bfa
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ spec:
template:
metadata:
annotations:
# Do not push logs until we have a Loki instance for audit purpose.
fluentbit.io/exclude: "true"
promtail-audit-logs: "true"
2 changes: 1 addition & 1 deletion falco/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ resources:
- upstream.yaml

patches:
- path: falco-audit-logs.yaml
- path: falco-driver-loader-privileged.yaml
- path: falco-exclude-logs.yaml
- path: falco-rules-local.yaml
- path: falcosidekick-exclude-logs.yaml

Expand Down
29 changes: 29 additions & 0 deletions kyverno/policies/pods/audit-logs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: audit-logs-label
annotations:
policies.kyverno.io/title: Control Labelling for pushing to Loki-audits
policies.kyverno.io/subject: Pod
policies.kyverno.io/description: >-
We should be able to control which pods logs will be pushed to Loki-audits.
Since this is selected via a label we should restrict the pods that can use
it.
spec:
validationFailureAction: Enforce
rules:
- name: default
match:
any:
- resources:
kinds:
- Pod
validate:
message: >-
Labelling pods with promtail-audit-logs: "true" is not allowed.
deny:
conditions:
all:
- key: "{{ request.object.metadata.labels.promtail-audit-logs || '' }}"
operator: Equals
value: "true"
1 change: 1 addition & 0 deletions kyverno/policies/pods/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- AppArmor.yaml
- audit-logs.yaml
- capabilities.yaml
- hostIPC.yaml
- hostNetwork.yaml
Expand Down
11 changes: 11 additions & 0 deletions promtail/promtail-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ scrape_configs:
selector: '{kubernetes_namespace=~"sys-ingress-.+"} |~ "kubernetes service not found|subset not found for|service port not found|Cannot create service: service not found|Skipping service: no endpoints found|middleware .+ does not exist"'
action: drop
drop_counter_reason: promtail_noisy_error
- match:
selector: '{promtail-audit-logs="true"}'
stages:
- client:
url: http://loki-audits.sys-log.svc.cluster.aws:3100/loki/api/v1/push
external_labels:
cloud_provider: ${CLOUD_PROVIDER}
uw_environment: ${UW_ENVIRONMENT}
kubernetes_cluster: ${KUBERNETES_CLUSTER}
cluster: ${KUBERNETES_CLUSTER}
provider: ${CLOUD_PROVIDER}
- limit:
rate: 10
burst: 10
Expand Down

0 comments on commit d016bfa

Please sign in to comment.