Skip to content

Commit 8466045

Browse files
committed
Adds the new annotations feild to the controller config
1 parent f9fdcdb commit 8466045

File tree

1 file changed

+54
-25
lines changed

1 file changed

+54
-25
lines changed

enhancements/external-secrets-operator/external-secrets-component-config.md

Lines changed: 54 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,22 @@ superseded-by:
2424

2525
## Summary
2626

27-
This document proposes an enhancement to the `ExternalSecretsConfig` API by introducing a `ComponentConfig` extension. This new structure allows administrators to specify component-specific overrides for deployment lifecycle settings for external-secrets components (Controller, Webhook, CertController, BitwardenSDKServer). Specifically, a dedicated field is introduced within `ComponentConfig` to accept structured, type-safe configuration values intended to modify the component's underlying Kubernetes Deployment resource. This change offers administrators greater control over the resource management and operational parameters of individual components.
27+
This document proposes an enhancement to the `ExternalSecretsConfig` API by introducing a `ComponentConfig` extension and global annotations support thorugh `Annotations` field. This allows administrators to specify component-specific overrides for deployment lifecycle settings and global custom annotations for external-secrets components (Controller, Webhook, CertController, BitwardenSDKServer). This change offers administrators greater control over the resource management and operational parameters of components.
2828

2929
## Motivation
3030

31-
Administrators often need to control deployment lifecycle settings without directly modifying the underlying operator-managed Deployment resources.
31+
Administrators often need to control deployment lifecycle settings and add custom annotations without directly modifying the underlying operator-managed Deployment resources.
3232

3333
### User Stories
3434

35-
- As an administrator, I want to customize deployment lifecycle properties for `external-secrets` components to manage their resource consumption and rollback behavior.
35+
- As an administrator, I want to customize deployment lifecycle properties for `external-secrets` operand components to manage their resource consumption and rollback behavior.
3636
- As an operator user, I want to be able to set specific deployment override values independently for each component via ComponentConfig to meet unique operational requirements.
37+
- As a platform engineer, I want to add custom annotations to external-secrets deployments without modifying operator-managed resources.
3738

3839
### Goals
3940

40-
- Provide a declarative API for specifying deployment lifecycle overrides for each component.
41+
- Provide a declarative API for specifying deployment lifecycle overrides for each component via `componentConfig`.
42+
- Provide a declarative API for adding custom annotations globally to all component Deployments and Pod templates via `controllerConfig.annotations`.
4143
- Support all four operand components: Controller, Webhook, CertController, and BitwardenSDKServer.
4244

4345
### Non-Goals
@@ -47,13 +49,24 @@ Administrators often need to control deployment lifecycle settings without direc
4749

4850
## Proposal
4951

50-
Extend the ControllerConfig API with a new componentConfig field for per-component deployment lifecycle overrides.
52+
Extend the ControllerConfig API with:
53+
1. A new `annotations` field for adding custom annotations globally to Deployments and Pod templates.
54+
2. A new `componentConfig` field for per-component deployment lifecycle overrides.
5155

5256
### Workflow Description
5357

58+
**For Global Annotations:**
59+
60+
1. **User Configuration:** Administrator updates the `ExternalSecretsConfig` CR with the `controllerConfig.annotations` field containing custom key-value pairs.
61+
2. **Validation:** The operator validates that annotation keys and values conform to Kubernetes annotation constraints.
62+
3. **Reconciliation:** The operator merges user-specified annotations with any default annotations. User annotations take precedence in case of conflicts. Annotations are applied to both the Deployment metadata and Pod template metadata for all components.
63+
4. **Rollout:** Kubernetes detects the annotation changes and performs updates as needed.
64+
65+
**For Component Configuration:**
66+
5467
1. **User Configuration:** Administrator updates the `ExternalSecretsConfig` CR, utilizing the new `componentConfig` list to specify configuration entries for a component (Controller, Webhook, etc.).
55-
2. **Validation:** It verifies the `componentName` against the allowed enum values and enforces uniqueness across the list.It strictly validates the `OverrideArgs` field using the provided `XValidation` rule, ensuring every entry uses the specified format
56-
3. **Reconciliation:** It parses the `OverrideArgs` field to identify and extract the deployment override key and its corresponding value. It updates the component's underlying Kubernetes Deployment resource by setting the parsed override value in the appropriate `.spec` field
68+
2. **Validation:** It verifies the `componentName` against the allowed enum values and enforces uniqueness across the list. It strictly validates the `OverrideArgs` field using the provided `XValidation` rule, ensuring every entry uses the specified format.
69+
3. **Reconciliation:** It parses the `OverrideArgs` field to identify and extract the deployment override key and its corresponding value. It updates the component's underlying Kubernetes Deployment resource by setting the parsed override value in the appropriate `.spec` field.
5770
4. **Rollout:** Kubernetes detects the change in the Deployment's spec and performs a rolling update, applying the new setting to the component.
5871

