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

lifecycle-sidecar and connect inject init container have mandatory resource requirements #289

Closed
wants to merge 6 commits into from

Conversation

kschoche
Copy link
Contributor

@kschoche kschoche commented Jul 7, 2020

In some environments we are seeing (#283) OOM killer being triggered during the init container for connect inject, as well as high cpu usage inside the lifecycle sidecar (hashicorp/consul-helm#515).
This PR resolves #283 and (hashicorp/consul-helm#529) by making the memory limits configurable by consul-helm, passed in as options in the ingress/mesh/terminating gateways and connect-inject deployments.

Resources for the connect inject init copy container and lifecycle sidecar are passed as flags into the consul-k8s binary now for : Cpu Limit, Cpu Request, Memory Limit, Memory Request. These are mandatory arguments passed in from consul-helm and defined as defaults which are set high enough to resolve the above issues.

This PR also makes the values configurable from the end user instead of compiled in, which will simplify maintenance and usability going forward.

@kschoche kschoche added type/bug Something isn't working type/enhancement New feature or request labels Jul 7, 2020
Copy link
Contributor

@thisisnotashwin thisisnotashwin left a comment

Choose a reason for hiding this comment

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

LGTM!! Good job bud!!

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.

Looking at this now I think it definitely does need a refactor as we discussed. The actual code flow is great. I don't think it would complicate things too much to include the refactor here as the tests would stay the same.

connect-inject/container_init.go Show resolved Hide resolved
connect-inject/lifecycle_sidecar_test.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_test.go Show resolved Hide resolved
connect-inject/container_init_test.go Outdated Show resolved Hide resolved
connect-inject/handler.go Outdated Show resolved Hide resolved
connect-inject/handler.go Outdated Show resolved Hide resolved
LifecycleSidecarCPULimit resource.Quantity
LifecycleSidecarCPURequest resource.Quantity
LifecycleSidecarMemoryLimit resource.Quantity
LifecycleSidecarMemoryRequest resource.Quantity
Copy link
Member

Choose a reason for hiding this comment

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

As discussed, in the refactor I think we could have

LifecycleSidecarResources corev1.ResourceRequirements

connect-inject/lifecycle_sidecar_test.go Outdated Show resolved Hide resolved
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.

Kyle, great work on all these changes; thanks for doing this work!

I've left a couple of comments inline.

An additional thought I had is that this will be a breaking change since we're making new flags required. Now to run this command I need to provide all the newly added resource flags, and I didn't need to before. I know some folks are running sync stand-alone, but I'm not sure if we have any users that are running inject-connect command as stand-alone. Would it make sense to add defaults to these flags to minimize the impact?

subcommand/inject-connect/command.go Show resolved Hide resolved
subcommand/inject-connect/command.go Outdated Show resolved Hide resolved
Comment on lines 247 to 248
"request must be <= limit: -default-sidecar-proxy-cpu-request value of %q is greater than the -default-sidecar-proxy-cpu-limit value of %q",
c.flagDefaultSidecarProxyCPURequest, c.flagDefaultSidecarProxyCPULimit))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to add a similar validation for other resource flags too.

@lkysow
Copy link
Member

lkysow commented Jul 8, 2020

An additional thought I had is that this will be a breaking change since we're making new flags required. Now to run this command I need to provide all the newly added resource flags, and I didn't need to before. I know some folks are running sync stand-alone, but I'm not sure if we have any users that are running inject-connect command as stand-alone. Would it make sense to add defaults to these flags to minimize the impact?

Kyle and I talked about this offline about how it's safe to require the consul-k8s version to match up with consul-helm but we should probably get on the same page about this as a team.

In this case I realize it's a moot point because the Helm chart supports setting null for the resources which will result in the flags not being passed in. So I don't think we can make them required.

In terms of defaults though, we agreed we wanted to put all defaults in the Helm chart so if the flag isn't passed in then I think the default needs to be 0 or not set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working type/enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OOM after moving to consul-k8 0.16.0
4 participants