diff --git a/pkg/render/kubecontrollers/kube-controllers.go b/pkg/render/kubecontrollers/kube-controllers.go index c85c3eb42a..b968b79afa 100644 --- a/pkg/render/kubecontrollers/kube-controllers.go +++ b/pkg/render/kubecontrollers/kube-controllers.go @@ -403,6 +403,19 @@ func kubeControllersRoleCommonRules(cfg *KubeControllersConfiguration) []rbacv1. Resources: []string{"virtualmachineinstances", "virtualmachines"}, Verbs: []string{"get", "list", "watch"}, }, + { + // The datastore migration controller watches DatastoreMigration CRs and updates their status. + APIGroups: []string{"migration.projectcalico.org"}, + Resources: []string{"datastoremigrations", "datastoremigrations/status"}, + Verbs: []string{"get", "list", "watch", "create", "update", "patch"}, + }, + { + // The datastore migration controller needs to list/watch CRDs to determine + // which API group is active. + APIGroups: []string{"apiextensions.k8s.io"}, + Resources: []string{"customresourcedefinitions"}, + Verbs: []string{"get", "list", "watch"}, + }, } if cfg.Installation.KubernetesProvider.IsOpenShift() { diff --git a/pkg/render/kubecontrollers/kube-controllers_test.go b/pkg/render/kubecontrollers/kube-controllers_test.go index 860d987f8a..8ea86c0e01 100644 --- a/pkg/render/kubecontrollers/kube-controllers_test.go +++ b/pkg/render/kubecontrollers/kube-controllers_test.go @@ -266,7 +266,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(25), "cluster role should have 25 rules") + Expect(clusterRole.Rules).To(HaveLen(27), "cluster role should have 27 rules") ms := rtest.GetResource(resources, kubecontrollers.KubeControllerMetrics, common.CalicoNamespace, "", "v1", "Service").(*corev1.Service) Expect(ms.Spec.ClusterIP).To(Equal("None"), "metrics service should be headless") @@ -353,7 +353,7 @@ 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(23), "cluster role should have 23 rules") + Expect(clusterRole.Rules).To(HaveLen(25), "cluster role should have 25 rules") Expect(clusterRole.Rules).To(ContainElement( rbacv1.PolicyRule{ APIGroups: []string{""}, @@ -564,7 +564,7 @@ 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(23), "cluster role should have 23 rules") + Expect(clusterRole.Rules).To(HaveLen(25), "cluster role should have 25 rules") Expect(clusterRole.Rules).To(ContainElement( rbacv1.PolicyRule{ APIGroups: []string{""},