Skip to content

Commit 7095d42

Browse files
authored
feat(plugins): add optional consumer name to show consumer permissions (#1455)
* feat(plugins): allow consumer name argument in show consumer permissions - Add optional ConsumerName parameter - Supports custom consumers created via provider-kubeconfig.py -c (e.g. team1, team2) - Update help text - Fixes #1091
1 parent cba0fcc commit 7095d42

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

plugins/kubeconfigretriever.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def retrieve_kubeconfig(self, serverURL, kubeconfigFor, kubeconfig):
1313
if kubeconfigFor == 'provider':
1414
cmd = "kubectl get configmaps kubeplus-saas-provider -n " + kubeplusNS + r" -o jsonpath='{.data.kubeplus-saas-provider\.json}'"
1515
if kubeconfigFor == 'consumer':
16-
cmd = "kubectl get configmaps kubeplus-saas-consumer-kubeconfig -n " + kubeplusNS + r" -o jsonpath='{.data.kubeplus-saas-consumer\.json}'"
16+
cmd = "kubectl get configmaps kubeplus-saas-consumer-kubeconfig -n " + kubeplusNS + r" -o jsonpath='{.data.kubeplus-saas-consumer\.json}'"
1717

1818
cmd = cmd + " --kubeconfig=" + kubeconfig
1919
out = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).communicate()[0]

plugins/kubectl-show-consumer-permissions

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,32 @@ print_help () {
77
echo " kubectl show consumer permissions"
88
echo ""
99
echo "SYNOPSIS"
10-
echo " kubectl show consumer permissions <Namespace>"
10+
echo " kubectl show consumer permissions <Namespace> <ConsumerName>"
1111
echo ""
1212
echo "DESCRIPTION"
13-
echo " kubectl show consumer permissions shows the permissions for kubeplus-saas-consumer service account in the namespace where kubeplus is installed."
13+
echo " kubectl show consumer permissions shows the RBAC permissions for a consumer service account."
14+
echo " Namespace is the namespace where the consumer service account lives."
15+
echo " ConsumerName is the name of the consumer service account."
16+
echo ""
17+
echo " Two use cases for consumer service accounts:"
18+
echo " 1) Instance-creation consumer: SA with permissions to create application instances (not restricted to a namespace)."
19+
echo " Typically lives in the KubePlus namespace (e.g. kubeplus-saas-consumer in default)."
20+
echo " 2) Instance-scoped consumer: SA with permissions restricted to a specific instance's namespace (e.g. for debugging)."
21+
echo " Lives in the instance namespace (e.g. team1mysql when team1 created an instance named team1mysql)."
22+
echo ""
23+
echo "EXAMPLES"
24+
echo " kubectl show consumer permissions default kubeplus-saas-consumer"
25+
echo " kubectl show consumer permissions team1mysql team1-debug"
1426
exit 0
1527
}
1628

17-
if (( $# < 1 || $# >= 2)); then
29+
if (( $# != 2)); then
1830
print_help
1931
fi
2032

2133
namespace="$1"
34+
consumer="$2"
2235

2336
check_namespace $namespace
2437

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

0 commit comments

Comments
 (0)