Skip to content

helm: kvstoremesh with external etcd #34174

Closed
calcium6 wants to merge 3 commits intocilium:mainfrom
calcium6:kvstoremesh-deploy
Closed

helm: kvstoremesh with external etcd #34174
calcium6 wants to merge 3 commits intocilium:mainfrom
calcium6:kvstoremesh-deploy

Conversation

@calcium6
Copy link
Copy Markdown
Contributor

@calcium6 calcium6 commented Aug 5, 2024

When running clustermesh-apiserver, there should be an option to enable and disable containers that are not needed.
For example the etcd and apiserver containers are not necessary when running kvstoremesh with an external kvstore.

This commit adds the options to disable these containers.

@calcium6 calcium6 requested review from a team as code owners August 5, 2024 07:41
@calcium6 calcium6 requested review from joamaki and jrajahalme August 5, 2024 07:41
@maintainer-s-little-helper
Copy link
Copy Markdown

@calcium6 calcium6 requested a review from a user August 5, 2024 07:41
@maintainer-s-little-helper maintainer-s-little-helper bot added dont-merge/needs-sign-off The author needs to add signoff to their commits before merge. dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. labels Aug 5, 2024
@github-actions github-actions bot added the kind/community-contribution This was a contribution made by a community member. label Aug 5, 2024
@gandro
Copy link
Copy Markdown
Member

gandro commented Aug 5, 2024

Thanks for the PR! I'll defer the initial review to the @cilium/sig-clustermesh team, since I lack the necessary domain knowledge to judge correctness.

Please also remove the merge commit from your branch, as we don't use merge commits in the Cilium project. Please use git rebase instead.

@calcium6 calcium6 force-pushed the kvstoremesh-deploy branch from 4081260 to e1b150b Compare August 5, 2024 08:25
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-sign-off The author needs to add signoff to their commits before merge. label Aug 5, 2024
@gandro gandro added area/clustermesh Relates to multi-cluster routing functionality in Cilium. release-note/misc This PR makes changes that have no direct user impact. area/helm Impacts helm charts and user deployment experience labels Aug 5, 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 Aug 5, 2024
@aanm aanm requested a review from giorio94 August 9, 2024 13:33
@marseel
Copy link
Copy Markdown
Member

marseel commented Aug 12, 2024

Thanks @calcium6 for PR I just have one question to make sure I understand it.

For example the etcd and apiserver containers are not necessary when running kvstoremesh with an external kvstore.

AFAIK kvstoremsh does not work with external kvstore right now / it's not officially supported.
Is the goal of this PR to introduce a new way of deploying it that allows for kvstoremesh container to propagate data across external kvstores? If so, I know that @hemanthmalla was also interested in that and we have some discussions around that.
We would probably need some documentation and testing on top of that as well.

@oblazek
Copy link
Copy Markdown
Contributor

oblazek commented Aug 14, 2024

hey @marseel.. yes the ultimate goal is to propagate data across external kvstores ;) this is just one of the pieces, do you want us to send it as one PR? (with docs, tests etc..) :)

@marseel
Copy link
Copy Markdown
Member

marseel commented Aug 14, 2024

hey Marcel Zięba.. yes the ultimate goal is to propagate data across external kvstores ;) this is just one of the pieces, do you want us to send it as one PR? (with docs, tests etc..) :)

nah, it's fine to do it in smaller parts. I was just lacking context. cc @hemanthmalla I know that you were looking into this as well.

In this case, wouldn't it be better to have a single helm flag, something like kvstoremeshExternalKVStore instead of two separate flags? I don't think there is a case when we want to disable one of two of apiserver/Etcd.

@oblazek
Copy link
Copy Markdown
Contributor

oblazek commented Aug 14, 2024

yeah, let's do that.. @calcium6 please let's fix this

@hemanthmalla
Copy link
Copy Markdown
Member

@marseel Sorry, missed the first ping. Yes, we already run clustermesh-apiserver in this mode. But we don't use the upstream chart. IIRC, when I was testing this there are few validations we'll need to disable as well.

We brought this up in one of the community meetings as well, but we ended up deciding maybe we shouldn't document too many variations of clustermesh that might confuse users. But with enough users interested in this, maybe the timing is right :)

@giorio94
Copy link
Copy Markdown
Member

Generally speaking, it makes sense to me to have the possibility of using kvstoremesh in combination with an external kvstore. I wonder whether an equally valid use case could be kvstoremesh+sidecar etcd, when Cilium operates in kvstore mode (i.e., just omitting the apiserver container, which is not necessary in that case).

As mentioned by Marcel, the clustermesh conformance/upgrade tests would need to be extended to cover this configuration as well (that should be pretty trivial, as we are already testing cilium in kvstore mode in a few matrix entries there).

Additionally, there's at least one known issue due to the fact that kvstoremesh does not update the Cilium's heartbeat key in etcd, which is used by the status checks performed by Cilium agents. Although this is not a problem when reusing the same etcd cluster of Cilium (as the hearbeat is updated by the operator), it would not work if using a dedicated etcd cluster for kvstoremesh. The fix may be as trivial as registering the heartbeat cell in the kvstoremesh case as well, although guarded by a dedicated flag (to avoid having two components updating the heartbeat in parallel).

