Skip to content

Conversation

littlejo
Copy link
Contributor

@littlejo littlejo commented Sep 24, 2024

Context: If you manage multiple Kubernetes clusters, it can be beneficial to parallelize the connection processes. However, running helm upgrade in parallel consumes significant CPU resources. Therefore, it's important to customize the resource limits accordingly.

Example of cli for 2 connections in parallel:
cilium clustermesh connect --destination-context kindB,kindC,kindD,kindE --parallel 2

By default --parallel=1

How it works:

  • A connection is created for the current context.
  • Only Remote context connections are created in parallel.

An improvement could be to parallelize both the current context and the remote contexts. However, it seems like a lot of work for minimal gain.

Example of log with timestamp (7 clusters kind and --parallel=5):

Wed, 25 Sep 2024 07:30:53 GMT ℹ️ Configuring Cilium in cluster kind-cmesh1 to connect to cluster kind-cmesh2,kind-cmesh3,kind-cmesh4,kind-cmesh5,kind-cmesh6,kind-cmesh7
Wed, 25 Sep 2024 07:31:00 GMT ℹ️ Configuring Cilium in cluster kind-cmesh6 to connect to cluster kind-cmesh2,kind-cmesh3,kind-cmesh4,kind-cmesh5,kind-cmesh7,kind-cmesh1
Wed, 25 Sep 2024 07:31:00 GMT ℹ️ Configuring Cilium in cluster kind-cmesh5 to connect to cluster kind-cmesh2,kind-cmesh3,kind-cmesh4,kind-cmesh6,kind-cmesh7,kind-cmesh1
Wed, 25 Sep 2024 07:31:00 GMT ℹ️ Configuring Cilium in cluster kind-cmesh3 to connect to cluster kind-cmesh2,kind-cmesh4,kind-cmesh5,kind-cmesh6,kind-cmesh7,kind-cmesh1
Wed, 25 Sep 2024 07:31:00 GMT ℹ️ Configuring Cilium in cluster kind-cmesh2 to connect to cluster kind-cmesh3,kind-cmesh4,kind-cmesh5,kind-cmesh6,kind-cmesh7,kind-cmesh1
Wed, 25 Sep 2024 07:31:00 GMT ℹ️ Configuring Cilium in cluster kind-cmesh4 to connect to cluster kind-cmesh2,kind-cmesh3,kind-cmesh5,kind-cmesh6,kind-cmesh7,kind-cmesh1
Wed, 25 Sep 2024 07:31:16 GMT ℹ️ Configuring Cilium in cluster kind-cmesh7 to connect to cluster kind-cmesh2,kind-cmesh3,kind-cmesh4,kind-cmesh5,kind-cmesh6,kind-cmesh1
Wed, 25 Sep 2024 07:31:29 GMT ✅ Connected clusters kind-cmesh2, kind-cmesh3, kind-cmesh4, kind-cmesh5, kind-cmesh6, kind-cmesh7, and kind-cmesh1!
  • The first line is the current context (it takes 7 seconds)
  • The 5 next lines are the connection parallels
  • When one connection is finished (after 16 seconds), it creates connection for the cluster (kind-cmesh7). It takes 14 seconds.

In total it took 36 seconds (estimated with no parallel: 7x7 = ~49 seconds)

Example of log with timestamp (7 clusters kind and --parallel=3):

Wed, 25 Sep 2024 07:31:07 GMT ℹ️ Configuring Cilium in cluster kind-cmesh1 to connect to cluster kind-cmesh2,kind-cmesh3,kind-cmesh4,kind-cmesh5,kind-cmesh6,kind-cmesh7
Wed, 25 Sep 2024 07:31:13 GMT ℹ️ Configuring Cilium in cluster kind-cmesh4 to connect to cluster kind-cmesh2,kind-cmesh3,kind-cmesh5,kind-cmesh6,kind-cmesh7,kind-cmesh1
Wed, 25 Sep 2024 07:31:13 GMT ℹ️ Configuring Cilium in cluster kind-cmesh2 to connect to cluster kind-cmesh3,kind-cmesh4,kind-cmesh5,kind-cmesh6,kind-cmesh7,kind-cmesh1
Wed, 25 Sep 2024 07:31:13 GMT ℹ️ Configuring Cilium in cluster kind-cmesh3 to connect to cluster kind-cmesh2,kind-cmesh4,kind-cmesh5,kind-cmesh6,kind-cmesh7,kind-cmesh1
Wed, 25 Sep 2024 07:31:24 GMT ℹ️ Configuring Cilium in cluster kind-cmesh5 to connect to cluster kind-cmesh2,kind-cmesh3,kind-cmesh4,kind-cmesh6,kind-cmesh7,kind-cmesh1
Wed, 25 Sep 2024 07:31:25 GMT ℹ️ Configuring Cilium in cluster kind-cmesh6 to connect to cluster kind-cmesh2,kind-cmesh3,kind-cmesh4,kind-cmesh5,kind-cmesh7,kind-cmesh1
Wed, 25 Sep 2024 07:31:25 GMT ℹ️ Configuring Cilium in cluster kind-cmesh7 to connect to cluster kind-cmesh2,kind-cmesh3,kind-cmesh4,kind-cmesh5,kind-cmesh6,kind-cmesh1
Wed, 25 Sep 2024 07:31:40 GMT ✅ Connected clusters kind-cmesh2, kind-cmesh3, kind-cmesh4, kind-cmesh5, kind-cmesh6, kind-cmesh7, and kind-cmesh1!
  • The first line is the current context (it takes 6 seconds)
  • The 3 next lines are the connection parallels
  • When one connection is finished (after 11 seconds), it creates connection for the cluster kind-cmesh5
  • Similar with kind-cmesh6 and kind-cmesh7 (it takes 15 seconds)

