OC-POLICY-ADD-ROLE-TO-USER(1)

πŸ“¦
version 4.22.0 Β· 2 versions
, in nixpkgs unstable

πŸ’– oc policy add-role-to-user β€” the glow-up your project access deserves ✨

Okay bestie, so you know the oc CLI? This is one of its cutest little commands, straight out of the OpenShift CLI User Manuals. Let me put you on. 🫢


🌈 SYNOPSIS

oc policy add-role-to-user [OPTIONS]

πŸŽ€ DESCRIPTION

So here's the tea: this command adds a role to users or service accounts for the project. That's it. That's the vibe. πŸ’…

Basically, it's how you grant a user access to specific resources and actions within the current project β€” you do it by assigning them to a role. It creates or modifies a role binding that references the role you specified, adding the user(s) or service account(s) to the list of subjects. And here's the iconic part: the command does not require that the matching role or user/service account resources actually exist. It will create the binding successfully even when the role or user/service account doesn't exist, or when the user doesn't even have access to view them. No vibe check required, it just slays. πŸ”₯

Now, if you pass the --rolebinding-name argument, it will look for an existing role binding with that name. And listen β€” the role on the matching role binding MUST match the role name you supplied to the command. No cap. If you don't give a role binding name, a default name gets used. When --role-namespace is specified as a non-empty value, it MUST match the current namespace. When role-namespace is specified, the role binding will reference a namespaced role. Otherwise? The role binding will reference a cluster role resource. iykyk. ✨

Wanna learn more? Go read up on RBAC and policy, or just use the get and describe commands on these resources: clusterroles, clusterrolebindings, roles, rolebindings, users, groups, and serviceaccounts. Very much giving "do your research, bestie." πŸ“š


✨ OPTIONS ✨

  • --allow-missing-template-keys=true β€” If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. No stress if a key's missing. πŸ’†β€β™€οΈ
  • --dry-run="none" β€” Must be "none", "server", or "client". If it's the client strategy, only print the object that would be sent, without actually sending it. If it's the server strategy, submit a server-side request without persisting the resource. It's giving "look but don't touch." πŸ‘€
  • -o, --output="" β€” Output format, bestie. One of: (json, yaml, kyaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file). Pick your aesthetic. 🎨
  • --role-namespace="" β€” namespace where the role is located: empty means a role defined in cluster policy. It's the "where's the role at" flag. πŸ“
  • --rolebinding-name="" β€” Name of the rolebinding to modify or create. If left empty, it creates a new rolebinding with a default name. Name it or let the universe decide. πŸ¦‹
  • -z, --serviceaccount=[] β€” service account in the current namespace to use as a user. Shoutout to the service accounts, they're doing amazing sweetie. πŸ€–
  • --show-managed-fields=false β€” If true, keep the managedFields when printing objects in JSON or YAML format. For the detail girlies. πŸ”
  • --template="" β€” Template string or path to template file to use when -o=go-template or -o=go-template-file. The template format is golang templates [ ⟨http://golang.org/pkg/text/template/#pkg-overview⟩ ]. Go off, template queen. πŸ‘‘

🌸 OPTIONS INHERITED FROM PARENT COMMANDS 🌸

These are the flags you get from the big oc energy. Inherited like your mom's good taste. πŸ’–

  • --as="" β€” Username to impersonate for the operation. User could be a regular user or a service account in a namespace. Be someone else for a sec, it's fine. 🎭
  • --as-group=[] β€” Group to impersonate for the operation. This flag can be repeated to specify multiple groups. Stack 'em up. πŸŽ€
  • --as-uid="" β€” UID to impersonate for the operation.
  • --as-user-extra=[] β€” User extras to impersonate for the operation. This flag can be repeated to specify multiple values for the same key. Extra as in extra. πŸ’…
  • --cache-dir="/homeless-shelter/.kube/cache" β€” Default cache directory. Yes, that's the actual path, no I'm not joking. πŸ’€
  • --certificate-authority="" β€” Path to a cert file for the certificate authority.
  • --client-certificate="" β€” Path to a client certificate file for TLS.
  • --client-key="" β€” Path to a client key file for TLS.
  • --cluster="" β€” The name of the kubeconfig cluster to use.
  • --context="" β€” The name of the kubeconfig context to use.
  • --disable-compression=false β€” If true, opt-out of response compression for all requests to the server. Sometimes you just want it raw. 🫣
  • --insecure-skip-tls-verify=false β€” If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. ⚠️ Bestie. Be careful with that one, fr fr.
  • --kubeconfig="" β€” Path to the kubeconfig file to use for CLI requests.
  • --kuberc="" β€” Path to the kuberc file to use for preferences. This can be disabled by exporting KUBECTL_KUBERC=false feature gate or turning off the feature KUBERC=off.
  • --match-server-version=false β€” Require server version to match client version. Matching outfits, but for versions. πŸ‘―β€β™€οΈ
  • -n, --namespace="" β€” If present, the namespace scope for this CLI request.
  • --profile="none" β€” Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex).
  • --profile-output="profile.pprof" β€” Name of the file to write the profile to.
  • --request-timeout="0" β€” The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. Zero = infinite patience, iconic. πŸ§˜β€β™€οΈ
  • -s, --server="" β€” The address and port of the Kubernetes API server.
  • --tls-server-name="" β€” Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used.
  • --token="" β€” Bearer token for authentication to the API server.
  • --user="" β€” The name of the kubeconfig user to use.
  • --warnings-as-errors=false β€” Treat warnings received from the server as errors and exit with a non-zero exit code. Harsh, but okay. 😀

πŸ¦‹ EXAMPLE πŸ¦‹

Like, actual examples. This is how you use it, bestie:

# Add the 'view' role to user1 for the current project
oc policy add-role-to-user view user1

# Add the 'edit' role to serviceaccount1 for the current project
oc policy add-role-to-user edit -z serviceaccount1

See? Easy. Iconic. Slayed. πŸ’…βœ¨


🌟 SEE ALSO 🌟

oc-policy(1) β€” go read the rest of the family, they're all cute.


πŸ’œ HISTORY πŸ’œ

June 2016, Ported from the Kubernetes man-doc generator. A little slay from way back, but still relevant. ⏳


Sign-off realness: this manual comes to you from Openshift β€” the Openshift CLI User Manuals β€” and it was last touched up in June 2016. She's vintage but she works. πŸŽ€πŸ’–

That's the whole page, bestie. Now go grant somebody a role and make it everyone's problem. 🫢✨

πŸ“¦ where this page comes from