You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
4
4
author: houk-ms
5
+
ms.reviewer: malev
5
6
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
8
9
ms.author: honc
9
10
---
10
-
# How to use Service Connector in Azure Kubernetes Service (AKS)
11
11
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:
13
16
14
17
* 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.
17
20
18
21
## Prerequisites
19
22
20
23
* This guide assumes that you already know the [basic concepts of Service Connector](concept-service-connector-internals.md).
21
24
22
-
## What operations Service Connector makes on the cluster
25
+
## Operations performed by Service Connector on the AKS cluster
23
26
24
27
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.
25
28
26
-
### Add the Service Connector kubernetes extension
29
+
### Adding the Service Connector Kubernetes extension
27
30
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.
29
32
30
33
:::image type="content" source="./media/aks-tutorial/sc-extension.png" alt-text="Screenshot of the Azure portal, view AKS extension.":::
31
34
32
35
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`.
33
36
34
-
### Create kubernetes resources
37
+
### Creating the Kubernetes resources
35
38
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.
37
40
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.
39
42
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.":::
41
44
42
45
Deleting a service connection doesn't delete the associated Kubernetes resource. If necessary, remove your resource manually, using for example the kubectl delete command.
43
46
44
-
### Enable the `azureKeyvaultSecretsProvider`addon
47
+
### Enabling the `azureKeyvaultSecretsProvider`add-on
45
48
46
49
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.
47
50
48
51
:::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.":::
49
52
50
53
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.
51
54
52
-
### Enable workload identity and OpenID Connect (OIDC) issuer
55
+
### Enabling workload identity and OpenID Connect (OIDC) issuer
53
56
54
57
If the authentication type is `Workload Identity` when creating a service connection, Service Connector enables workload identity and OIDC issuer for the cluster.
55
58
56
59
:::image type="content" source="./media/aks-tutorial/workload-identity.png" alt-text="Screenshot of the Azure portal, using workload identity to create a connection.":::
57
60
58
61
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.
59
62
60
-
## How to use the Service Connector created kubernetes resources
63
+
## Use the Kubernetes resources created by Service Connector
61
64
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.
63
66
64
-
####Kubernetes secret
67
+
### Kubernetes secret
65
68
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.
67
70
68
71
```yaml
69
72
apiVersion: batch/v1
@@ -85,11 +88,11 @@ spec:
85
88
86
89
```
87
90
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.
89
92
90
-
####Kubernetes service account
93
+
### Kubernetes service account
91
94
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.
93
96
94
97
```yaml
95
98
apiVersion: batch/v1
@@ -113,149 +116,158 @@ spec:
113
116
restartPolicy: OnFailure
114
117
```
115
118
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).
117
120
118
-
## How to troubleshoot and view logs
121
+
## Troubleshoot and view logs
119
122
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.
121
124
122
-
### Check Service Connector kubernetes extension
125
+
### Check Service Connector Kubernetes extension
123
126
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.
125
128
126
129
1. Install the `k8s-extension` Azure CLI extension.
127
130
128
-
```azurecli
129
-
az extension add --name k8s-extension
130
-
```
131
+
```azurecli
132
+
az extension add --name k8s-extension
133
+
```
131
134
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.
133
136
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
+
```
141
144
142
-
### Check kubernetes cluster logs
145
+
### Check Kubernetes cluster logs
143
146
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.
145
148
146
149
1. Connect to your AKS cluster.
147
150
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.
154
157
155
158
- Check the namespace exists.
156
159
157
-
```Bash
158
-
kubectl get ns
159
-
```
160
+
```Bash
161
+
kubectl get ns
162
+
```
160
163
161
164
- Check the helm release status.
162
165
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.
167
171
168
172
- Check the job exists.
169
173
170
-
```Bash
171
-
kubectl get job -n sc-system
172
-
```
174
+
```Bash
175
+
kubectl get job -n sc-system
176
+
```
173
177
174
178
- Get the job status.
175
179
176
-
```Bash
177
-
kubectl describe job/sc-job -n sc-system
178
-
```
180
+
```Bash
181
+
kubectl describe job/sc-job -n sc-system
182
+
```
179
183
180
184
- View the job logs.
181
185
182
-
```Bash
183
-
kubectl logs job/sc-job -n sc-system
184
-
```
186
+
```Bash
187
+
kubectl logs job/sc-job -n sc-system
188
+
```
185
189
186
190
### Common errors and mitigations
187
191
188
-
#### Conflict
192
+
#### Extension creation error
189
193
190
-
**Error Message:**
191
-
`Operation returned an invalid status code: Conflict`.
194
+
**Error message:**
192
195
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`
195
212
196
213
**Mitigation:**
197
-
- Run the following command to make sure your subscription is registered for `Microsoft.KubernetesConfiguration` resource provider.
198
214
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)
203
216
204
217
205
-
#### Timeout
218
+
#### Conflict
219
+
220
+
**Error message:**
206
221
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`.
210
223
211
224
**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.
213
227
214
228
**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
+
```
216
236
217
237
#### Unauthorized resource access
218
238
219
-
**Error Message:**
239
+
**Error message:**
240
+
220
241
`You do not have permission to perform ... If access was recently granted, please refresh your credentials`.
221
242
222
243
**Reason:**
244
+
223
245
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.
224
246
225
247
**Mitigation:**
248
+
226
249
Check the permissions on the Azure resources specified in the error message. Obtain the required permissions and retry the creation.
227
250
228
251
#### Missing subscription registration
229
-
**Error Message:**
252
+
253
+
**Error message:**
254
+
230
255
`The subscription is not registered to use namespace 'Microsoft.KubernetesConfiguration'`
231
256
232
257
**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).
234
260
235
261
**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).
237
264
238
265
```azurecli
239
266
az provider register -n Microsoft.KubernetesConfiguration
240
267
```
241
268
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
-
```
257
269
258
-
## Next steps
270
+
## Next step
259
271
260
272
Learn how to integrate different target services and read about their configuration settings and authentication methods.
0 commit comments