feat: [CLI-51461]: implementing checks to allow upgrade to ES v1 API#167
Open
harness-jc wants to merge 1 commit intomainfrom
Open
feat: [CLI-51461]: implementing checks to allow upgrade to ES v1 API#167harness-jc wants to merge 1 commit intomainfrom
harness-jc wants to merge 1 commit intomainfrom
Conversation
Collaborator
Author
|
File: Added API version detection: {{- /* Detect which API version to use based on CRD availability */ -}}
{{- $useV1API := false }}
{{- if $.Capabilities.APIVersions.Has "external-secrets.io/v1/ExternalSecret" }}
{{- $useV1API = true }}
{{- end }}
{{- if $useV1API }}
apiVersion: external-secrets.io/v1
{{- else }}
apiVersion: external-secrets.io/v1beta1
{{- end }}
File: src/common/templates/_dbv3.tpl
Fixed missing ctx parameter in function calls (lines 234, 514):
// Before
{{- include "harnesscommon.secrets.generateExternalSecret" (dict "secretsCtx" $localDBCtx.secrets "secretNamePrefix" $localDBESOSecretCtxIdentifier) }}
// After
{{- include "harnesscommon.secrets.generateExternalSecret" (dict "ctx" $ "secretsCtx" $localDBCtx.secrets "secretNamePrefix" $localDBESOSecretCtxIdentifier) }}
Why this fix was needed:
- The function signature always expected ctx parameter (per USAGE docs)
- Previous code had a dormant bug where ctx wasn't passed
- Didn't cause issues before because $ variable was never referenced
- Our new API detection logic requires $.Capabilities, making the fix necessary
How It Works
The template now automatically detects which ESO CRD version is available in the cluster:
1. Checks if external-secrets.io/v1/ExternalSecret CRD exists using Capabilities.APIVersions.Has
2. If available → uses apiVersion: external-secrets.io/v1
3. If not available → falls back to apiVersion: external-secrets.io/v1beta1
API Compatibility
Good news: The ExternalSecret spec structure is identical between v1beta1 and v1:
- ✅ Same secretStoreRef structure
- ✅ Same target.template structure
- ✅ Same data[].secretKey and remoteRef structure
- ⚠️ Only difference: engine field renamed to engineVersion (already updated)
Migration Path
Zero-downtime upgrade:
1. Current state: Charts generate v1beta1 resources (ESO < 0.17.0)
2. After this PR: Charts auto-detect and use v1 if available (ESO 0.16.2+)
3. After ESO upgrade to 0.17.0+: Charts automatically switch to v1
4. Result: No manual manifest updates needed ✨
Impact
Affected Components:
- All helm charts using harnesscommon.secrets.generateExternalSecret
- All charts with MongoDB or Redis using ESO secrets (via _dbv3.tpl)
- Static templates in harness-cluster-resources
Breaking Changes:
- ❌ None - backward compatible with ESO 0.16.2+
- ✅ Graceful fallback to v1beta1 for older versions
- ✅ Automatic upgrade path to v1
Testing Recommendations
Before merging:
- Verify templates render correctly on clusters with ESO 0.16.2 (should use v1)
- Verify templates render correctly on clusters with ESO < 0.17.0 (should use v1beta1)
- Test MongoDB/Redis chart deployments with ESO secrets enabled
- Validate ExternalSecret resources are created successfully
References
- https://github.com/external-secrets/external-secrets/releases/tag/v0.17.0 - v1beta1 removal
- https://external-secrets.io/latest/api/spec/ |
arya-harness
approved these changes
Oct 2, 2025
Collaborator
arya-harness
left a comment
There was a problem hiding this comment.
LGTM, can you also bump up the chart version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
External Secrets has deprecated v1beta API. We need the capability to support older versions of ES but also migrate to V1 for future releases.