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

Allow init and lifecycle containers resource limits to be configured #298

Merged
merged 1 commit into from
Jul 27, 2020

Conversation

adilyse
Copy link
Contributor

@adilyse adilyse commented Jul 21, 2020

Updates the work done in #289.

Changes proposed in this PR:

  • Adds resource request and limit flags for both the injected init and lifecycle sidecar containers

How I've tested this PR:
Added and updated tests for the functionality. Changed default values to unique values and deployed to a cluster, verifying that they were applied and in the correct place.

How I expect reviewers to test this PR:
Verify the tests function as expected and include all the relevant cases. Deploy the connect injector using the new flags and verify that any injected pods include the provided values.

Checklist:

  • [ x ] Tests added
  • [ x ] CHANGELOG entry added (HashiCorp engineers only, community PRs should not add a changelog entry)

@adilyse adilyse added type/enhancement New feature or request area/connect Related to Connect service mesh, e.g. injection labels Jul 21, 2020
@adilyse adilyse requested review from a team, lkysow and ishustava and removed request for a team July 21, 2020 22:42
Copy link
Contributor

@ishustava ishustava left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! I've made a couple of edits and refactoring suggestions.

Deploy the connect injector using the new flags and verify that any injected pods include the provided values.

Should we wait for the consul-helm changes to deploy it or make those changes ourselves in order to test it? Or maybe use hashicorp/consul-helm#532?

connect-inject/handler.go Outdated Show resolved Hide resolved
subcommand/inject-connect/command.go Outdated Show resolved Hide resolved
subcommand/inject-connect/command.go Outdated Show resolved Hide resolved
subcommand/inject-connect/command.go Outdated Show resolved Hide resolved
subcommand/inject-connect/command.go Outdated Show resolved Hide resolved
subcommand/inject-connect/command.go Show resolved Hide resolved
connect-inject/handler.go Show resolved Hide resolved
subcommand/inject-connect/command.go Show resolved Hide resolved
subcommand/inject-connect/command_test.go Show resolved Hide resolved
CHANGELOG.md Outdated
@@ -1,5 +1,9 @@
## UNRELEASED

IMPROVEMENTS:

* Connect: Add resource request and limit flags for the injected init container and lifecycle sidecar.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Connect: Add resource request and limit flags for the injected init container and lifecycle sidecar.
* Connect: Add resource request and limit flags for the injected init and lifecycle sidecar containers [[GH-298](https://github.com/hashicorp/consul-k8s/pull/298)].

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also mention what their defaults are and why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. No, I don't think listing the new flags is necessary here. The flags are clearly laid out in the PR and descriptions available through the command's help text.

The pull request didn't exist so I couldn't link it when I wrote this up. It's pretty circular to expect it as part of the PR submission.

Copy link
Member

@lkysow lkysow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! I haven't got to testing it out yet but I saw Iryna's review come in so posting my code review too since I think it's largely similar feedback.

subcommand/inject-connect/command.go Outdated Show resolved Hide resolved
subcommand/inject-connect/command.go Show resolved Hide resolved
subcommand/inject-connect/command.go Show resolved Hide resolved
subcommand/inject-connect/command_test.go Outdated Show resolved Hide resolved
@ishustava
Copy link
Contributor

As I was testing this out, I had a question about how would one disable/remove resources for init and lifecycle containers. I think in a Helm/yaml world you would just set it to an empty hash, but how would we translate that to consul-k8s flags? I couldn't find a way to set these flags in a way that would essentially remove them. I could be missing something.

I'll address the rest of the comments and finish my testing tomorrow.

Copy link
Member

@lkysow lkysow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I built a docker image and tested it out and it all works!

I looked over the refactoring suggestions again and I think they make sense to tackle in this PR. I briefly looked at the code changes to make them happen and they didn't seem too onerous so I think we should get them in while we're here.

connect-inject/handler.go Show resolved Hide resolved
subcommand/inject-connect/command.go Outdated Show resolved Hide resolved
subcommand/inject-connect/command.go Show resolved Hide resolved
subcommand/inject-connect/command_test.go Outdated Show resolved Hide resolved
subcommand/inject-connect/command_test.go Show resolved Hide resolved
@ishustava
Copy link
Contributor

I've finished my testing; everything looked great! I've resolved the issue from my comment above with @lkysow 's suggestion to set flags to 0, and that worked.

I don't have any other feedback, other than 👍 to Luke's refactoring comments that if we think this is a good refactor, we should address it here.

Copy link
Contributor Author

@adilyse adilyse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suggested refactor can be addressed in a separate PR. I've filed an (internal) issue to track the work.

CHANGELOG.md Outdated
@@ -1,5 +1,9 @@
## UNRELEASED

IMPROVEMENTS:

* Connect: Add resource request and limit flags for the injected init container and lifecycle sidecar.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. No, I don't think listing the new flags is necessary here. The flags are clearly laid out in the PR and descriptions available through the command's help text.

The pull request didn't exist so I couldn't link it when I wrote this up. It's pretty circular to expect it as part of the PR submission.

connect-inject/handler.go Outdated Show resolved Hide resolved
subcommand/inject-connect/command.go Outdated Show resolved Hide resolved
subcommand/inject-connect/command.go Outdated Show resolved Hide resolved
subcommand/inject-connect/command.go Outdated Show resolved Hide resolved
subcommand/inject-connect/command.go Outdated Show resolved Hide resolved
subcommand/inject-connect/command.go Outdated Show resolved Hide resolved
subcommand/inject-connect/command.go Show resolved Hide resolved
subcommand/inject-connect/command_test.go Outdated Show resolved Hide resolved
subcommand/inject-connect/command_test.go Show resolved Hide resolved
…nit container

Adds default flag values so this isn't a breaking change. Moves
the flag parsing and validation into a separate function which
includes the translation into a ResourceRequirement.
@adilyse adilyse force-pushed the make_resource_mandatory_for_sidecar_and_init branch from fe070f1 to 9a57a42 Compare July 27, 2020 16:47
@adilyse adilyse merged commit 9d1cdb8 into master Jul 27, 2020
@adilyse adilyse deleted the make_resource_mandatory_for_sidecar_and_init branch July 27, 2020 17:01
ndhanushkodi pushed a commit to ndhanushkodi/consul-k8s that referenced this pull request Jul 9, 2021
Allow setting hostPath for client data directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/connect Related to Connect service mesh, e.g. injection type/enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants