Skip to content

Instantly share code, notes, and snippets.

@alaypatel07
Last active May 27, 2020 20:16
Show Gist options
  • Save alaypatel07/9e06cbb074eb7fcd2157aa65478761f5 to your computer and use it in GitHub Desktop.
Save alaypatel07/9e06cbb074eb7fcd2157aa65478761f5 to your computer and use it in GitHub Desktop.
export RESOURCE="migrationcontrollers"
export NAMESPACE="openshift-migration"
if [ -z "$1" ]; then
export USER="bob"
else
export USER=$1
fi
if [ -z "$2" ]; then
export NAMESPACE="openshift-migration"
else
export USER=$2
fi
export ROLE_NAME=use-migration-controller
cat <<EOF | oc apply -f -
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: "$NAMESPACE"
name: "$ROLE_NAME"
rules:
- apiGroups: ["migration.openshift.io"]
resources: ["$RESOURCE"]
resourceNames: ["migration-controller"]
verbs: ["use"]
EOF
oc create rolebinding $USER-use-migration-controller --role $ROLE_NAME --user $USER --namespace $NAMESPACE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment