Skip to content

Commit b29ea8b

Browse files
committed
Adds the new custom environment variables in the API
1 parent 8466045 commit b29ea8b

File tree

1 file changed

+59
-20
lines changed

1 file changed

+59
-20
lines changed

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

Lines changed: 59 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ approvers:
99
api-approvers:
1010
- "@tgeer"
1111
creation-date: 2025-12-1
12-
last-updated: 2025-12-1
12+
last-updated: 2025-12-5
1313
tracking-link:
1414
- https://issues.redhat.com/browse/ESO-266
1515
see-also:
@@ -24,7 +24,7 @@ superseded-by:
2424

2525
## Summary
2626

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.
27+
This document proposes an enhancement to the `ExternalSecretsConfig` API by introducing a `ComponentConfig` extension and global annotations support through `Annotations` field. This allows administrators to specify component-specific overrides for deployment lifecycle settings, custom environment variables, 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

@@ -33,19 +33,21 @@ Administrators often need to control deployment lifecycle settings and add custo
3333
### User Stories
3434

3535
- As an administrator, I want to customize deployment lifecycle properties for `external-secrets` operand components to manage their resource consumption and rollback behavior.
36-
- 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.
36+
- As an `external-secrets` user, I want to be able to set specific deployment override values independently for each component via ComponentConfig to meet unique operational requirements.
3737
- As a platform engineer, I want to add custom annotations to external-secrets deployments without modifying operator-managed resources.
38+
- As an `external-secrets` user, I want to set custom environment variables for specific components to configure component behavior or integrate with external systems.
3839

3940
### Goals
4041

4142
- Provide a declarative API for specifying deployment lifecycle overrides for each component via `componentConfig`.
4243
- Provide a declarative API for adding custom annotations globally to all component Deployments and Pod templates via `controllerConfig.annotations`.
44+
- Provide a declarative API for specifying custom environment variables for each component via `componentConfig.overrideEnv`.
4345
- Support all four operand components: Controller, Webhook, CertController, and BitwardenSDKServer.
4446

4547
### Non-Goals
4648

4749
- Exhaustive validation of individual argument values. Users should consult upstream documentation. Only basic structural validation (non-empty strings, list length limits) will be performed. Invalid arguments will result in container runtime failures (CrashLoopBackOff) rather than API rejection.
48-
- Resource limits, replica counts, environment variables, or other deployment-level settings except for the RevisionHistoryLimit which is specifically introduced by this proposal.
50+
- Resource limits, replica counts, or other deployment-level settings except for the RevisionHistoryLimit which is specifically introduced by this proposal.
4951

5052
## Proposal
5153

@@ -64,9 +66,9 @@ Extend the ControllerConfig API with:
6466

6567
**For Component Configuration:**
6668

67-
1. **User Configuration:** Administrator updates the `ExternalSecretsConfig` CR, utilizing the new `componentConfig` list to specify configuration entries for a component (Controller, Webhook, etc.).
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.
69+
1. **User Configuration:** Administrator updates the `ExternalSecretsConfig` CR, utilizing the new `componentConfig` list to specify configuration entries for a component (Controller, Webhook, etc.). This includes deployment-level overrides via `overrideArgs` and custom environment variables via `overrideEnv`.
70+
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. For `overrideEnv`, it validates that environment variable names and values conform to Kubernetes conventions.
71+
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. For `overrideEnv`, the operator merges user-specified environment variables with default variables, with user values taking precedence in case of conflicts.
7072
4. **Rollout:** Kubernetes detects the change in the Deployment's spec and performs a rolling update, applying the new setting to the component.
7173

7274
### Implementation Details/Notes/Constraints
@@ -94,6 +96,14 @@ type ComponentConfig struct {
9496
// +kubebuilder:validation:Optional
9597
// +optional
9698
OverrideArgs []string `json:"overrideArgs,omitempty"`
99+
100+
// overrideEnv allows setting custom environment variables for the component's container.
101+
// These environment variables are merged with the default environment variables set by
102+
// the operator. User-specified variables take precedence in case of conflicts.
103+
//
104+
// +kubebuilder:validation:Optional
105+
// +optional
106+
OverrideEnv []corev1.EnvVar `json:"overrideEnv,omitempty"`
97107
}
98108

