Logo

dev-resources.site

for different kinds of informations.

Kubernetes Cluster as an OpenID Connect Identity Provider

Published at
12/2/2023
Categories
kubernetes
oauth
oidc
Author
zhengxin
Categories
3 categories in total
kubernetes
open
oauth
open
oidc
open
Author
8 person written this
zhengxin
open
Kubernetes Cluster as an OpenID Connect Identity Provider

Overview

Traditionally, when executing programs or applications on Virtual Machines (VMs) provided by cloud services, the cloud provider grants specified permissions to the VM. This setup allows the program running on the VM to access designated cloud resources without the need for password authentication. For instance, in Azure, binding a system-assigned or user-assigned managed identity to a VM enables the program running on the VM to operate as the managed identity, inheriting permissions associated with it.

We aim to replicate this user experience in Kubernetes, whereby a pod in a Kubernetes cluster (k8s) can be granted permissions without requiring the program within the pod to read any long-term credentials like passwords.

Previously, Azure Kubernetes Service (AKS) had introduced a feature known as Pod Identity to achieve this. However, this feature was deprecated before reaching General Availability (GA) as a more robust and widely accepted solution emerged.

The feature, Service Account Issuer Discovery, marked as stable starting from Kubernetes version v1.21, transforms the Kubernetes API server into an OIDC identity provider. This setup facilitates the issuance of tokens, via service accounts to pods, which are recognizable by external services outside the Kubernetes cluster, thereby establishing an authentication pathway between the pod within the cluster and external services including those on Azure, AWS, etc.

Both Azure AKS and AWS EKS have enabled this feature by default, offering convenient methods to configure the Kubernetes cluster OIDC Provider to integrate with their respective access control services, namely Microsoft Entra ID and AWS IAM. This feature is termed differently in their respective managed cluster documentation as follows:

Note: All Kubernetes clusters with the "Service Account Issuer Discovery" feature enabled can be integrated with cloud providers, not merely the managed clusters provided by cloud providers, albeit the setup may be slightly complex.

In this document, we will delve into the workings of this feature.

Service Account Issuer Discovery Flow

Assume we have a Kubernetes cluster, hosting applications purposed for reading and writing Azure Blobs.

Initially, the cluster administrator should activate the "Service Account Issuer Discovery" feature on the cluster. Following this, the cluster should be configured with the cloud provider, in this instance, Microsoft Entra ID, ensuring that Microsoft Entra ID is cognizant of the cluster's existence. In more precise terms, Microsoft Entra ID and the Kubernetes OIDC provider are federated, establishing a trust relationship.

Applications running in the cluster are assigned service accounts. (If not explicitly defined, a default service account is bound to every pod). Assigning a service account to a pod results in a JWT token being projected into the pod, stored on the pod’s disk.

Through different annotations on the service account, the cluster administrator can manipulate the claims within the token, thus, various service accounts can be endowed with different permissions.

The application can read the JWT token and forward it to the cloud access control service, in this scenario, Microsoft Entra ID. Upon receiving the token, Microsoft Entra ID validates it. Given the pre-established trust relationship with the Kubernetes cluster OIDC provider, it can ascertain the token’s validity.

Note: In this step, the cloud access control service may or may not access the Kubernetes API server, depending on whether the JWT token validation is a local or remote process.

Post validation, Microsoft Entra ID issues an access token to the application. The application can then utilize this token to access Azure Blobs or other cloud resources managed by Microsoft Entra ID.

References

oidc Article's
30 articles in total
Favicon
Defending OAuth2: Advanced Tactics to Block Replay Attacks
Favicon
Understanding the Differences Between OAuth2 and OpenID Connect (OIDC)
Favicon
Demystifying Social Logins: How OAuth2 Powers Seamless Authentication
Favicon
OAuth2 vs. OpenID Connect: Understanding the Differences
Favicon
GitHub Action security hardening with OpenID (OIDC) Connect - "Password-Less"
Favicon
OIDC vs SAML: A Comprehensive Technical Comparison
Favicon
OIDC Prompt 101: A simple guide for developers
Favicon
How to create a WeCom App to enable WeCom Login for the Web app
Favicon
No More Passwords! OIDC Terraform Module Makes GCP-GitHub Authentication a Breeze
Favicon
Learn OIDC - Part 2 - JWT
Favicon
Oidc node mongodb adapter in normal functions
Favicon
Learn OIDC - Part 1 - JWS
Favicon
OpenVPN + SSO via OAUTH2
Favicon
Kubernetes Cluster as an OpenID Connect Identity Provider
Favicon
How To Configure Audience In Keycloak
Favicon
Single Sign-On (SSO) with Zoho in Vue3
Favicon
Demystifying OpenID Connect (OIDC) - The Key to Secure and Seamless Authentication
Favicon
Adding single sign-on to a Next.js app using OIDC
Favicon
Implementing OpenID Connect (OIDC) Authentication with Nuxt 3
Favicon
Connect GitHub Actions to Azure using OpenID Connect
Favicon
OpenID Connect authentication with Apache Kafka 3.1
Favicon
Writing Java library to build OAuth 2.0 Authorization Server / OpenID Connect Identity Provider
Favicon
SSO Building blocks - SAML, OAuth 2.0 and OpenID Connect
Favicon
ASP.NET: Autenticación OIDC Multi Tenant - Parte 2
Favicon
Keycloak 19.0.1 and Setting the id_token_hint
Favicon
OIDC Forever, IAM Credentials Never!
Favicon
Fortifying federated access to AWS via OIDC
Favicon
Understanding OAuth and OIDC: Introduction
Favicon
OAuth 2.0 and OpenID Connect Explained: Building Secure Authentication Systems
Favicon
Securely authenticate to Google Cloud from GitHub

Featured ones: