|
| 1 | +--- |
| 2 | +title: "Connect an Azure Arc-enabled Kubernetes cluster (Preview)" |
| 3 | +services: azure-arc |
| 4 | +ms.service: azure-arc |
| 5 | +#ms.subservice: azure-arc-kubernetes coming soon |
| 6 | +ms.date: 05/19/2020 |
| 7 | +ms.topic: article |
| 8 | +author: mlearned |
| 9 | +ms.author: mlearned |
| 10 | +description: "Connect an Azure Arc-enabled Kubernetes cluster with Azure Arc" |
| 11 | +keywords: "Kubernetes, Arc, Azure, K8s, containers" |
| 12 | +--- |
| 13 | + |
| 14 | +# Connect an Azure Arc-enabled Kubernetes cluster (Preview) |
| 15 | + |
| 16 | +Connect a Kubernetes cluster to Azure Arc. |
| 17 | + |
| 18 | +## Before you begin |
| 19 | + |
| 20 | +Verify you have the following requirements ready: |
| 21 | + |
| 22 | +* A Kubernetes cluster that is up and running |
| 23 | +* You'll need access with kubeconfig, and cluster-admin access. |
| 24 | +* The user or service principal used with `az login` and `az connectedk8s connect` commands must have the 'Read' and 'Write' permissions on the 'Microsoft.Kubernetes/connectedclusters' resource type. |
| 25 | +* Latest version of the *connectedk8s* and *k8sconfiguration* extensions |
| 26 | + |
| 27 | +## Supported regions |
| 28 | + |
| 29 | +* East US |
| 30 | +* West Europe |
| 31 | + |
| 32 | +## Network requirements |
| 33 | + |
| 34 | +Azure Arc agents require the following protocols/ports/outbound URLs to function. |
| 35 | + |
| 36 | +* TCP on port 443 --> `https://:443` |
| 37 | +* TCP on port 9418 --> `git://:9418` |
| 38 | + |
| 39 | +| Endpoint (DNS) | Description | |
| 40 | +| ------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------- | |
| 41 | +| `https://management.azure.com` | Required for the agent to connect to Azure and register the cluster | |
| 42 | +| `https://eastus.dp.kubernetesconfiguration.azure.com`, `https://westeurope.dp.kubernetesconfiguration.azure.com` | Data plane endpoint for the agent to push status and fetch configuration information | |
| 43 | +| `https://docker.io` | Required to pull container images | |
| 44 | +| `https://github.com`, git://github.com | Example GitOps repos are hosted on GitHub. Configuration agent requires connectivity to whichever git endpoint you specify. | |
| 45 | +| `https://login.microsoftonline.com` | Required to fetch and update Azure Resource Manager tokens | |
| 46 | +| `https://azurearcfork8s.azurecr.io` | Required to pull container images for Azure Arc agents | |
| 47 | + |
| 48 | +## Register the two providers for Azure Arc enabled Kubernetes: |
| 49 | + |
| 50 | +```console |
| 51 | +az provider register --namespace Microsoft.Kubernetes |
| 52 | +Registering is still on-going. You can monitor using 'az provider show -n Microsoft.Kubernetes' |
| 53 | + |
| 54 | +az provider register --namespace Microsoft.KubernetesConfiguration |
| 55 | +Registering is still on-going. You can monitor using 'az provider show -n Microsoft.KubernetesConfiguration' |
| 56 | +``` |
| 57 | + |
| 58 | +Registration is an asynchronous process. Registration may take approximately 10 minutes. You can monitor the registration process with the following commands: |
| 59 | + |
| 60 | +```console |
| 61 | +az provider show -n Microsoft.Kubernetes -o table |
| 62 | +``` |
| 63 | + |
| 64 | +```console |
| 65 | +az provider show -n Microsoft.KubernetesConfiguration -o table |
| 66 | +``` |
| 67 | + |
| 68 | +## Install CLI extensions |
| 69 | + |
| 70 | +Install the `connectedk8s` extension, which helps you connect Kubernetes clusters to Azure: |
| 71 | + |
| 72 | +```console |
| 73 | +az extension add --name connectedk8s |
| 74 | +``` |
| 75 | + |
| 76 | +Install the `k8sconfiguration` extension: |
| 77 | + |
| 78 | +```console |
| 79 | +az extension add --name k8sconfiguration |
| 80 | +``` |
| 81 | + |
| 82 | +Run the following commands to update the extensions to the latest versions. |
| 83 | + |
| 84 | +```console |
| 85 | +az extension update --name connectedk8s |
| 86 | +az extension update --name k8sconfiguration |
| 87 | +``` |
| 88 | + |
| 89 | +## Create a Resource Group |
| 90 | + |
| 91 | +Use a resource group to store metadata for your cluster. |
| 92 | + |
| 93 | +First, create a resource group to hold the connected cluster resource. |
| 94 | + |
| 95 | +```console |
| 96 | +az group create --name AzureArcTest -l EastUS -o table |
| 97 | +``` |
| 98 | + |
| 99 | +**Output:** |
| 100 | + |
| 101 | +```console |
| 102 | +Location Name |
| 103 | +---------- ------------ |
| 104 | +eastus AzureArcTest |
| 105 | +``` |
| 106 | + |
| 107 | +## Connect a cluster |
| 108 | + |
| 109 | +Next, we will connect our Kubernetes cluster to Azure. The workflow for `az connectedk8s connect` is as follows: |
| 110 | + |
| 111 | +1. Verify connectivity to your Kubernetes cluster: via `KUBECONFIG`, `~/.kube/config`, or `--kube-config` |
| 112 | +1. Deploy Azure Arc Agents for Kubernetes using Helm 3, into the `azure-arc` namespace |
| 113 | + |
| 114 | +```console |
| 115 | +az connectedk8s connect --name AzureArcTest1 --resource-group AzureArcTest |
| 116 | +``` |
| 117 | + |
| 118 | +**Output:** |
| 119 | + |
| 120 | +```console |
| 121 | +Command group 'connectedk8s' is in preview. It may be changed/removed in a future release. |
| 122 | +Helm release deployment succeeded |
| 123 | + |
| 124 | +{ |
| 125 | + "aadProfile": { |
| 126 | + "clientAppId": "", |
| 127 | + "serverAppId": "", |
| 128 | + "tenantId": "" |
| 129 | + }, |
| 130 | + "agentPublicKeyCertificate": "...", |
| 131 | + "agentVersion": "0.1.0", |
| 132 | + "id": "/subscriptions/57ac26cf-a9f0-4908-b300-9a4e9a0fb205/resourceGroups/AzureArcTest/providers/Microsoft.Kubernetes/connectedClusters/AzureArcTest1", |
| 133 | + "identity": { |
| 134 | + "principalId": null, |
| 135 | + "tenantId": null, |
| 136 | + "type": "None" |
| 137 | + }, |
| 138 | + "kubernetesVersion": "v1.15.0", |
| 139 | + "location": "eastus", |
| 140 | + "name": "AzureArcTest1", |
| 141 | + "resourceGroup": "AzureArcTest", |
| 142 | + "tags": {}, |
| 143 | + "totalNodeCount": 1, |
| 144 | + "type": "Microsoft.Kubernetes/connectedClusters" |
| 145 | +} |
| 146 | +``` |
| 147 | + |
| 148 | +## Verify connected cluster |
| 149 | + |
| 150 | +List your connected clusters: |
| 151 | + |
| 152 | +```console |
| 153 | +az connectedk8s list -g AzureArcTest |
| 154 | +``` |
| 155 | + |
| 156 | +**Output:** |
| 157 | + |
| 158 | +```console |
| 159 | +Command group 'connectedk8s' is in preview. It may be changed/removed in a future release. |
| 160 | +Name Location ResourceGroup |
| 161 | +------------- ---------- --------------- |
| 162 | +AzureArcTest1 eastus AzureArcTest |
| 163 | +``` |
| 164 | + |
| 165 | +Azure Arc enabled Kubernetes deploys a few operators into the `azure-arc` namespace. You can view these deployments and pods here: |
| 166 | + |
| 167 | +```console |
| 168 | +kubectl -n azure-arc get deploy,po |
| 169 | +``` |
| 170 | + |
| 171 | +**Output:** |
| 172 | + |
| 173 | +```console |
| 174 | +NAME READY UP-TO-DATE AVAILABLE AGE |
| 175 | +deployment.apps/cluster-metadata-operator 1/1 1 1 16h |
| 176 | +deployment.apps/clusteridentityoperator 1/1 1 1 16h |
| 177 | +deployment.apps/config-agent 1/1 1 1 16h |
| 178 | +deployment.apps/controller-manager 1/1 1 1 16h |
| 179 | +deployment.apps/flux-logs-agent 1/1 1 1 16h |
| 180 | +deployment.apps/metrics-agent 1/1 1 1 16h |
| 181 | +deployment.apps/resource-sync-agent 1/1 1 1 16h |
| 182 | + |
| 183 | +NAME READY STATUS RESTART AGE |
| 184 | +pod/cluster-metadata-operator-7fb54d9986-g785b 2/2 Running 0 16h |
| 185 | +pod/clusteridentityoperator-6d6678ffd4-tx8hr 3/3 Running 0 16h |
| 186 | +pod/config-agent-544c4669f9-4th92 3/3 Running 0 16h |
| 187 | +pod/controller-manager-fddf5c766-ftd96 3/3 Running 0 16h |
| 188 | +pod/flux-logs-agent-7c489f57f4-mwqqv 2/2 Running 0 16h |
| 189 | +pod/metrics-agent-58b765c8db-n5l7k 2/2 Running 0 16h |
| 190 | +pod/resource-sync-agent-5cf85976c7-522p5 3/3 Running 0 16h |
| 191 | +``` |
| 192 | + |
| 193 | +## Azure Arc agents for Kubernetes |
| 194 | + |
| 195 | +Azure Arc enabled Kubernetes consists of a few agents (operators) that run in your cluster deployed to the `azure-arc` namespace. |
| 196 | + |
| 197 | +* `deploy/config-agent`: watches the connected cluster for source control configuration resources applied on the cluster and updates compliance state |
| 198 | +* `deploy/controller-manager`: is an operator of operators and orchestrates interactions between Azure Arc components |
| 199 | + |
| 200 | +## Delete a connected cluster |
| 201 | + |
| 202 | +You can delete a `Microsoft.Kubernetes/connectedcluster` resource using the CLI or Azure portal. |
| 203 | + |
| 204 | +The Azure CLI command `az connectedk8s delete` removes the `Microsoft.Kubernetes/connectedCluster` resource in Azure. The Azure CLI deletes any associated `sourcecontrolconfiguration` resources in Azure. The Azure CLI uses helm uninstall to remove the agents in the cluster. |
| 205 | + |
| 206 | +The Azure portal deletes the `Microsoft.Kubernetes/connectedcluster` resource in Azure, and deletes any associated `sourcecontrolconfiguration` resources in Azure. |
| 207 | + |
| 208 | +To remove the agents in the cluster you need to run `az connectedk8s delete` or `helm uninstall azurearcfork8s`. |
| 209 | + |
| 210 | +## Next steps |
| 211 | + |
| 212 | +* [Use GitOps in a connected cluster](./use-gitops-connected-cluster.md) |
| 213 | +* [Use Azure Policy to govern cluster configuration](./use-azure-policy.md) |
0 commit comments