Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions plugins/kubectl-kubeplus-commands
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ print_help () {
echo " kubectl grantpermission consumer"
echo " kubectl upload chart"
echo " kubectl show provider permissions"
echo " kubectl show consumer permissions"
echo " kubectl show consumer permissions <Namespace> <ConsumerName>"
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.

No need to include parameters here. This file (and the "kubectl kubeplus commands" command) just shows all the available commands. The details about individual command's parameters are defined in each command's file.
Also, if you notice, none of the other commands include parameters in this file.

echo " kubectl license create"
echo " kubectl license get"
echo " kubectl license delete"
Expand Down Expand Up @@ -57,7 +57,7 @@ print_help () {
echo " Upload Helm chart (tgz) to KubePlus Operator."
echo ""
echo " - kubectl show provider permissions shows the permissions for kubeplus-saas-provider service account in the namespace where kubeplus is installed."
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. Namespace and ConsumerName are required."
echo " License Management."
echo " - kubectl license create - creates license for a Kind"
echo " - kubectl license get - gets license for a Kind"
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