Moreover, please keep in mind that kvstoremesh does not currently perform an explicit reconciliation on restart, as it works under the assumption that the etcd instance is ephemeral and recreated from scratch every time. This means that, when using a persistent etcd cluster, possible cached entries disappearing while kvstoremesh is down will not be deleted from the cache until the corresponding lease expires (15 minutes by default, but configurable).

In this case, wouldn't it be better to have a single helm flag, something like kvstoremeshExternalKVStore instead of two separate flags?

I'm also personally in favor of an explicit flag, to prevent configuring unsupported/invalid combinations. If we decide that kvstoremesh+sidecar etcd is a valid use case, then we may have a mode flag that allows selecting among the three possible alternatives.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd suggest to add a note to the documentation on how to deploy kvstoremesh in this context, rather than adding an example here. Examples tend to be easily missed and get stale over time, as well as require a-priory knowledge about the specific goal, as lacking the accompanying description.

@calcium6 calcium6 marked this pull request as draft August 29, 2024 08:49
@calcium6 calcium6 closed this Aug 29, 2024
@calcium6 calcium6 force-pushed the kvstoremesh-deploy branch from e1b150b to 21700f1 Compare August 29, 2024 13:04
@calcium6 calcium6 reopened this Aug 29, 2024
@maintainer-s-little-helper
Copy link
Copy Markdown

@maintainer-s-little-helper maintainer-s-little-helper bot added dont-merge/needs-sign-off The author needs to add signoff to their commits before merge. labels Aug 29, 2024
@calcium6 calcium6 changed the title helm: be able to run only Kvstoremesh container in clustermesh-apiserver helm: external etcd with kvstoremesh Aug 29, 2024
@calcium6 calcium6 force-pushed the kvstoremesh-deploy branch from 9d20080 to 7d4d29e Compare August 29, 2024 14:35
@maintainer-s-little-helper
Copy link
Copy Markdown

@calcium6 calcium6 changed the title helm: external etcd with kvstoremesh helm: kvstoremesh with external etcd Aug 29, 2024
@calcium6 calcium6 force-pushed the kvstoremesh-deploy branch from 7d4d29e to 1f86f38 Compare August 29, 2024 14:38
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-sign-off The author needs to add signoff to their commits before merge. label Aug 29, 2024
have the option to use external etcd with kvstoremesh

Signed-off-by: Jiri Vanura <[email protected]>
@calcium6 calcium6 force-pushed the kvstoremesh-deploy branch from 1f86f38 to a975482 Compare August 29, 2024 14:40
@calcium6 calcium6 marked this pull request as ready for review August 29, 2024 14:51
cilium install --set cluster.name=$CLUSTER1 --set cluster.id=1 --context $CLUSTER1
cilium install --set cluster.name=$CLUSTER2 --set cluster.id=2 --context $CLUSTER2

.. note::
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This note in "Specify the Cluster Name and ID" section seems out of place. How about moving it to "Enable Cluster Mesh" section?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@giorio94 giorio94 self-requested a review September 3, 2024 14:14
Copy link
Copy Markdown
Member

@giorio94 giorio94 left a comment

Choose a reason for hiding this comment

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

Thanks for the changes.

I've left a few additional comments inline. Overall, the main concern I have about the current proposal is that it would work in a very specific use-case only (and with specific settings, which are also not documented), while leading to a most likely broken configuration otherwise. I personally think that it should be generalized a bit so that it works out of the box in most common scenarios, as well as the validation should be extended to provide safe-guards and prevent users from enabling unsupported configurations. My comments mostly go in that direction. WDYT?

Comment on lines +2941 to +2942
# -- Use external KVStore for KVStoreMesh.
kvstoremeshExternalKVStore: false
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The dedicated clustermesh.kvstoremesh section seems a better fit to me. Additionally, I'd clarify in the comment that the target etcd instance is the one configured via etcd.endpoints, as not obvious otherwise.

Do you have any opinions on:

If we decide that kvstoremesh+sidecar etcd is a valid use case, then we may have a mode flag that allows selecting among the three possible alternatives.

