Skip to content

Commit d183281

Browse files
Merge pull request #195338 from erik-ha-msft/erikha-aks-ca-cert
[AKS] - Custom CA Trust
2 parents 891ecd0 + 81e0cf8 commit d183281

File tree

2 files changed

+141
-0
lines changed

2 files changed

+141
-0
lines changed

articles/aks/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@
280280
href: manage-azure-rbac.md
281281
- name: Use Kubernetes RBAC with Azure AD integration
282282
href: azure-ad-rbac.md
283+
- name: Use custom certificate authorities (preview)
284+
href: custom-certificate-authority.md
283285
- name: Rotate certificates
284286
href: certificate-rotation.md
285287
- name: Use Azure Policy
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
---
2+
title: Custom certificate authority (CA) in Azure Kubernetes Service (AKS) (preview)
3+
description: Learn how to use a custom certificate authority (CA) in an Azure Kubernetes Service (AKS) cluster.
4+
services: container-service
5+
author: erik-ha-msft
6+
ms.author: erikha
7+
ms.topic: article
8+
ms.date: 4/12/2022
9+
---
10+
11+
# Custom certificate authority (CA) in Azure Kubernetes Service (AKS) (preview)
12+
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.
14+
15+
This feature is applied per nodepool, so new and existing nodepools must be configured to enable this feature.
16+
17+
[!INCLUDE [preview features note](./includes/preview/preview-callout.md)]
18+
19+
## Prerequisites
20+
21+
* An Azure subscription. If you don't have an Azure subscription, you can create a [free account](https://azure.microsoft.com/free).
22+
* [Azure CLI installed][azure-cli-install].
23+
* A base64 encoded certificate string.
24+
25+
### Limitations
26+
27+
This feature isn't currently supported for Windows nodepools.
28+
29+
### Install the `aks-preview` extension
30+
31+
You also need the *aks-preview* Azure CLI extensions version 0.5.72 or later. Install the *aks-preview* extension by using the [az extension add][az-extension-add] command, or install any available updates by using the [az extension update][az-extension-update] command.
32+
33+
```azurecli
34+
# Install the aks-preview extension
35+
az extension add --name aks-preview
36+
37+
# Update the extension to make sure you have the latest version installed
38+
az extension update --name aks-preview
39+
```
40+
41+
### Register the `CustomCATrustPreview` preview feature
42+
43+
Register the `CustomCATrustPreview` feature flag by using the [az feature register][az-feature-register] command:
44+
45+
```azurecli
46+
az feature register --namespace "Microsoft.ContainerService" --name "CustomCATrustPreview"
47+
```
48+
49+
It takes a few minutes for the status to show *Registered*. Verify the registration status by using the [az feature list][az-feature-list] command:
50+
51+
```azurecli
52+
az feature list --query "[?contains(name, 'Microsoft.ContainerService/CustomCATrustPreview')].{Name:name,State:properties.state}" -o table
53+
```
54+
55+
Refresh the registration of the *Microsoft.ContainerService* resource provider by using the [az provider register][az-provider-register] command:
56+
57+
```azurecli
58+
az provider register --namespace Microsoft.ContainerService
59+
```
60+
61+
## Configure a new AKS cluster to use a custom CA
62+
63+
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.
64+
65+
```azurecli
66+
az aks create \
67+
--resource-group myResourceGroup \
68+
--name myAKSCluster \
69+
--node-count 2 \
70+
--enable-custom-ca-trust
71+
```
72+
73+
## Configure a new nodepool to use a custom CA
74+
75+
To configure a new nodepool to use a custom CA, run the [az aks nodepool add][az-aks-nodepool-add] command with the `--enable-custom-ca-trust` parameter.
76+
77+
```azurecli
78+
az aks nodepool add \
79+
--cluster-name myAKSCluster \
80+
--resource-group myResourceGroup \
81+
--name myNodepool \
82+
--enable-custom-ca-trust
83+
```
84+
85+
## Configure an existing nodepool to use a custom CA
86+
87+
To configure an existing nodepool to use a custom CA, run the [az aks nodepool update][az-aks-nodepool-update] command with the `--enable-custom-trust-ca` parameter.
88+
89+
```azurecli
90+
az aks nodepool update \
91+
--resource-group myResourceGroup \
92+
--cluster-name myAKSCluster \
93+
--name myNodepool \
94+
--enable-custom-ca-trust
95+
```
96+
97+
## Create a Kubernetes secret with your CA information
98+
99+
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.
100+
101+
You must ensure that:
102+
* The secret is named `custom-ca-trust-secret`.
103+
* The secret is created in the `kube-system` namespace.
104+
105+
```yaml
106+
apiVerison: v1
107+
kind: Secret
108+
metadata:
109+
name: custom-ca-trust-secret
110+
namespace: kube-system
111+
type: Opaque
112+
data:
113+
ca1.crt: |
114+
{base64EncodedCertStringHere}
115+
ca2.crt: |
116+
{anotherBase64EncodedCertStringHere}
117+
```
118+
119+
To update or remove a CA, edit and apply the 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.
120+
121+
## Next steps
122+
123+
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].
124+
125+
<!-- LINKS EXTERNAL -->
126+
[kubernetes-secrets]:https://kubernetes.io/docs/concepts/configuration/secret/
127+
128+
<!-- LINKS INTERNAL -->
129+
[aks-best-practices-security-upgrades]: operator-best-practices-cluster-security.md
130+
[azure-cli-install]: /cli/azure/install-azure-cli
131+
[az-aks-create]: /cli/azure/aks#az-aks-create
132+
[az-aks-update]: /cli/azure/aks#az-aks-update
133+
[az-aks-nodepool-add]: /cli/azure/aks#az-aks-nodepool-add
134+
[az-aks-nodepool-update]: /cli/azure/aks#az-aks-update
135+
[az-extension-add]: /cli/azure/extension#az-extension-add
136+
[az-extension-update]: /cli/azure/extension#az-extension-update
137+
[az-feature-list]: /cli/azure/feature#az-feature-list
138+
[az-feature-register]: /cli/azure/feature#az-feature-register
139+
[az-provider-register]: /cli/azure/provider#az-provider-register

0 commit comments

Comments
 (0)