Skip to content

Output fields consumable by pods, config maps, etc. #740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
RedbackThomson opened this issue Apr 14, 2021 · 5 comments
Closed

Output fields consumable by pods, config maps, etc. #740

RedbackThomson opened this issue Apr 14, 2021 · 5 comments
Assignees
Labels
kind/enhancement Categorizes issue or PR as related to existing feature enhancements. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.

Comments

@RedbackThomson
Copy link
Contributor

RedbackThomson commented Apr 14, 2021

Is your feature request related to a problem?
Although custom resources display their outputs in their own status fields, there is currently no way to consume these fields from other (native) k8s resources. Such an example would be consuming the configurationEndpoint field from the ElastiCache ReplicationGroup resource into a pod's environment variable.

Describe the solution you'd like

  • Exporting some subset of the status (and spec fields?) into a config map - possibly through an annotation

Describe alternatives you've considered

@RedbackThomson RedbackThomson added the kind/enhancement Categorizes issue or PR as related to existing feature enhancements. label Apr 14, 2021
@jaypipes
Copy link
Collaborator

See: #292

@jaypipes
Copy link
Collaborator

In short, I think ACK should focus on control plane operations. A controller that integrates data plane fields into various native Kubernetes resources is interesting but primarily the purview of things like https://github.com/redhat-developer/service-binding-operator

@ack-bot
Copy link
Collaborator

ack-bot commented Aug 28, 2021

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Provide feedback via https://github.com/aws-controllers-k8s/community.
/lifecycle stale

@ack-bot ack-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 28, 2021
@a-hilaly
Copy link
Member

/lifecycle frozen

@ack-bot ack-bot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Aug 30, 2021
@RedbackThomson RedbackThomson self-assigned this Feb 25, 2022
ack-bot pushed a commit to aws-controllers-k8s/runtime that referenced this issue Mar 18, 2022
Issue #, if available: aws-controllers-k8s/community#740

Description of changes:
Creates a new `FieldExport` CRD as outlined [this proposal](aws-controllers-k8s/community#1183). Also creates a new reconciler that reconciles changes to `FieldExport` and changes to any ACK resource recognised by the current controller.

The path for reconciling a `FieldExport`:
1. Ensure the `FieldExport` `Source` resource group matches the current controller's group
2. Mark as managed (add finalizer)
3. Describe the source object
3a. If no source object is found, stop reconciling
4. Use the [`gojq` library](https://github.com/itchyny/gojq) to parse the unstructured source object 
5. Write to `ConfigMap`/`Secret`

The path when any ACK resource is updated:
1. Ensure the resource has the synced condition set to true
2. List and filter all `FieldExport` types in the namespace that reference the current resource as its `Source`
3. For each matching `FieldExport` do steps 3 and 4 from the previous path

The reconciler converts all primitive types into strings (ConfigMap is a string-string map, Secret is a string-byte[] map). If the jq query returns a list of results, we will only take the first result (this PR does not support exporting slices/maps). If the jq query returns a struct, we will not take any action, treating the query as a failure. 

The reconciler will not delete any values from the ConfigMap or Secret. If the referenced field is removed from the object, the reconciler will no-op, rather than overwriting the data with an empty string. When the `FieldExport` is deleted, the ConfigMap or Secret will also be left untouched - meaning it contains whatever was last written to it.

Upon creating a `FieldExport` CR, the reconciler will initially attempt to export the field. If it fails, it will not attempt to retry. After the first sync, the reconciler will only wait until the `ResourceVersion` of the source object changes for it to trigger a new update.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
@RedbackThomson
Copy link
Contributor Author

Done! aws-controllers-k8s/runtime#75

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Categorizes issue or PR as related to existing feature enhancements. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.
Projects
None yet
Development

No branches or pull requests

4 participants