Skip to content

Commit eecb1da

Browse files
feature: add user cluster create with terraform sample (metallb) (#593)
* chore: add samples for metalln usercluster terraform * chore: add cluster name variable * doc: add intro to user cluster with manuallb * doc: update readme for the user cluster create * linkt: fix errors * lint: fix linting errors * lint: fix linting errors * chore: update tfvars files * chore: add dynamic admin user block * chore: add region tags * chore: update tfvars sample * doc: update readme * chore: fix sample terraform vars file * lint: add whitespace at end * feature: add sample for Anthos bare metal on VMware (metal-lb) (#597) * Add sample for Anthos VMware on metal lb * Update sample file with placeholders * Remove ignored annotations as the field is defaulted * reformat sample file * fix lint error * fix lint error by running terraform fmt * change back the update on abm directory * fix: update TF sample files of AVMW for beta release (#604) * Update provider to google-beta * Add enable_load_balancer in node pool * update lb_address_pools sample value to keep consistent with ABM sample * add authorization field to support admin_users var * Add instructions of preps for cluster upgrade * remove google-private in versions and add admin_users in variable * update the var name for admin_cluster and readme * Correct gkectl command in readme file * Update provider in ABM samples to google-beta * Add upgrade via gcloud command example in readme * update description for upgrade in readme file * chore: add readme link to AVMW * chore: fix docs --------- Co-authored-by: Naitian Liu <[email protected]>
1 parent 3e95884 commit eecb1da

File tree

13 files changed

+930
-10
lines changed

13 files changed

+930
-10
lines changed

anthos-bm-gcp-terraform/README.md

+40-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
> #### This is a terraform script to provision the GCE infrastructure in which Anthos clusters on bare metal (ABM) will be installed. The cluster installation is done using `bash` scripts. This does NOT use the `google_gkeonprem_*` terraform resources of the `google` provider to create the ABM cluster. If you are looking for a sample that is fully based off of the terraform provider, see the [anthos-onprem-terraform](/anthos-onprem-terraform/) directory.
2+
---
13

24
## Anthos Baremetal on Google Compute Engine VMs with Terraform
35

4-
This repository shows you how to use Terraform to try Anthos clusters on bare metal in High Availability (HA) mode using Virtual Machines (VMs) running on Compute Engine. For information about how to use the `gcloud` command-line tool to try this, see [Try Anthos clusters on bare metal on Compute Engine VMs](https://cloud.google.com/anthos/clusters/docs/bare-metal/latest/try/gce-vms).
6+
> Read the dosclaimer on top of this README before you continue.
7+
8+
This repository shows you how to use Terraform to try Anthos clusters on bare
9+
metal in High Availability (HA) mode using Virtual Machines (VMs) running on
10+
Compute Engine. For information about how to use the `gcloud` command-line tool
11+
to try this, see [Try Anthos clusters on bare metal on Compute Engine VMs](https://cloud.google.com/anthos/clusters/docs/bare-metal/latest/try/gce-vms).
512

613
### Pre-requisites
714

@@ -12,14 +19,19 @@ This repository shows you how to use Terraform to try Anthos clusters on bare me
1219

1320
- A [Google Cloud Project](https://console.cloud.google.com/cloud-resource-manager?_ga=2.187862184.1029435410.1614837439-1338907320.1614299892) _(in which the resources for the setup will be provisioned)_
1421

15-
- A [Service Account](https://cloud.google.com/iam/docs/creating-managing-service-accounts) in the project that satisfies **one** of the following requirements and its **[key file downloaded](docs/create_sa_key.md)** to the workstation:
22+
- A [Service Account](https://cloud.google.com/iam/docs/creating-managing-service-accounts)
23+
in the project that satisfies **one** of the following requirements and its
24+
**[key file downloaded](docs/create_sa_key.md)** to the workstation:
1625
- The Service Account has `Owner` permissions
1726
- The Service Account has both `Editor` and `Project IAM Admin` permissions
1827

1928
---
2029
### Bare metal infrastructure on Google Cloud using Compute Engine VMs
2130

22-
The [Quick starter](docs/quickstart.md) guide sets up the following infrastructure in Google Cloud using Compute Engine VMs. The diagram assumes that the none of the default values for the [variables](variables.tf) were changed other than the ones mentioned in the quick starter.
31+
The [Quick starter](docs/quickstart.md) guide sets up the following
32+
infrastructure in Google Cloud using Compute Engine VMs. The diagram assumes
33+
that the none of the default values for the [variables](variables.tf) were
34+
changed other than the ones mentioned in the quick starter.
2335

2436
![Bare metal infrastructure on Google Cloud using Compute Engine VMs](docs/images/abm_gcp_infra.svg)
2537

@@ -29,22 +41,42 @@ The [Quick starter](docs/quickstart.md) guide sets up the following infrastructu
2941
- [Terraform Module Information _(includes variables definitions)_](docs/variables.md)
3042

3143
- [Quick start guide](docs/quickstart.md):
32-
- The terraform script sets up the GCE VM environment. The output of the script prints out the commands to follow to install **Anthos on bare metal** in the provisioned GCE VMs.
44+
- The terraform script sets up the GCE VM environment. The output of the
45+
script prints out the commands to follow to install
46+
**Anthos on bare metal** in the provisioned GCE VMs.
3347

3448
- [All in one install](docs/one_click_install.md):
35-
- The terraform script sets up the GCE VM environment and also triggers the **Anthos on bare metal** installation on the provisioned GCE VMs. The output of the script prints out the commands to SSH into the *admin workstation VM* and monitor the Anthos on bare metal installation process.
49+
- The terraform script sets up the GCE VM environment and also triggers the
50+
**Anthos on bare metal** installation on the provisioned GCE VMs. The
51+
output of the script prints out the commands to SSH into the
52+
*admin workstation VM* and monitor the Anthos on bare metal installation
53+
process.
3654

3755
- [Manual LB install](docs/manuallb_install.md):
38-
- The terraform script sets up the GCE environment and triggers the **Anthos on bare metal** installation similar to the [all-in-one install](docs/one_click_install.md). However, in this mode **Anthos on bare metal** is installed with a [`Manual Loadbalancer`](https://cloud.google.com/anthos/clusters/docs/bare-metal/latest/installing/manual-lb) instead of the default [`Bundled LB`](https://cloud.google.com/anthos/clusters/docs/bare-metal/latest/installing/bundled-lb). We use [Google Cloud Loadbalancer](https://cloud.google.com/load-balancing/docs/load-balancing-overview) as the manual loadbalancer for the Anthos on bare metal cluster. The output of the script prints out the same instructions as the all-in-one install; additionally it also prints out the **Public IP** addresses of the loadbalancers.
56+
- The terraform script sets up the GCE environment and triggers the
57+
**Anthos on bare metal** installation similar to the
58+
[all-in-one install](docs/one_click_install.md). However, in this mode
59+
**Anthos on bare metal** is installed with a
60+
[`Manual Loadbalancer`](https://cloud.google.com/anthos/clusters/docs/bare-metal/latest/installing/manual-lb) instead of the default
61+
[`Bundled LB`](https://cloud.google.com/anthos/clusters/docs/bare-metal/latest/installing/bundled-lb).
62+
We use
63+
[Google Cloud Loadbalancer](https://cloud.google.com/load-balancing/docs/load-balancing-overview)
64+
as the manual loadbalancer for the Anthos on bare metal cluster. The
65+
output of the script prints out the same instructions as the all-in-one
66+
install; additionally it also prints out the **Public IP** addresses of
67+
the loadbalancers.
3968

4069
- [NFS Shared Storage](docs/nfs.md):
41-
- An optional NFS server is provisioned in conjunction with any of the install methods above to provide shared storage to the **Anthos on bare metal** cluster.
70+
- An optional NFS server is provisioned in conjunction with any of the
71+
install methods above to provide shared storage to the
72+
**Anthos on bare metal** cluster.
4273

4374
---
4475
## Contributing
4576

4677
#### Pre-requisites
47-
- The same [pre-requisites](#pre-requisites) to run this sample is required for testing as well
78+
- The same [pre-requisites](#pre-requisites) to run this sample is required for
79+
testing as well
4880

4981
#### Pull requests
5082
- For improvements to this sample submit your pull requests to the `main` branch

anthos-multi-cloud/Azure/provider.tf

+7-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
terraform {
1818
required_providers {
1919
azuread = {
20-
source = "hashicorp/azuread"
20+
source = "hashicorp/azuread"
21+
version = ">= 2.14.0"
2122
}
2223
azurerm = {
2324
source = "hashicorp/azurerm"
@@ -35,8 +36,12 @@ provider "azurerm" {
3536
}
3637

3738
provider "azuread" {
38-
version = ">= 2.14.0"
39+
/**
40+
* update this block with your default Azure Active Directory information
41+
* like tenant_id or client_id.
42+
*/
3943
}
44+
4045
provider "google" {
4146
project = var.gcp_project_id
4247
}

anthos-onprem-terraform/README.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## Install Anthos onPrem clusters using Terraform
2+
3+
This directory hosts samples and how-to's for installing Anthos onPrem clusters
4+
_(i.e. Anthos on bare metal and Anthos on VMware)_ using the
5+
`google_gkeonprem-*` resources of the canonical
6+
[Google Cloud Terraform provider](https://registry.terraform.io/providers/hashicorp/google/latest/docs).
7+
8+
9+
All the samples here, first **emulates** a bare metal infrastucture using
10+
Compute Engine (GCE) VMs. It is on this imaginary bare metal environment the
11+
clusters are installed. Thus, as a prestep to all the guides here, you will see
12+
a step for provisioning the bare metal insfrastructure. If you have your own
13+
bare metal infrastructure, you can skip that section and adjust the sample to
14+
suit your environment.
15+
16+
<!--
17+
# TODO: Add links to the Terraform provider once it has been published
18+
-->
19+
---
20+
21+
### Anthos clusters on bare metal (ABM)
22+
- Create **admin** clusters with Terraform `(coming soon)`
23+
- See [guide](https://cloud.google.com/anthos/clusters/docs/bare-metal/latest/installing/creating-clusters/create-admin-cluster-api) for creating an admin cluster using other clients
24+
- Create **user** clusters with Terraform
25+
- [MetalLB](./abm_user_cluster_metallb/)
26+
- ManualLB `(coming soon)`
27+
- Create **standalone** clusters with Terraform `(coming soon)`
28+
---
29+
30+
### Anthos clusters on VMware (AVMware)
31+
- Create **admin** clusters with Terraform `(coming soon)`
32+
- Create **user** clusters with Terraform
33+
- [MetalLB](./avmw_user_cluster_metallb/)
34+
- ManualLB `(coming soon)`
35+
- Create **standalone** clusters with Terraform `(coming soon)`
36+
37+
---
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
## Create Anthos on bare metal **user** clusters (MetalLB) with Terraform
2+
3+
The steps here acheive the same result as what is explained in the
4+
[Create an Anthos on bare metal user cluster on Compute Engine VMs using Anthos On-Prem API clients](https://cloud.google.com/anthos/clusters/docs/bare-metal/latest/try/admin-user-gce-vms)
5+
public documentation. We show an example of how to create an Anthos on bare
6+
metal **user cluster** with **MetalLB** using the Google provider for Terraform.
7+
8+
The sample here has a prerequisite step of creating an **admin cluster** using
9+
the [script available in this repository](/anthos-bm-gcp-bash/install_admin_cluster.sh).
10+
Thus, the default variables _(especially IP addresses)_ used in this sample are
11+
based on the assumption that the admin cluster and the GCE VM based bare metal
12+
infrstructure for the user cluster was created using that script. If you
13+
already have an **admin cluster and bare metal nodes for the user cluster**, you
14+
may skip running this script. However, you will have to update the sample to use
15+
values appropriate to your environment.
16+
17+
---
18+
### Prerequisite
19+
20+
#### Create admin cluster and VMs for user cluster
21+
22+
> **Note:** If you already have an admin cluster and the bare metal nodes for
23+
> a new user cluster, then you can skip this step. But don't forget to update
24+
> the sample with the values appropriate to your environment.
25+
26+
- First you will have to create an admin cluster that will manage your user
27+
cluster. At the time of writing this guide, admin cluster creation
28+
**using Terraform** is not supported.
29+
30+
- Follow the [instructions here](/anthos-bm-gcp-bash/docs/admin.md) to create an
31+
admin cluster and to provision the GCE VMs for the user cluster using the
32+
[install_admin_cluster.sh](/anthos-bm-gcp-bash/install_admin_cluster.sh)
33+
script.
34+
35+
- Upon completion, you will see the node information for the GCE VMs printed on
36+
screen.
37+
38+
```sh
39+
|---------------------------------------------------------------------------------------------------------|
40+
| VM Name | L2 Network IP (VxLAN) | INFO |
41+
|---------------------------------------------------------------------------------------------------------|
42+
| abm-admin-cluster-cp1 | 10.200.0.3 | Has control plane of admin cluster running inside |
43+
| abm-user-cluster-cp1 | 10.200.0.4 | 🌟 Ready for use as control plane for the user cluster |
44+
| abm-user-cluster-w1 | 10.200.0.5 | 🌟 Ready for use as worker for the user cluster |
45+
| abm-user-cluster-w2 | 10.200.0.6 | 🌟 Ready for use as worker for the user cluster |
46+
|---------------------------------------------------------------------------------------------------------|
47+
```
48+
49+
#### Create the user cluster with terraform
50+
51+
The steps that follow assumes that you already have this repo cloned locally and
52+
have changed directory to where this samples is:
53+
`<REPO_ROOT_DIR>/anthos-onprem-terraform/abm_user_cluster_metallb`.
54+
55+
- Make a copy of the `terraform.tfvars.sample` file:
56+
57+
```sh
58+
cp terraform.tfvars.sample terraform.tfvars
59+
```
60+
The sample terraform vaiables file has most of the default values filled in
61+
based on the output of the [install_admin_cluster.sh](/anthos-bm-gcp-bash/install_admin_cluster.sh)
62+
script from the previous section.
63+
64+
- Update missing variables in the `terraform.tfvars` file:
65+
- **`project_id`**: The GCP project of the admin cluster and where the user
66+
cluster will be created.
67+
- **`region`**: The Google Cloud region in which the Anthos On-Prem API
68+
runs.
69+
- **`admin_cluster_name`**: The name of the admin cluster that will manage the
70+
new user cluster. If you used the [install_admin_cluster.sh](/anthos-bm-gcp-bash/install_admin_cluster.sh)
71+
script and used the default name, then this must be `abm-admin-cluster`.
72+
- **`bare_metal_version`**: The Anthos clusters on bare metal version for
73+
your user cluster. This must be same as the admin cluster version or one
74+
minor version less, at most. It cannot be higher in any case - minor or
75+
patch.
76+
77+
- **`admin_user_emails`**: List of GCP accounts that must be given
78+
administrator rights on the user cluster.
79+
80+
- Execute terraform:
81+
82+
```sh
83+
terraform init
84+
```
85+
```sh
86+
terraform plan
87+
```
88+
```sh
89+
terraform apply
90+
```
91+
92+
Once completed you will see an output as follows:
93+
```sh
94+
...
95+
96+
```
97+
98+
You can view your user cluster in the
99+
[Anthos clusters page](https://console.cloud.google.com/anthos/clusters).

0 commit comments

Comments
 (0)