how can i control the number of events a namespace can save?

I want to control the number of events my tenants can create.

My ttl is 1 our, and that ok, but sometimes we have spikes in several namespaces and i am worry about etcd getting flouted if it happens in several namespaces.

I have tried to use resource quotas like this:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>apiVersion: v1
kind: ResourceQuota
metadata:
creationTimestamp: "2024-09-16T04:54:44Z"
name: compute-resources
namespace: test-dev
resourceVersion: "35872662"
uid: 78d46d9b-9b1d-435d-88c2-0cfd6f61c64c
spec:
hard:
count/events: 1k
status:
hard:
count/events: 1k
used:
# i dont see it here
</code>
<code>apiVersion: v1 kind: ResourceQuota metadata: creationTimestamp: "2024-09-16T04:54:44Z" name: compute-resources namespace: test-dev resourceVersion: "35872662" uid: 78d46d9b-9b1d-435d-88c2-0cfd6f61c64c spec: hard: count/events: 1k status: hard: count/events: 1k used: # i dont see it here </code>
apiVersion: v1
kind: ResourceQuota
metadata:
  creationTimestamp: "2024-09-16T04:54:44Z"
  name: compute-resources
  namespace: test-dev
  resourceVersion: "35872662"
  uid: 78d46d9b-9b1d-435d-88c2-0cfd6f61c64c
spec:
  hard:
    count/events: 1k
status:
  hard:
    count/events: 1k
  used: 
  # i dont see it here

But it doesn’t seem to work.

Is there any way to make it work with a Resource Quota? or i need to create web hook?

Thanks,

1

There is no direct way to limit event resources using Resource Quotas because events are not considered as quota managed resources.

A resource quota, defined by a ResourceQuota object, provides
constraints that limit aggregate resource consumption per namespace.
It can limit the quantity of objects that can be created in a
namespace by type, as well as the total amount of compute resources
that may be consumed by resources in that namespace.

See this Medium blog by Anvesh Muppeda and kodekloud blog about Hands-On Guide to Kubernetes Resource Quotas ,Limit Ranges and how to collect kubernetes events.

Resource Quotas in Kubernetes allow administrators to set constraints
on the total resource usage per namespace. By using Resource Quotas,
you can limit the number of resources such as Pods, CPU, and memory
that can be consumed within a namespace.

You can use an admission webhook to capture event creation requests. You can also check the number of events already present in a namespace.

Admission webhooks are HTTP callbacks that receive admission requests
and do something with them. You can define two types of admission
webhooks, validating admission webhook and mutating admission webhook.
Mutating admission webhooks are invoked first, and can modify objects
sent to the API server to enforce custom defaults. After all object
modifications are complete, and after the incoming object is validated
by the API server, validating admission webhooks are invoked and can
reject requests to enforce custom policies.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật