Skip to content

Commit b448757

Browse files
Merge pull request #276 from rvanderp3/OCPBUGS-17652
OCPBUGS-17652: apply necessary RBAC for the alibaba cloud controller manager
2 parents 5662bea + f07b7db commit b448757

9 files changed

Lines changed: 126 additions & 11 deletions

manifests/0000_26_cloud-controller-manager-operator_02_rbac_operator.yaml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ rules:
7373
- update
7474
- patch
7575

76-
# vSphere has a separate node manager that uses the serivce account kube-system/vsphere-cloud-controller-manager.
76+
# vSphere has a separate node manager that uses the service account kube-system/vsphere-cloud-controller-manager.
7777
# The operator must have these permissions to then grant them to the vSphere node manager.
7878
- apiGroups:
7979
- ""
@@ -103,8 +103,29 @@ rules:
103103
verbs:
104104
- create
105105
- patch
106-
# nutanix has a separate node manager that uses the serivce account kube-system/nutanix-cloud-controller-manager.
107-
# The operator must have these permissions to then grant them to the nutanix node manager. (note it also uses some of the ones requred by vsphere)
106+
107+
# alibaba has a separate node manager that uses the service account kube-system/alibaba-cloud-controller-manager.
108+
# The operator must have these permissions to then grant them to the alibaba node manager. (note it also uses some of the ones requred by vsphere)
109+
- apiGroups:
110+
- ""
111+
resources:
112+
- endpoints
113+
verbs:
114+
- get
115+
- create
116+
- list
117+
- watch
118+
- update
119+
- apiGroups:
120+
- ""
121+
resources:
122+
- services
123+
- services/status
124+
verbs:
125+
- patch
126+
127+
# nutanix has a separate node manager that uses the service account kube-system/nutanix-cloud-controller-manager.
128+
# The operator must have these permissions to then grant them to the nutanix node manager. (note it also uses some of the ones requred by vsphere and alibaba)
108129
- apiGroups:
109130
- ""
110131
resources:

pkg/cloud/alibaba/alibaba.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/openshift/cluster-cloud-controller-manager-operator/pkg/config"
1010

1111
appsv1 "k8s.io/api/apps/v1"
12+
rbacv1 "k8s.io/api/rbac/v1"
1213
"sigs.k8s.io/controller-runtime/pkg/client"
1314

1415
"github.com/openshift/cluster-cloud-controller-manager-operator/pkg/cloud/common"
@@ -21,7 +22,11 @@ var (
2122
assetsFs embed.FS
2223

2324
templates = []common.TemplateSource{
24-
{ReferenceObject: &appsv1.Deployment{}, EmbedFsPath: "assets/cloud-controller-manager-deployment.yaml"},
25+
{ReferenceObject: &appsv1.Deployment{}, EmbedFsPath: "assets/alibaba-cloud-controller-manager-deployment.yaml"},
26+
{ReferenceObject: &rbacv1.Role{}, EmbedFsPath: "assets/alibaba-cloud-controller-manager-role.yaml"},
27+
{ReferenceObject: &rbacv1.RoleBinding{}, EmbedFsPath: "assets/alibaba-cloud-controller-manager-rolebinding.yaml"},
28+
{ReferenceObject: &rbacv1.ClusterRole{}, EmbedFsPath: "assets/alibaba-cloud-controller-manager-clusterrole.yaml"},
29+
{ReferenceObject: &rbacv1.ClusterRoleBinding{}, EmbedFsPath: "assets/alibaba-cloud-controller-manager-clusterrolebinding.yaml"},
2530
}
2631
)
2732

pkg/cloud/alibaba/alibaba_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestGetResources(t *testing.T) {
4343
}
4444

