Skip to content

Commit

Permalink
fix: use namespaced Role and RoleBinding instead of ClusterRole
Browse files Browse the repository at this point in the history
  • Loading branch information
Matéo Mévollon committed Oct 27, 2022
1 parent d0ebb57 commit a39479f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions nsplease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,16 @@ main() {
while read -r NAMESPACE PROJECT; do
info "got labelled namespace: $NAMESPACE $PROJECT"

# create privileged role in requested namespace
out kubectl create role nsplease-role \
--namespace="$NAMESPACE" \
--verb="*" \
--resource="*"

# give rights on namespace to project's ServiceAccount
out kubectl create clusterrolebinding "nsplease-crb-$PROJECT-$NAMESPACE" \
--clusterrole=cluster-admin \
out kubectl create rolebinding "nsplease-rb-$PROJECT-$NAMESPACE" \
--namespace="$NAMESPACE" \
--role=nsplease-role \
--serviceaccount="$PROJECT:nsplease-sa"

# remove label to avoid doing this again for the same namespace
Expand Down

0 comments on commit a39479f

Please sign in to comment.