In total it took 33 seconds (better option than 5 parallels because the server only has 4 vCPU)

Test on 64 EKS clusters with --parallel=7 and Pulumi (on 8vCPU): 132s (about 7 + 9*14): Youtube

Please ensure your pull request adheres to the following guidelines:

  • For first time contributors, read Submitting a pull request
  • All code is covered by unit and/or runtime tests where feasible.
  • All commits contain a well written commit description including a title,
    description and a Fixes: #XXX line if the commit addresses a particular
    GitHub issue.
  • If your commit description contains a Fixes: <commit-id> tag, then
    please add the commit author[s] as reviewer[s] to this issue.
  • All commits are signed off. See the section Developer’s Certificate of Origin
  • Provide a title or release-note blurb suitable for the release notes.
  • Are you a user of Cilium? Please add yourself to the Users doc
  • Thanks for contributing!

Fixes: #issue-number

@littlejo littlejo requested review from a team as code owners September 24, 2024 10:35
@littlejo littlejo requested review from thorn3r and asauber September 24, 2024 10:35
@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Sep 24, 2024
@github-actions github-actions bot added cilium-cli This PR contains changes related with cilium-cli cilium-cli-exclusive This PR only impacts cilium-cli binary kind/community-contribution This was a contribution made by a community member. labels Sep 24, 2024
@littlejo littlejo force-pushed the cilium-clustermesh-parallel branch from c2b3973 to f108fdf Compare September 24, 2024 10:52
@littlejo littlejo closed this Sep 25, 2024
@littlejo littlejo force-pushed the cilium-clustermesh-parallel branch from f108fdf to e639dde Compare September 25, 2024 07:10
example:
> cilium clustermesh connect --destination-context kindB,kindC,kindD,kindE --parallel 4

Signed-off-by: Joseph Ligier <joseph.ligier@gmail.com>
@littlejo littlejo reopened this Sep 25, 2024
Copy link
Contributor

@thorn3r thorn3r left a comment

Choose a reason for hiding this comment

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

Nice addition, lgtm 👍

@thorn3r
Copy link
Contributor

thorn3r commented Sep 30, 2024

/test

@thorn3r thorn3r added the release-note/minor This PR changes functionality that users may find relevant to operating Cilium. label Sep 30, 2024
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Sep 30, 2024
@littlejo
Copy link
Contributor Author

littlejo commented Oct 1, 2024

@thorn3r in github action integration tests, i saw a problem "github.com/cilium/cilium/operator/pkg/ciliumidentity". i don't think it's related to my feature.

@thorn3r
Copy link
Contributor

thorn3r commented Oct 1, 2024

@littlejo Yeah it looks like it hit this flake. I kicked off a rerun, but doesn't appear to be related to your change 👍

@littlejo
Copy link
Contributor Author

littlejo commented Oct 1, 2024

@thorn3r i tested with parallel=7 with 64 Kubernetes Cluster:
Youtube video

  • connection creation time: 132s for 64 EKS clusters.

@pchaigno pchaigno enabled auto-merge October 5, 2024 10:04
@pchaigno pchaigno added this pull request to the merge queue Oct 7, 2024
@asauber
Copy link
Member

asauber commented Oct 7, 2024

LGTM, thanks for the contribution.

Merged via the queue into cilium:main with commit f093cee Oct 7, 2024
64 of 94 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cilium-cli This PR contains changes related with cilium-cli cilium-cli-exclusive This PR only impacts cilium-cli binary kind/community-contribution This was a contribution made by a community member. release-note/minor This PR changes functionality that users may find relevant to operating Cilium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants