Skip to content

Commit c2fa089

Browse files
authored
Merge pull request #1477 from nader-ziada/deprecation-notice
Add deprecation notice to using credentials from environment variables
2 parents fc7e6ee + 24bce1e commit c2fa089

File tree

4 files changed

+43
-4
lines changed

4 files changed

+43
-4
lines changed

controllers/azurecluster_controller.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package controllers
1818

1919
import (
2020
"context"
21+
"fmt"
2122
"time"
2223

2324
"go.opentelemetry.io/otel/attribute"
@@ -171,6 +172,12 @@ func (r *AzureClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request
171172
return reconcile.Result{}, err
172173
}
173174
}
175+
} else {
176+
warningMessage := ("You're using deprecated functionality: ")
177+
warningMessage += ("Using Azure credentials from the manager environment is deprecated and will be removed in future releases. ")
178+
warningMessage += ("Please specify an AzureClusterIdentity for the AzureCluster instead, see: https://capz.sigs.k8s.io/topics/multitenancy.html ")
179+
log.Info(fmt.Sprintf("WARNING, %s", warningMessage))
180+
r.Recorder.Eventf(azureCluster, corev1.EventTypeWarning, "AzureClusterIdentity", warningMessage)
174181
}
175182

176183
// Create the scope.

docs/book/src/topics/getting-started.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,24 @@ An Azure Service Principal is needed for deploying Azure resources. The below in
5151
export AZURE_LOCATION="eastus" # this should be an Azure region that your subscription has quota for.
5252
```
5353

54-
:warning: NOTE: If your password contains single quotes (`'`), make sure to escape them. To escape a single quote, close the quoting before it, insert the single quote, and re-open the quoting.
54+
<aside class="note warning">
55+
56+
<h1> Warning </h1>
57+
58+
NOTE: If your password contains single quotes (`'`), make sure to escape them. To escape a single quote, close the quoting before it, insert the single quote, and re-open the quoting.
5559
For example, if your password is `foo'blah$`, you should do `export AZURE_CLIENT_SECRET='foo'\''blah$'`.
5660

61+
</aside>
62+
63+
<aside class="note warning">
64+
65+
<h1> Warning </h1>
66+
67+
The capability to set credentials using environment variables is now deprecated and will be removed in future releases, the recommended approach is to use `AzureClusterIdentity` as explained [here](multitenancy.md)
68+
69+
</aside>
70+
71+
5772
### Building your first cluster
5873

5974
Check out the [Cluster API Quick Start](https://cluster-api.sigs.k8s.io/user/quick-start.html) to create your first Kubernetes cluster on Azure using Cluster API. Make sure to select the "Azure" tabs.

docs/book/src/topics/identities-use-cases.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,25 @@
22

33
## CAPZ controller:
44
This is the identity used by the management cluster to provision infrastructure in Azure
5-
- Env config
5+
- Multi-tenant config
6+
- [AAD Pod Identity](https://azure.github.io/aad-pod-identity/) using Service Principals and Managed Identities: by default, the identity used by the workload cluster running on Azure is the same Service Principal assigned to the management cluster. If an identity is specified on the Azure Cluster Resource, that identity will be used when creating Azure resources related to that cluster. See [Multi-tenancy](multitenancy.md) page for details.
7+
8+
- Env config (deprecated)
69
- Service Principal: A [service principal](https://docs.microsoft.com/en-us/azure/active-directory/develop/app-objects-and-service-principals) is an identity in AAD which is described by a TenantID, ClientID, and ClientSecret. The set of these three values will enable the holder to exchange the values for a JWT token to communicate with Azure. The values are normally stored in a file or environment variables.
710
- Configuration:
811
- Scope: Subscription
912
- Role: `Contributor` since the controller is responsible for creating resource groups and cluster resources within the group. To create a resource group within a subscription, one must have subscription contributor rights. Note, this role's scope can be reduced to Resource Group Contributor if all resource groups are created prior to cluster creation.
1013
- If the workload clusters are going to use system-assigned managed identities, then the role here should be `Owner` to be able to create role assignments for system-assigned managed identity.
1114
More details in [Azure built-in roles documentation](https://docs.microsoft.com/en-us/azure/role-based-access-control/built-in-roles).
1215

13-
- Multi-tenant config
14-
- [AAD Pod Identity](https://azure.github.io/aad-pod-identity/) using Service Principals and Managed Identities: by default, the identity used by the workload cluster running on Azure is the same Service Principal assigned to the management cluster. If an identity is specified on the Azure Cluster Resource, that identity will be used when creating Azure resources related to that cluster. See [Multi-tenancy](multitenancy.md) page for details.
16+
<aside class="note warning">
17+
18+
<h1> Warning </h1>
19+
20+
The capability to set credentials using environment variables is now deprecated and will be removed in future releases, the recommended approach is to use `AzureClusterIdentity` as explained [here](multitenancy.md)
21+
22+
</aside>
23+
1524

1625
## Azure Host Identity:
1726
The identity assigned to the Azure host which in the control plane provides the identity to Azure Cloud Provider, and can be used on all nodes to provide access to Azure services during cloud-init, etc.

exp/controllers/azuremanagedcontrolplane_controller.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ package controllers
1818

1919
import (
2020
"context"
21+
"fmt"
2122
"time"
2223

24+
corev1 "k8s.io/api/core/v1"
2325
"sigs.k8s.io/cluster-api/util/patch"
2426

2527
"github.com/go-logr/logr"
@@ -213,6 +215,12 @@ func (r *AzureManagedControlPlaneReconciler) Reconcile(ctx context.Context, req
213215
return reconcile.Result{}, err
214216
}
215217
}
218+
} else {
219+
warningMessage := ("You're using deprecated functionality: ")
220+
warningMessage += ("Using Azure credentials from the manager environment is deprecated and will be removed in future releases. ")
221+
warningMessage += ("Please specify an AzureClusterIdentity for the AzureManagedControlPlane instead, see: https://capz.sigs.k8s.io/topics/multitenancy.html ")
222+
log.Info(fmt.Sprintf("WARNING, %s", warningMessage))
223+
r.Recorder.Eventf(azureControlPlane, corev1.EventTypeWarning, "AzureClusterIdentity", warningMessage)
216224
}
217225

218226
// Create the scope.

0 commit comments

Comments
 (0)