Mostly to decide whether to generalize the setting to potentially enable this combination in the future (it doesn't need to be as part of this PR, considering that it requires a bit of extra work). Still, I'd rather prefer to pick a future-proof setting from the beginning if possible, to avoid having to deal with backward-compatible changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I also think it would be better to add a mode flag to select from the three options, I'll do that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

{{/* validate clustermesh-apiserver */}}
{{- if .Values.clustermesh.useAPIServer }}
{{- if and (ne .Values.identityAllocationMode "crd") (ne .Values.identityAllocationMode "doublewrite-readkvstore") (ne .Values.identityAllocationMode "doublewrite-readcrd") }}
{{- if and (ne .Values.identityAllocationMode "crd") (ne .Values.identityAllocationMode "doublewrite-readkvstore") (ne .Values.identityAllocationMode "doublewrite-readcrd") (not .Values.clustermesh.kvstoremeshExternalKVStore) }}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd suggest adding a similar validation to ensure that the external kvstore mode can only be enabled if etcd.enabled is set to true, and etcd.endpoints is not empty, to avoid surprises (given the current implementation). Similarly, I'd suggest validating that kvstoremesh.enabled=true when useAPIServer=true and kvstoremeshExternalKVStore=true, otherwise the resulting deployment is invalid. Finally, it should be forbidden to enable externalWorkloads.enabled=true if kvstoremeshExternalKVStore=true.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The creation of the clustermesh-apiserver specific ClusterRole and ClusterRoleBinding should be disabled when running only KVStoreMesh, as not required. Similarly, the creation of the clustermesh-apiserver Service should be disabled, and the clustermesh-apiserver-metrics Service/ServiceMonitor should be adapted to disable all but KVStoreMesh-related entries. Finally, the creation of the clustermesh-remote-users ConfigMap and of the different TLS-related secrets should be most likely disabled as well.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe this coment has already been resolved by the original submiter.

{{- end }}
{{- end }}
containers:
{{- if not .Values.clustermesh.kvstoremeshExternalKVStore}}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There are a bunch of volumes configured for this deployment that should be skipped when running in KVStoreMesh-only mode, as not mounted in that case.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

data:
{{- $kvstoremesh := and .Values.clustermesh.useAPIServer .Values.clustermesh.apiserver.kvstoremesh.enabled }}
{{- $override := ternary (printf "https://clustermesh-apiserver.%s.svc:2379" .Release.Namespace) "" $kvstoremesh }}
{{- $override := ternary (join "\n- " $.Values.etcd.endpoints) (ternary (printf "https://clustermesh-apiserver.%s.svc:2379" .Release.Namespace) "" $kvstoremesh) .Values.clustermesh.kvstoremeshExternalKVStore }}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When external KVStore mode is enabled, the Cilium agents appear to default using the etcd endpoints configured via .Values.etcd.endpoints. However, this change does not seem to account for the handling of the TLS certificates, accounting for .Values.etcd.ssl. Similarly, neither the endpoints nor the certificates seem to be automatically configured in the kvstoremesh container, which would not work out of the box.

{{- if and (ne .Values.identityAllocationMode "crd") (ne .Values.identityAllocationMode "doublewrite-readkvstore") (ne .Values.identityAllocationMode "doublewrite-readcrd") (not .Values.clustermesh.kvstoremeshExternalKVStore) }}
{{ fail (printf "The clustermesh-apiserver cannot be enabled in combination with .Values.identityAllocationMode=%s. To establish a Cluster Mesh, directly configure the parameters to access the remote kvstore through .Values.clustermesh.config" .Values.identityAllocationMode ) }}
{{- end }}
{{- if .Values.disableEndpointCRD }}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The disableEndpointCRD validation can be skipped if kvstoremeshExternalKVStore=true.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

@giorio94 giorio94 left a comment

Choose a reason for hiding this comment

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

(Requesting changes as per above comments)

@calcium6 calcium6 marked this pull request as draft September 9, 2024 06:16
changed the flag name clustermesh.kvstoremeshExternalKVStore to clustermesh.apiserver.kvstoremesh.useExternalKVStore

Signed-off-by: Jiri Vanura <[email protected]>
changed the flag clustermesh.apiserver.kvstoremesh.useExternalKVStore to clustermesh.apiserver.kvstoremesh.kvstoreMode

Signed-off-by: Jiri Vanura <[email protected]>
@github-actions
Copy link
Copy Markdown

This pull request has been automatically marked as stale because it
has not had recent activity. It will be closed if no further activity
occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale The stale bot thinks this issue is old. Add "pinned" label to prevent this from becoming stale. label Oct 27, 2024
@github-actions
Copy link
Copy Markdown

This pull request has not seen any activity since it was marked stale.
Closing.

@github-actions github-actions bot closed this Nov 11, 2024
@balous
Copy link
Copy Markdown
Contributor

balous commented Nov 13, 2024

I'd like to revive this PR. I checked all the PR comments and think that most of them were addressed by the original submitter. The only exception I see is the TLS certificate comment, I am going to address it myself. Should I post a new PR with my new commit(s)?

@giorio94
Copy link
Copy Markdown
Member

Should I post a new PR with my new commit(s)?

Hey @balous, yes, I guess that's the easiest way given that this one got closed due to inactivity.
Please, link the new one here as well.

@balous
Copy link
Copy Markdown
Contributor

balous commented Nov 27, 2024

Should I post a new PR with my new commit(s)?

Hey @balous, yes, I guess that's the easiest way given that this one got closed due to inactivity. Please, link the new one here as well.

Here it is: #36216

I believe all comments from this PR were addressed (especially the TLS config one) additional fix in metrics-service.yaml was made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/clustermesh Relates to multi-cluster routing functionality in Cilium. area/helm Impacts helm charts and user deployment experience kind/community-contribution This was a contribution made by a community member. release-note/misc This PR makes changes that have no direct user impact. stale The stale bot thinks this issue is old. Add "pinned" label to prevent this from becoming stale.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants