|
1 | 1 | # Learn Terraform - Provision AKS Cluster
|
2 | 2 |
|
3 |
| -This repo is a companion repo to the [Provision an AKS Cluster learn guide](https://learn.hashicorp.com/terraform/kubernetes/provision-aks-cluster), containing |
4 |
| -Terraform configuration files to provision an AKS cluster on |
5 |
| -Azure. |
6 |
| - |
7 |
| -After installing the Azure CLI and logging in. Create an Active Directory service |
8 |
| -principal account. |
9 |
| - |
10 |
| -```shell |
11 |
| -$ az ad sp create-for-rbac --skip-assignment |
12 |
| -{ |
13 |
| - "appId": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", |
14 |
| - "displayName": "azure-cli-2019-04-11-00-46-05", |
15 |
| - "name": "http://azure-cli-2019-04-11-00-46-05", |
16 |
| - "password": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", |
17 |
| - "tenant": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" |
18 |
| -} |
19 |
| -``` |
20 |
| - |
21 |
| -Then, replace `terraform.tfvars` values with your `appId` and `password`. |
22 |
| -Terraform will use these values to provision resources on Azure. |
23 |
| - |
24 |
| -After you've done this, initalize your Terraform workspace, which will download |
25 |
| -the provider and initialize it with the values provided in the `terraform.tfvars` file. |
26 |
| - |
27 |
| -```shell |
28 |
| -$ terraform init |
29 |
| - |
30 |
| -Initializing provider plugins... |
31 |
| -- Checking for available provider plugins on https://releases.hashicorp.com... |
32 |
| -- Downloading plugin for provider "azurerm" (1.27.0)... |
33 |
| - |
34 |
| -Terraform has been successfully initialized! |
35 |
| -``` |
36 |
| - |
37 |
| - |
38 |
| -Then, provision your AKS cluster by running `terraform apply`. This will |
39 |
| -take approximately 10 minutes. |
40 |
| - |
41 |
| -```shell |
42 |
| -$ terraform apply |
43 |
| - |
44 |
| -# Output truncated... |
45 |
| - |
46 |
| -Plan: 3 to add, 0 to change, 0 to destroy. |
47 |
| - |
48 |
| -Do you want to perform these actions? |
49 |
| - Terraform will perform the actions described above. |
50 |
| - Only 'yes' will be accepted to approve. |
51 |
| - |
52 |
| -# Output truncated... |
53 |
| - |
54 |
| -Apply complete! Resources: 3 added, 0 changed, 0 destroyed. |
55 |
| - |
56 |
| -Outputs: |
57 |
| - |
58 |
| -kubernetes_cluster_name = light-eagle-aks |
59 |
| -resource_group_name = light-eagle-rg |
60 |
| -``` |
61 |
| - |
62 |
| -## Configure kubectl |
63 |
| - |
64 |
| -To configure kubetcl run the following command: |
65 |
| - |
66 |
| -```shell |
67 |
| -$ az aks get-credentials --resource-group light-eagle-rg --name light-eagle-aks; |
68 |
| -``` |
69 |
| - |
70 |
| -The |
71 |
| -[resource group name](https://github.com/hashicorp/learn-terraform-provision-aks-cluster/blob/master/aks-cluster.tf#L16) |
72 |
| -and [AKS name](https://github.com/hashicorp/learn-terraform-provision-aks-cluster/blob/master/aks-cluster.tf#L25) |
73 |
| - correspond to the output variables showed after the successful Terraform run. |
74 |
| - |
75 |
| -You can view these outputs again by running: |
76 |
| - |
77 |
| -```shell |
78 |
| -$ terraform output |
79 |
| -``` |
80 |
| - |
81 |
| -## Configure Kubernetes Dashboard |
82 |
| - |
83 |
| -To use the Kubernetes dashboard, we need to create a `ClusterRoleBinding`. This |
84 |
| -gives the `cluster-admin` permission to access the `kubernetes-dashboard`. |
85 |
| - |
86 |
| -```shell |
87 |
| -$ kubectl create clusterrolebinding kubernetes-dashboard --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard --user=clusterUser |
88 |
| -clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created |
89 |
| -``` |
90 |
| - |
91 |
| -Finally, to access the Kubernetes dashboard, run the following command: |
92 |
| - |
93 |
| -```shell |
94 |
| -$ az aks browse --resource-group light-eagle-rg --name light-eagle-aks |
95 |
| -Merged "light-eagle-aks" as current context in /var/folders/s6/m22_k3p11z104k2vx1jkqr2c0000gp/T/tmpcrh3pjs_ |
96 |
| -Proxy running on http://127.0.0.1:8001/ |
97 |
| -Press CTRL+C to close the tunnel... |
98 |
| -``` |
99 |
| - |
100 |
| - You should be able to access the Kubernetes dashboard at [http://127.0.0.1:8001/](http://127.0.0.1:8001/). |
| 3 | +This repo is a companion repo to the [Provision an AKS Cluster learn guide](https://learn.hashicorp.com/terraform/kubernetes/provision-aks-cluster), containing Terraform configuration files to provision an AKS cluster on Azure. |
0 commit comments