-
Notifications
You must be signed in to change notification settings - Fork 333
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
Support Kubernetes Namespaces in Policies #2921
Comments
What problems would users be able to solve with namespace support that are difficult to solve now? |
The main reasons for introducing it would be
|
(1) makes sense for simple deployments, though if Kuma has a parallel RBAC system, that calculus might not make sense any more For (2), I think the idea of being able to delegate policy control to a service owner (defined as an actor with permission to deploy in a namespace) is pretty attractive, which I think is the original goal of this proposal 👍
cert-manager APIs might be an interesting point of comparison since that allow both cluster-scoped and namespace-scoped uses (i.e. Issuer, ClusterIssuer, etc). |
yeah, I saw this pattern in Kong Ingress Controller also. It might be ok with when you have a couple of CRDs, but duplicating 10? 15? CRDs with Cluster prefix may not be the best idea 🤔 |
This issue was inactive for 30 days it will be reviewed in the next triage meeting and might be closed. |
This issue was inactive for 30 days it will be reviewed in the next triage meeting and might be closed. |
This issue was inactive for 30 days it will be reviewed in the next triage meeting and might be closed. |
|
This issue was inactive for 90 days. It will be reviewed in the next triage meeting and might be closed. |
Would be interesting to see what this would love like with targetRef policies |
This issue was inactive for 90 days. It will be reviewed in the next triage meeting and might be closed. |
This has been done now |
Problem
Kuma was built with an assumption that it spawns across many workloads regardless of a Kubernetes namespace. For example, workloads across two different namespaces can be placed in one Mesh. For this reason and many more, we decided that there is no good way to support Kubernetes Namespaces and respecting Universal at the same time.
The policies in the initial version of Kuma were Namespaced scoped. For example, TrafficRoute could be placed in namespace team-a, but the fact that it was placed in
team-a
namespace meant nothing because when we generate Envoy config we took TrafficRoutes from all namespaces.Eventually, we figured out that it is confusing for users therefore we changed our policy scope to Global.
The problem is that users are familiar with namespace separation and it would be great to support such a concept.
Solution
Incoming changes in policies described here bring more clear rules of matching which opens new possibilities for solving this problem.
Step 1 - add canonical k8s.kuma.io/namespace tagDone in #3367
The first step is to introduce a new canonical
k8s.kuma.io/namespace
tag. This tag will be automatically added to the inbounds of Dataplane objects that are generated in Kubernetes. ExampleStep 2 - restore Namespace scope of policiesRelated #1366
All the policies can again be placed in the namespace. You could place
TrafficRoute
namedroute-1
in namespaceteam-a
. This will be converted in our core model to nameteam-a.route-1
just likeDataplane
objects are at this moment (to support the same names in different namespaces). However...Step 3 - introduce
kuma-global-policies
namespaceIntroduce an arbitrary namespace that is configurable in the CP config that holds resources not bound to a namespace.
For example,
TrafficRoute
namedroute-2
inkuma-global-policies
will be named justroute-2
in our core model.This could be just
kuma-system
namespace.This will also be a namespace that we will use to sync resources from Global. We should sync them to this namespace.
The side effect of this change is that most likely we would enable the use case of having both Global and Zone CP in one Kubernetes cluster.
Step 4 - take into account the namespace when converting policies to our core model
Here is where interesting things happen. Since we want to change policy matching, we now know that we ALWAYS apply policy on Envoy selected in
source
in Connection Policy (like Timeout) andselectors
in Dataplane Policy (like ProxyTemplate).When converting policy from Kubernetes to our core model, if the policy is placed in the namespace, we automatically add a tag to selectors, so connection policy like this this
becomes
and Dataplane Policy defined like this
becomes
Policies defined in
kuma-global-policies
won't have this tag automatically added.This has a nice implication that owners of namespace
team-a
can only define policies that affects data plane proxies in namespaceteam-a
which is what Kubernetes users are used to.From the implementation perspective, retrieving resources and matching stays exactly the same. Internally we don't need to take into account namespaces as a special case since it's just another tag.
The text was updated successfully, but these errors were encountered: