Skip to content

Commit 41e68a2

Browse files
committed
final edits kubelogin
1 parent de3137d commit 41e68a2

1 file changed

Lines changed: 40 additions & 22 deletions

File tree

articles/aks/kubelogin-authentication.md

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@ ms.date: 11/28/2023
88

99
# Use kubelogin to authenticate users in Azure Kubernetes Service
1010

11-
The kubelogin plugin in Azure is a client-go credential [plugin][client-go-cred-plugin] that implements Microsoft Entra authentication. In kubelogin, you can access features that aren't available in the kubectl command-line tool.
11+
The kubelogin plugin in Azure is a client-go credential [plugin][client-go-cred-plugin] that implements Microsoft Entra authentication. The kubelogin plugin offers features that aren't available in the kubectl command-line tool.
1212

13-
Azure Kubernetes Service (AKS) clusters that are integrated with Microsoft Entra ID and running Kubernetes versions 1.24 or later automatically use the kubelogin format.
13+
Azure Kubernetes Service (AKS) clusters that are integrated with Microsoft Entra ID and running Kubernetes version 1.24 or later automatically use the kubelogin format.
1414

15-
This article provides an overview and examples of how to use all [supported Microsoft Entra authentication methods][authentication-methods] for AKS.
15+
This article provides an overview and examples of how to use kubelogin for all [supported Microsoft Entra authentication methods][authentication-methods] in AKS.
1616

1717
## Limitations
1818

19-
* You can include a maximum of 200 groups in a Microsoft Entra JSON Web Token (JWT) claim. For more than 200 groups, consider using [application roles][entra-id-application-roles].
20-
* Groups that are created in Microsoft Entra ID are included only by using their **ObjectID** value, and not by their display name. The `sAMAccountName` command is available only for groups that are synchronized from on-premises Windows Server Active Directory.
21-
* In AKS, the service principal authentication method works only with managed Microsoft Entra ID, and not with earlier-version Azure Active Directory.
22-
* The device code authentication method doesn't work when a Microsoft Entra Conditional Access policy is configured on a Microsoft Entra tenant. Use web browser interactive authentication instead.
19+
* You can include a maximum of 200 groups in a Microsoft Entra JSON Web Token (JWT) claim. If you have more than 200 groups, consider using [application roles][entra-id-application-roles].
20+
* Groups that are created in Microsoft Entra ID are included only by their **ObjectID** value, and not by their display name. The `sAMAccountName` command is available only for groups that are synchronized from on-premises Windows Server Active Directory.
21+
* In AKS, the service principal authentication method works only with managed Microsoft Entra ID, and not with the earlier version Azure Active Directory.
22+
* The device code authentication method doesn't work when a Microsoft Entra Conditional Access policy is set on a Microsoft Entra tenant. In that scenario, use web browser interactive authentication.
2323

2424
## How authentication works
2525

26-
For most interactions with kubelogin, you use the `convert-kubeconfig` subcommand. The subcommand uses the kubeconfig file that's specified in `--kubeconfig` or in the `KUBECONFIG` environment variable to convert to the final kubeconfig file to exec format based on the specified authentication method.
26+
For most interactions with kubelogin, you use the `convert-kubeconfig` subcommand. The subcommand uses the kubeconfig file that's specified in `--kubeconfig` or in the `KUBECONFIG` environment variable to convert the final kubeconfig file to exec format based on the specified authentication method.
2727

28-
The authentication methods that kubelogin implements are Microsoft Entra OAuth 2.0 token grant flows. The following parameter flags are common to use in kubelogin subcommands. In general, these flags are already set up when you get the kubeconfig file from AKS.
28+
The authentication methods that kubelogin implements are Microsoft Entra OAuth 2.0 token grant flows. The following parameter flags are common to use in kubelogin subcommands. In general, these flags are ready to use when you get the kubeconfig file from AKS.
2929

3030
* `--tenant-id`: The Microsoft Entra tenant ID.
3131
* `--client-id`: The application ID of the public client application. This client app is used only in the device code, web browser interactive, and OAuth 2.0 Resource Owner Password Credentials (ROPC) (workflow identity) sign-in methods.
@@ -36,7 +36,7 @@ The authentication methods that kubelogin implements are Microsoft Entra OAuth 2
3636
3737
## Authentication methods
3838

