Skip to content
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

Cherry-pick #3660 Retain the get/list/watch for calico-kube-controller SA #3666

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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