Example
Here is an example of RBAC configuration. It has two policies:
- Service account “cluster.local/ns/default/sa/admin” has full access to the service, and so does “cluster.local/ns/default/sa/superuser”.
- Any user can read (
GET
) the service at paths with prefix/products
, so long as the destination port is either 80 or 443.
gsl.#RBACFilter & {
#options: {
rules: {
action: "ALLOW"
policies: {
// Service admin role
"service-admin": {
permissions: [ { any: true } ]
principals: [
{ authenticated: principal_name: exact: "cluster.local/ns/default/sa/admin" },
{ authenticated: principal_name: exact: "cluster.local/ns/default/sa/superuser" },
]
}
// Product viewer role
"product-viewer": {
permissions: [ {
and_rules: rules: [
// Match GET requests
{
header: {
name: ":method"
string_match: exact: "GET"
}
},
// ...on the /product url prefix
{
url_path: path: prefix: "/products"
},
{
// use OR to match either port 80 or 443
or_rules: rules: [
{ destination_port: 80 },
{ destination_port: 443 },
]
}
]
} ]
principals: [ { any: true } ]
}
}
} // end rules
}
}
Note: this example is adapted from Envoy’s documentation.