Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/kubeconfigretriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def retrieve_kubeconfig(self, serverURL, kubeconfigFor, kubeconfig):
if kubeconfigFor == 'provider':
cmd = "kubectl get configmaps kubeplus-saas-provider -n " + kubeplusNS + r" -o jsonpath='{.data.kubeplus-saas-provider\.json}'"
if kubeconfigFor == 'consumer':
cmd = "kubectl get configmaps kubeplus-saas-consumer-kubeconfig -n " + kubeplusNS + r" -o jsonpath='{.data.kubeplus-saas-consumer\.json}'"
cmd = "kubectl get configmaps kubeplus-saas-consumer-kubeconfig -n " + kubeplusNS + r" -o jsonpath='{.data.kubeplus-saas-consumer\.json}'"

cmd = cmd + " --kubeconfig=" + kubeconfig
out = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).communicate()[0]
Expand Down
21 changes: 17 additions & 4 deletions plugins/kubectl-show-consumer-permissions
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,32 @@ print_help () {
echo " kubectl show consumer permissions"
echo ""
echo "SYNOPSIS"
echo " kubectl show consumer permissions <Namespace>"
echo " kubectl show consumer permissions <Namespace> <ConsumerName>"
echo ""
echo "DESCRIPTION"
echo " kubectl show consumer permissions shows the permissions for kubeplus-saas-consumer service account in the namespace where kubeplus is installed."
echo " kubectl show consumer permissions shows the RBAC permissions for a consumer service account."
echo " Namespace is the namespace where the consumer service account lives."
echo " ConsumerName is the name of the consumer service account."
echo ""
echo " Two use cases for consumer service accounts:"
echo " 1) Instance-creation consumer: SA with permissions to create application instances (not restricted to a namespace)."
echo " Typically lives in the KubePlus namespace (e.g. kubeplus-saas-consumer in default)."
echo " 2) Instance-scoped consumer: SA with permissions restricted to a specific instance's namespace (e.g. for debugging)."
echo " Lives in the instance namespace (e.g. team1mysql when team1 created an instance named team1mysql)."
echo ""
echo "EXAMPLES"
echo " kubectl show consumer permissions default kubeplus-saas-consumer"
echo " kubectl show consumer permissions team1mysql team1-debug"
exit 0
}

if (( $# < 1 || $# >= 2)); then
if (( $# != 2)); then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

print_help
fi

namespace="$1"
consumer="$2"

check_namespace $namespace

kubectl auth can-i --list --as=system:serviceaccount:$namespace:kubeplus-saas-consumer
kubectl auth can-i --list --as=system:serviceaccount:$namespace:$consumer