-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move project creation to use RBAC objects
Also move Service Account Project Role Bindings to RBAC objects Signed-off-by: Simo Sorce <[email protected]>
- Loading branch information
Showing
7 changed files
with
63 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,20 @@ | ||
package bootstrappolicy | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apiserver/pkg/authentication/serviceaccount" | ||
kapi "k8s.io/kubernetes/pkg/api" | ||
|
||
authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization" | ||
"k8s.io/kubernetes/pkg/apis/rbac" | ||
) | ||
|
||
func GetBootstrapServiceAccountProjectRoleBindings(namespace string) []authorizationapi.RoleBinding { | ||
return []authorizationapi.RoleBinding{ | ||
{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: ImagePullerRoleBindingName, | ||
Namespace: namespace, | ||
}, | ||
RoleRef: kapi.ObjectReference{ | ||
Name: ImagePullerRoleName, | ||
}, | ||
Subjects: []kapi.ObjectReference{{Kind: authorizationapi.SystemGroupKind, Name: serviceaccount.MakeNamespaceGroupName(namespace)}}, | ||
}, | ||
{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: ImageBuilderRoleBindingName, | ||
Namespace: namespace, | ||
}, | ||
RoleRef: kapi.ObjectReference{ | ||
Name: ImageBuilderRoleName, | ||
}, | ||
Subjects: []kapi.ObjectReference{{Kind: authorizationapi.ServiceAccountKind, Name: BuilderServiceAccountName}}, | ||
}, | ||
{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: DeployerRoleBindingName, | ||
Namespace: namespace, | ||
}, | ||
RoleRef: kapi.ObjectReference{ | ||
Name: DeployerRoleName, | ||
}, | ||
Subjects: []kapi.ObjectReference{{Kind: authorizationapi.ServiceAccountKind, Name: DeployerServiceAccountName}}, | ||
}, | ||
func GetBootstrapServiceAccountProjectRoleBindings(namespace string) []rbac.RoleBinding { | ||
return []rbac.RoleBinding{ | ||
newOriginRoleBindingForClusterRole(ImagePullerRoleBindingName, ImagePullerRoleName, namespace). | ||
Groups(serviceaccount.MakeNamespaceGroupName(namespace)). | ||
BindingOrDie(), | ||
newOriginRoleBindingForClusterRole(ImageBuilderRoleBindingName, ImageBuilderRoleName, namespace). | ||
SAs(namespace, BuilderServiceAccountName). | ||
BindingOrDie(), | ||
newOriginRoleBindingForClusterRole(DeployerRoleBindingName, DeployerRoleName, namespace). | ||
SAs(namespace, DeployerServiceAccountName). | ||
BindingOrDie(), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 12 additions & 13 deletions
25
test/testdata/bootstrappolicy/bootstrap_service_account_project_role_bindings.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,45 @@ | ||
apiVersion: v1 | ||
items: | ||
- apiVersion: v1 | ||
groupNames: | ||
- system:serviceaccounts:myproject | ||
- apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
kind: RoleBinding | ||
metadata: | ||
creationTimestamp: null | ||
name: system:image-pullers | ||
namespace: myproject | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: system:image-puller | ||
subjects: | ||
- kind: SystemGroup | ||
- kind: Group | ||
name: system:serviceaccounts:myproject | ||
userNames: null | ||
- apiVersion: v1 | ||
groupNames: null | ||
- apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
kind: RoleBinding | ||
metadata: | ||
creationTimestamp: null | ||
name: system:image-builders | ||
namespace: myproject | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: system:image-builder | ||
subjects: | ||
- kind: ServiceAccount | ||
name: builder | ||
userNames: | ||
- system:serviceaccount:myproject:builder | ||
- apiVersion: v1 | ||
groupNames: null | ||
namespace: myproject | ||
- apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
kind: RoleBinding | ||
metadata: | ||
creationTimestamp: null | ||
name: system:deployers | ||
namespace: myproject | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: system:deployer | ||
subjects: | ||
- kind: ServiceAccount | ||
name: deployer | ||
userNames: | ||
- system:serviceaccount:myproject:deployer | ||
namespace: myproject | ||
kind: List | ||
metadata: {} |