Skip to content

Conversation

giorio94
Copy link
Member

Currently, the same etcd user (i.e., remote) is granted permissions to read the whole content of the clustermesh-apiserver's sidecar etcd instance, including also the data cached by kvstoremesh, when enabled. In an effort to harden the overall clustermesh posture, let's introduce a separate and dedicated user for local access, to ensure that remote clusters cannot access cached data, as it may include information that they would not normally have access to.

Specifically, the remote user is intended to have access only to the information regarding the local cluster, while the local user can access cached data about remote clusters only. Still, for backward compatibility purposes, the remote user still retains access to cached data as well in this release. The reason being that there would otherwise be a time window upon upgrade in which Cilium Agents would lose access to the kvstoremesh data (especially in large clusters). Indeed, the new certificate would be mounted by the agents only upon rollout, but the configuration would be immediately reloaded (thus targeting the new, not yet mounted, certificate), hence breaking the access to the information cached by kvstoremesh.

Please review commit by commit, and refer to the individual descriptions for additional details.

@giorio94 giorio94 added kind/enhancement This would improve or streamline existing functionality. release-note/minor This PR changes functionality that users may find relevant to operating Cilium. area/clustermesh Relates to multi-cluster routing functionality in Cilium. labels Jun 12, 2024
giorio94 added 3 commits June 13, 2024 09:06
Currently, the same etcd user (i.e., remote) is granted permissions to
read the whole content of the clustermesh-apiserver's sidecar etcd
instance, including also the data cached by kvstoremesh, when enabled.
In an effort to harden the overall clustermesh posture, let's introduce
a separate and dedicated user for local access, to ensure that remote
clusters cannot access cached data, as it may include information that
they would not normally have access to.

Specifically, the remote user is intended to have access only to the
information regarding the local cluster, while the local user can
access cached data about remote clusters only. Still, for backward
compatibility purposes, the remote user still retains access to cached
data as well in this release. The reason being that there would
otherwise be a time window upon upgrade in which Cilium Agents would
lose access to the kvstoremesh data (especially in large clusters).
Indeed, the new certificate would be mounted by the agents only upon
rollout, but the configuration would be immediately reloaded (thus
targeting the new, not yet mounted, certificate), hence breaking the
access to the information cached by kvstoremesh.

Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
Extend the helm chart to additionally generate the "local" certificate
with the common name matching the newly introduced "local" etcd user,
when kvstoremesh is enabled.

Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
Let's additionally mount the kvstoremesh-specific certificate into
cilium agents, so that it can be used to authenticate against the
local etcd instance storing the cached data. The secret entry is
always configured (although marked as optional), regardless of
whether KVStoreMesh is actually enabled or not, so that it can be
automatically mounted in case it gets subsequently enabled, without
requiring a restart of the agents.

Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
@giorio94 giorio94 force-pushed the mio/kvstoremesh-user branch from 9d2f5dd to 461da7f Compare June 13, 2024 07:08
@giorio94
Copy link
Member Author

/test

@giorio94
Copy link
Member Author

ClusterMesh related workflows are green. Dropping the last commit, which will be introduced in v1.17 only.

@giorio94 giorio94 force-pushed the mio/kvstoremesh-user branch from 461da7f to fecfd7b Compare June 13, 2024 07:41
@giorio94
Copy link
Member Author

/test

1 similar comment
@giorio94
Copy link
Member Author

/test

@giorio94 giorio94 marked this pull request as ready for review June 13, 2024 09:33
@giorio94 giorio94 requested review from a team as code owners June 13, 2024 09:33
@aanm aanm enabled auto-merge June 13, 2024 12:06
Copy link
Member

@sayboras sayboras left a comment

Choose a reason for hiding this comment

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

I only check helm related file ✅

@aanm aanm added this pull request to the merge queue Jun 13, 2024
Merged via the queue into cilium:main with commit c464e66 Jun 13, 2024
@giorio94 giorio94 deleted the mio/kvstoremesh-user branch June 13, 2024 13:42
rangeForKey(kvstore.HasClusterConfigPath),
rangeForPrefix(kvstore.CachePrefix),
rangeForPrefix(kvstore.ClusterConfigPrefix),
rangeForPrefix(kvstore.SyncedPrefix),
Copy link
Contributor

@marseel marseel Jun 13, 2024

Choose a reason for hiding this comment

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

I would probably fix "Prefixes" so they are actually prefixes with "/" at the end, while "Path" are actual keys in Etcd (so I would change variable naming to Key)
For example, instead of:

SyncedPrefix = BaseKeyPrefix + "/synced"

have

SyncedPrefix = BaseKeyPrefix + "/synced/"

Then we could have rangeForKey function, without having rangeForPrefix, which is a bit confusing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed in #33140

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. kind/enhancement This would improve or streamline existing functionality. 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