Skip to content

Commit 349d605

Browse files
committed
Freshness pass and formatting edits
1 parent fcfe754 commit 349d605

File tree

1 file changed

+127
-123
lines changed

1 file changed

+127
-123
lines changed

articles/aks/custom-certificate-authority.md

Lines changed: 127 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,23 @@ author: rayoef
55
ms.author: rayoflores
66
ms.topic: article
77
ms.custom: devx-track-azurecli
8-
ms.date: 4/24/2022
8+
ms.date: 04/25/2023
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) 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.
13+
AKS generates and uses the following certificates, Certificate Authorities (CAs), and Service Accounts (SAs):
1414

15-
This feature is applied per node pool, so new and existing node pools must be configured to enable this feature.
15+
* The AKS API server creates a CA called the Cluster CA.
16+
* The API server has a Cluster CA, which signs certificates for one-way communication from the API server to kubelets.
17+
* Each kubelet also creates a Certificate Signing Request (CSR), which is signed by the Cluster CA, for communication from the kubelet to the API server.
18+
* The API aggregator uses the Cluster CA to issue certificates for communication with other APIs. The API aggregator can also have its own CA for issuing those certificates, but it currently uses the Cluster CA.
19+
* Each node uses an SA token, which is signed by the Cluster CA.
20+
* The `kubectl` client has a certificate for communicating with the AKS cluster.
21+
22+
You can also create custom certificate authorities, which 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. This feature is applied per node pool, so you need to enable it on new and existing node pools.
23+
24+
This article shows you how to create custom CAs and apply them to your AKS clusters.
1625

1726
## Prerequisites
1827

@@ -28,44 +37,45 @@ This feature is applied per node pool, so new and existing node pools must be co
2837

2938
[!INCLUDE [preview features callout](includes/preview/preview-callout.md)]
3039

31-
Install the aks-preview extension using the [`az extension add`][az-extension-add] command.
40+
1. Install the aks-preview extension using the [`az extension add`][az-extension-add] command.
3241

33-
```azurecli
34-
az extension add --name aks-preview
35-
```
42+
```azurecli
43+
az extension add --name aks-preview
44+
```
3645
37-
Update to the latest version of the extension using the [`az extension update`][az-extension-update] command.
46+
2. Update to the latest version of the extension using the [`az extension update`][az-extension-update] command.
3847
39-
```azurecli
40-
az extension update --name aks-preview
41-
```
48+
```azurecli
49+
az extension update --name aks-preview
50+
```
4251
43-
## Register the 'CustomCATrustPreview' feature flag
52+
## Register the `CustomCATrustPreview` feature flag
4453
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*.
54+
1. Register the `CustomCATrustPreview` feature flag using the [`az feature register`][az-feature-register] command.
4655
47-
```azurecli
48-
az feature register --namespace "Microsoft.ContainerService" --name "CustomCATrustPreview"
49-
```
56+
```azurecli
57+
az feature register --namespace "Microsoft.ContainerService" --name "CustomCATrustPreview"
58+
```
5059
51-
Verify the registration status using the [`az feature show`][az-feature-show] command.
60+
It takes a few minutes for the status to show *Registered*.
5261
53-
```azurecli
54-
az feature show --namespace "Microsoft.ContainerService" --name "CustomCATrustPreview"
55-
```
62+
2. Verify the registration status using the [`az feature show`][az-feature-show] command.
5663
57-
When the status reflects *Registered*, refresh the registration of the *Microsoft.ContainerService* resource provider using the [`az provider register`][az-provider-register] command.
64+
```azurecli
65+
az feature show --namespace "Microsoft.ContainerService" --name "CustomCATrustPreview"
66+
```
5867
59-
```azurecli
60-
az provider register --namespace Microsoft.ContainerService
61-
```
68+
3. When the status reflects *Registered*, refresh the registration of the *Microsoft.ContainerService* resource provider using the [`az provider register`][az-provider-register] command.
69+
70+
```azurecli
71+
az provider register --namespace Microsoft.ContainerService
72+
```
6273
6374
## Custom CA installation on AKS node pools
6475
65-
### Install CAs during node pool creation
76+
### Install CAs on AKS node pools
6677
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.
78+
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 [`az aks create`][az-aks-create] or [`az aks update`][az-aks-update] operations.
6979
7080
Example text file:
7181
@@ -79,128 +89,125 @@ cert2
7989
-----END CERTIFICATE-----
8090
```
8191

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-
```
92+
#### Install CAs during node pool creation
9093