39-
The next sections describe the supported authentication methods and how to use them:
39+
The next sections describe supported authentication methods and how to use them:
4040

4141
* Device code
4242
* Azure CLI
@@ -49,9 +49,9 @@ The next sections describe the supported authentication methods and how to use t
4949

5050
Device code is the default authentication method for the `convert-kubeconfig` subcommand. The `-l devicecode` parameter is optional. This authentication method prompts the device code for the user to sign in from a browser session.
5151

52-
Before the kubelogin and exec plugins were introduced, the Azure authentication method in kubectl supported only the device code flow. It used an earlier version of a library that produces the token with the `audience` claim that has the `spn:` prefix. (`spn` refers to *Service Principal Name (SPN)*.) It isn't compatible with [AKS managed Microsoft Entra ID][aks-managed-microsoft-entra-id], which uses an [on-behalf-of (OBO)][oauth-on-behalf-of] flow. When you run the `convert-kubeconfig` subcommand, kubelogin removes the `spn:` prefix from the audience claim.
52+
Before the kubelogin and exec plugins were introduced, the Azure authentication method in kubectl supported only the device code flow. It used an earlier version of a library that produces a token that has the `audience` claim with an `spn:` prefix. It isn't compatible with [AKS managed Microsoft Entra ID][aks-managed-microsoft-entra-id], which uses an [on-behalf-of (OBO)][oauth-on-behalf-of] flow. When you run the `convert-kubeconfig` subcommand, kubelogin removes the `spn:` prefix from the audience claim.
5353

54-
If your requirements include using earlier-version functionality, add the `--legacy` argument. If you're using the kubeconfig file in an earlier-version Azure Active Directory cluster, kubelogin automatically adds the `--legacy` flag.
54+
If your requirements include using functionality from earlier versions, add the `--legacy` argument. If you're using the kubeconfig file in an earlier version Azure Active Directory cluster, kubelogin automatically adds the `--legacy` flag.
5555

5656
In this sign-in method, the access token and the refresh token are cached in the *${HOME}/.kube/cache/kubelogin* directory. To override this path, include the `--token-cache-dir` parameter.
5757

@@ -75,15 +75,17 @@ kubelogin remove-tokens
7575
```
7676

7777
> [!NOTE]
78-
> The device code sign-in method doesn't work when a Conditional Access policy is configured on a Microsoft Entra tenant. In this scenario, use the [web browser interactive method][web-browser-interactive-method] instead.
78+
> The device code sign-in method doesn't work when a Conditional Access policy is configured on a Microsoft Entra tenant. In this scenario, use the [web browser interactive method][web-browser-interactive-method].
7979
8080
### Azure CLI
8181

82-
The Azure CLI method of authentication uses the signed-in context that the Azure CLI establishes to get the access token. The token is issued in the same Microsoft Entra tenant as `az login`. kubelogin doesn't write the tokens to the token cache file because it's already managed by the Azure CLI.
82+
The Azure CLI authentication method uses the signed-in context that the Azure CLI establishes to get the access token. The token is issued in the same Microsoft Entra tenant as `az login`. kubelogin doesn't write tokens to the token cache file because they are already managed by the Azure CLI.
8383

8484
> [!NOTE]
8585
> This authentication method works only with AKS managed Microsoft Entra ID.
8686
87+
The following example shows how to use the Azure CLI method to authenticate:
88+
8789
```bash
8890
az login
8991

