Skip to content

Commit

Permalink
Merge branch 'main' into renovate/github.com-googlecloudplatform-clou…
Browse files Browse the repository at this point in the history
…d-foundation-toolkit-infra-blueprint-test-0.x
  • Loading branch information
minherz authored May 23, 2023
2 parents 8a14635 + 1757b32 commit 0ae123d
Show file tree
Hide file tree
Showing 15 changed files with 924 additions and 10 deletions.
1 change: 1 addition & 0 deletions anthos-bm-gcp-bash/install_admin_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ gcloud services enable \
container.googleapis.com \
gkeconnect.googleapis.com \
gkehub.googleapis.com \
gkeonprem.googleapis.com \
serviceusage.googleapis.com \
stackdriver.googleapis.com \
monitoring.googleapis.com \
Expand Down
48 changes: 40 additions & 8 deletions anthos-bm-gcp-terraform/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
> #### 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.
---

## Anthos Baremetal on Google Compute Engine VMs with Terraform

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).
> Read the dosclaimer on top of this README before you continue.
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).

### Pre-requisites

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

- 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)_

- 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:
- 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:
- The Service Account has `Owner` permissions
- The Service Account has both `Editor` and `Project IAM Admin` permissions

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

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.
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.

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

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

- [Quick start guide](docs/quickstart.md):
- 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.
- 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.

- [All in one install](docs/one_click_install.md):
- 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.
- 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.

- [Manual LB install](docs/manuallb_install.md):
- 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.
- 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.

- [NFS Shared Storage](docs/nfs.md):
- 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.
- 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.

---
## Contributing

