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

Limit Kubernetes connections #12275

Merged
merged 15 commits into from
May 2, 2022
Merged

Limit Kubernetes connections #12275

merged 15 commits into from
May 2, 2022

Conversation

xacrimon
Copy link
Contributor

@xacrimon xacrimon commented Apr 27, 2022

This PR implements limiting Kubernetes connections the same way as SSH connections can be limited by adding a max_kubernetes_connections configuration variable under role options.

Fixes #10672

@xacrimon xacrimon marked this pull request as ready for review April 28, 2022 11:40
integration/kube_integration_test.go Show resolved Hide resolved
integration/kube_integration_test.go Outdated Show resolved Hide resolved
// Create and maintain the maximum amount of open connections
errors := make(chan error)
for i := 0; i < maxConnections; i++ {
go func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should have a waitgroup here to wait for all the intended sessions to be opened?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a check so that we wait until all sessions are open.

integration/kube_integration_test.go Show resolved Hide resolved
@xacrimon xacrimon requested a review from espadolini April 28, 2022 14:59
lib/kube/proxy/sess.go Show resolved Hide resolved

// MaxKubernetesConnections defines the maximum number of concurrent
// Kubernetes sessions a user may hold.
int64 MaxKubernetesConnections = 18
Copy link
Contributor

Choose a reason for hiding this comment

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

It's more of an question rather than an issue, but do we have any guidelines for using specific scalar value types inside protobuf types? I'm asking just because an int64 seems like an overkill for number of connections, but at the same time I've seen that in other protobuf types we also tend to use int64, e.g:

int64 Version = 4;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure we have specific guidelines for this. Here I was merely trying to be consistent with the field concerning max regular connections.

@xacrimon xacrimon force-pushed the joel/limit-k8s-conn branch from 3dc51dd to 616b637 Compare May 2, 2022 14:32
@xacrimon xacrimon merged commit 21ff622 into master May 2, 2022
xacrimon added a commit that referenced this pull request May 2, 2022
@xacrimon xacrimon mentioned this pull request May 2, 2022
xacrimon added a commit that referenced this pull request May 3, 2022
xacrimon added a commit that referenced this pull request May 3, 2022
* Harden SQLite permissions (#12096)

* Check oidc email_verified claim (#12140)

* Limit Kubernetes connections (#12275)

* Handle DynamoDB pay-per-request mode correctly (#12295)
@zmb3 zmb3 deleted the joel/limit-k8s-conn branch September 1, 2022 21:17
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.

Limit concurrent kubernetes session requests
3 participants