All Projects → int128 → Kubelogin

int128 / Kubelogin

Licence: apache-2.0
kubectl plugin for Kubernetes OpenID Connect authentication (kubectl oidc-login)

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Kubelogin

Openid connect
OpenID Connect Server & Client Library
Stars: ✭ 331 (-33.13%)
Mutual labels:  openid-connect
Passport
Simple, unobtrusive authentication for Node.js.
Stars: ✭ 19,608 (+3861.21%)
Mutual labels:  openid-connect
Fish Kubectl Completions
kubectl completions for fish shell
Stars: ✭ 453 (-8.48%)
Mutual labels:  kubectl
Zsh Kubectl Prompt
Display information about the kubectl current context and namespace in zsh prompt.
Stars: ✭ 342 (-30.91%)
Mutual labels:  kubectl
Kubecolor
colorizes kubectl output
Stars: ✭ 363 (-26.67%)
Mutual labels:  kubectl
Webkubectl
Run kubectl command in Web Browser.
Stars: ✭ 390 (-21.21%)
Mutual labels:  kubectl
Django Oidc Provider
OpenID Connect and OAuth2 provider implementation for Djangonauts.
Stars: ✭ 320 (-35.35%)
Mutual labels:  openid-connect
Krew Index
Plugin index for https://github.com/kubernetes-sigs/krew. This repo is for plugin maintainers.
Stars: ✭ 476 (-3.84%)
Mutual labels:  kubectl
Play Pac4j
Security library for Play framework 2 in Java and Scala: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 375 (-24.24%)
Mutual labels:  openid-connect
Buji Pac4j
pac4j security library for Shiro: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 444 (-10.3%)
Mutual labels:  openid-connect
Kubectl Plugins
A Collection of Plugins for kubectl Integration (exec as any user, context switching, etc).
Stars: ✭ 340 (-31.31%)
Mutual labels:  kubectl
Krew
📦 Find and install kubectl plugins
Stars: ✭ 4,354 (+779.6%)
Mutual labels:  kubectl
Redux Oidc
A package for managing OpenID Connect authentication in ReactJS / Redux apps
Stars: ✭ 395 (-20.2%)
Mutual labels:  openid-connect
Openid Connect Php
Minimalist OpenID Connect client
Stars: ✭ 336 (-32.12%)
Mutual labels:  openid-connect
Gbt
Highly configurable prompt builder for Bash, ZSH and PowerShell written in Go.
Stars: ✭ 457 (-7.68%)
Mutual labels:  kubectl
Kubedog
Library to watch and follow kubernetes resources in CI/CD deploy pipelines
Stars: ✭ 326 (-34.14%)
Mutual labels:  kubectl
Fubectl
Reduces repetitive interactions with kubectl
Stars: ✭ 370 (-25.25%)
Mutual labels:  kubectl
Kubelive
kubectl tool reinvented to be more reactive and interactive 🔥
Stars: ✭ 497 (+0.4%)
Mutual labels:  kubectl
Cloudfront Auth
An AWS CloudFront [email protected] function to authenticate requests using Google Apps, Microsoft, Auth0, OKTA, and GitHub login
Stars: ✭ 471 (-4.85%)
Mutual labels:  openid-connect
Kubectl Who Can
Show who has RBAC permissions to perform actions on different resources in Kubernetes
Stars: ✭ 432 (-12.73%)
Mutual labels:  kubectl

kubelogin CircleCI Go Report Card

This is a kubectl plugin for Kubernetes OpenID Connect (OIDC) authentication, also known as kubectl oidc-login.

Here is an example of Kubernetes authentication with the Google Identity Platform:

screencast

Kubelogin is designed to run as a client-go credential plugin. When you run kubectl, kubelogin opens the browser and you can log in to the provider. Then kubelogin gets a token from the provider and kubectl access Kubernetes APIs with the token. Take a look at the diagram:

Diagram of the credential plugin

Getting Started

Setup

Install the latest release from Homebrew, Krew, Chocolatey or GitHub Releases.

# Homebrew (macOS and Linux)
brew install int128/kubelogin/kubelogin

# Krew (macOS, Linux, Windows and ARM)
kubectl krew install oidc-login

# Chocolatey (Windows)
choco install kubelogin

You need to set up the OIDC provider, cluster role binding, Kubernetes API server and kubeconfig. The kubeconfig looks like:

users:
- name: oidc
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1beta1
      command: kubectl
      args:
      - oidc-login
      - get-token
      - --oidc-issuer-url=ISSUER_URL
      - --oidc-client-id=YOUR_CLIENT_ID
      - --oidc-client-secret=YOUR_CLIENT_SECRET

See setup guide for more.

Run

Run kubectl.

kubectl get pods

Kubectl executes kubelogin before calling the Kubernetes APIs. Kubelogin automatically opens the browser, and you can log in to the provider.

keycloak-login

After authentication, kubelogin returns the credentials to kubectl and finally kubectl calls the Kubernetes APIs with the credential.

% kubectl get pods
Open http://localhost:8000 for authentication
NAME                          READY   STATUS    RESTARTS   AGE
echoserver-86c78fdccd-nzmd5   1/1     Running   0          26d

Kubelogin writes the ID token and refresh token to the token cache file.

If the cached ID token is valid, kubelogin just returns it. If the cached ID token has expired, kubelogin will refresh the token using the refresh token. If the refresh token has expired, kubelogin will perform reauthentication.

Troubleshoot

You can log out by removing the token cache directory (default ~/.kube/cache/oidc-login). Kubelogin will perform authentication if the token cache file does not exist.

You can dump claims of an ID token by setup command.

% kubectl oidc-login setup --oidc-issuer-url https://accounts.google.com --oidc-client-id REDACTED --oidc-client-secret REDACTED
...
You got a token with the following claims:

{
  "sub": "********",
  "iss": "https://accounts.google.com",
  "aud": "********",
  ...
}

You can increase the log level by -v1 option.

users:
- name: oidc
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1beta1
      command: kubectl
      args:
      - oidc-login
      - get-token
      - -v1

You can verify kubelogin works with your provider using acceptance test.

Docs

Related works

Kubernetes Dashboard

You can access the Kubernetes Dashboard using kubelogin and kauthproxy.

Contributions

This is an open source software licensed under Apache License 2.0. Feel free to open issues and pull requests for improving code and documents.

Your pull request will be merged into master with squash.

Development

Go 1.15+ is required.

make
./kubelogin

See also:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].