-
Notifications
You must be signed in to change notification settings - Fork 76
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
Adding sidecar configuration versioning and inheritance #36
Merged
Conversation
This file contains 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
komapa
approved these changes
Nov 5, 2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great unit tests and this makes a lot of sense to me. One concern around the use of more than one :
which I left inline.
@@ -381,13 +383,13 @@ func updateAnnotations(target map[string]string, added map[string]string) (patch | |||
target = map[string]string{} | |||
patch = append(patch, patchOperation{ | |||
Op: "add", | |||
Path: "/metadata/annotations/" + keyEscaped, | |||
Path: path.Join("/metadata/annotations/", keyEscaped), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
komapa
approved these changes
Nov 5, 2019
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.
What and why?
We add 2 features to the sidecar injector to make use at scale more ergonomic. 1) versioned configurations and 2) inheritance.
Versioning
We found ourselves suffixing the names of sidecars with versioning information, so we could make improvements to sidecars without breaking legacy consumers of a given sidecar. For example, we would name configs
name: some-sidecar-v3
. To codify this behavior without changing the request interface, we add support for versioned sidecar configurations, similar to how Docker images work.By changing nothing in your configs, each sidecar configuration now has a
Version()
which is derived by splitting off the last field after:
. By default, this islatest
. Here are some examples ofname:
fields, and the derivedversion
.my-sidecar
->latest
my-sidecar:latest
->latest
my-sidecar:v420
->v420
my-sidecar:extra:fields:6.9
->6.9
This change allows you to maintain versioned configs, as well as "symlink" consumers to the latest version of a sidecar, via
:latest
.Inheritance
In addition to versioning, we have found that a lot of our sidecar configurations are actually quite similar, and tend to have only a few differences. This brought us to build inheritance functionality into the configs. By introducing an
inherits:
field to configs loaded from disk (notConfigMap
s!), we support a config using a base, and merging in any fields from the child as necessary.Note: some (most) fields in the config format are sets, so we must perform merging in a manner that provides set uniqueness by
name
field.For example, a config like the following would load
another.yaml
, and then add 2 env vars to it. IfEXISTING_VAR
exists inanother.yaml
, it will be replaced.NEW_VAR
, if not appearing in theenv
list, will be appended. All configs referenced viainherits:
are relative to the directory of the parent file, and cannot traverse upwards in the directory.Testing Steps
make test
)Reviewers
Required reviewers:
@byxorna
Request reviews from other people you want to review this PR in the "Reviewers" section on the right.