Autogenerate RBAC policies based on Kubernetes audit logs
Autogenerate RBAC policies based on Kubernetes audit logs
audit2rbac takes a Kubernetes audit log and username as input, and generates RBAC role and binding objects that cover all the API requests made by that user.
--audit-policy-file defined. See documentation for more details.audit.k8s.io/v1, audit.k8s.io/v1beta1 and audit.k8s.io/v1alpha1 events are supported.Metadata log level works best to minimize log size.alice, bob, and the service account ns1:sa1 is available.--user --serviceaccount :audit2rbac, capturing the output:audit2rbac -f https://git.io/v51iG --user alice > alice-roles.yaml
audit2rbac -f https://git.io/v51iG --user bob > bob-roles.yaml
audit2rbac -f https://git.io/v51iG --serviceaccount ns1:sa1 > sa1-roles.yamlmore alice-roles.yaml…kubectl create -f roles.yaml
role "audit2rbac:alice" created
rolebinding "audit2rbac:alice" createdRequirements:
To build and install from source:
go get -d github.com/liggitt/audit2rbac
cd $GOPATH/src/github.com/liggitt/audit2rbac
git fetch --tags
make install-deps
make installNo open issues yet, or sync has not completed.