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

Add 'versioned-explicit-ref' annotation #311

Merged
merged 4 commits into from
Oct 1, 2021

Conversation

100mik
Copy link
Contributor

@100mik 100mik commented Sep 14, 2021

Synthetic reference to a versioned resource.
For example:

kapp.k14s.io/versioned-explicit-ref: |
    apiVersion: v1
    kind: Secret
    name: root-password

The value of the key name is to be replaced by the latest versioned name of the referred resource
Pending:

  • E2E tests

@cppforlife
Copy link
Contributor

questions to be resolved:

  • apigroup vs apiversion
  • namespacing (especially when resource doesnt specify explicit ns). is this similar to what we do with other refs?
  • cluster scoped resources (how it works today and how should ann work with that?)

@100mik
Copy link
Contributor Author

100mik commented Sep 16, 2021

We have to consider a resource that might wanna have multiple versioned resources referenced explicitly.

@100mik 100mik force-pushed the 286-explicit-versioned-ref branch 3 times, most recently from 870d46a to 09853d1 Compare September 20, 2021 11:30
@100mik
Copy link
Contributor Author

100mik commented Sep 20, 2021

Changed how explicit references are structured. Multiple references are now supported using the format specified here. The format should also address our other requirements.

@100mik
Copy link
Contributor Author

100mik commented Sep 20, 2021

Will attempt appending existing annotation instead of adding labels. Do we also wanna avoid adding more annotations?
cc: @cppforlife

@cppforlife
Copy link
Contributor

Do we also wanna avoid adding more annotations?

yup, as much as possible. (especially ones that we would have to add automatically)

@100mik
Copy link
Contributor Author

100mik commented Sep 20, 2021

  • The annotation now has a map which maps unique keys to the latest versioned name.
  • This map is populated for a resource if it's reference is found in the list of user-defined resources.

For example:
For annotation value,

{
   "references":[
      {
         "namespace":"default",
         "kind":"ConfigMap",
         "name":"config-1"
      },
      {
         "namespace":"default",
         "kind":"ConfigMap",
         "name":"config-2"
      }
   ]
}

The updated value is:

{
   "references":[
      {
         "namespace":"default",
         "apiGroup":"",
         "kind":"ConfigMap",
         "name":"config-1"
      },
      {
         "namespace":"default",
         "apiGroup":"",
         "kind":"ConfigMap",
         "name":"config-2"
      }
   ],
   "VersionedNames":{
      "default//ConfigMap/config-1":"config-1-ver-2",
      "default//ConfigMap/config-2":"config-2-ver-3"
   }
}

The versioned names are the updated ones added by kapp. Demo YAML on gist.

@100mik 100mik marked this pull request as ready for review September 21, 2021 11:39
@cppforlife
Copy link
Contributor

lets refine this a bit more...

let's support kapp.k14s.io/versioned-explicit-ref.X annotation where X can be anything like number or some string. resource can have multiple of those annotations. value of that annotation would be {"name": "...", "apiGr...}. when we match reference we would update name field with versioned name. this way this is very similar to regular k8s references:

secretRef:
  name: 
  kind: 
  ...

another question to think about is, should we use json or yaml within that annotation? e.g.

annotations:
  kapp.k14s.io/versioned-explicit-ref.X: |
    name: foo
    namespace: blah
    kind: ConfigMap

pkg/kapp/diff/versioned_resource.go Show resolved Hide resolved
pkg/kapp/diff/explicit_versioned_ref.go Outdated Show resolved Hide resolved
pkg/kapp/diff/explicit_versioned_ref.go Outdated Show resolved Hide resolved
pkg/kapp/diff/explicit_versioned_ref.go Outdated Show resolved Hide resolved
test/e2e/versioned_explicit_reference_test.go Outdated Show resolved Hide resolved
test/e2e/versioned_explicit_reference_test.go Outdated Show resolved Hide resolved
@100mik 100mik force-pushed the 286-explicit-versioned-ref branch 4 times, most recently from 1e751a4 to 0d1020b Compare September 27, 2021 04:58
pkg/kapp/diff/versioned_resource.go Outdated Show resolved Hide resolved
pkg/kapp/diff/versioned_resource.go Outdated Show resolved Hide resolved
@100mik 100mik force-pushed the 286-explicit-versioned-ref branch 2 times, most recently from c0d4758 to a692a0e Compare September 27, 2021 19:39
@100mik 100mik changed the title Added 'versioned-explicit-ref' annotation Add 'versioned-explicit-ref' annotation Sep 29, 2021
@cppforlife cppforlife merged commit f7ad131 into carvel-dev:develop Oct 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Restart deployment/daemonset when referred resources' content is changing
6 participants