@@ -98,14 +100,16 @@ Run this kubectl command to get node information:
98100
kubectl get nodes
99101
```
100102

101-
When the Azure CLI config directory is outside the *${HOME}* directory, use the `--azure-config-dir` parameter with the `convert-kubeconfig` subcommand. It generates the kubeconfig with the environment variable configured. You can get the same configuration by setting the `AZURE_CONFIG_DIR` environment variable to this directory when you run a kubectl command.
103+
If the Azure CLI config directory is outside the *${HOME}* directory, use the `--azure-config-dir` parameter with the `convert-kubeconfig` subcommand. The command generates the kubeconfig file with the environment variable configured. You can get the same configuration by setting the `AZURE_CONFIG_DIR` environment variable to this directory when you run a kubectl command.
102104

103105
### Web browser interactive
104106

105-
The web browser interactive method of authentication automatically opens a web browser to sign in the user. After the user is authenticated, the browser redirects back to a local web server by using the verified credentials. This authentication method complies with Conditional Access policy.
107+
The web browser interactive method of authentication automatically opens a web browser to sign in the user. After the user is authenticated, the browser redirects to the local web server by using the verified credentials. This authentication method complies with Conditional Access policy.
106108

107109
When you authenticate by using this method, the access token is cached in the *${HOME}/.kube/cache/kubelogin* directory. You can override this path by using the `--token-cache-dir` parameter.
108110

111+
#### Bearer token
112+
109113
The following example shows how to use a bearer token with the web browser interactive flow:
110114

111115
```bash
@@ -120,7 +124,9 @@ Run this kubectl command to get node information:
120124
kubectl get nodes
121125
```
122126

123-
The following example shows how to use PoP tokens with the web browser interactive flow:
127+
#### Proof-of-Possession token
128+
129+
The following example shows how to use a Proof-of-Possession (PoP) token with the web browser interactive flow:
124130

125131
```bash
126132
export KUBECONFIG=/path/to/kubeconfig
@@ -136,21 +142,23 @@ kubectl get nodes
136142

137143
### Service principal
138144

139-
This authentication method uses a service principal to sign in. You can provide the credential by using an environment variable or by using it in a command-line argument. The supported credentials to use are a password or a Personal Information Exchange (PFX) client certificate.
145+
This authentication method uses a service principal to sign in the user. You can provide the credential by setting an environment variable or by using the credential in a command-line argument. The supported credentials that you can use are a password or a Personal Information Exchange (PFX) client certificate.
140146

141147
Before you use this method, consider the following limitations:
142148

143149
* This method works only with managed Microsoft Entra ID.
144150
* The service principal can be a member of a maximum of 200 [Microsoft Entra groups][microsoft-entra-group-membership].
145151

146-
The following examples show how to set up a client secret by using an environment variable:
152+
#### Environment variables
153+
154+
The following example shows how to set up a client secret by using environment variables:
147155

148156
```bash
149157
export KUBECONFIG=/path/to/kubeconfig
150158

151159
kubelogin convert-kubeconfig -l spn
152160

153-
export AAD_SERVICE_PRINCIPAL_CLIENT_ID=<SPN client ID>
161+
export AAD_SERVICE_PRINCIPAL_CLIENT_ID=<Service Principal Name (SPN) client ID>
154162
export AAD_SERVICE_PRINCIPAL_CLIENT_SECRET=<SPN secret>
155163
```
156164

@@ -177,6 +185,8 @@ Run this kubectl command to get node information:
177185
kubectl get nodes
178186
```
179187

188+
#### Command-line argument
189+
180190
The following example shows how to set up a client secret in a command-line argument:
181191

182192
```bash
@@ -192,9 +202,11 @@ kubectl get nodes
192202
```
193203

194204
> [!WARNING]
195-
> This method leaves the secret in the kubeconfig file.
205+
> The command-line argument method stores the secret in the kubeconfig file.
206+
207+
#### Client certificate
196208

197-
The following examples show how to set up a client secret by using a client certificate:
209+
The following example shows how to set up a client secret by using a client certificate:
198210

199211
```bash
200212
export KUBECONFIG=/path/to/kubeconfig
@@ -230,6 +242,8 @@ Run this kubectl command to get node information:
230242
kubectl get nodes
231243
```
232244

245+
#### PoP token and environment variables
246+
233247
The following example shows how to set up a PoP token that uses a client secret that it gets from environment variables:
234248

235249
```bash
@@ -251,6 +265,8 @@ kubectl get nodes
251265

252266
Use the [managed identity][managed-identity-overview] authentication method for applications that connect to resources that support Microsoft Entra authentication. Examples include accessing Azure resources like an Azure virtual machine, a virtual machine scale set, or Azure Cloud Shell.
253267

268+
#### Default managed identity
269+
254270
The following example shows how to use the default managed identity:
255271

256272
```bash
@@ -265,6 +281,8 @@ Run this kubectl command to get node information:
265281
kubectl get nodes
266282
```
267283

284+
#### Specific identity
285+
268286
The following example shows how to use a managed identity with a specific identity:
269287

270288
```bash

0 commit comments

Comments
 (0)