Skip to content

Commit 85de283

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 85de283

File tree

1 file changed

+273
-0
lines changed

1 file changed

+273
-0
lines changed
Lines changed: 273 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,273 @@
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+
For HyperShift, this enhancement will use an annotation-based approach on the `HostedCluster` resource, just as with other kube-apiserver configurations such as `goaway-chance`. Users can control the event-ttl setting by specifying the `hypershift.openshift.io/event-ttl-minutes` annotation. The control-plane-operator will read this annotation and update the kube-apiserver deployment in the hosted control plane accordingly (following the pattern described in [openshift/hypershift#6019](https://github.com/openshift/hypershift/pull/6019)). HyperShift continues to use the same 3-hour default as standalone OpenShift clusters unless overridden.
92+
93+
#### Standalone Clusters
94+
95+
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.
96+
97+
#### Single-node Deployments or MicroShift
98+
99+
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.
100+
101+
For MicroShift, this enhancement is not directly applicable as MicroShift uses a different architecture and may not have the same event-ttl configuration options. MicroShift also uses a 3-hour TTL by default, but since it doesn't use the kube-apiserver operator, the configuration approach described in this enhancement may not work.
102+
103+
### Implementation Details/Notes/Constraints
104+
105+
The proposed API looks like this:
106+
107+
```yaml
108+
apiVersion: operator.openshift.io/v1
109+
kind: KubeAPIServer
110+
metadata:
111+
name: cluster
112+
spec:
113+
eventTTLMinutes: 60 # Integer value in minutes, e.g., 60, 180
114+
```
115+
116+
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.
117+
118+
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:
119+
120+
```go
121+
type KubeAPIServerSpec struct {
122+
StaticPodOperatorSpec `json:",inline"`
123+
124+
// eventTTLMinutes specifies the amount of time that the events are stored before being deleted.
125+
// The TTL is allowed between 5 minutes minimum up to a maximum of 180 minutes (3 hours).
126+
//
127+
// Lowering this value will reduce the storage required in etcd. Note that this setting will only apply
128+
// to new events being created and will not update existing events.
129+
//
130+
// When omitted this means no opinion, and the platform is left to choose a reasonable default, which is subject to change over time.
131+
// The current default value is 3h (180 minutes).
132+
//
133+
// +openshift:enable:FeatureGate=EventTTL
134+
// +kubebuilder:validation:Minimum=5
135+
// +kubebuilder:validation:Maximum=180
136+
// +optional
137+
EventTTLMinutes int32 `json:"eventTTLMinutes,omitempty"`
138+
}
139+
```
140+
141+
### Impact of Lower TTL Values
142+
143+
Setting the event-ttl to values lower than the upstream default of 1 hour will primarily impact:
144+
145+
1. **etcd Compaction Bandwidth**: With faster expiring events, etcd will need more bandwidth to remove expired events.
146+
147+
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.
148+
149+
3. **Event Availability**: Events will be deleted more quickly, potentially reducing the time window available for debugging and troubleshooting.
150+
151+
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.
152+
153+
#### Fleet Analytics Data
154+
155+
Based on fleet analytics data, the storage impact of reducing event TTL can be quantified:
156+
157+
- **Largest Cluster**: ~3-4 million events with average size of 1.5KB
158+
- Reducing TTL from 3 hours to 1 hour (by 1/3) would reduce etcd event storage to approximately 1.5GB
159+
- **Median Cluster**: ~1,391 events in storage
160+
- **90th Percentile**: ~6,700 events in storage
161+
162+
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.
163+
164+
#### Impact of removing 3 gigabytes of events
165+
166+
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.
167+
Then configured a 5 minute TTL and watch the resource usage over the coming three hours...
168+
169+
170+
### Risks and Mitigations
171+
172+
**Risk**: Customers might set extremely low values that could impact etcd performance.
173+
**Mitigation**: The API validation ensures values are within a reasonable range (5-180 minutes).
174+
175+
176+
### Drawbacks
177+
178+
- Adds complexity to the configuration API
179+
- Additional validation and error handling required
180+
181+
## Alternatives (Not Implemented)
182+
183+
1. **Hardcoded Values**: Keep the current fixed value of 3 hours
184+
- **Rejected**: Does not meet customer requirements for configurability
185+
186+
2. **Environment Variable**: Use environment variables instead of API configuration
187+
- **Rejected**: Less user-friendly and harder to manage
188+
189+
3. **Separate CRD**: Create a separate CRD for event configuration
190+
- **Rejected**: Overkill for a single setting, better to include in existing APIServer resource
191+
192+
## Test Plan
193+
194+
The test plan will include:
195+
196+
1. **Unit Tests**: Test the API validation and parsing logic
197+
2. **Integration Tests**: Test that the configuration is properly applied to kube-apiserver
198+
3. **E2E Tests**: Test that events are properly deleted after the configured TTL
199+
4. **Performance Tests**: Test the impact of different TTL values on etcd performance
200+
201+
## Tech Preview
202+
203+
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.
204+
205+
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.
206+
207+
## Graduation Criteria
208+
209+
### Dev Preview -> Tech Preview
210+
211+
- API is implemented and validated
212+
- Basic functionality works end-to-end
213+
- Documentation is available
214+
- Sufficient test coverage
215+
- EventTTL feature gate is enabled in DevPreview and TechPreview feature sets
216+
217+
### Tech Preview -> GA
218+
219+
- More comprehensive testing (upgrade, downgrade, scale)
220+
- Performance testing with various TTL values
221+
- User feedback incorporated
222+
- Documentation updated in openshift-docs
223+
- EventTTL feature gate is removed as the feature becomes GA
224+
225+
### Removing a deprecated feature
226+
227+
This enhancement does not remove any existing features. It only adds new configuration options while maintaining backward compatibility with the existing default behavior.
228+
229+
## Upgrade / Downgrade Strategy
230+
231+
### Upgrade Strategy
232+
233+
- Existing clusters will continue to use the default 3-hour (180-minute) TTL
234+
- No changes required for existing clusters
235+
- New configuration option is available immediately
236+
237+
### Downgrade Strategy
238+
239+
- Configuration will be ignored by older versions
240+
- No impact on cluster functionality
241+
- Events will continue to use the default TTL (180 minutes)
242+
243+
## Version Skew Strategy
244+
245+
- The event-ttl setting is a kube-apiserver configuration
246+
- No coordination required with other components
247+
- Version skew is not a concern for this enhancement
248+
249+
## Operational Aspects of API Extensions
250+
251+
This enhancement modifies the operator API but does not add new API extensions. The impact is limited to:
252+
253+
- Configuration validation in the kube-apiserver-operator
254+
- Application of the setting to kube-apiserver deployment
255+
- No impact on API availability or performance
256+
257+
## Support Procedures
258+
259+
### Detection
260+
261+
- Configuration can be verified by checking the operator configuration resource
262+
- kube-apiserver logs will show the configured event-ttl value
263+
- etcd metrics can be monitored for compaction frequency
264+
265+
### Troubleshooting
266+
267+
- If events are not being deleted as expected, check the event-ttl configuration
268+
- Monitor etcd compaction metrics for unusual patterns
269+
270+
## Implementation History
271+
272+
- 2025-10-08: Initial enhancement proposal
273+

0 commit comments

Comments
 (0)