#### Pre-requisites
- The same [pre-requisites](#pre-requisites) to run this sample is required for testing as well
- The same [pre-requisites](#pre-requisites) to run this sample is required for
testing as well

#### Pull requests
- For improvements to this sample submit your pull requests to the `main` branch
Expand Down
9 changes: 7 additions & 2 deletions anthos-multi-cloud/Azure/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
terraform {
required_providers {
azuread = {
source = "hashicorp/azuread"
source = "hashicorp/azuread"
version = ">= 2.14.0"
}
azurerm = {
source = "hashicorp/azurerm"
Expand All @@ -35,8 +36,12 @@ provider "azurerm" {
}

provider "azuread" {
version = ">= 2.14.0"
/**
* update this block with your default Azure Active Directory information
* like tenant_id or client_id.
*/
}

provider "google" {
project = var.gcp_project_id
}
26 changes: 26 additions & 0 deletions anthos-onprem-terraform/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Install Anthos On-Prem clusters using Terraform

This directory hosts samples and how-to's for installing Anthos On-Prem clusters
_(i.e. Anthos on bare metal and Anthos on VMware)_ using the
`google_gkeonprem-*` resources in the
[Google Cloud Terraform provider](https://registry.terraform.io/providers/hashicorp/google/latest/docs).

For more information, see the reference documentation for each resource.

---

#### Anthos clusters on bare metal (ABM)

| Type | Sample _(by loadbalancer type)_ | Terraform resources |
| ---------------- | ---------------------------------------------- | ------------------- |
| **user** cluster | Bundled [MetalLB](./abm_user_cluster_metallb/) | [google_gkeonprem_bare_metal_cluster](https://registry.terraform.io/providers/hashicorp/google-beta/latest/docs/resources/gkeonprem_bare_metal_cluster) </br> [google_gkeonprem_vmware_node_pool](https://registry.terraform.io/providers/hashicorp/google-beta/latest/docs/resources/gkeonprem_vmware_node_pool) |

---

#### Anthos clusters on VMware (AVMware)

| Type | Sample _(by loadbalancer type)_ | Terraform resources |
| ---------------- | ----------------------------------------------- | ------------------- |
| **user** cluster | Bundled [MetalLB](./avmw_user_cluster_metallb/) | [google_gkeonprem_vmware_cluster](https://registry.terraform.io/providers/hashicorp/google-beta/latest/docs/resources/gkeonprem_vmware_cluster) </br> [google_gkeonprem_vmware_node_pool](https://registry.terraform.io/providers/hashicorp/google-beta/latest/docs/resources/gkeonprem_vmware_node_pool) |

---
99 changes: 99 additions & 0 deletions anthos-onprem-terraform/abm_user_cluster_metallb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
## Create Anthos on bare metal **user** clusters (MetalLB) with Terraform

The steps here acheive the same result as what is explained in the
[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)
public documentation. We show an example of how to create an Anthos on bare
metal **user cluster** with **MetalLB** using the Google provider for Terraform.

The sample here has a prerequisite step of creating an **admin cluster** using
the [script available in this repository](/anthos-bm-gcp-bash/install_admin_cluster.sh).
Thus, the default variables _(especially IP addresses)_ used in this sample are
based on the assumption that the admin cluster and the GCE VM based bare metal
infrstructure for the user cluster was created using that script. If you
already have an **admin cluster and bare metal nodes for the user cluster**, you
may skip running this script. However, you will have to update the sample to use
values appropriate to your environment.

---
### Prerequisite

#### Create admin cluster and VMs for user cluster

> **Note:** If you already have an admin cluster and the bare metal nodes for
> a new user cluster, then you can skip this step. But don't forget to update
> the sample with the values appropriate to your environment.
- First you will have to create an admin cluster that will manage your user
cluster. At the time of writing this guide, admin cluster creation
**using Terraform** is not supported.

- Follow the [instructions here](/anthos-bm-gcp-bash/docs/admin.md) to create an
admin cluster and to provision the GCE VMs for the user cluster using the
[install_admin_cluster.sh](/anthos-bm-gcp-bash/install_admin_cluster.sh)
script.

- Upon completion, you will see the node information for the GCE VMs printed on
screen.

```sh
|---------------------------------------------------------------------------------------------------------|
| VM Name | L2 Network IP (VxLAN) | INFO |
|---------------------------------------------------------------------------------------------------------|
| abm-admin-cluster-cp1 | 10.200.0.3 | Has control plane of admin cluster running inside |
| abm-user-cluster-cp1 | 10.200.0.4 | 🌟 Ready for use as control plane for the user cluster |
| abm-user-cluster-w1 | 10.200.0.5 | 🌟 Ready for use as worker for the user cluster |
| abm-user-cluster-w2 | 10.200.0.6 | 🌟 Ready for use as worker for the user cluster |
|---------------------------------------------------------------------------------------------------------|
```

#### Create the user cluster with terraform

The steps that follow assumes that you already have this repo cloned locally and
have changed directory to where this samples is:
`<REPO_ROOT_DIR>/anthos-onprem-terraform/abm_user_cluster_metallb`.

- Make a copy of the `terraform.tfvars.sample` file:

```sh
cp terraform.tfvars.sample terraform.tfvars
```
The sample terraform vaiables file has most of the default values filled in
based on the output of the [install_admin_cluster.sh](/anthos-bm-gcp-bash/install_admin_cluster.sh)
script from the previous section.

- Update missing variables in the `terraform.tfvars` file:
- **`project_id`**: The GCP project of the admin cluster and where the user
cluster will be created.
- **`region`**: The Google Cloud region in which the Anthos On-Prem API
runs.
- **`admin_cluster_name`**: The name of the admin cluster that will manage the
new user cluster. If you used the [install_admin_cluster.sh](/anthos-bm-gcp-bash/install_admin_cluster.sh)
script and used the default name, then this must be `abm-admin-cluster`.
- **`bare_metal_version`**: The Anthos clusters on bare metal version for
your user cluster. This must be same as the admin cluster version or one
minor version less, at most. It cannot be higher in any case - minor or
patch.

- **`admin_user_emails`**: List of GCP accounts that must be given
administrator rights on the user cluster.

- Execute terraform:

```sh
terraform init
```
```sh
terraform plan
```
```sh
terraform apply
```

Once completed you will see an output as follows:
```sh
...
```

You can view your user cluster in the
[Anthos clusters page](https://console.cloud.google.com/anthos/clusters).
Loading

0 comments on commit 0ae123d

Please sign in to comment.