5972
### Implementation Details/Notes/Constraints
@@ -86,6 +99,16 @@ type ComponentConfig struct {
8699
type ControllerConfig struct {
87100
// ... existing fields ...
88101

102+
// annotations allows adding custom annotations to all external-secrets component
103+
// Deployments and Pod templates. These annotations are applied globally to all
104+
// operand components (Controller, Webhook, CertController, BitwardenSDKServer).
105+
// These annotations are merged with any default annotations set by the operator.
106+
// User-specified annotations take precedence over defaults in case of conflicts.
107+
//
108+
// +kubebuilder:validation:Optional
109+
// +optional
110+
Annotations map[string]string `json:"annotations,omitempty"`
111+
89112
// componentConfig allows specifying component-specific configuration overrides
90113
// for individual components (Controller, Webhook, CertController, Bitwarden).
91114
// +kubebuilder:validation:XValidation:rule="self.all(x, self.exists_one(y, x.componentName == y.componentName))",message="componentName must be unique across all componentConfig entries"
@@ -115,7 +138,7 @@ spec:
115138
- "RevisionHistoryLimit:5"
116139
```
117140
118-
**Configure the limit for a different component (Webhook):**
141+
**Add custom annotations (applied to all components):**
119142
120143
```yaml
121144
apiVersion: operator.openshift.io/v1alpha1
@@ -124,14 +147,11 @@ metadata:
124147
name: cluster
125148
spec:
126149
controllerConfig:
127-
componentConfig:
128-
- componentName: Webhook
129-
# Sets the Deployment's revision history limit to 3
130-
overrideArgs:
131-
- "RevisionHistoryLimit:3"
150+
annotations:
151+
example.com/custom-annotation: "value"
132152
```
133153
134-
**Multiple components with different configurations:**
154+
**Combined: annotations (global) with component-specific overrideArgs:**
135155
136156
```yaml
137157
apiVersion: operator.openshift.io/v1alpha1
@@ -140,6 +160,10 @@ metadata:
140160
name: cluster
141161
spec:
142162
controllerConfig:
163+
# Annotations applied to ALL components
164+
annotations:
165+
example.com/custom-annotation: "value"
166+
# Component-specific overrides
143167
componentConfig:
144168
- componentName: ExternalSecretsCoreController
145169
overrideArgs:
@@ -186,13 +210,16 @@ None
186210
2. Test validation of argument count limits (max 50).
187211
3. Test parsing of deployment-level overrides (e.g., "RevisionHistoryLimit:5").
188212
4. Test that invalid override formats are handled gracefully.
213+
5. Test annotation merging logic with defaults and user overrides.
189214
190215
* **Integration Tests:**
191216
1. Deploy the operator and create an `ExternalSecretsConfig` with component configuration.
192217
2. Verify that "RevisionHistoryLimit:X" is correctly applied to the deployment's `spec.revisionHistoryLimit`.
193-
3. Update the configuration and verify the deployment is updated accordingly.
194-
4. Remove the configuration and verify defaults are restored.
195-
5. Attempt to apply a configuration that fails XValidation and verify the API server rejects the resource with the appropriate error message.
218+
3. Verify that specified annotations appear on both Deployment and Pod template.
219+
4. Update the configuration and verify the deployment is updated accordingly.
220+
5. Remove the configuration and verify defaults are restored.
221+
6. Attempt to apply a configuration that fails XValidation and verify the API server rejects the resource with the appropriate error message.
222+
7. Test annotation override behavior when user annotation conflicts with operator default.
196223

197224
* **End-to-End (E2E) Tests:**
198225
1. Test each component type (Controller, Webhook, CertController, BitwardenSDKServer) individually.
@@ -205,6 +232,7 @@ This feature will be delivered as GA directly, as it uses stable Kubernetes APIs
205232

206233
* All API fields are implemented with proper validation.
207234
* Argument merging logic is complete.
235+
* Annotation merging logic is complete and applies to both Deployment and Pod template.
208236
* All tests outlined in the Test Plan are passing.
209237
* Documentation includes examples for common use cases.
210238

@@ -222,9 +250,9 @@ Not applicable.
222250

223251
## Upgrade / Downgrade Strategy
224252

225-
* **Upgrade:** On upgrade, the new `componentConfig` field will be available. Existing installations without this configuration will continue to work with default settings. Users can optionally add component configurations after upgrade.
253+
* **Upgrade:** On upgrade, the new `annotations` and `componentConfig` fields will be available. Existing installations without these configurations will continue to work with default settings. Users can optionally add annotations and component configurations after upgrade.
226254

227-
* **Downgrade:** If a user downgrades to a version that doesn't support `componentConfig`, the field will be ignored by the older operator, and deployments will revert to default configurations. Users should be aware that custom configurations will be lost on downgrade.
255+
* **Downgrade:** If a user downgrades to a version that doesn't support `annotations` or `componentConfig`, these fields will be ignored by the older operator. Deployments will revert to default configurations, and custom annotations will be removed. Users should be aware that custom configurations will be lost on downgrade.
228256

229257
## Alternatives (Not Implemented)
230258

@@ -236,18 +264,19 @@ NA
236264

237265
## Operational Aspects of API Extensions
238266

239-
The `componentConfig` API extension follows standard Kubernetes patterns:
267+
The `annotations` and `componentConfig` API extensions follow standard Kubernetes patterns:
240268

241-
* **Failure Modes:** Invalid configurations will be rejected by the API server validation. Runtime failures (e.g., invalid arguments causing pod crashes) will be visible through standard pod status and events.
269+
* **Failure Modes:** Invalid configurations will be rejected by the API server validation. Invalid annotation formats will be rejected at the API level. Runtime failures (e.g., invalid arguments causing pod crashes) will be visible through standard pod status and events.
242270

243-
* **Support Procedures:** Administrators can verify the applied configuration by inspecting the deployment specs and comparing them to the `ExternalSecretsConfig` resource.
271+
* **Support Procedures:** Administrators can verify the applied configuration by inspecting the deployment specs and comparing them to the `ExternalSecretsConfig` resource. Custom annotations can be verified on both Deployment and Pod template metadata.
244272

245273
## Support Procedures
246274

247275
Support personnel debugging configuration issues should:
248276

249277
1. Verify the `ExternalSecretsConfig` resource: `oc get externalsecretconfigs cluster -o yaml`
250278
2. Compare the deployment spec to the expected configuration: `oc get deployment external-secrets -n external-secrets -o yaml`
251-
3. Check pod logs for argument parsing errors.
252-
4. Review events for the deployment: `oc get events -n external-secrets`
253-
5. If a pod is failing to start due to invalid arguments, check the container's termination message and logs.
279+
3. Verify custom annotations are applied to Deployment and Pod template: check `.metadata.annotations` and `.spec.template.metadata.annotations` in the deployment spec.
280+
4. Check pod logs for argument parsing errors.
281+
5. Review events for the deployment: `oc get events -n external-secrets`
282+
6. If a pod is failing to start due to invalid arguments, check the container's termination message and logs.

0 commit comments

Comments
 (0)