Skip to content

Commit

Permalink
Adds GCP ClusterRole and ClusterRoleBinding
Browse files Browse the repository at this point in the history
This change adds back the ClusterRole and ClusterRoleBinding removed in
[OCPBUGS-5825](openshift/cluster-kube-controller-manager-operator#778).

This is because it is still required at present.
  • Loading branch information
theobarberbany committed Dec 18, 2023
1 parent 8a71f3e commit 7883b25
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
20 changes: 20 additions & 0 deletions pkg/cloud/gcp/assets/gcp-cloud-controller-manager-clusterrole.yaml
@@ -0,0 +1,20 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: gcp-cloud-controller-manager
rules:
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
- update
- apiGroups:
- ""
resources:
- services/status
verbs:
- patch
- update
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: gcp-cloud-controller-manager:gcp-cloud-controller-manager
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: gcp-cloud-controller-manager
subjects:
- kind: ServiceAccount
name: cloud-provider
namespace: kube-system
3 changes: 3 additions & 0 deletions pkg/cloud/gcp/gcp.go
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/asaskevich/govalidator"
appsv1 "k8s.io/api/apps/v1"
rbacv1 "k8s.io/api/rbac/v1"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/openshift/cluster-cloud-controller-manager-operator/pkg/cloud/common"
Expand All @@ -19,6 +20,8 @@ var (
assetsFs embed.FS
templates = []common.TemplateSource{
{ReferenceObject: &appsv1.Deployment{}, EmbedFsPath: "assets/cloud-controller-manager.yaml"},
{ReferenceObject: &rbacv1.ClusterRole{}, EmbedFsPath: "assets/gcp-cloud-controller-manager-clusterrole.yaml"},
{ReferenceObject: &rbacv1.ClusterRoleBinding{}, EmbedFsPath: "assets/gcp-cloud-controller-manager-clusterrolebinding.yaml"},
}
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/cloud/gcp/gcp_test.go
Expand Up @@ -55,7 +55,7 @@ func TestResourcesRenderingSmoke(t *testing.T) {
}

resources := assets.GetRenderedResources()
assert.Len(t, resources, 1)
assert.Len(t, resources, 3)
})
}
}

0 comments on commit 7883b25

Please sign in to comment.