Skip to content

Commit 780c377

Browse files
authored
Merge pull request #294172 from houk-ms/hongkun/serviceconnector-aks
[Service Connector] Refine AKS quickstart and trouble shooting doc
2 parents e92b347 + 1c2f366 commit 780c377

File tree

2 files changed

+125
-110
lines changed

2 files changed

+125
-110
lines changed

articles/service-connector/how-to-use-service-connector-in-aks.md

Lines changed: 112 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,72 @@
11
---
2-
title: How Service Connector helps Azure Kubernetes Service (AKS) connect to other Azure services
3-
description: Learn how to use Service Connector in Azure Kubernetes Service (AKS).
2+
title: How to use Service Connector in Azure Kubernetes Service (AKS)
3+
description: Learn how to use Service Connector to connect AKS to other Azure services. Learn about Service Connector operations, resource management, and troubleshooting.
44
author: houk-ms
5+
ms.reviewer: malev
56
ms.service: service-connector
6-
ms.topic: conceptual
7-
ms.date: 03/01/2024
7+
ms.topic: how-to
8+
ms.date: 02/06/2025
89
ms.author: honc
910
---
10-
# How to use Service Connector in Azure Kubernetes Service (AKS)
1111

12-
Azure Kubernetes Service (AKS) is one of the compute services supported by Service Connector. This article aims to help you understand:
12+
# Use Service Connector in Azure Kubernetes Service (AKS)
13+
14+
Azure Kubernetes Service (AKS) is one of the compute services supported by Service Connector.
15+
This article aims to help you understand:
1316

1417
* What operations are made on the cluster when creating a service connection.
15-
* How to use the kubernetes resources Service Connector creates.
16-
* How to troubleshoot and view logs of Service Connector in an AKS cluster.
18+
* How to use the Kubernetes resources created by Service Connector.
19+
* How to troubleshoot and view Service Connector logs in an AKS cluster.
1720

1821
## Prerequisites
1922

2023
* This guide assumes that you already know the [basic concepts of Service Connector](concept-service-connector-internals.md).
2124

22-
## What operations Service Connector makes on the cluster
25+
## Operations performed by Service Connector on the AKS cluster
2326

2427
Depending on the different target services and authentication types selected when creating a service connection, Service Connector makes different operations on the AKS cluster. The following lists the possible operations made by Service Connector.
2528

26-
### Add the Service Connector kubernetes extension
29+
### Adding the Service Connector Kubernetes extension
2730

28-
A kubernetes extension named `sc-extension` is added to the cluster the first time a service connection is created. Later on, the extension helps create kubernetes resources in user's cluster, whenever a service connection request comes to Service Connector. You can find the extension in your AKS cluster in the Azure portal, in the **Extensions + applications** menu.
31+
A Kubernetes extension named `sc-extension` is added to the cluster the first time a service connection is created. Later on, the extension helps create Kubernetes resources in user's cluster, whenever a service connection request comes to Service Connector. You can find the extension in your AKS cluster in the Azure portal, in the **Extensions + applications** menu.
2932

3033
:::image type="content" source="./media/aks-tutorial/sc-extension.png" alt-text="Screenshot of the Azure portal, view AKS extension.":::
3134

3235
The extension is also where the cluster connections metadata are stored. Uninstalling the extension makes all the connections in the cluster unavailable. The extension operator is hosted in the cluster namespace `sc-system`.
3336

34-
### Create kubernetes resources
37+
### Creating the Kubernetes resources
3538

36-
Service Connector creates some kubernetes resources to the namespace the user specified when creating a service connection. The kubernetes resources store the connection information, which is needed by the user's workload definitions or application code to talk to target services. Depending on different authentication types, different kubernetes resources are created. For the `Connection String` and `Service Principal` auth types, a kubernetes secret is created. For the `Workload Identity` auth type, a kubernetes service account is also created in addition to a kubernetes secret.
39+
Service Connector creates some Kubernetes resources to the namespace the user specified when creating a service connection. The Kubernetes resources store the connection information, which is needed by the user's workload definitions or application code to talk to target services. Depending on different authentication types, different Kubernetes resources are created. For the `Connection String` and `Service Principal` auth types, a Kubernetes secret is created. For the `Workload Identity` auth type, a Kubernetes service account is also created in addition to a Kubernetes secret.
3740

38-
You can find the kubernetes resources created by Service Connector for each service connection on the Azure portal in your kubernetes resource, in the Service Connector menu.
41+
You can find the Kubernetes resources created by Service Connector for each service connection on the Azure portal in your Kubernetes resource, in the Service Connector menu.
3942

40-
:::image type="content" source="./media/aks-tutorial/kubernetes-resources.png" alt-text="Screenshot of the Azure portal, view Service Connector created kubernetes resources.":::
43+
:::image type="content" source="./media/aks-tutorial/kubernetes-resources.png" alt-text="Screenshot of the Azure portal, view Service Connector created Kubernetes resources.":::
4144

4245
Deleting a service connection doesn't delete the associated Kubernetes resource. If necessary, remove your resource manually, using for example the kubectl delete command.
4346

44-
### Enable the `azureKeyvaultSecretsProvider` addon
47+
### Enabling the `azureKeyvaultSecretsProvider` add-on
4548

4649
If target service is Azure Key Vault and the Secret Store CSI Driver is enabled when creating a service connection, Service Connector enables the `azureKeyvaultSecretsProvider` add-on for the cluster.
4750

4851
:::image type="content" source="./media/aks-tutorial/keyvault-csi.png" alt-text="Screenshot of the Azure portal, enabling CSI driver for keyvault when creating a connection.":::
4952

5053
Follow the [Connect to Azure Key Vault using CSI driver tutorial](./tutorial-python-aks-keyvault-csi-driver.md)to set up a connection to Azure Key Vault using Secret Store CSI driver.
5154

52-
### Enable workload identity and OpenID Connect (OIDC) issuer
55+
### Enabling workload identity and OpenID Connect (OIDC) issuer
5356

5457
If the authentication type is `Workload Identity` when creating a service connection, Service Connector enables workload identity and OIDC issuer for the cluster.
5558

5659
:::image type="content" source="./media/aks-tutorial/workload-identity.png" alt-text="Screenshot of the Azure portal, using workload identity to create a connection.":::
5760

5861
When the authentication type is `Workload Identity`, a user-assigned managed identity is needed to create the federated identity credential. Learn more from [what are workload identities](/entra/workload-id/workload-identities-overview), or follow the [tutorial](./tutorial-python-aks-storage-workload-identity.md)to set up a connection to Azure Storage using workload identity.
5962

60-
## How to use the Service Connector created kubernetes resources
63+
## Use the Kubernetes resources created by Service Connector
6164

62-
Different kubernetes resources are created when the target service type and authentication type are different. The following sections show how to use the Service Connector created kubernetes resources in your cluster workloads definition and application codes.
65+
Various Kubernetes resources are created by Service Connector depending on the target service type and authentication type. The following sections show how to use the Kubernetes resources created by Service Connector in your cluster workloads definition and application code.
6366

64-
#### Kubernetes secret
67+
### Kubernetes secret
6568

66-
A kubernetes secret is created when the authentication type is `Connection String` or `Service Principal`. Your cluster workload definition can reference the secret directly. The following snippet is an example.
69+
A Kubernetes secret is created when the authentication type is set to either `Connection String` or `Service Principal`. Your cluster workload definition can reference the secret directly. The following snippet provides an example.
6770

6871
```yaml
6972
apiVersion: batch/v1
@@ -85,11 +88,11 @@ spec:
8588

8689
```
8790

88-
Then, your application codes can consume the connection string in the secret from environment variable. You can check the [sample code](./how-to-integrate-storage-blob.md) to learn more about the environment variable names and how to use them in your application codes to authenticate to different target services.
91+
Your application code can consume the connection string in the secret from an environment variable. Check the following [sample code](./how-to-integrate-storage-blob.md) to learn more about the environment variable names and how to use them in your application code to authenticate to different target services.
8992

90-
#### Kubernetes service account
93+
### Kubernetes service account
9194

92-
Both a kubernetes service account and a secret are created when the authentication type is `Workload Identity`. Your cluster workload definition can reference the service account and secret to authenticate through workload identity. The following snippet provides an example.
95+
A Kubernetes service account and a secret are created when the authentication type is set to `Workload Identity`. Your cluster workload definition can reference the service account and secret to authenticate through workload identity. The following snippet provides an example.
9396

9497
```yaml
9598
apiVersion: batch/v1
@@ -113,149 +116,158 @@ spec:
113116
restartPolicy: OnFailure
114117
```
115118
116-
You may check the tutorial to learn [how to connect to Azure Storage using workload identity](tutorial-python-aks-storage-workload-identity.md).
119+
Check the following tutorial to learn [how to connect to Azure Storage using workload identity](tutorial-python-aks-storage-workload-identity.md).
117120
118-
## How to troubleshoot and view logs
121+
## Troubleshoot and view logs
119122
120-
If an error happens and couldn't be mitigated by retrying when creating a service connection, the following methods can help gather more information for troubleshooting.
123+
If an error occurs and can't be resolved by retrying when creating a service connection, the following methods help gather more information for troubleshooting.
121124
122-
### Check Service Connector kubernetes extension
125+
### Check Service Connector Kubernetes extension
123126
124-
Service Connector kubernetes extension is built on top of [Azure Arc-enabled Kubernetes cluster extensions](/azure/azure-arc/kubernetes/extensions). Use the following commands to investigate if there are any errors during the extension installation or updating.
127+
The Service Connector Kubernetes extension is built on top of [Azure Arc-enabled Kubernetes cluster extensions](/azure/azure-arc/kubernetes/extensions). Use the following commands to check for any errors that occurred during the extension installation or update process.
125128
126129
1. Install the `k8s-extension` Azure CLI extension.
127130

128-
```azurecli
129-
az extension add --name k8s-extension
130-
```
131+
```azurecli
132+
az extension add --name k8s-extension
133+
```
131134

132-
1. Get the Service Connector extension status. Check the `statuses` property in the command output to see if there are any errors.
135+
1. Retrieve the status of the Service Connector extension. Check the `statuses` property in the command output to identify any errors.
133136

134-
```azurecli
135-
az k8s-extension show \
136-
--resource-group MyClusterResourceGroup \
137-
--cluster-name MyCluster \
138-
--cluster-type managedClusters \
139-
--name sc-extension
140-
```
137+
```azurecli
138+
az k8s-extension show \
139+
--resource-group MyClusterResourceGroup \
140+
--cluster-name MyCluster \
141+
--cluster-type managedClusters \
142+
--name sc-extension
143+
```
141144

142-
### Check kubernetes cluster logs
145+
### Check Kubernetes cluster logs
143146

144-
If there's an error during the extension installation, and the error message in the `statuses` property doesn't provide enough information about what happened, you can further check the kubernetes logs with the followings steps.
147+
If an error occurs during the extension installation and the error message in the `statuses` property doesn't provide sufficient information, you can further investigate by checking the Kubernetes logs with the followings steps.
145148

146149
1. Connect to your AKS cluster.
147150

148-
```azurecli
149-
az aks get-credentials \
150-
--resource-group MyClusterResourceGroup \
151-
--name MyCluster
152-
```
153-
1. Service Connector extension is installed in the namespace `sc-system` through helm chart, check the namespace and the helm release by following commands.
151+
```azurecli
152+
az aks get-credentials \
153+
--resource-group MyClusterResourceGroup \
154+
--name MyCluster
155+
```
156+
1. The Service Connector extension is installed in the `sc-system` namespace using a Helm chart. Check the namespace and the Helm release using the following commands.
154157

155158
- Check the namespace exists.
156159

157-
```Bash
158-
kubectl get ns
159-
```
160+
```Bash
161+
kubectl get ns
162+
```
160163

161164
- Check the helm release status.
162165

163-
```Bash
164-
helm list -n sc-system
165-
```
166-
1. During the extension installation or updating, a kubernetes job called `sc-job` creates the kubernetes resources for the service connection. The job execution failure usually causes the extension failure. Check the job status by running the following commands. If `sc-job` doesn't exist in `sc-system` namespace, it should have been executed successfully. This job is designed to be automatically deleted after successful execution.
166+
```Bash
167+
helm list -n sc-system
168+
```
169+
170+
1. During the extension installation or update, a Kubernetes job called `sc-job` creates the Kubernetes resources for the service connection. A job execution failure typically causes the extension to fail. Check the job status by running the following commands. If `sc-job` doesn't exist in the `sc-system` namespace, it should have been executed successfully. This job is designed to be automatically deleted after successful execution.
167171

168172
- Check the job exists.
169173

170-
```Bash
171-
kubectl get job -n sc-system
172-
```
174+
```Bash
175+
kubectl get job -n sc-system
176+
```
173177

174178
- Get the job status.
175179

176-
```Bash
177-
kubectl describe job/sc-job -n sc-system
178-
```
180+
```Bash
181+
kubectl describe job/sc-job -n sc-system
182+
```
179183

180184
- View the job logs.
181185

182-
```Bash
183-
kubectl logs job/sc-job -n sc-system
184-
```
186+
```Bash
187+
kubectl logs job/sc-job -n sc-system
188+
```
185189

186190
### Common errors and mitigations
187191

188-
#### Conflict
192+
#### Extension creation error
189193

190-
**Error Message:**
191-
`Operation returned an invalid status code: Conflict`.
194+
**Error message:**
192195

193-
**Reason:**
194-
This error usually occurs when attempting to create a service connection while the AKS (Azure Kubernetes Service) cluster is in an updating state. The service connection update conflicts with the ongoing update. It could also happen when your subscription is not registered for the `Microsoft.KubernetesConfiguration` resource provider.
196+
`Unable to get a response from the agent in time`.
197+
198+
**Mitigation:**
199+
200+
Refer to [extension creation errors](/troubleshoot/azure/azure-kubernetes/extensions/cluster-extension-deployment-errors#extension-creation-errors)
201+
202+
203+
#### Helm errors
204+
205+
**Error messages:**
206+
207+
- `Timed out waiting for resource readiness`
208+
- `Unable to download the Helm chart from the repo URL`
209+
- `Helm chart rendering failed with given values`
210+
- `Resource already exists in your cluster`
211+
- `Operation is already in progress for Helm`
195212

196213
**Mitigation:**
197-
- Run the following command to make sure your subscription is registered for `Microsoft.KubernetesConfiguration` resource provider.
198214

199-
```azurecli
200-
az provider register -n Microsoft.KubernetesConfiguration
201-
```
202-
- Ensure your cluster is in a "Succeeded" state and retry the creation.
215+
Refer to [Helm errors](/troubleshoot/azure/azure-kubernetes/extensions/cluster-extension-deployment-errors#helm-errors)
203216

204217

205-
#### Timeout
218+
#### Conflict
219+
220+
**Error message:**
206221

207-
**Error Message:**
208-
- `Long running operation failed with status 'Failed'. Unable to get a response from the Agent in time`.
209-
- `Timed out waiting for the resource to come to a ready/completed state`
222+
`Operation returned an invalid status code: Conflict`.
210223

211224
**Reason:**
212-
This error often happens when the Kubernetes job used to create or update the Service Connector cluster extension fails to be scheduled due to resource limitations or other issues.
225+
226+
This error typically occurs when attempting to create a service connection while the Azure Kubernetes Service (AKS) cluster is in an updating state. The service connection update conflicts with the ongoing update. This error also occurs when your subscription is not registered with the `Microsoft.KubernetesConfiguration` resource provider.
213227

214228
**Mitigation:**
215-
Refer to [Check Kubernetes cluster logs](#check-kubernetes-cluster-logs) to identify and resolve the detailed reasons. A common issue is that no nodes are available due to preemption. In this case, consider adding more nodes or enabling auto-scaling for your nodes.
229+
230+
1. Ensure your cluster is in a "Succeeded" state and retry the creation.
231+
1. Run the following command to make sure your subscription is registered with the `Microsoft.KubernetesConfiguration` resource provider.
232+
233+
```azurecli
234+
az provider register -n Microsoft.KubernetesConfiguration
235+
```
216236

217237
#### Unauthorized resource access
218238

219-
**Error Message:**
239+
**Error message:**
240+
220241
`You do not have permission to perform ... If access was recently granted, please refresh your credentials`.
221242

222243
**Reason:**
244+
223245
Service Connector requires permissions to operate the Azure resources you want to connect to, in order to perform connection operations on your behalf. This error indicates a lack of necessary permissions on some Azure resources.
224246

225247
**Mitigation:**
248+
226249
Check the permissions on the Azure resources specified in the error message. Obtain the required permissions and retry the creation.
227250

228251
#### Missing subscription registration
229-
**Error Message:**
252+
253+
**Error message:**
254+
230255
`The subscription is not registered to use namespace 'Microsoft.KubernetesConfiguration'`
231256

232257
**Reason:**
233-
Service Connector requires the subscription to be registered for `Microsoft.KubernetesConfiguration`, which is the resource provider for [Azure Arc-enabled Kubernetes cluster extensions](/azure/azure-arc/kubernetes/extensions).
258+
259+
Service Connector requires the subscription to be registered with `Microsoft.KubernetesConfiguration`, which is the resource provider for [Azure Arc-enabled Kubernetes cluster extensions](/azure/azure-arc/kubernetes/extensions).
234260

235261
**Mitigation:**
236-
Register the `Microsoft.KubernetesConfiguration` resource provider by running the following command. For more information on resource provider registration errors, please refer to this [tutorial](../azure-resource-manager/troubleshooting/error-register-resource-provider.md).
262+
263+
Register the `Microsoft.KubernetesConfiguration` resource provider by running the following command. For more information on resource provider registration errors, please refer to [Resolve errors for resource provider registration](../azure-resource-manager/troubleshooting/error-register-resource-provider.md).
237264

238265
```azurecli
239266
az provider register -n Microsoft.KubernetesConfiguration
240267
```
241268

242-
#### Other issues
243-
244-
If the above mitigations don't resolve your issue, try resetting the service connector cluster extension by removing it and then retrying the creation. This method is expected to resolve most issues related to the Service Connector cluster extension.
245-
246-
Use the following CLI commands to reset the extension:
247-
248-
```azurecli
249-
az extension add --name k8s-extension
250-
251-
az k8s-extension delete \
252-
--resource-group <MyClusterResourceGroup> \
253-
--cluster-name <MyCluster> \
254-
--cluster-type managedClusters \
255-
--name sc-extension
256-
```
257269

258-
## Next steps
270+
## Next step
259271

260272
Learn how to integrate different target services and read about their configuration settings and authentication methods.
261273

0 commit comments

Comments
 (0)