GitHub SSO for Kubernetes Rancher

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up github sso for kubernetes rancher by linking a GitHub app to Rancher. Then you map your GitHub teams to cluster roles for login. Most teams start by linking their main GitHub group to the cluster manager. This stops admins from making local user accounts by hand. Still, teams often attach broad cluster roles to get developers working fast. When roles are too broad, any logged-in user can read secrets or change live workloads. How github sso for kubernetes rancher works with RBAC Th

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You set up github sso for kubernetes rancher by linking a GitHub app to Rancher. Then you map your GitHub teams to cluster roles for login. Most teams start by linking their main GitHub group to the cluster manager. This stops admins from making local user accounts by hand. Still, teams often attach broad cluster roles to get developers working fast. When roles are too broad, any logged-in user can read secrets or change live workloads.

How github sso for kubernetes rancher works with RBAC

The login flow connects your GitHub identity to native Kubernetes role rules. First, an admin registers an app inside GitHub to get a client key and secret. The admin enters those keys into the Rancher login provider settings. When an engineer logs in, GitHub checks their identity and sends back their team list. Rancher reads that team list and matches it to internal role bindings.

Under the hood, Kubernetes uses its standard role API group to check permissions. A Role sets rules inside a single namespace. A ClusterRole sets rules across the whole cluster, including nodes and all namespaces. A RoleBinding grants those permissions inside one namespace. A ClusterRoleBinding grants access across the entire cluster. In Kubernetes, permissions are purely additive, which means there are no deny rules.

When you map a GitHub team to a ClusterRoleBinding, every team member gets those exact rules. You cannot add a second rule to take away one specific action later. Because of this, your initial group mapping decides the full blast radius for each developer.

Why group mapping needs stricter subresource rules

Setting up GitHub login solves the problem of who can enter the cluster. When someone leaves your company, you remove them from the GitHub team. They lose cluster access right away without manual cleanup across twenty clusters. Central login also gives you a clear name in your cluster logs instead of shared admin keys.

Still, login setup alone does not control what happens after a user enters a pod. Kubernetes treats actions like reading pod logs or running a shell inside a pod as subresources. In role rules, these subresources use a slash format to join the resource and the action. If a role allows pod exec access, the user can open a shell inside running containers.

Kubernetes RBAC + Rancher Access Control: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Native role rules decide if a user can start that shell session. Once the shell opens, Kubernetes RBAC cannot inspect the Linux commands the engineer runs inside the container. It also cannot rewrite sensitive fields like emails, phone numbers, card numbers, or national IDs in output. A developer debugging a live issue might run a bad command or print customer data to their screen. Group login gets the right people in, but teams still need command-level control and data masking in flight.

Best practices for mapping GitHub teams to clusters

Start by creating separate GitHub teams for each namespace and job duty. Never map your main engineering team to a cluster-wide binding. Instead, use namespace RoleBindings so developers only touch their own apps. Since Kubernetes has no deny rules, build small roles with only the verbs each team needs.

Next, separate read-only viewing from pod shell access. Give most engineers permission to view pod status and read logs for daily checks. Put pod exec permissions in a separate role tied to a smaller on-call GitHub team. Review your GitHub team members every month to keep cluster access tight and clean.

Check Kubernetes API requests and responses on the wire

Kubernetes RBAC decides who may call the API server. RBAC does not check response payloads or split listing Secret names from reading Secret values when a role grants get access. With hoop.dev, you run an open-source HTTP proxy, a sidecar for your Kubernetes API. The kubectl client changes only the server address it talks to while RBAC stays in place.

On each call, hoop.dev guardrails read the method, normalized path, and headers to refuse bad deletes or full Secret reads with a 403 error. On the way back, hoop.dev data masking walks JSON responses by key and masks matched values in Secrets, ConfigMaps, and pod logs. Every request and verdict is logged without storing bearer tokens. View the project on GitHub.

Frequently asked questions

Can I add a deny rule in Kubernetes RBAC to block one GitHub user?

No, Kubernetes RBAC permissions are purely additive and have no deny rules. To block one person, remove them from the GitHub team that holds the broad role binding.

What is the difference between a RoleBinding and a ClusterRoleBinding?

A RoleBinding grants permissions inside one specific namespace only. A ClusterRoleBinding grants permissions across the entire cluster and all of its namespaces.

Does GitHub SSO control which commands a user runs inside a pod shell?

No, GitHub login and Kubernetes RBAC only check if the user can open the pod exec subresource. Native RBAC does not inspect or block individual shell commands once the session starts.

The query runs. The emails stay hidden.