Skip to content

Commit

Permalink
feat(kyverno): add flux policy
Browse files Browse the repository at this point in the history
  • Loading branch information
buroa committed Jan 9, 2025
1 parent aad9409 commit 610205b
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
6 changes: 6 additions & 0 deletions kubernetes/apps/kyverno/kyverno/app/helmrelease.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ spec:
- apiGroups: ["volsync.backube"]
resources: ["replicationsources", "replicationdestinations"]
verbs: ["create", "update", "patch", "delete", "get", "list"]
- apiGroups: ["notification.toolkit.fluxcd.io"]
resources: ["alerts", "providers"]
verbs: ["create", "update", "patch", "delete", "get", "list"]
serviceMonitor:
enabled: true
backgroundController:
Expand All @@ -55,6 +58,9 @@ spec:
- apiGroups: ["volsync.backube"]
resources: ["replicationsources", "replicationdestinations"]
verbs: ["create", "update", "patch", "delete", "get", "list"]
- apiGroups: ["notification.toolkit.fluxcd.io"]
resources: ["alerts", "providers"]
verbs: ["create", "update", "patch", "delete", "get", "list"]
resources:
requests:
cpu: 100m
Expand Down
64 changes: 64 additions & 0 deletions kubernetes/apps/kyverno/kyverno/policies/flux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: flux
annotations:
policies.kyverno.io/title: Flux
policies.kyverno.io/category: Monitoring
policies.kyverno.io/severity: low
policies.kyverno.io/subject: Namespace
policies.kyverno.io/description: >-
This policy will automatically generate the necessary resources for
Flux monitoring for Namespaces.
pod-policies.kyverno.io/autogen-controllers: none
spec:
rules:
- &rule
name: flux-provider
match:
resources:
kinds:
- Namespace
generate:
generateExisting: true
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Provider
name: alert-manager
namespace: "{{ request.object.metadata.name }}"
synchronize: true
data:
spec:
type: alertmanager
address: http://alertmanager-operated.monitoring.svc.cluster.local:9093/api/v2/alerts/
- <<: *rule
name: flux-alert
generate:
generateExisting: true
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Alert
name: alert-manager
namespace: "{{ request.object.metadata.name }}"
synchronize: true
data:
spec:
providerRef:
name: alert-manager
eventSeverity: error
eventSources:
- kind: GitRepository
name: "*"
- kind: HelmRelease
name: "*"
- kind: HelmRepository
name: "*"
- kind: Kustomization
name: "*"
- kind: OCIRepository
name: "*"
exclusionList:
- "error.*lookup github\\.com"
- "error.*lookup raw\\.githubusercontent\\.com"
- "dial.*tcp.*timeout"
- "waiting.*socket"
suspend: false
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:
- ./flux.yaml
- ./gatus.yaml
- ./limits.yaml
- ./ndots.yaml
Expand Down

0 comments on commit 610205b

Please sign in to comment.