4545
resources := assets.GetRenderedResources()
46-
assert.Len(t, resources, 1)
46+
assert.Len(t, resources, 5)
4747
})
4848
}
4949

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: alibaba-cloud-controller-manager
5+
namespace: openshift-cloud-controller-manager
6+
annotations:
7+
include.release.openshift.io/self-managed-high-availability: "true"
8+
include.release.openshift.io/single-node-developer: "true"
9+
rules:
10+
- apiGroups:
11+
- ""
12+
resources:
13+
- endpoints
14+
verbs:
15+
- get
16+
- list
17+
- watch
18+
- update
19+
- apiGroups:
20+
- ""
21+
resources:
22+
- nodes
23+
- nodes/status
24+
- services
25+
- services/status
26+
verbs:
27+
- patch
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRoleBinding
3+
metadata:
4+
name: alibaba-cloud-controller-manager:alibaba-cloud-controller-manager
5+
namespace: openshift-cloud-controller-manager
6+
roleRef:
7+
kind: ClusterRole
8+
name: alibaba-cloud-controller-manager
9+
apiGroup: rbac.authorization.k8s.io
10+
subjects:
11+
- kind: ServiceAccount
12+
namespace: openshift-cloud-controller-manager
13+
name: cloud-controller-manager

pkg/cloud/alibaba/assets/cloud-controller-manager-deployment.yaml renamed to pkg/cloud/alibaba/assets/alibaba-cloud-controller-manager-deployment.yaml

File renamed without changes.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: Role
3+
metadata:
4+
name: alibaba-cloud-controller-manager
5+
namespace: openshift-cloud-controller-manager
6+
annotations:
7+
include.release.openshift.io/self-managed-high-availability: "true"
8+
include.release.openshift.io/single-node-developer: "true"
9+
rules:
10+
- apiGroups:
11+
- ""
12+
resources:
13+
- endpoints
14+
verbs:
15+
- get
16+
- list
17+
- watch
18+
- update
19+
- create
20+
- apiGroups:
21+
- coordination.k8s.io
22+
resources:
23+
- leases
24+
verbs:
25+
- get
26+
- create
27+
- update
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: RoleBinding
3+
metadata:
4+
name: alibaba-cloud-controller-manager:alibaba-cloud-controller-manager
5+
namespace: openshift-cloud-controller-manager
6+
roleRef:
7+
kind: Role
8+
name: alibaba-cloud-controller-manager
9+
apiGroup: rbac.authorization.k8s.io
10+
subjects:
11+
- kind: ServiceAccount
12+
namespace: openshift-cloud-controller-manager
13+
name: cloud-controller-manager

pkg/cloud/cloud_test.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,26 @@ func TestGetResources(t *testing.T) {
104104
name: "Alibaba resources returned as expected",
105105
testPlatform: platformsMap[string(configv1.AlibabaCloudPlatformType)],
106106
singleReplica: false,
107-
expectedResourceCount: 2,
107+
expectedResourceCount: 6,
108108
expectedResourcesKindName: []string{
109109
"Deployment/alibaba-cloud-controller-manager",
110+
"Role/alibaba-cloud-controller-manager",
111+
"RoleBinding/alibaba-cloud-controller-manager:alibaba-cloud-controller-manager",
112+
"ClusterRole/alibaba-cloud-controller-manager",
113+
"ClusterRoleBinding/alibaba-cloud-controller-manager:alibaba-cloud-controller-manager",
110114
"PodDisruptionBudget/alibabacloud-cloud-controller-manager",
111115
},
112116
}, {
113-
name: "Alibaba resources returned as expected with single node cluster",
114-
testPlatform: platformsMap[string(configv1.AlibabaCloudPlatformType)],
115-
expectedResourceCount: 1,
116-
singleReplica: true,
117-
expectedResourcesKindName: []string{"Deployment/alibaba-cloud-controller-manager"},
117+
name: "Alibaba resources returned as expected with single node cluster",
118+
testPlatform: platformsMap[string(configv1.AlibabaCloudPlatformType)],
119+
expectedResourceCount: 5,
120+
singleReplica: true,
121+
expectedResourcesKindName: []string{
122+
"Deployment/alibaba-cloud-controller-manager",
123+
"Role/alibaba-cloud-controller-manager",
124+
"RoleBinding/alibaba-cloud-controller-manager:alibaba-cloud-controller-manager",
125+
"ClusterRole/alibaba-cloud-controller-manager",
126+
"ClusterRoleBinding/alibaba-cloud-controller-manager:alibaba-cloud-controller-manager"},
118127
}, {
119128
name: "AWS resources returned as expected",
120129
testPlatform: platformsMap[string(configv1.AWSPlatformType)],

0 commit comments

Comments
 (0)