Skip to content

Commit f7cb19b

Browse files
committed
CNTRLPLANE-1575: Add support for event-ttl in Kube API Server Operator
API PR in openshift/api#2520 Feature Gate PR in openshift/api#2525 Signed-off-by: Thomas Jungblut <[email protected]>
1 parent 7f59958 commit f7cb19b

File tree

1 file changed

+275
-0
lines changed

1 file changed

+275
-0
lines changed
Lines changed: 275 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,275 @@
1+
---
2+
title: event-ttl
3+
authors:
4+
- "@tjungblu"
5+
- "CursorAI"
6+
reviewers:
7+
- benluddy
8+
- p0lyn0mial
9+
approvers:
10+
- sjenning
11+
api-approvers:
12+
- JoelSpeed
13+
creation-date: 2025-10-08
14+
last-updated: 2025-10-08
15+
tracking-link:
16+
- https://issues.redhat.com/browse/OCPSTRAT-2095
17+
- https://issues.redhat.com/browse/CNTRLPLANE-1539
18+
- https://github.com/openshift/api/pull/2520
19+
- https://github.com/openshift/api/pull/2525
20+
status: proposed
21+
see-also:
22+
replaces:
23+
superseded-by:
24+
---
25+
26+
# Event TTL Configuration
27+
28+
## Summary
29+
30+
This enhancement describes a configuration option in the operator API to configure the event-ttl setting for the kube-apiserver. The event-ttl setting controls how long events are retained in etcd before being automatically deleted.
31+
32+
Currently, OpenShift uses a default event-ttl of 3 hours (180 minutes), while upstream Kubernetes uses 1 hour. This enhancement allows customers to configure this value based on their specific requirements, with a range of 5 minutes to 3 hours (180 minutes), with a default of 180 minutes (3 hours).
33+
34+
## Motivation
35+
36+
The event-ttl setting in kube-apiserver controls the retention period for events in etcd. Events are automatically deleted after this duration to prevent etcd from growing indefinitely. Different customers have different requirements for event retention:
37+
38+
- Some customers need longer retention for compliance or debugging purposes
39+
- Others may want shorter retention to reduce etcd storage usage
40+
- The current fixed value of 3 hours may not suit all use cases
41+
42+
The maximum value of 3 hours (180 minutes) was chosen to align with the current OpenShift default value. While upstream Kubernetes uses 1 hour as the default, OpenShift's 3-hour default was established to support CI runs that may need to retain events for the entire duration of a test run. For customer use cases, the 3-hour maximum provides sufficient retention for compliance and debugging needs, while the 1-hour upstream default would be more appropriate for general customer workloads.
43+
44+
### Goals
45+
46+
1. Allow customers to configure the event-ttl setting for kube-apiserver through the OpenShift API
47+
2. Provide a reasonable range of values (5 minutes to 3 hours) that covers most customer needs
48+
3. Maintain backward compatibility with the current default of 3 hours (180 minutes)
49+
4. Ensure the configuration is properly validated and applied
50+
51+
### Non-Goals
52+
53+
- Changing the default event-ttl value (will remain 3 hours/180 minutes)
54+
- Supporting event-ttl values outside the recommended range (5-180 minutes)
55+
- Modifying the underlying etcd compaction behavior beyond what the event-ttl setting provides
56+
57+
## Proposal
58+
59+
We propose to add an `eventTTLMinutes` field to the operator API that allows customers to configure the event-ttl setting for kube-apiserver.
60+
61+
### User Stories
62+
63+
#### Story 1: Storage Optimization
64+
As a cluster administrator with limited etcd storage, I want to configure a shorter event retention period so that I can reduce etcd storage usage while maintaining sufficient event history for troubleshooting. Event data can consume significant etcd storage over time, and reducing the retention period can help manage storage growth.
65+
66+
#### Story 2: Default Behavior
67+
As a cluster administrator, I want the current default behavior to be preserved so that existing clusters continue to work without changes.
68+
69+
### API Extensions
70+
71+
This enhancement modifies the operator API by adding a new `eventTTLMinutes` field.
72+
73+
### Workflow Description
74+
75+
The workflow for configuring event-ttl is straightforward:
76+
77+
1. **Cluster Administrator** accesses the OpenShift cluster via CLI or web console
78+
2. **Cluster Administrator** edits the operator configuration resource
79+
3. **Cluster Administrator** sets the `eventTTLMinutes` field to the desired value in minutes (e.g., 60, 180)
80+
4. **kube-apiserver-operator** detects the configuration change
81+
5. **kube-apiserver-operator** updates the kube-apiserver deployment with the new configuration
82+
6. **kube-apiserver** restarts with the new event-ttl setting
83+
7. **etcd** begins using the new event retention policy for future events
84+
85+
The configuration change takes effect immediately for new events, while existing events continue to use their original TTL until they expire.
86+
87+
### Topology Considerations
88+
89+
#### Hypershift / Hosted Control Planes
90+
91+
This enhancement applies to HyperShift and will be implemented using an annotation-based approach on the `HostedCluster` resource, similar to how other kube-apiserver configurations like `goaway-chance` are handled. HyperShift uses the same 3-hour default as standalone OpenShift clusters, and this enhancement will allow HyperShift users to configure the event-ttl setting through a `hypershift.openshift.io/event-ttl-minutes` annotation on the HostedCluster resource.
92+
93+
The implementation will follow the same pattern as the goaway-chance configuration (see [openshift/hypershift#6019](https://github.com/openshift/hypershift/pull/6019)), where the control-plane-operator reads the annotation from the HostedCluster and applies the configuration to the kube-apiserver deployment in the hosted control plane.
94+
95+
#### Standalone Clusters
96+
97+
This enhancement is fully applicable to standalone OpenShift clusters. The event-ttl configuration will be applied to the kube-apiserver running in the control plane, affecting event retention in the cluster's etcd.
98+
99+
#### Single-node Deployments or MicroShift
100+
101+
For single-node OpenShift (SNO) deployments, this enhancement will work as expected. The event-ttl configuration will be applied to the kube-apiserver running on the single node.
102+
103+
For MicroShift, this enhancement is not directly applicable as MicroShift uses a different architecture and may not have the same event-ttl configuration options. However, if MicroShift adopts similar event management, the same principles would apply.
104+
105+
### Implementation Details/Notes/Constraints
106+
107+
The proposed API looks like this:
108+
109+
```yaml
110+
apiVersion: operator.openshift.io/v1
111+
kind: KubeAPIServer
112+
metadata:
113+
name: cluster
114+
spec:
115+
eventTTLMinutes: 60 # Integer value in minutes, e.g., 60, 180
116+
```
117+
118+
The `eventTTLMinutes` field will be an integer value representing minutes. The field will be validated to ensure it falls within the required range of 5-180 minutes. In the upstream Kubernetes API server configuration, `event-ttl` is typically set as a standalone parameter, so placing `eventTTLMinutes` directly under the operator spec without additional nesting maintains consistency with upstream patterns.
119+
120+
The API design is based on the changes in [openshift/api PR #2520](https://github.com/openshift/api/pull/2520), and the feature gate implementation is in [openshift/api PR #2525](https://github.com/openshift/api/pull/2525). The API changes include:
121+
122+
```go
123+
type KubeAPIServerSpec struct {
124+
StaticPodOperatorSpec `json:",inline"`
125+
126+
// eventTTLMinutes specifies the amount of time that the events are stored before being deleted.
127+
// The TTL is allowed between 5 minutes minimum up to a maximum of 180 minutes (3 hours).
128+
//
129+
// Lowering this value will reduce the storage required in etcd. Note that this setting will only apply
130+
// to new events being created and will not update existing events.
131+
//
132+
// When omitted this means no opinion, and the platform is left to choose a reasonable default, which is subject to change over time.
133+
// The current default value is 3h (180 minutes).
134+
//
135+
// +openshift:enable:FeatureGate=EventTTL
136+
// +kubebuilder:validation:Minimum=5
137+
// +kubebuilder:validation:Maximum=180
138+
// +optional
139+
EventTTLMinutes int32 `json:"eventTTLMinutes,omitempty"`
140+
}
141+
```
142+
143+
### Impact of Lower TTL Values
144+
145+
Setting the event-ttl to values lower than the upstream default of 1 hour will primarily impact:
146+
147+
1. **etcd Compaction Bandwidth**: With faster expiring events, etcd will need more bandwidth to remove expired events.
148+
149+
2. **etcd CPU Usage**: More expensive compaction operations will increase CPU usage on etcd nodes, as the compaction process requires CPU cycles to identify and remove expired events.
150+
151+
3. **Event Availability**: Events will be deleted more quickly, potentially reducing the time window available for debugging and troubleshooting.
152+
153+
The main reason for this impact is that with faster expiring events, the system needs to delete events much more frequently, increasing the overhead of the cleanup process.
154+
155+
#### Fleet Analytics Data
156+
157+
Based on fleet analytics data, the storage impact of reducing event TTL can be quantified:
158+
159+
- **Largest Cluster**: ~3-4 million events with average size of 1.5KB
160+
- Reducing TTL from 3 hours to 1 hour (by 1/3) would reduce etcd event storage to approximately 1.5GB
161+
- **Median Cluster**: ~1,391 events in storage
162+
- **90th Percentile**: ~6,700 events in storage
163+
164+
This data shows that while the largest clusters would see significant storage savings (reducing from ~4.5GB to ~1.5GB for the biggest outlier), the majority of clusters have much smaller event footprints where the storage impact would be minimal. We expect, even drastic, lowering to not have any observable impact to CPU or bandwidth on the majority of our clusters.
165+
166+
#### Impact of removing 3 gigabytes of events
167+
168+
To represent the worst case of removing 3 gigabyte of events, we have filled a 4.21 nightly cluster with 3 million events and the default TTL.
169+
Then configured a 5 minute TTL and watch the resource usage over the coming three hours...
170+
171+
172+
### Risks and Mitigations
173+
174+
**Risk**: Customers might set extremely low values that could impact etcd performance.
175+
**Mitigation**: The API validation ensures values are within a reasonable range (5-180 minutes).
176+
177+
178+
### Drawbacks
179+
180+
- Adds complexity to the configuration API
181+
- Additional validation and error handling required
182+
183+
## Alternatives (Not Implemented)
184+
185+
1. **Hardcoded Values**: Keep the current fixed value of 3 hours
186+
- **Rejected**: Does not meet customer requirements for configurability
187+
188+
2. **Environment Variable**: Use environment variables instead of API configuration
189+
- **Rejected**: Less user-friendly and harder to manage
190+
191+
3. **Separate CRD**: Create a separate CRD for event configuration
192+
- **Rejected**: Overkill for a single setting, better to include in existing APIServer resource
193+
194+
## Test Plan
195+
196+
The test plan will include:
197+
198+
1. **Unit Tests**: Test the API validation and parsing logic
199+
2. **Integration Tests**: Test that the configuration is properly applied to kube-apiserver
200+
3. **E2E Tests**: Test that events are properly deleted after the configured TTL
201+
4. **Performance Tests**: Test the impact of different TTL values on etcd performance
202+
203+
## Tech Preview
204+
205+
The EventTTL feature is controlled by the `EventTTL` feature gate, which is enabled by default in both DevPreview and TechPreview feature sets. This allows the feature to be available for testing and evaluation without requiring additional configuration.
206+
207+
The EventTTL feature gate is implemented in [openshift/api PR #2525](https://github.com/openshift/api/pull/2525) and will be removed when the feature graduates to GA, as the functionality will become a standard part of the platform.
208+
209+
## Graduation Criteria
210+
211+
### Dev Preview -> Tech Preview
212+
213+
- API is implemented and validated
214+
- Basic functionality works end-to-end
215+
- Documentation is available
216+
- Sufficient test coverage
217+
- EventTTL feature gate is enabled in DevPreview and TechPreview feature sets
218+
219+
### Tech Preview -> GA
220+
221+
- More comprehensive testing (upgrade, downgrade, scale)
222+
- Performance testing with various TTL values
223+
- User feedback incorporated
224+
- Documentation updated in openshift-docs
225+
- EventTTL feature gate is removed as the feature becomes GA
226+
227+
### Removing a deprecated feature
228+
229+
This enhancement does not remove any existing features. It only adds new configuration options while maintaining backward compatibility with the existing default behavior.
230+
231+
## Upgrade / Downgrade Strategy
232+
233+
### Upgrade Strategy
234+
235+
- Existing clusters will continue to use the default 3-hour (180-minute) TTL
236+
- No changes required for existing clusters
237+
- New configuration option is available immediately
238+
239+
### Downgrade Strategy
240+
241+
- Configuration will be ignored by older versions
242+
- No impact on cluster functionality
243+
- Events will continue to use the default TTL (180 minutes)
244+
245+
## Version Skew Strategy
246+
247+
- The event-ttl setting is a kube-apiserver configuration
248+
- No coordination required with other components
249+
- Version skew is not a concern for this enhancement
250+
251+
## Operational Aspects of API Extensions
252+
253+
This enhancement modifies the operator API but does not add new API extensions. The impact is limited to:
254+
255+
- Configuration validation in the kube-apiserver-operator
256+
- Application of the setting to kube-apiserver deployment
257+
- No impact on API availability or performance
258+
259+
## Support Procedures
260+
261+
### Detection
262+
263+
- Configuration can be verified by checking the operator configuration resource
264+
- kube-apiserver logs will show the configured event-ttl value
265+
- etcd metrics can be monitored for compaction frequency
266+
267+
### Troubleshooting
268+
269+
- If events are not being deleted as expected, check the event-ttl configuration
270+
- Monitor etcd compaction metrics for unusual patterns
271+
272+
## Implementation History
273+
274+
- 2025-10-08: Initial enhancement proposal
275+

0 commit comments

Comments
 (0)