|
8 | 8 |
|
9 | 9 | - [Requirements](#requirements) |
10 | 10 | - [Optional](#optional) |
11 | | - - [Install the project](#install-the-project) |
12 | | - - [Release binaries](#release-binaries) |
| 11 | +- [Prerequisites](#prerequisites) |
| 12 | + - [Install release binaries](#install-release-binaries) |
13 | 13 | - [Building from master](#building-from-master) |
14 | | - - [Prepare your environment](#prepare-your-environment) |
15 | | - - [Usage](#usage) |
16 | | - - [Creating a Cluster](#creating-a-cluster) |
| 14 | +- [Deploying a cluster](#deploying-a-cluster) |
| 15 | + - [Setting up the environment](#setting-up-the-environment) |
| 16 | + - [Generating cluster manifests and example cluster](#generating-cluster-manifests-and-example-cluster) |
| 17 | + - [Customizing the cluster deployment](#customizing-the-cluster-deployment) |
| 18 | + - [Running the manifest generation script](#running-the-manifest-generation-script) |
| 19 | + - [Creating a cluster](#creating-a-cluster) |
| 20 | +- [Using the cluster](#using-the-cluster) |
| 21 | +- [Troubleshooting](#troubleshooting) |
| 22 | + - [Bootstrap running, but resources aren't being created](#bootstrap-running-but-resources-arent-being-created) |
17 | 23 |
|
18 | 24 | <!-- /TOC --> |
19 | 25 |
|
|
41 | 47 | [kubectl]: https://kubernetes.io/docs/tasks/tools/install-kubectl/ |
42 | 48 | [kustomize]: https://github.com/kubernetes-sigs/kustomize |
43 | 49 |
|
44 | | -### Install the project |
| 50 | +## Prerequisites |
45 | 51 |
|
46 | | -#### Release binaries |
47 | | -TODO. Coming soon! |
| 52 | +### Install release binaries |
| 53 | + |
| 54 | +Get the latest [release of `clusterctl`](https://github.com/kubernetes-sigs/cluster-api-provider-azure/releases) and place them in your PATH. |
48 | 55 |
|
49 | 56 | #### Building from master |
50 | 57 |
|
51 | 58 | If you're interested in developing cluster-api-provider-azure and getting the latest version from `master`, please follow the [development guide][development]. |
52 | 59 |
|
53 | | -### Prepare your environment |
54 | | -An Azure Service Principal is needed for usage by the `clusterctl` tool and for populating the controller manifests. This utilizes [environment-based authentication](https://docs.microsoft.com/en-us/go/azure/azure-sdk-go-authorization#use-environment-based-authentication). The following environment variables should be set: `AZURE_SUBSCRIPTION_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_ID` and `AZURE_CLIENT_SECRET`. |
| 60 | +## Deploying a cluster |
| 61 | + |
| 62 | +### Setting up the environment |
| 63 | + |
| 64 | +An Azure Service Principal is needed for usage by the `clusterctl` tool and for populating the controller manifests. This utilizes [environment-based authentication](https://docs.microsoft.com/en-us/go/azure/azure-sdk-go-authorization#use-environment-based-authentication). |
| 65 | + |
| 66 | +The following environment variables should be set: |
| 67 | +- `AZURE_SUBSCRIPTION_ID` |
| 68 | +- `AZURE_TENANT_ID` |
| 69 | +- `AZURE_CLIENT_ID` |
| 70 | +- `AZURE_CLIENT_SECRET` |
55 | 71 |
|
56 | 72 | An alternative is to install [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest) and have the project's script create the service principal automatically. _Note that the service principals created by the scripts will not be deleted automatically._ |
57 | 73 |
|
58 | | -### Usage |
| 74 | +### Generating cluster manifests and example cluster |
| 75 | + |
| 76 | +Download the cluster-api-provider-azure-examples.tar file and unpack it. |
| 77 | + |
| 78 | +```bash |
| 79 | +tar -xvf cluster-api-provider-azure-examples.tar |
| 80 | +``` |
| 81 | + |
| 82 | +#### Customizing the cluster deployment |
59 | 83 |
|
60 | | -#### Creating a Cluster |
61 | | -1. Generate the `cluster.yaml`, `machines.yaml`, and `addons.yaml` files, and create the service principal if needed. |
| 84 | +A set of sane defaults are utilized when generating manifests via `./azure/generate-yaml.sh`, but these can be overridden by exporting environment variables. |
62 | 85 |
|
63 | | - ```bash |
64 | | - make clean # Clean up any previous manifests |
| 86 | +Here is a list of commonly overriden configuration parameters (the full list is available in `./azure/generate-yaml.sh`): |
| 87 | +```bash |
| 88 | +# Azure settings. |
| 89 | +export LOCATION="eastus2" |
| 90 | +export RESOURCE_GROUP="kubecuddles" |
65 | 91 |
|
66 | | - REGISTRY="<container-registry>" MANAGER_IMAGE_TAG="<image-tag>" RESOURCE_GROUP="<resource-group>" CLUSTER_NAME="<cluster-name>" make manifests # set CREATE_SP=TRUE if creating a new Service Principal is desired |
67 | | - |
68 | | - # If CREATE_SP=TRUE |
69 | | - source cmd/clusterctl/examples/azure/out/credentials.sh |
70 | | - ``` |
71 | | -2. Ensure kind has been reset: |
72 | | - ```bash |
73 | | - make kind-reset |
74 | | - ``` |
75 | | -3. Create the cluster. |
| 92 | +# Cluster settings. |
| 93 | +export CLUSTER_NAME="pony-unicorns" |
76 | 94 |
|
77 | | - **NOTE:** Kubernetes Version >= 1.11 is required to enable CRD subresources without needing a feature gate. |
| 95 | +# Machine settings. |
| 96 | +export CONTROL_PLANE_MACHINE_TYPE="Standard_B2ms" |
| 97 | +export NODE_MACHINE_TYPE="Standard_B2ms" |
| 98 | +``` |
78 | 99 |
|
79 | | - ```bash |
80 | | - make create-cluster |
81 | | - ``` |
| 100 | +#### Running the manifest generation script |
82 | 101 |
|
83 | | -Once the cluster is created successfully, you can interact with the cluster using `kubectl` and the kubeconfig downloaded by the `clusterctl` tool. |
| 102 | +Now that the deployment has been customized, the next step is to generate the required manifests: |
84 | 103 |
|
| 104 | +```bash |
| 105 | +./azure/generate-yaml.sh |
85 | 106 | ``` |
| 107 | + |
| 108 | +Manually editing the generated manifests should not be required, but this is the stage where final customizations can be done. |
| 109 | + |
| 110 | +Verify that `./azure/out/cluster.yaml` and `./azure/out/machine.yaml` reflect the expected settings before continuing. |
| 111 | + |
| 112 | +### Creating a cluster |
| 113 | + |
| 114 | +You can now start the Cluster API controllers and deploy a new cluster in Azure: |
| 115 | + |
| 116 | +```bash |
| 117 | +clusterctl create cluster -v 4 \ |
| 118 | + --bootstrap-type kind \ |
| 119 | + --provider azure \ |
| 120 | + -m ./azure/out/machines.yaml \ |
| 121 | + -c ./azure/out/cluster.yaml \ |
| 122 | + -p ./azure/out/provider-components.yaml \ |
| 123 | + -a ./azure/out/addons.yaml |
| 124 | + |
| 125 | +I0324 23:19:37.110948 27739 decoder.go:224] decoding stream as YAML |
| 126 | +I0324 23:19:37.111615 27739 decoder.go:224] decoding stream as YAML |
| 127 | +I0324 23:19:37.115835 27739 createbootstrapcluster.go:27] Creating bootstrap cluster |
| 128 | +I0324 23:19:37.115883 27739 kind.go:69] Running: kind [create cluster --name=clusterapi] |
| 129 | + |
| 130 | +I0324 23:23:58.081879 27739 kind.go:72] Ran: kind [create cluster --name=clusterapi] Output: Creating cluster "clusterapi" ... |
| 131 | + • Ensuring node image (kindest/node:v1.13.3) 🖼 ... |
| 132 | + ✓ Ensuring node image (kindest/node:v1.13.3) 🖼 |
| 133 | + • [control-plane] Creating node container 📦 ... |
| 134 | + ✓ [control-plane] Creating node container 📦 |
| 135 | + • [control-plane] Fixing mounts 🗻 ... |
| 136 | + ✓ [control-plane] Fixing mounts 🗻 |
| 137 | + • [control-plane] Starting systemd 🖥 ... |
| 138 | + ✓ [control-plane] Starting systemd 🖥 |
| 139 | + • [control-plane] Waiting for docker to be ready 🐋 ... |
| 140 | + ✓ [control-plane] Waiting for docker to be ready 🐋 |
| 141 | + • [control-plane] Pre-loading images 🐋 ... |
| 142 | + ✓ [control-plane] Pre-loading images 🐋 |
| 143 | + • [control-plane] Creating the kubeadm config file ⛵ ... |
| 144 | + ✓ [control-plane] Creating the kubeadm config file ⛵ |
| 145 | + • [control-plane] Starting Kubernetes (this may take a minute) ☸ ... |
| 146 | + ✓ [control-plane] Starting Kubernetes (this may take a minute) ☸ |
| 147 | +Cluster creation complete. You can now use the cluster with: |
| 148 | + |
86 | 149 | export KUBECONFIG="$(kind get kubeconfig-path --name="clusterapi")" |
87 | | -kubectl get clusters |
88 | | -kubectl get machines |
| 150 | +kubectl cluster-info |
| 151 | +I0324 23:23:58.081925 27739 kind.go:69] Running: kind [get kubeconfig-path --name=clusterapi] |
| 152 | +I0324 23:23:58.149609 27739 kind.go:72] Ran: kind [get kubeconfig-path --name=clusterapi] Output: /home/fakeuser/.kube/kind-config-clusterapi |
| 153 | +I0324 23:23:58.150729 27739 clusterdeployer.go:78] Applying Cluster API stack to bootstrap cluster |
| 154 | +I0324 23:23:58.150752 27739 applyclusterapicomponents.go:26] Applying Cluster API Provider Components |
| 155 | +I0324 23:23:58.150774 27739 clusterclient.go:919] Waiting for kubectl apply... |
| 156 | +I0324 23:23:58.756964 27739 clusterclient.go:948] Waiting for Cluster v1alpha resources to become available... |
| 157 | +I0324 23:23:58.763134 27739 clusterclient.go:961] Waiting for Cluster v1alpha resources to be listable... |
| 158 | +I0324 23:23:58.771783 27739 clusterdeployer.go:83] Provisioning target cluster via bootstrap cluster |
| 159 | +I0324 23:23:58.777256 27739 applycluster.go:36] Creating cluster object test-1 in namespace "default" |
| 160 | +I0324 23:23:58.783757 27739 clusterdeployer.go:92] Creating control plane test-1-controlplane-0 in namespace "default" |
| 161 | +I0324 23:23:58.788974 27739 applymachines.go:36] Creating machines in namespace "default" |
| 162 | +I0324 23:23:58.801805 27739 clusterclient.go:972] Waiting for Machine test-1-controlplane-0 to become ready... |
| 163 | +<output snipped> |
| 164 | +I0324 23:44:38.804516 27739 clusterclient.go:972] Waiting for Machine test-1-controlplane-0 to become ready... |
| 165 | +I0324 23:44:38.811944 27739 clusterdeployer.go:97] Updating bootstrap cluster object for cluster test-1 in namespace "default" with control plane endpoint running on test-1-controlplane-0 |
| 166 | +I0324 23:44:38.835236 27739 clusterdeployer.go:102] Creating target cluster |
| 167 | +I0324 23:44:38.835270 27739 getkubeconfig.go:38] Getting target cluster kubeconfig. |
| 168 | +I0324 23:44:38.840932 27739 getkubeconfig.go:59] Waiting for kubeconfig on test-1-controlplane-0 to become ready... |
| 169 | +I0324 23:44:38.846004 27739 applyaddons.go:25] Applying Addons |
| 170 | +I0324 23:44:38.846038 27739 clusterclient.go:919] Waiting for kubectl apply... |
| 171 | +I0324 23:44:40.794352 27739 clusterdeployer.go:120] Pivoting Cluster API stack to target cluster |
| 172 | +I0324 23:44:40.794449 27739 pivot.go:67] Applying Cluster API Provider Components to Target Cluster |
| 173 | +I0324 23:44:40.794495 27739 clusterclient.go:919] Waiting for kubectl apply... |
| 174 | +I0324 23:44:43.012086 27739 pivot.go:72] Pivoting Cluster API objects from bootstrap to target cluster. |
| 175 | +I0324 23:44:43.012155 27739 pivot.go:83] Ensuring cluster v1alpha1 resources are available on the source cluster |
| 176 | +I0324 23:44:43.012225 27739 clusterclient.go:948] Waiting for Cluster v1alpha resources to become available... |
| 177 | +I0324 23:44:43.015046 27739 clusterclient.go:961] Waiting for Cluster v1alpha resources to be listable... |
| 178 | +I0324 23:44:43.023466 27739 pivot.go:88] Ensuring cluster v1alpha1 resources are available on the target cluster |
| 179 | +I0324 23:44:43.023547 27739 clusterclient.go:948] Waiting for Cluster v1alpha resources to become available... |
| 180 | +I0324 23:44:43.190476 27739 clusterclient.go:961] Waiting for Cluster v1alpha resources to be listable... |
| 181 | +I0324 23:44:43.251215 27739 pivot.go:93] Parsing list of cluster-api controllers from provider components |
| 182 | +I0324 23:44:43.251262 27739 decoder.go:224] decoding stream as YAML |
| 183 | +I0324 23:44:43.269534 27739 pivot.go:101] Scaling down controller azure-provider-system/azure-provider-controller-manager |
| 184 | +I0324 23:44:43.402303 27739 pivot.go:101] Scaling down controller cluster-api-system/cluster-api-controller-manager |
| 185 | +I0324 23:44:43.409192 27739 pivot.go:107] Retrieving list of MachineClasses to move |
| 186 | +I0324 23:44:43.411218 27739 pivot.go:212] Preparing to copy MachineClasses: [] |
| 187 | +I0324 23:44:43.411252 27739 pivot.go:117] Retrieving list of Clusters to move |
| 188 | +I0324 23:44:43.415212 27739 pivot.go:171] Preparing to move Clusters: [test-1] |
| 189 | +I0324 23:44:43.415246 27739 pivot.go:234] Moving Cluster default/test-1 |
| 190 | +I0324 23:44:43.415269 27739 pivot.go:236] Ensuring namespace "default" exists on target cluster |
| 191 | +I0324 23:44:43.929506 27739 pivot.go:247] Retrieving list of MachineDeployments to move for Cluster default/test-1 |
| 192 | +I0324 23:44:43.932485 27739 pivot.go:287] Preparing to move MachineDeployments: [] |
| 193 | +I0324 23:44:43.932519 27739 pivot.go:256] Retrieving list of MachineSets not associated with a MachineDeployment to move for Cluster default/test-1 |
| 194 | +I0324 23:44:43.935291 27739 pivot.go:331] Preparing to move MachineSets: [] |
| 195 | +I0324 23:44:43.935325 27739 pivot.go:265] Retrieving list of Machines not associated with a MachineSet to move for Cluster default/test-1 |
| 196 | +I0324 23:44:43.937558 27739 pivot.go:374] Preparing to move Machines: [test-1-controlplane-0] |
| 197 | +I0324 23:44:43.937592 27739 pivot.go:385] Moving Machine default/test-1-controlplane-0 |
| 198 | +I0324 23:44:44.353159 27739 clusterclient.go:972] Waiting for Machine test-1-controlplane-0 to become ready... |
| 199 | +I0324 23:44:44.408896 27739 pivot.go:399] Successfully moved Machine default/test-1-controlplane-0 |
| 200 | +I0324 23:44:44.434373 27739 pivot.go:278] Successfully moved Cluster default/test-1 |
| 201 | +I0324 23:44:44.434407 27739 pivot.go:127] Retrieving list of MachineDeployments not associated with a Cluster to move |
| 202 | +I0324 23:44:44.436304 27739 pivot.go:287] Preparing to move MachineDeployments: [] |
| 203 | +I0324 23:44:44.436327 27739 pivot.go:136] Retrieving list of MachineSets not associated with a MachineDeployment or a Cluster to move |
| 204 | +I0324 23:44:44.437964 27739 pivot.go:331] Preparing to move MachineSets: [] |
| 205 | +I0324 23:44:44.437987 27739 pivot.go:145] Retrieving list of Machines not associated with a MachineSet or a Cluster to move |
| 206 | +I0324 23:44:44.439735 27739 pivot.go:374] Preparing to move Machines: [] |
| 207 | +I0324 23:44:44.439780 27739 pivot.go:186] Preparing to delete MachineClasses: [] |
| 208 | +I0324 23:44:44.439803 27739 pivot.go:158] Deleting provider components from source cluster |
| 209 | +I0324 23:44:57.831009 27739 clusterdeployer.go:125] Saving provider components to the target cluster |
| 210 | +I0324 23:44:58.696579 27739 clusterdeployer.go:133] Updating target cluster object with control plane endpoint running on test-1-controlplane-0 |
| 211 | +I0324 23:44:58.846821 27739 clusterdeployer.go:138] Creating node machines in target cluster. |
| 212 | +I0324 23:44:58.886538 27739 applymachines.go:36] Creating machines in namespace "default" |
| 213 | +I0324 23:44:58.923186 27739 clusterclient.go:972] Waiting for Machine test-1-node-c426q to become ready... |
| 214 | +<output snipped> |
| 215 | +I0324 23:53:58.955885 27739 clusterclient.go:972] Waiting for Machine test-1-node-c426q to become ready... |
| 216 | +I0324 23:53:58.997577 27739 clusterdeployer.go:143] Done provisioning cluster. You can now access your cluster with kubectl --kubeconfig kubeconfig |
| 217 | +I0324 23:53:58.997892 27739 createbootstrapcluster.go:36] Cleaning up bootstrap cluster. |
| 218 | +I0324 23:53:58.997937 27739 kind.go:69] Running: kind [delete cluster --name=clusterapi] |
| 219 | +I0324 23:54:00.260254 27739 kind.go:72] Ran: kind [delete cluster --name=clusterapi] Output: Deleting cluster "clusterapi" ... |
| 220 | +``` |
| 221 | +
|
| 222 | +The created KIND cluster is ephemeral and is cleaned up automatically when done. During the cluster creation, the KIND configuration is written to a local directory and can be retrieved using `kind get kubeconfig-path --name="clusterapi"`. |
| 223 | +
|
| 224 | +For a more in-depth look into what `clusterctl` is doing during this create step, please see the [clusterctl document](/docs/clusterctl.md). |
| 225 | +
|
| 226 | +## Using the cluster |
| 227 | +
|
| 228 | +The kubeconfig for the new cluster is created in the directory from where the above `clusterctl create` was run. |
| 229 | +
|
| 230 | +Run the following command to point `kubectl` to the kubeconfig of the new cluster: |
| 231 | +```bash |
| 232 | +export KUBECONFIG=$(PWD)/kubeconfig |
| 233 | +``` |
| 234 | +
|
| 235 | +Alternatively, move the kubeconfig file to a desired location and set the `KUBECONFIG` environment variable accordingly. |
| 236 | +
|
| 237 | +
|
| 238 | +## Troubleshooting |
| 239 | +
|
| 240 | +### Bootstrap running, but resources aren't being created |
| 241 | +
|
| 242 | +Logs can be tailed using [`kubectl`][kubectl]: |
| 243 | +
|
| 244 | +```bash |
| 245 | +export KUBECONFIG=$(kind get kubeconfig-path --name="clusterapi") |
| 246 | +kubectl logs azure-provider-controller-manager-0 -n azure-provider-system -f |
89 | 247 | ``` |
90 | 248 |
|
91 | 249 | [development]: /docs/development.md |
0 commit comments