91-
#### CA rotation for availability during node pool boot up
94+
* Install CAs during node pool creation using the [`az aks create][az-aks-create] command and specifying your text file for the `--custom-ca-trust-certificates` parameter.
9295

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.
96+
```azurecli
97+
az aks create \
98+
--resource-group myResourceGroup \
99+
--name myAKSCluster \
100+
--node-count 2 \
101+
--enable-custom-ca-trust \
102+
--custom-ca-trust-certificates pathToFileWithCAs
103+
```
94104
95-
```azurecli
96-
az aks update \
97-
--resource-group myResourceGroup \
98-
--name myAKSCluster \
99-
--custom-ca-trust-certificates pathToFileWithCAs
100-
```
105+
#### CA rotation for availability during node pool boot up
101106
102-
> [!NOTE]
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.
107+
* Update CAs passed to your cluster during boot up using the [`az aks update`][az-aks-update] command and specifying your text file for the `--custom-ca-trust-certificates` parameter.
104108
105-
### Install CAs once node pool is up and running
109+
```azurecli
110+
az aks update \
111+
--resource-group myResourceGroup \
112+
--name myAKSCluster \
113+
--custom-ca-trust-certificates pathToFileWithCAs
114+
```
106115
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.
116+
> [!NOTE]
117+
> 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.
108118
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.
110-
111-
```yaml
112-
apiVersion: v1
113-
kind: Secret
114-
metadata:
115-
name: custom-ca-trust-secret
116-
namespace: kube-system
117-
type: Opaque
118-
data:
119-
ca1.crt: |
120-
{base64EncodedCertStringHere}
121-
ca2.crt: |
122-
{anotherBase64EncodedCertStringHere}
123-
```
119+
### Install CAs after node pool creation
124120
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.
121+
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.
126122
127-
> [!NOTE]
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```
123+
* Create a [Kubernetes secret][kubernetes-secrets] YAML manifest with your base64 encoded certificate string in the `data` field.
124+
125+
```yaml
126+
apiVersion: v1
127+
kind: Secret
128+
metadata:
129+
name: custom-ca-trust-secret
130+
namespace: kube-system
131+
type: Opaque
132+
data:
133+
ca1.crt: |
134+
{base64EncodedCertStringHere}
135+
ca2.crt: |
136+
{anotherBase64EncodedCertStringHere}
137+
```
138+
139+
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. 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.
140+
141+
> [!NOTE]
142+
>
143+
> 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:
144+
>
145+
> ```systemctl restart containerd```
131146
132147
## Configure a new AKS cluster to use a custom CA
133148
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.
149+
* 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.
135150
136-
```azurecli
137-
az aks create \
138-
--resource-group myResourceGroup \
139-
--name myAKSCluster \
140-
--node-count 2 \
141-
--enable-custom-ca-trust
142-
```
151+
```azurecli
152+
az aks create \
153+
--resource-group myResourceGroup \
154+
--name myAKSCluster \
155+
--node-count 2 \
156+
--enable-custom-ca-trust
157+
```
143158
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.
159+
## Configure a new AKS cluster to use a custom CA with CAs installed before node boots up
145160
146-
```azurecli
147-
az aks create \
148-
--resource-group myResourceGroup \
149-
--name myAKSCluster \
150-
--node-count 2 \
151-
--enable-custom-ca-trust \
152-
--custom-ca-trust-certificates pathToFileWithCAs
153-
```
161+
* 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.
162+
163+
```azurecli
164+
az aks create \
165+
--resource-group myResourceGroup \
166+
--name myAKSCluster \
167+
--node-count 2 \
168+
--enable-custom-ca-trust \
169+
--custom-ca-trust-certificates pathToFileWithCAs
170+
```
154171
155172
## Configure an existing AKS cluster to have custom CAs installed before node boots up
156173
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.
174+
* 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.
158175
159-
```azurecli
160-
az aks update \
161-
--resource-group myResourceGroup \
162-
--name myAKSCluster \
163-
--custom-ca-trust-certificates pathToFileWithCAs
164-
```
176+
```azurecli
177+
az aks update \
178+
--resource-group myResourceGroup \
179+
--name myAKSCluster \
180+
--custom-ca-trust-certificates pathToFileWithCAs
181+
```
165182
166183
## Configure a new node pool to use a custom CA
167184
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.
185+
* 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.
169186
170-
```azurecli
171-
az aks nodepool add \
172-
--cluster-name myAKSCluster \
173-
--resource-group myResourceGroup \
174-
--name myNodepool \
175-
--enable-custom-ca-trust \
176-
--os-type Linux
177-
```
187+
```azurecli
188+
az aks nodepool add \
189+
--cluster-name myAKSCluster \
190+
--resource-group myResourceGroup \
191+
--name myNodepool \
192+
--enable-custom-ca-trust \
193+
--os-type Linux
194+
```
178195
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 daemon set and pods don't appear on the cluster. You can trigger an immediate reconcile operation using the [`az aks update`][az-aks-update] command. The daemon set and pods appear after the update completes.
180-
181-
```azurecli
182-
az aks update \
183-
--resource-group myResourceGroup \
184-
--name cluster-name
185-
```
196+
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 daemon set and pods don't appear on the cluster. You can trigger an immediate reconcile operation using the [`az aks update`][az-aks-update] command. The daemon set and pods appear after the update completes.
186197
187198
## Configure an existing node pool to use a custom CA
188199
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.
190-
191-
```azurecli
192-
az aks nodepool update \
193-
--resource-group myResourceGroup \
194-
--cluster-name myAKSCluster \
195-
--name myNodepool \
196-
--enable-custom-ca-trust
197-
```
200+
* 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.
198201
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 daemon set and pods don't appear on the cluster. You can trigger an immediate reconcile operation using the [`az aks update`][az-aks-update] command. The daemon set and pods appear after the update completes.
202+
```azurecli
203+
az aks nodepool update \
204+
--resource-group myResourceGroup \
205+
--cluster-name myAKSCluster \
206+
--name myNodepool \
207+
--enable-custom-ca-trust
208+
```
200209
201-
```azurecli
202-
az aks update -g myResourceGroup --name cluster-name
203-
```
210+
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 daemon set and pods don't appear on the cluster. You can trigger an immediate reconcile operation using the [`az aks update`][az-aks-update] command. The daemon set and pods appear after the update completes.
204211
205212
## Troubleshooting
206213
@@ -219,9 +226,6 @@ From the node's shell, run ```systemctl restart containerd```. Once containerd i
219226
220227
For more information on AKS security best practices, see [Best practices for cluster security and upgrades in Azure Kubernetes Service (AKS)][aks-best-practices-security-upgrades].
221228
222-
<!-- LINKS EXTERNAL -->
223-
[kubernetes-secrets]:https://kubernetes.io/docs/concepts/configuration/secret/
224-
225229
<!-- LINKS INTERNAL -->
226230
[aks-best-practices-security-upgrades]: operator-best-practices-cluster-security.md
227231
[azure-cli-install]: /cli/azure/install-azure-cli

0 commit comments

Comments
 (0)