Giter VIP home page Giter VIP logo

kubectl-rolesum's Introduction

kubectl-rolesum (ex-bindrole)

Summarize RBAC roles for the specified subject (ServiceAccount, User and Group).

screenshot

Installation

krew

krew is a package manager for k8s plugins. Please see krew document for more detail.

kubectl krew install rolesum

Homebrew (for MacOS)

rolesum supports homebrew 🍺

brew install Ladicle/kubectl-bindrole/kubectl-rolesum

Binaries

The easiest way is to download binary from the release page. You can also download this repository and install it using Makefile.

Usage

$ kubectl rolesum -h  # or kubectl-rolesum -h
Summarize RBAC roles for the specified subject

Usage:
  kubectl rolesum [options] <SubjectName>

Examples:
  # Summarize roles bound to the "ci-bot" ServiceAccount.
  kubectl rolesum ci-bot

  # Summarize roles bound to the "developer" Group.
  kubectl rolesum -k Group developer

SubjectKinds:
  - ServiceAccount (default)
  - User
  - Group

Options:
  -h, --help                   Display this help message
  -n, --namespace string       Change the namespace scope for this CLI request
  -k, --subject-kind string    Set SubjectKind to summarize (default: ServiceAccount)
  -o, --options                List of all options for this command
  -c, --cluster-only           Ingore namespaced Roles and show only ClusterRoles
      --version                Show version for this command

Use "kubectl rolesum --options" for a list of all options (applies to this command).

This command supports both kubectl-plugin mode and standalone mode.

kubectl-rolesum's People

Contributors

jianhuabi avatar jpriebe avatar ladicle avatar masayaaoyama avatar mkgrei avatar ohatakky avatar sylr avatar the-gigi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kubectl-rolesum's Issues

Allow to combine multiple subject in the same command

Is your feature request related to a problem? Please describe.
We want to get a summary of the permission that can be done for a user. I am not sure if this is the goal of the project or if you are aware of another project that would fit more our needs.

It would be nice if we would be able to do something like kubectl rolesum -K User <username> -K Group <group1> -K Group <group2> to combine the results of different groups. We use OIDC to authenticate to our cluster and users have multiple groups.

Describe the solution you'd like
New parameters for group and user could be used instead of a global kind.

  • kubectl rolesum -G <group1,group2> -U <[email protected]> to get groups and/or user
  • Only -G would allow for a list since 2 users does not make sense
  • -G and -U cannot be combined with ServiceAccount
  • kubectl rolesum <serviceAccount> can still be used to query SA.
  • -K <kind> parameter can still be used for backward, but cannot be combined with -G or -U

Describe alternatives you've considered
Use another tool for that usecase if you know one!

Krew support

Hi, can you make your plugin available on Krew?

Brew installation error: Error: SHA256 mismatch

Describe the bug

brew install Ladicle/kubectl-bindrole/kubectl-rolesum
Updating Homebrew...
==> Installing kubectl-rolesum from ladicle/kubectl-bindrole
==> Downloading https://github.com/Ladicle/kubectl-rolesum/releases/download/v1.4.0/kube
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.com/186
######################################################################## 100.0%
Error: SHA256 mismatch
Expected: aaa1780cdef58cb7711a323af7d78bf8ab1b637ebab2bab9fd969dcfc8514a79
  Actual: f5fc2ab889bb0ddf47bc9e467eb6517ea7c876f7262a016d0658e15fd11aa366
 Archive: /Users/mederyfm/Library/Caches/Homebrew/downloads/f3f65ed2aaf6907c7ca0cbca91eb94eb8e50309024ae30539745995411921682--kubectl-rolesum_darwin-amd64.tar.gz
To retry an incomplete download, remove the file above.
``

**To Reproduce**
Steps to reproduce the behavior:
1. `brew install Ladicle/kubectl-bindrole/kubectl-rolesum`

**Expected behavior**
Installation of kubectl-rolesum

An error occurs when using for kubernetes on GCP

Describe the bug
I used kubectl-bindrole command for kubernetes running on GCP.
But, The following error occurred.

Error: No Auth Provider found for name "gcp"

Expected behavior
kubectl-bindrole works properly

Desktop (please complete the following information):

  • OS: macOS

Group with role/rolebinding cause Error: empty namespace

Describe the bug
If a group has role binding to a role, command will fail with the following error.

 > Error: an empty namespace may not be set when a resource name is provided.
 > Run kubectl rolesum -h command for the usage.

Might be the same as the following issue.
#24

To Reproduce
Steps to reproduce the behavior:

  1. Create a role.
  2. Create a role binding to the role with Group.
  3. Use rolesum to look for the summary for the Group.

Expected behavior
The summary for the Group should be shown.

Screenshots
None

Desktop (please complete the following information):

  • OS: Ubuntu
  • Kubernetes: 1.18.2
  • Version: 1.5.0