99109
type ControllerConfig struct {
@@ -151,7 +161,23 @@ spec:
151161
example.com/custom-annotation: "value"
152162
```
153163
154-
**Combined: annotations (global) with component-specific overrideArgs:**
164+
**Set custom environment variables for a component:**
165+
166+
```yaml
167+
apiVersion: operator.openshift.io/v1alpha1
168+
kind: ExternalSecretsConfig
169+
metadata:
170+
name: cluster
171+
spec:
172+
controllerConfig:
173+
componentConfig:
174+
- componentName: ExternalSecretsCoreController
175+
overrideEnv:
176+
- name: HTTP_PROXY
177+
value: "http://proxy.example.com:8080"
178+
```
179+
180+
**Combined: annotations (global) with component-specific overrideArgs and overrideEnv:**
155181
156182
```yaml
157183
apiVersion: operator.openshift.io/v1alpha1
@@ -168,6 +194,9 @@ spec:
168194
- componentName: ExternalSecretsCoreController
169195
overrideArgs:
170196
- "RevisionHistoryLimit:10"
197+
overrideEnv:
198+
- name: HTTP_PROXY
199+
value: "http://proxy.example.com:8080"
171200
- componentName: Webhook
172201
overrideArgs:
173202
- "RevisionHistoryLimit:3"
@@ -195,6 +224,9 @@ None
195224
* **Risk:** Users may accidentally override critical arguments required for proper operation.
196225
* **Mitigation:** The operator will protect certain critical arguments from being overridden and will log warnings if users attempt to do so.
197226
227+
* **Risk:** Users may override critical environment variables required for proper component operation.
228+
* **Mitigation:** The operator will protect certain critical environment variables from being overridden and will log warnings if users attempt to do so.
229+
198230
* **Risk:** Configuration changes may cause service disruption during rollout.
199231
* **Mitigation:** Standard Kubernetes rolling update strategies will minimize disruption. Users can control rollout behavior through the deployment's update strategy.
200232
@@ -211,20 +243,25 @@ None
211243
3. Test parsing of deployment-level overrides (e.g., "RevisionHistoryLimit:5").
212244
4. Test that invalid override formats are handled gracefully.
213245
5. Test annotation merging logic with defaults and user overrides.
246+
6. Test environment variable merging logic with defaults and user overrides.
247+
7. Test that environment variable names conform to Kubernetes conventions.
214248
215249
* **Integration Tests:**
216250
1. Deploy the operator and create an `ExternalSecretsConfig` with component configuration.
217251
2. Verify that "RevisionHistoryLimit:X" is correctly applied to the deployment's `spec.revisionHistoryLimit`.
218252
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.
253+
4. Verify that specified environment variables appear in the container spec.
254+
5. Update the configuration and verify the deployment is updated accordingly.
255+
6. Remove the configuration and verify defaults are restored.
256+
7. Attempt to apply a configuration that fails XValidation and verify the API server rejects the resource with the appropriate error message.
257+
8. Test annotation override behavior when user annotation conflicts with operator default.
258+
9. Test environment variable override behavior when user variable conflicts with operator default.
223259

224260
* **End-to-End (E2E) Tests:**
225261
1. Test each component type (Controller, Webhook, CertController, BitwardenSDKServer) individually.
226262
2. Configure `RevisionHistoryLimit:X` and verify old ReplicaSets are cleaned up accordingly.
227-
3. Verify that the operator correctly handles invalid configurations gracefully.
263+
3. Configure custom environment variables and verify they are available in the running container.
264+
4. Verify that the operator correctly handles invalid configurations gracefully.
228265

229266
## Graduation Criteria
230267

@@ -233,6 +270,7 @@ This feature will be delivered as GA directly, as it uses stable Kubernetes APIs
233270
* All API fields are implemented with proper validation.
234271
* Argument merging logic is complete.
235272
* Annotation merging logic is complete and applies to both Deployment and Pod template.
273+
* Environment variable merging logic is complete and applies to the container spec.
236274
* All tests outlined in the Test Plan are passing.
237275
* Documentation includes examples for common use cases.
238276

@@ -250,9 +288,9 @@ Not applicable.
250288

251289
## Upgrade / Downgrade Strategy
252290

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.
291+
* **Upgrade:** On upgrade, the new `annotations` and `componentConfig` fields (including `overrideArgs` and `overrideEnv`) will be available. Existing installations without these configurations will continue to work with default settings. Users can optionally add annotations, deployment overrides, and custom environment variables after upgrade.
254292

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.
293+
* **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, custom annotations will be removed, and custom environment variables will be reset. Users should be aware that custom configurations will be lost on downgrade.
256294

257295
## Alternatives (Not Implemented)
258296

@@ -266,9 +304,9 @@ NA
266304

267305
The `annotations` and `componentConfig` API extensions follow standard Kubernetes patterns:
268306

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.
307+
* **Failure Modes:** Invalid configurations will be rejected by the API server validation. Invalid annotation formats will be rejected at the API level. Invalid environment variable names will be rejected at the API level.
270308

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.
309+
* **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. Custom environment variables can be verified in the container spec of the Deployment.
272310

273311
## Support Procedures
274312

@@ -277,6 +315,7 @@ Support personnel debugging configuration issues should:
277315
1. Verify the `ExternalSecretsConfig` resource: `oc get externalsecretconfigs cluster -o yaml`
278316
2. Compare the deployment spec to the expected configuration: `oc get deployment external-secrets -n external-secrets -o yaml`
279317
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.
318+
4. Verify custom environment variables are applied to containers: check `.spec.template.spec.containers[*].env` in the deployment spec.
319+
5. Check pod logs for argument parsing errors or environment variable issues.
320+
6. Review events for the deployment: `oc get events -n external-secrets`
321+
7. If a pod is failing to start due to invalid arguments or environment variables, check the container's termination message and logs.

0 commit comments

Comments
 (0)