Skip to content
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

Restart deployment/daemonset when referred resources' content is changing #286

Closed
chenliu1993 opened this issue Aug 23, 2021 · 8 comments · Fixed by #311
Closed

Restart deployment/daemonset when referred resources' content is changing #286

chenliu1993 opened this issue Aug 23, 2021 · 8 comments · Fixed by #311
Assignees
Labels
carvel accepted This issue should be considered for future work and that the triage process has been completed discussion This issue is not a bug or feature and a conversation is needed to find an appropriate resolution enhancement This issue is a feature request

Comments

@chenliu1993
Copy link

chenliu1993 commented Aug 23, 2021

Hi team, I met a senario when using kapp's versioned annotation. Opened this issue to track the question.
The scenario is:
config C refers a secret S in its data, and this config C is referred by a Deployment D. Will update the content of secret S trigger restart of Deployment D?

I get a solution that is referring the secret S directly in Depoyment D. But I think that may be not the best way.

Will kapp's versioned annotation supports above scenario? Or already supported?
Thanks.

@chenliu1993 chenliu1993 added the carvel triage This issue has not yet been reviewed for validity label Aug 23, 2021
@cppforlife
Copy link
Contributor

config C refers a secret S in its data, and this config C is referred by a Deployment D. Will update the content of secret S trigger restart of Deployment D?

it will not today, since kapp does not support updating resource references within arbitrary content (data of ConfigMap). im not sure we want to extend kapp to try to update contents of ConfigMaps with new resource name. (we do something like this in kbld to update image refs but it only works for json/yaml content).

I get a solution that is referring the secret S directly in Depoyment D. But I think that may be not the best way.

currently, that's the only way to make this work with versioned resources. note that referencing a secret on the deployment does not mean that you Deployment needs to actually consume it directly, it could still be doing it through changed ConfigMap.

outside of versioned resources feature, you could do what folks do with templating tricks to hash content and throw in an annotation onto Deployment, but to me that feels more work that referencing secret on the Deployment.

as an enhancement to versioned resources feature, i could imagine supporting special annotation that will make kapp consider ConfigMap as related to changed Secret which then would trigger Deployment change. e.g.

kind: Secret
metadata:
  name: something
  annotations:
   kapp.k14s.io/versioned: ""
# ...
---
kind: ConfigMap
metadata:
  name: config
  annotations:
   kapp.k14s.io/versioned: ""
   kapp.k14s.io/versioned-explicit-ref: "v1/Secret/something" <--- this would be "synthetic reference"
# ...
---
kind: Deployment # only references ConfigMap
# ...

@chenliu1993
Copy link
Author

Thanks @cppforlife . The information is really detailed😊 and I would vote for the example solution kapp.k14s.io/versioned-explicit-ref if it is doable.

@renuy renuy added the discussion This issue is not a bug or feature and a conversation is needed to find an appropriate resolution label Aug 30, 2021
@renuy renuy added carvel accepted This issue should be considered for future work and that the triage process has been completed and removed carvel triage This issue has not yet been reviewed for validity labels Sep 8, 2021
@renuy
Copy link
Contributor

renuy commented Sep 8, 2021

Moving it to carvel accepted. Will try and prioritise this

@100mik 100mik linked a pull request Sep 14, 2021 that will close this issue
1 task
@100mik 100mik self-assigned this Sep 14, 2021
@100mik 100mik added the enhancement This issue is a feature request label Sep 14, 2021
@renuy
Copy link
Contributor

renuy commented Sep 16, 2021

Pulling this issue for the next release v0.41.0 . @100mik , please update the approach here.

@100mik
Copy link
Contributor

100mik commented Sep 16, 2021

We can support a synthetic reference which mirrors the latest versioned name of a versioned resource.

For example, a synthetic reference like

kapp.k14s.io/versioned-explicit-ref: default/v1/Secret/credentials

will be assigned the following value on deployment

kapp.k14s.io/versioned-explicit-ref: credentials-ver-1

This leads to the referencing versioned resource being versioned whenever the referenced resource is. It can be used to explicitly refer a versioned resource from a non-versioned resource as well.

Ongoing work on this with this draft PR!

@100mik
Copy link
Contributor

100mik commented Sep 20, 2021

Addressing the questions raised in the ongoing PR, we will allow users to reference a single or multiple resources in a JSON object with specified format.

kapp.k14s.io/versioned-explicit-ref: '{ "references": [ { "namespace": <resource-namespace>, "apiGroup":  <resource-apiGroup>, "kind" : <resource-kind>, "name":  <resource-name> } ] }'
  • references can have multiple objects referring to different resources
  • The namespace key should be omitted for cluster scoped resources

@chenliu1993 I believe this will satisfy your requirements ?

@100mik
Copy link
Contributor

100mik commented Oct 2, 2021

As of v0.41.0+, versioned resources can be explicitly referred to by the kapp.k14s.io/versioned-explicit-ref annotations like

kapp.k14s.io/versioned-explicit-ref: |
      apiVersion: v1
      kind: ConfigMap
      name: config-1 

(a namespace key can be added for namespaces resources). Documentation regarding the same canoe found at the end of this section in our documentation.

@github-actions github-actions bot added the carvel triage This issue has not yet been reviewed for validity label Oct 2, 2021
@100mik 100mik removed the carvel triage This issue has not yet been reviewed for validity label Oct 2, 2021
@renuy
Copy link
Contributor

renuy commented Oct 5, 2021

Hi @chenliu1993, This feature is now available as part of v0.41.0 . Do provide feedback on this.
Thanks

@github-actions github-actions bot added the carvel triage This issue has not yet been reviewed for validity label Oct 5, 2021
@aaronshurley aaronshurley removed the carvel triage This issue has not yet been reviewed for validity label Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
carvel accepted This issue should be considered for future work and that the triage process has been completed discussion This issue is not a bug or feature and a conversation is needed to find an appropriate resolution enhancement This issue is a feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants