Skip to content

Commit bdfaaa4

Browse files
committed
Freshness pass
1 parent 4b5eea9 commit bdfaaa4

File tree

1 file changed

+51
-67
lines changed

1 file changed

+51
-67
lines changed

articles/aks/custom-certificate-authority.md

Lines changed: 51 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -5,82 +5,71 @@ author: rayoef
55
ms.author: rayoflores
66
ms.topic: article
77
ms.custom: devx-track-azurecli
8-
ms.date: 4/12/2022
8+
ms.date: 4/24/2022
99
---
1010

1111
# Custom certificate authority (CA) in Azure Kubernetes Service (AKS) (preview)
1212

13-
Custom certificate authorities (CAs) allow you to establish trust between your Azure Kubernetes Service (AKS) cluster and your workloads, such as private registries, proxies, and firewalls. A Kubernetes secret is used to store the certificate authority's information, then it's passed to all nodes in the cluster.
13+
Custom certificate authorities (CAs) allow you to establish trust between your Azure Kubernetes Service (AKS) clusters and workloads, such as private registries, proxies, and firewalls. A Kubernetes secret stores the certificate authority's information, and then it's passed to all nodes in the cluster.
1414

15-
This feature is applied per nodepool, so new and existing node pools must be configured to enable this feature.
15+
This feature is applied per node pool, so new and existing node pools must be configured to enable this feature.
1616

1717
## Prerequisites
1818

19-
* An Azure subscription. If you don't have an Azure subscription, you can create a [free account](https://azure.microsoft.com/free).
19+
* An Azure subscription. If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free).
2020
* [Azure CLI installed][azure-cli-install] (version 2.43.0 or greater).
2121
* A base64 encoded certificate string or a text file with certificate.
2222

2323
## Limitations
2424

25-
This feature isn't currently supported for Windows node pools.
25+
* This feature currently isn't supported for Windows node pools.
2626

27-
## Install the aks-preview Azure CLI extension
27+
## Install the `aks-preview` Azure CLI extension
2828

2929
[!INCLUDE [preview features callout](includes/preview/preview-callout.md)]
3030

31-
To install the aks-preview extension, run the following command:
31+
Install the aks-preview extension using the [`az extension add`][az-extension-add] command.
3232

3333
```azurecli
3434
az extension add --name aks-preview
3535
```
3636

37-
Run the following command to update to the latest version of the extension released:
37+
Update to the latest version of the extension using the [`az extension update`][az-extension-update] command.
3838

3939
```azurecli
4040
az extension update --name aks-preview
4141
```
4242

4343
## Register the 'CustomCATrustPreview' feature flag
4444

45-
Register the `CustomCATrustPreview` feature flag by using the [az feature register][az-feature-register] command, as shown in the following example:
45+
Register the `CustomCATrustPreview` feature flag using the [`az feature register`][az-feature-register] command. It takes a few minutes for the status to show *Registered*.
4646

4747
```azurecli
4848
az feature register --namespace "Microsoft.ContainerService" --name "CustomCATrustPreview"
4949
```
5050

51-
It takes a few minutes for the status to show *Registered*. Verify the registration status by using the [az feature show][az-feature-show] command:
51+
Verify the registration status using the [`az feature show`][az-feature-show] command.
5252

53-
```azurecli-interactive
53+
```azurecli
5454
az feature show --namespace "Microsoft.ContainerService" --name "CustomCATrustPreview"
5555
```
5656

57-
When the status reflects *Registered*, refresh the registration of the *Microsoft.ContainerService* resource provider by using the [az provider register][az-provider-register] command:
57+
When the status reflects *Registered*, refresh the registration of the *Microsoft.ContainerService* resource provider using the [`az provider register`][az-provider-register] command.
5858

59-
```azurecli-interactive
59+
```azurecli
6060
az provider register --namespace Microsoft.ContainerService
6161
```
6262

63-
## Two ways for custom CA installation on AKS node pools
63+
## Custom CA installation on AKS node pools
6464

65-
Two ways of installing custom CAs on your AKS cluster are available. They're intended for different use cases, which are outlined below.
65+
### Install CAs during node pool creation
6666

67-
### Install CAs during node pool boot up
68-
If your environment requires your custom CAs to be added to node trust store for correct provisioning,
69-
text file containing up to 10 blank line separated certificates needs to be passed during
70-
[az aks create][az-aks-create] or [az aks update][az-aks-update] operations.
67+
If your environment requires your custom CAs to be added to node trust store for correct provisioning, you need to pass a text file containing up to 10 blank line separated certificates during
68+
[`az aks create`][az-aks-create] or [`az aks update`][az-aks-update] operations.
7169

72-
Example command:
73-
```azurecli
74-
az aks create \
75-
--resource-group myResourceGroup \
76-
--name myAKSCluster \
77-
--node-count 2 \
78-
--enable-custom-ca-trust \
79-
--custom-ca-trust-certificates pathToFileWithCAs
80-
```
70+
Example text file:
8171

82-
Example file:
83-
```
72+
```txt
8473
-----BEGIN CERTIFICATE-----
8574
cert1
8675
-----END CERTIFICATE-----
@@ -90,10 +79,19 @@ cert2
9079
-----END CERTIFICATE-----
9180
```
9281

93-
CAs will be added to node's trust store during node boot up process, allowing the node to, for example access a private registry.
82+
```azurecli
83+
az aks create \
84+
--resource-group myResourceGroup \
85+
--name myAKSCluster \
86+
--node-count 2 \
87+
--enable-custom-ca-trust \
88+
--custom-ca-trust-certificates pathToFileWithCAs
89+
```
9490

9591
#### CA rotation for availability during node pool boot up
96-
To update CAs passed to cluster during boot up [az aks update][az-aks-update] operation has to be used.
92+
93+
You can update CAs passed to your cluster during boot up using the [`az aks update`][az-aks-update] command and specifying your text file.
94+
9795
```azurecli
9896
az aks update \
9997
--resource-group myResourceGroup \
@@ -102,19 +100,13 @@ az aks update \
102100
```
103101

104102
> [!NOTE]
105-
> Running this operation will trigger a model update, to ensure that new nodes added during for example scale up operation have the newest CAs required for correct provisioning.
106-
> This means that AKS will create additional nodes, drain currently existing ones, delete them and then replace them with nodes that have the new set of CAs installed.
107-
103+
> This operation triggers a model update, ensuring new nodes have the newest CAs required for correct provisioning. AKS creates additional nodes, drains existing ones, deletes them, and replaces them with nodes that have the new set of CAs installed.
108104
109105
### Install CAs once node pool is up and running
110-
If your environment can be successfully provisioned without your custom CAs, you can provide the CAs using a secret deployed in the kube-system namespace.
111-
This approach allows for certificate rotation without the need for node recreation.
112106

113-
Create a [Kubernetes secret][kubernetes-secrets] YAML manifest with your base64 encoded certificate string in the `data` field. Data from this secret is used to update CAs on all nodes.
107+
If your environment can be successfully provisioned without your custom CAs, you can provide the CAs by deploying a secret in the `kube-system` namespace. This approach allows for certificate rotation without the need for node recreation.
114108

115-
You must ensure that:
116-
* The secret is named `custom-ca-trust-secret`.
117-
* The secret is created in the `kube-system` namespace.
109+
Create a [Kubernetes secret][kubernetes-secrets] YAML manifest with your base64 encoded certificate string in the `data` field. Data from this secret is used to update CAs on all nodes. Make sure the secret is named `custom-ca-trust-secret` and is created in the `kube-system` namespace. Installing CAs using the secret in the `kube-system` namespace allows for CA rotation without the need for node recreation.
118110

119111
```yaml
120112
apiVersion: v1
@@ -130,18 +122,16 @@ data:
130122
{anotherBase64EncodedCertStringHere}
131123
```
132124
133-
To update or remove a CA, edit and apply the secret's YAML manifest. The cluster will poll for changes and update the nodes accordingly. This process may take a couple of minutes before changes are applied.
134-
135-
Sometimes containerd restart on the node might be required for the CAs to be picked up properly. If it appears like CAs aren't added correctly to your node's trust store, you can trigger such restart using the following command from node's shell:
136-
137-
```systemctl restart containerd```
125+
To update or remove a CA, you can edit and apply the YAML manifest. The cluster polls for changes and updates the nodes accordingly. It may take a couple minutes before changes are applied.
138126
139127
> [!NOTE]
140-
> Installing CAs using the secret in the kube-system namespace will allow for CA rotation without need for node recreation.
128+
> Sometimes, containerd restart on the node might be required for the CAs to be picked up properly. If it appears like CAs aren't correctly added to your node's trust store, you can trigger a restart using the following command from node's shell:
129+
>
130+
> ```systemctl restart containerd```
141131

142132
## Configure a new AKS cluster to use a custom CA
143133

144-
To configure a new AKS cluster to use a custom CA, run the [az aks create][az-aks-create] command with the `--enable-custom-ca-trust` parameter.
134+
Configure a new AKS cluster to use a custom CA using the [`az aks create`][az-aks-create] command with the `--enable-custom-ca-trust` parameter.
145135

146136
```azurecli
147137
az aks create \
@@ -151,7 +141,7 @@ az aks create \
151141
--enable-custom-ca-trust
152142
```
153143

154-
To configure a new AKS cluster to use custom CA with CAs installed before node boots up, run the [az aks create][az-aks-create] command with the `--enable-custom-ca-trust` and `--custom-ca-trust-certificates` parameters.
144+
You can also configure a new AKS cluster to use custom CA with CAs installed before the node boots up using the [`az aks create`][az-aks-create] command with the `--enable-custom-ca-trust` and `--custom-ca-trust-certificates` parameters.
155145

156146
```azurecli
157147
az aks create \
@@ -164,7 +154,7 @@ az aks create \
164154

165155
## Configure an existing AKS cluster to have custom CAs installed before node boots up
166156

167-
To configure an existing AKS cluster to have your custom CAs added to node's trust store before it boots up, run [az aks update][az-aks-update] command with the `--custom-ca-trust-certificates` parameter.
157+
Configure an existing AKS cluster to have your custom CAs added to node's trust store before it boots up using the [`az aks update`][az-aks-update] command with the `--custom-ca-trust-certificates` parameter.
168158

169159
```azurecli
170160
az aks update \
@@ -175,7 +165,7 @@ az aks update \
175165

176166
## Configure a new node pool to use a custom CA
177167

178-
To configure a new node pool to use a custom CA, run the [az aks nodepool add][az-aks-nodepool-add] command with the `--enable-custom-ca-trust` parameter.
168+
Configure a new node pool to use a custom CA using the [`az aks nodepool add`][az-aks-nodepool-add] command with the `--enable-custom-ca-trust` parameter.
179169

180170
```azurecli
181171
az aks nodepool add \
@@ -186,22 +176,17 @@ az aks nodepool add \
186176
--os-type Linux
187177
```
188178

189-
If there are currently no other node pools with the feature enabled, cluster will have to reconcile its settings for
190-
the changes to take effect. Before that happens, daemonset and pods, which install CAs won't appear on the cluster.
191-
This operation will happen automatically as a part of AKS's reconcile loop.
192-
You can trigger reconcile operation immediately by running the [az aks update][az-aks-update] command:
179+
If no other node pools with the feature enabled exist, the cluster has to reconcile its settings for the changes to take effect. This operation happens automatically as a part of AKS's reconcile loop. Before the operation, the daemonset and pods won't appear on the cluster. You can trigger an immediate reconcile operation using the [`az aks update`][az-aks-update] command. The daemonset and pods will appear after the update completes.
193180

194181
```azurecli
195182
az aks update \
196183
--resource-group myResourceGroup \
197184
--name cluster-name
198185
```
199186

200-
Once completed, the daemonset and pods will appear in the cluster.
201-
202187
## Configure an existing node pool to use a custom CA
203188

204-
To configure an existing node pool to use a custom CA, run the [az aks nodepool update][az-aks-nodepool-update] command with the `--enable-custom-trust-ca` parameter.
189+
Configure an existing node pool to use a custom CA using the [`az aks nodepool update`][az-aks-nodepool-update] command with the `--enable-custom-trust-ca` parameter.
205190

206191
```azurecli
207192
az aks nodepool update \
@@ -211,25 +196,24 @@ az aks nodepool update \
211196
--enable-custom-ca-trust
212197
```
213198

214-
If there are currently no other node pools with the feature enabled, cluster will have to reconcile its settings for
215-
the changes to take effect. Before that happens, daemon set and pods, which install CAs won't appear on the cluster.
216-
This operation will happen automatically as a part of AKS's reconcile loop.
217-
You can trigger reconcile operation by running the following command:
199+
If no other node pools with the feature enabled exist, the cluster has to reconcile its settings for the changes to take effect. This operation happens automatically as a part of AKS's reconcile loop. Before the operation, the daemonset and pods won't appear on the cluster. You can trigger an immediate reconcile operation using the [`az aks update`][az-aks-update] command. The daemonset and pods will appear after the update completes.
218200

219201
```azurecli
220202
az aks update -g myResourceGroup --name cluster-name
221203
```
222204

223-
Once complete, the daemonset and pods will appear in the cluster.
224-
225205
## Troubleshooting
226206

227207
### Feature is enabled and secret with CAs is added, but operations are failing with X.509 Certificate Signed by Unknown Authority error
208+
228209
#### Incorrectly formatted certs passed in the secret
210+
229211
AKS requires certs passed in the user-created secret to be properly formatted and base64 encoded. Make sure the CAs you passed are properly base64 encoded and that files with CAs don't have CRLF line breaks.
230-
Certificates passed to ```--custom-ca-trust-certificates``` option shouldn't be base64 encoded.
231-
#### Containerd hasn't picked up new certs
232-
From node's shell, run ```systemctl restart containerd```, once containerd is restarted, new certs will be properly picked up by the container runtime.
212+
Certificates passed to ```--custom-ca-trust-certificates``` shouldn't be base64 encoded.
213+
214+
#### containerd hasn't picked up new certs
215+
216+
From the node's shell, run ```systemctl restart containerd```. Once containerd is restarts, the new certs will be properly picked up by the container runtime.
233217

234218
## Next steps
235219

0 commit comments

Comments
 (0)