-
Notifications
You must be signed in to change notification settings - Fork 5
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
CNS-2801 - Minimize the operator's RBAC access #163
Conversation
…tead of coming from agentSpec. Modify objects to take the value from their own fields.
… and will not have any effect.
…ng a newer operator. Rename the local RoleBinding instead to avoid conflicts.
…t mimics deploying a CR with secret
…rences to repositories that we don't support. Added the missing labeling when pre-creating a namespace.
…ems from last releases
… as well to be latest so far.
This PR will also resolve #117 |
@@ -35,12 +35,12 @@ func (obj *ConfigurationK8sObject) MutateK8sObject(k8sObject client.Object, agen | |||
return fmt.Errorf("expected ConfigMap K8s object") | |||
} | |||
|
|||
configMap.Namespace = agentSpec.Namespace | |||
configMap.Namespace = obj.Namespace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't really matter
Is this line necessary? (and in other files)
The function NamespacedName takes care on this.
Just so we won't have confusion in the future.
I also wrote a comment next to the c.SetNamespace() in state applier about passing the namespace as a parameter to DesiredK8sObjectes New
functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done - both the constructor and removing these lines.
…e on the k8s object as it has no affect (NamespacedName is what sets the namespace).
…they shouldn't need it
Main PR change
The main change in this MR is to reduce the RBAC of the operator's roles. As it stands, the operator has cluster-wide access to many objects, including secrets and configmaps. This is not strictly required and came to be because that is the default of
kubebuilder
and theoperator-sdk
.To implement this in a good way, we decided to tie the operator + agent together and always deploy in the same namespace. The namespace cannot be changed when using the setup wizard. It can be changed by a cluster admin when deploying via Helm, but not via the operator itself.
This was made because the operator could previously move the agent around based on the CRD's
Namespace
value. But to scope the RBAC in that case, we require ClusterRoles orelevate
permission so the operator can "assume" the required permissions in any namespace. This was deemed as too high risk for no real value, as we don't see customers changing the agent's namespace post-deployment without good reason (or needing the operator to be in a separate namespace).The current operator RBAC is split in two roles - ClusterRole for cluster-wide resources (nodes, webhooks, priorityclasses, etc.) and a Role for anything that has a namespace.
In addition, for cluster resources we try to restrict the operations by resource name as well. For
create, list, watch
verbs this is not possible so we have two sets of permissions - one for those verbs and one for the remaining ones. See k8s docs for additional info.Note that this introduces three functional (but not API) breaking changes - the deprecated CRD
Namespace
value, the same-namespace enforcement and the restructured Helm charts. So it is planned to be bundled in the next major operator release.Summarized changes
cbcontainers-dataplane
)Namespace
field remains but is not used in any way anymore (previously the operator would use it to deploy agent components)imagePullSecret
from the dataplane accounts, it's not needed for them (they pull from cbartifactory)rbac
to make it clearer. I think some more restructuring there would be nice in a separate PR.Tests:
createNamespace=false,operatorNamespace=X
createNamespace=true
create_operator_spec