Skip to content

Commit

Permalink
Retain the get/list/watch for calico-kube-controller SA (tigera#3666)
Browse files Browse the repository at this point in the history
The Federated Services Controller needs access to the remote kubeconfig secret
in order to create a remote syncer.
  • Loading branch information
vara2504 authored Dec 19, 2024
1 parent 718ab85 commit e1e8c58
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
7 changes: 7 additions & 0 deletions pkg/render/kubecontrollers/kube-controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,13 @@ func kubeControllersRoleEnterpriseCommonRules(cfg *KubeControllersConfiguration)
Resources: []string{"configmaps"},
Verbs: []string{"watch", "list", "get", "update", "create", "delete"},
},
{
// The Federated Services Controller needs access to the remote kubeconfig secret
// in order to create a remote syncer.
APIGroups: []string{""},
Resources: []string{"secrets"},
Verbs: []string{"watch", "list", "get"},
},
{
// Needed to validate the license
APIGroups: []string{"projectcalico.org"},
Expand Down
18 changes: 15 additions & 3 deletions pkg/render/kubecontrollers/kube-controllers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ var _ = Describe("kube-controllers rendering tests", func() {
Expect(len(dp.Spec.Template.Spec.Volumes)).To(Equal(1))

clusterRole := rtest.GetResource(resources, kubecontrollers.KubeControllerRole, "", "rbac.authorization.k8s.io", "v1", "ClusterRole").(*rbacv1.ClusterRole)
Expect(clusterRole.Rules).To(HaveLen(20))
Expect(clusterRole.Rules).To(HaveLen(21))

ms := rtest.GetResource(resources, kubecontrollers.KubeControllerMetrics, common.CalicoNamespace, "", "v1", "Service").(*corev1.Service)
Expect(ms.Spec.ClusterIP).To(Equal("None"), "metrics service should be headless")
Expand Down Expand Up @@ -341,13 +341,19 @@ var _ = Describe("kube-controllers rendering tests", func() {
Expect(dp.Spec.Template.Spec.Volumes[0].ConfigMap.Name).To(Equal("tigera-ca-bundle"))

clusterRole := rtest.GetResource(resources, kubecontrollers.EsKubeControllerRole, "", "rbac.authorization.k8s.io", "v1", "ClusterRole").(*rbacv1.ClusterRole)
Expect(clusterRole.Rules).To(HaveLen(19))
Expect(clusterRole.Rules).To(HaveLen(20))
Expect(clusterRole.Rules).To(ContainElement(
rbacv1.PolicyRule{
APIGroups: []string{""},
Resources: []string{"configmaps"},
Verbs: []string{"watch", "list", "get", "update", "create", "delete"},
}))
Expect(clusterRole.Rules).To(ContainElement(
rbacv1.PolicyRule{
APIGroups: []string{""},
Resources: []string{"secrets"},
Verbs: []string{"watch", "list", "get"},
}))
})

It("should render all calico-kube-controllers resources for a default configuration using TigeraSecureEnterprise and ClusterType is Management", func() {
Expand Down Expand Up @@ -544,13 +550,19 @@ var _ = Describe("kube-controllers rendering tests", func() {
Expect(dp.Spec.Template.Spec.Containers[0].Image).To(Equal("test-reg/tigera/kube-controllers:" + components.ComponentTigeraKubeControllers.Version))

clusterRole := rtest.GetResource(resources, kubecontrollers.EsKubeControllerRole, "", "rbac.authorization.k8s.io", "v1", "ClusterRole").(*rbacv1.ClusterRole)
Expect(clusterRole.Rules).To(HaveLen(19))
Expect(clusterRole.Rules).To(HaveLen(20))
Expect(clusterRole.Rules).To(ContainElement(
rbacv1.PolicyRule{
APIGroups: []string{""},
Resources: []string{"configmaps"},
Verbs: []string{"watch", "list", "get", "update", "create", "delete"},
}))
Expect(clusterRole.Rules).To(ContainElement(
rbacv1.PolicyRule{
APIGroups: []string{""},
Resources: []string{"secrets"},
Verbs: []string{"watch", "list", "get"},
}))
})

It("should include a ControlPlaneNodeSelector when specified", func() {
Expand Down
6 changes: 3 additions & 3 deletions pkg/render/logstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ func (es *elasticsearchComponent) elasticsearchRolesAndBindings() ([]*rbacv1.Rol
{
APIGroups: []string{""},
Resources: []string{"secrets"},
Verbs: []string{"create", "delete", "deletecollection", "get", "list", "update", "watch"},
Verbs: []string{"create", "delete", "deletecollection", "update"},
},
},
}
Expand All @@ -1030,7 +1030,7 @@ func (es *elasticsearchComponent) elasticsearchRolesAndBindings() ([]*rbacv1.Rol
{
APIGroups: []string{""},
Resources: []string{"secrets"},
Verbs: []string{"create", "delete", "deletecollection", "get", "list", "update", "watch"},
Verbs: []string{"create", "delete", "deletecollection", "update"},
},
},
}
Expand Down Expand Up @@ -1366,7 +1366,7 @@ func (m managedClusterLogStorage) kubeControllersRolesAndBindings() ([]*rbacv1.R
{
APIGroups: []string{""},
Resources: []string{"secrets"},
Verbs: []string{"create", "delete", "deletecollection", "get", "list", "update", "watch"},
Verbs: []string{"create", "delete", "deletecollection", "update"},
},
},
}
Expand Down

0 comments on commit e1e8c58

Please sign in to comment.