Additional context
Add any other context about the problem here.

Homebrew Support

Would be awesome to add Homebrew support so as new versions are released it will be easier to upgrade to that newer version as well as making it easier for new users to download the utility for the first time.

installation via krew fails for the new arm64 release

Describe the bug

Installing via krew fails on Apple M1.

To Reproduce
Steps to reproduce the behavior:

  1. Have a machine with Arm processor :-)
  2. Run kubectl krew install rolesum
  3. See error
$ kubectl krew install rolesum
Updated the local copy of plugin index.
Installing plugin: rolesum
W0528 09:40:35.196321   10093 install.go:164] failed to install plugin "rolesum": plugin "rolesum" does not offer installation for this platform
failed to install some plugins: [rolesum]: plugin "rolesum" does not offer installation for this platform

Expected behavior
rolesum should be installed correctly.

Laptop (please complete the following information):

  • Chip: Apple M1 Max
  • Processor: arm64
  • OS: macOS monterey 12.1

Additional context

Installation via homebrew works as expected.

Add support for oidc

Is your feature request related to a problem? Please describe.
support OIDC auth provider

Failed to release v1.5.6

It failed to release the latest version v1.5.6.

https://github.com/Ladicle/kubectl-rolesum/releases/tag/v1.5.6

image

https://github.com/Ladicle/kubectl-rolesum/actions/runs/8730791354/job/23955176692

Run echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
Error response from daemon: Get "https://registry-1.docker.io/v2/": unauthorized: your account must log in with a Personal Access Token (PAT) - learn more at docs.docker.com/go/access-tokens
Error: Process completed with exit code 1.

- name: Docker Login
if: success() && startsWith(github.ref, 'refs/tags/')
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin

Error response from daemon: Get "https://registry-1.docker.io/v2/":
unauthorized: your account must log in with a Personal Access Token (PAT)

https://docs.docker.com/security/for-developers/access-tokens/

explicit display of RoleBindings and ClusterRoleBindings

Is your feature request related to a problem? Please describe.
When I'm debugging RBAC issues, rolesum gives me almost everything I need, but it doesn't display which rolebindings or clusterrolebindings are binding the roles and clusterroles.

Describe the solution you'd like
Instead of

• Name: sample-namespace/sample-role
...
• Name: */sample-cluster-role
...
• Name: */sample-cluster-role2

It might be nice to see something like this:

• RB sample-namespace/sample-role-rolebinding ==> R sample-namespace/sample-role
...
• RB sample-namespace/sample-clusterrole-rolebinding ==> CR */sample-cluster-role
...
• CRB */sample-clusterrolebinding ==> CR */sample-cluster-role2

In other words, you could see if the policies are coming from a clusterrole or a role (and which one it is), and whether the binding is a rolebinding or a clusterrolebinding (and which one it is).

It seems like some of the information is indirectly available in the current rolesum output:

  • if the Name starts with "*/", it's a ClusterRole; if it starts with a namespace name, then it's a Role
  • if the resources have a ".*" on the end, it is a ClusterRoleBinding, otherwise it's a RoleBinding

But that's a little less explicit, and it doesn't tell you exactly which resource is doing the binding.

Darwin arm64 build

Hi, I'm looking for something like this, the screenshot looks really good but I can't try this out without recompiling on Apple Silicon. Would you support darwin arm64 builds? Thanks!

macos binary for 1.0.0 release is actually a linux bin

Describe the bug

$ ~/Downloads/kubectl-bindrole_darwin_amd64
zsh: exec format error: /Users/joe/Downloads/kubectl-bindrole_darwin_amd64

$ file ~/Downloads/kubectl-bindrole_darwin_amd64
/Users/joe/Downloads/kubectl-bindrole_darwin_amd64: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped

$ md5sum ~/Downloads/kubectl-bindrole*
2d71173f19cd5505451cee37da873dff  /Users/joe/Downloads/kubectl-bindrole_darwin_amd64
2d71173f19cd5505451cee37da873dff  /Users/joe/Downloads/kubectl-bindrole_linux_amd64

Missing RoleBinding for Group and User

Is your feature request related to a problem? Please describe.
When we perform a kubectl rolesum -k Group or kubectl rolesum -K User, the RoleBindings in the current namespace are not returned.

Describe the solution you'd like

  • When -n <namespace> is specified or the current context has a namespace, the command should return the ClusterRoleBindings and the RoleBindings.
  • When a namespace is not set, only ClusterRoleBindings are returned.

Describe alternatives you've considered

  • A flag could be added to ignore namespace --ignore-namespace | --cluster-only in case we cannot know if a namespace is set or not.

Additional context
We were trying to use the extension to summarize the permission of an user or AD group. Most of the permissions are given at the namespace level.

Problem started after fix for #29

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.