From 40ace4e1d77be8323369b2075fb2d8a6eae4820d Mon Sep 17 00:00:00 2001 From: shabirmean Date: Fri, 21 Oct 2022 20:00:25 -0400 Subject: [PATCH 1/7] feature: add admin cluster script --- anthos-bm-gcp-bash/README.md | 122 +------ anthos-bm-gcp-bash/docs/admin.md | 119 +++++++ anthos-bm-gcp-bash/{FAQ.md => docs/faq.md} | 4 +- anthos-bm-gcp-bash/docs/hybrid.md | 117 +++++++ anthos-bm-gcp-bash/install_admin_cluster.sh | 315 +++++++++++++++++++ anthos-bm-gcp-bash/install_hybrid_cluster.sh | 300 ++++++++++++++++++ 6 files changed, 861 insertions(+), 116 deletions(-) create mode 100644 anthos-bm-gcp-bash/docs/admin.md rename anthos-bm-gcp-bash/{FAQ.md => docs/faq.md} (91%) create mode 100644 anthos-bm-gcp-bash/docs/hybrid.md create mode 100644 anthos-bm-gcp-bash/install_admin_cluster.sh create mode 100644 anthos-bm-gcp-bash/install_hybrid_cluster.sh diff --git a/anthos-bm-gcp-bash/README.md b/anthos-bm-gcp-bash/README.md index 07f0183d..7b30e882 100644 --- a/anthos-bm-gcp-bash/README.md +++ b/anthos-bm-gcp-bash/README.md @@ -1,123 +1,17 @@ ## Anthos Baremetal on Google Compute Engine VMs -This sample shows you how to setup an Anthos clusters on bare metal in High -Availability (HA) mode using Compute Engine Virtual Machines (VMs). The -[setup_and_install_abm](./setup_and_install_abm.sh) script encapsulates all -the steps required to setup the Compute Engine VMs and to trigger the -installation of Anthos on bare metal. Follow the -[Try Anthos clusters on bare metal on Compute Engine VMs](https://cloud.google.com/anthos/clusters/docs/bare-metal/latest/try/gce-vms) guide for a step by step -explanation of all the steps included in this script. +The scripts here show how to setup various types of +_(e.g. hybrid, admin, user, standalone)_ Anthos clusters on bare metal in +Compute Engine Virtual Machines (VMs). Select the guide for the type of cluster +you want to install and follow the guide. +- [Setup and install a **hybrid** Anthos on bare metal cluster](./docs/admin.md) +- [Setup and install a **admin** Anthos on bare metal cluster](./docs/hybrid.md) -### Prerequisites - -- A workstation with access to the Internet _(i.e. Google Cloud APIs)_ with the following installed - - [Git](https://git-scm.com/) - - [Google Cloud SDK (gcloud CLI)](https://cloud.google.com/sdk/docs/install) -- 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)_ -- The gcloud CLI must be [authenticated to Google Cloud and be configured to use - the Google Cloud Project](https://cloud.google.com/sdk/gcloud/reference/init) you intend to use --- -### Quickstart - The steps inside the script is written with the assumption that you are working with a Google Cloud Project that has most of the default settings. This is to keep the different customizations to a minimal and allow for anyone to start at this baseline and make changes as required. Based on the popularity of certain -variations, information about them are explained in the [FAQ](./FAQ.md) section. - -1. Clone this repo into the workstation from where the rest of this guide will - be followed. - - ```sh - git clone https://github.com/GoogleCloudPlatform/anthos-samples - cd anthos-bm-gcp-bash - ``` - -2. Setup environment variables. - ```sh - export PROJECT_ID= - export ZONE= - ``` - -3. Run the installation script. - - ```sh - bash setup_and_install_abm.sh - ``` - ```sh - # expected output - ... - ... - ... - āœ… Successfully set up SSH access from admin workstation to cluster node VMs. - - šŸ”„ Installing Anthos on bare metal... - Your active configuration is: [shabir-shell-check2] - Pseudo-terminal will not be allocated because stdin is not a terminal. - Enter passphrase for key '/Users/shabirmean/.ssh/google_compute_engine': - Welcome to Ubuntu 20.04.5 LTS (GNU/Linux 5.15.0-1018-gcp x86_64) - - * Documentation: https://help.ubuntu.com - * Management: https://landscape.canonical.com - * Support: https://ubuntu.com/advantage - - System information as of Tue Oct 4 19:09:07 UTC 2022 - - System load: 0.39 Users logged in: 0 - Usage of /: 1.3% of 193.65GB IPv4 address for docker0: 172.17.0.1 - Memory usage: 1% IPv4 address for ens4: 10.128.0.2 - Swap usage: 0% IPv4 address for vxlan0: 10.200.0.2 - Processes: 153 - - - 0 updates can be applied immediately. - - New release '22.04.1 LTS' available. - Run 'do-release-upgrade' to upgrade to it. - - - + export PROJECT_ID=shabir-shell-check2 - + PROJECT_ID=shabir-shell-check2 - + export clusterid=cluster-1 - + clusterid=cluster-1 - + bmctl create config -c cluster-1 - [2022-10-04 19:09:08+0000] Created config: bmctl-workspace/cluster-1/cluster-1.yaml - + cat - + bmctl create cluster -c cluster-1 - Please check the logs at bmctl-workspace/cluster-1/log/create-cluster-20221004-190908/create-cluster.log - [2022-10-04 19:09:14+0000] Creating bootstrap cluster... OK - [2022-10-04 19:10:24+0000] Installing dependency components... OK - [2022-10-04 19:11:51+0000] Waiting for preflight check job to finish... OK - [2022-10-04 19:13:51+0000] - Validation Category: machines and network - [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.5 - [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.6 - [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.7 - [2022-10-04 19:13:51+0000] - [PASSED] gcp - [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.4-gcp - [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.3-gcp - [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.4 - [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.5-gcp - [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.6-gcp - [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.7-gcp - [2022-10-04 19:13:51+0000] - [PASSED] node-network - [2022-10-04 19:13:51+0000] - [PASSED] pod-cidr - [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.3 - [2022-10-04 19:13:51+0000] Flushing logs... OK - [2022-10-04 19:13:53+0000] Applying resources for new cluster - [2022-10-04 19:13:53+0000] Waiting for cluster kubeconfig to become ready OK - [2022-10-04 19:17:03+0000] Writing kubeconfig file - [2022-10-04 19:17:03+0000] kubeconfig of cluster being created is present at bmctl-workspace/cluster-1/cluster-1-kubeconfig - [2022-10-04 19:17:03+0000] Please restrict access to this file as it contains authentication credentials of your cluster. - [2022-10-04 19:17:03+0000] Waiting for cluster to become ready OK - [2022-10-04 19:23:43+0000] Please run - [2022-10-04 19:23:43+0000] kubectl --kubeconfig bmctl-workspace/cluster-1/cluster-1-kubeconfig get nodes - [2022-10-04 19:23:43+0000] to get cluster nodes status. - [2022-10-04 19:23:43+0000] Waiting for node pools to become ready OK - [2022-10-04 19:24:03+0000] Waiting for metrics to become ready in GCP OK - [2022-10-04 19:24:13+0000] Moving admin cluster resources to the created admin cluster - [2022-10-04 19:24:20+0000] Waiting for node update jobs to finish OK - [2022-10-04 19:26:40+0000] Flushing logs... OK - [2022-10-04 19:26:40+0000] Deleting bootstrap cluster... OK - āœ… Installation complete. Please check the logs for any errors!!! - ``` +variations, information about them are explained in the [FAQ](./docs/faq.md) +section. \ No newline at end of file diff --git a/anthos-bm-gcp-bash/docs/admin.md b/anthos-bm-gcp-bash/docs/admin.md new file mode 100644 index 00000000..c1406e83 --- /dev/null +++ b/anthos-bm-gcp-bash/docs/admin.md @@ -0,0 +1,119 @@ +## Install an Anthos on bare metal cluster of type 'admin' + +This sample shows you how to setup an **admin** Anthos clusters on bare metal +in High Availability (HA) mode using Compute Engine Virtual Machines (VMs). The +[install_admin_cluster](/anthos-bm-gcp-bash/install_admin_cluster.sh) script +encapsulates all the steps required to setup the Compute Engine VMs and to +trigger the installation of the admin cluster. The steps used for setting up the +Compute Engine VM environment in this script are the same as the ones explained +in the [Try Anthos clusters on bare metal on Compute Engine VMs](https://cloud.google.com/anthos/clusters/docs/bare-metal/latest/try/gce-vms) guide. The only differences are the number +of Compute Engine VMs used and the cluster configuration file +_(which is specific to an admin cluster)_. + +### Prerequisites + +- A workstation with access to the Internet _(i.e. Google Cloud APIs)_ with the following installed + - [Git](https://git-scm.com/) + - [Google Cloud SDK (gcloud CLI)](https://cloud.google.com/sdk/docs/install) +- 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)_ +- The gcloud CLI must be [authenticated to Google Cloud and be configured to use + the Google Cloud Project](https://cloud.google.com/sdk/gcloud/reference/init) you intend to use +--- +### Quickstart + +1. Clone this repo into the workstation from where the rest of this guide will + be followed. + + ```sh + git clone https://github.com/GoogleCloudPlatform/anthos-samples + cd anthos-bm-gcp-bash + ``` + +2. Setup environment variables. + ```sh + export PROJECT_ID= + export ZONE= + export ADMIN_CLUSTER_NAME= + ``` + +3. Run the installation script. + + ```sh + bash install_admin_cluster.sh + ``` + ```sh + # expected output + ... + ... + ... + āœ… Successfully set up SSH access from admin workstation to cluster node VMs. + + šŸ”„ Installing Anthos on bare metal... + Your active configuration is: [shabir-shell-check2] + Pseudo-terminal will not be allocated because stdin is not a terminal. + Enter passphrase for key '/Users/shabirmean/.ssh/google_compute_engine': + Welcome to Ubuntu 20.04.5 LTS (GNU/Linux 5.15.0-1018-gcp x86_64) + + * Documentation: https://help.ubuntu.com + * Management: https://landscape.canonical.com + * Support: https://ubuntu.com/advantage + + System information as of Tue Oct 4 19:09:07 UTC 2022 + + System load: 0.39 Users logged in: 0 + Usage of /: 1.3% of 193.65GB IPv4 address for docker0: 172.17.0.1 + Memory usage: 1% IPv4 address for ens4: 10.128.0.2 + Swap usage: 0% IPv4 address for vxlan0: 10.200.0.2 + Processes: 153 + + + 0 updates can be applied immediately. + + New release '22.04.1 LTS' available. + Run 'do-release-upgrade' to upgrade to it. + + + + export PROJECT_ID=shabir-shell-check2 + + PROJECT_ID=shabir-shell-check2 + + export clusterid=cluster-1 + + clusterid=cluster-1 + + bmctl create config -c cluster-1 + [2022-10-04 19:09:08+0000] Created config: bmctl-workspace/cluster-1/cluster-1.yaml + + cat + + bmctl create cluster -c cluster-1 + Please check the logs at bmctl-workspace/cluster-1/log/create-cluster-20221004-190908/create-cluster.log + [2022-10-04 19:09:14+0000] Creating bootstrap cluster... OK + [2022-10-04 19:10:24+0000] Installing dependency components... OK + [2022-10-04 19:11:51+0000] Waiting for preflight check job to finish... OK + [2022-10-04 19:13:51+0000] - Validation Category: machines and network + [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.5 + [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.6 + [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.7 + [2022-10-04 19:13:51+0000] - [PASSED] gcp + [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.4-gcp + [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.3-gcp + [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.4 + [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.5-gcp + [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.6-gcp + [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.7-gcp + [2022-10-04 19:13:51+0000] - [PASSED] node-network + [2022-10-04 19:13:51+0000] - [PASSED] pod-cidr + [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.3 + [2022-10-04 19:13:51+0000] Flushing logs... OK + [2022-10-04 19:13:53+0000] Applying resources for new cluster + [2022-10-04 19:13:53+0000] Waiting for cluster kubeconfig to become ready OK + [2022-10-04 19:17:03+0000] Writing kubeconfig file + [2022-10-04 19:17:03+0000] kubeconfig of cluster being created is present at bmctl-workspace/cluster-1/cluster-1-kubeconfig + [2022-10-04 19:17:03+0000] Please restrict access to this file as it contains authentication credentials of your cluster. + [2022-10-04 19:17:03+0000] Waiting for cluster to become ready OK + [2022-10-04 19:23:43+0000] Please run + [2022-10-04 19:23:43+0000] kubectl --kubeconfig bmctl-workspace/cluster-1/cluster-1-kubeconfig get nodes + [2022-10-04 19:23:43+0000] to get cluster nodes status. + [2022-10-04 19:23:43+0000] Waiting for node pools to become ready OK + [2022-10-04 19:24:03+0000] Waiting for metrics to become ready in GCP OK + [2022-10-04 19:24:13+0000] Moving admin cluster resources to the created admin cluster + [2022-10-04 19:24:20+0000] Waiting for node update jobs to finish OK + [2022-10-04 19:26:40+0000] Flushing logs... OK + [2022-10-04 19:26:40+0000] Deleting bootstrap cluster... OK + āœ… Installation complete. Please check the logs for any errors!!! + ``` diff --git a/anthos-bm-gcp-bash/FAQ.md b/anthos-bm-gcp-bash/docs/faq.md similarity index 91% rename from anthos-bm-gcp-bash/FAQ.md rename to anthos-bm-gcp-bash/docs/faq.md index eb538861..8b39d3df 100644 --- a/anthos-bm-gcp-bash/FAQ.md +++ b/anthos-bm-gcp-bash/docs/faq.md @@ -38,8 +38,8 @@ to do the following changes: ``` 2. Update the command for creating Compute Engine VMs in the - [setup_and_install_abm](./setup_and_install_abm.sh) script to use the network - of your choice instead of `default`. + [install_hybrid_cluster](/anthos-bm-gcp-bash/install_admin_cluster.sh) script + to use the network of your choice instead of `default`. ```sh ... diff --git a/anthos-bm-gcp-bash/docs/hybrid.md b/anthos-bm-gcp-bash/docs/hybrid.md new file mode 100644 index 00000000..ca364f0e --- /dev/null +++ b/anthos-bm-gcp-bash/docs/hybrid.md @@ -0,0 +1,117 @@ +## Install an Anthos on bare metal cluster of type 'hybrid' + +This sample shows you how to setup an **hybrid** Anthos clusters on bare metal +in High Availability (HA) mode using Compute Engine Virtual Machines (VMs). The +[install_hybrid_cluster](/anthos-bm-gcp-bash/install_hybrid_cluster.sh) script +encapsulates all the steps required to setup the Compute Engine VMs and to +trigger the installation of Anthos on bare metal. Follow the +[Try Anthos clusters on bare metal on Compute Engine VMs](https://cloud.google.com/anthos/clusters/docs/bare-metal/latest/try/gce-vms) guide for a step by step +explanation of all the steps included in this script. + + +### Prerequisites + +- A workstation with access to the Internet _(i.e. Google Cloud APIs)_ with the following installed + - [Git](https://git-scm.com/) + - [Google Cloud SDK (gcloud CLI)](https://cloud.google.com/sdk/docs/install) +- 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)_ +- The gcloud CLI must be [authenticated to Google Cloud and be configured to use + the Google Cloud Project](https://cloud.google.com/sdk/gcloud/reference/init) you intend to use +--- +### Quickstart + +1. Clone this repo into the workstation from where the rest of this guide will + be followed. + + ```sh + git clone https://github.com/GoogleCloudPlatform/anthos-samples + cd anthos-bm-gcp-bash + ``` + +2. Setup environment variables. + ```sh + export PROJECT_ID= + export ZONE= + ``` + +3. Run the installation script. + + ```sh + bash install_hybrid_cluster.sh + ``` + ```sh + # expected output + ... + ... + ... + āœ… Successfully set up SSH access from admin workstation to cluster node VMs. + + šŸ”„ Installing Anthos on bare metal... + Your active configuration is: [shabir-shell-check2] + Pseudo-terminal will not be allocated because stdin is not a terminal. + Enter passphrase for key '/Users/shabirmean/.ssh/google_compute_engine': + Welcome to Ubuntu 20.04.5 LTS (GNU/Linux 5.15.0-1018-gcp x86_64) + + * Documentation: https://help.ubuntu.com + * Management: https://landscape.canonical.com + * Support: https://ubuntu.com/advantage + + System information as of Tue Oct 4 19:09:07 UTC 2022 + + System load: 0.39 Users logged in: 0 + Usage of /: 1.3% of 193.65GB IPv4 address for docker0: 172.17.0.1 + Memory usage: 1% IPv4 address for ens4: 10.128.0.2 + Swap usage: 0% IPv4 address for vxlan0: 10.200.0.2 + Processes: 153 + + + 0 updates can be applied immediately. + + New release '22.04.1 LTS' available. + Run 'do-release-upgrade' to upgrade to it. + + + + export PROJECT_ID=shabir-shell-check2 + + PROJECT_ID=shabir-shell-check2 + + export clusterid=cluster-1 + + clusterid=cluster-1 + + bmctl create config -c cluster-1 + [2022-10-04 19:09:08+0000] Created config: bmctl-workspace/cluster-1/cluster-1.yaml + + cat + + bmctl create cluster -c cluster-1 + Please check the logs at bmctl-workspace/cluster-1/log/create-cluster-20221004-190908/create-cluster.log + [2022-10-04 19:09:14+0000] Creating bootstrap cluster... OK + [2022-10-04 19:10:24+0000] Installing dependency components... OK + [2022-10-04 19:11:51+0000] Waiting for preflight check job to finish... OK + [2022-10-04 19:13:51+0000] - Validation Category: machines and network + [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.5 + [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.6 + [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.7 + [2022-10-04 19:13:51+0000] - [PASSED] gcp + [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.4-gcp + [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.3-gcp + [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.4 + [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.5-gcp + [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.6-gcp + [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.7-gcp + [2022-10-04 19:13:51+0000] - [PASSED] node-network + [2022-10-04 19:13:51+0000] - [PASSED] pod-cidr + [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.3 + [2022-10-04 19:13:51+0000] Flushing logs... OK + [2022-10-04 19:13:53+0000] Applying resources for new cluster + [2022-10-04 19:13:53+0000] Waiting for cluster kubeconfig to become ready OK + [2022-10-04 19:17:03+0000] Writing kubeconfig file + [2022-10-04 19:17:03+0000] kubeconfig of cluster being created is present at bmctl-workspace/cluster-1/cluster-1-kubeconfig + [2022-10-04 19:17:03+0000] Please restrict access to this file as it contains authentication credentials of your cluster. + [2022-10-04 19:17:03+0000] Waiting for cluster to become ready OK + [2022-10-04 19:23:43+0000] Please run + [2022-10-04 19:23:43+0000] kubectl --kubeconfig bmctl-workspace/cluster-1/cluster-1-kubeconfig get nodes + [2022-10-04 19:23:43+0000] to get cluster nodes status. + [2022-10-04 19:23:43+0000] Waiting for node pools to become ready OK + [2022-10-04 19:24:03+0000] Waiting for metrics to become ready in GCP OK + [2022-10-04 19:24:13+0000] Moving admin cluster resources to the created admin cluster + [2022-10-04 19:24:20+0000] Waiting for node update jobs to finish OK + [2022-10-04 19:26:40+0000] Flushing logs... OK + [2022-10-04 19:26:40+0000] Deleting bootstrap cluster... OK + āœ… Installation complete. Please check the logs for any errors!!! + ``` diff --git a/anthos-bm-gcp-bash/install_admin_cluster.sh b/anthos-bm-gcp-bash/install_admin_cluster.sh new file mode 100644 index 00000000..f157c95d --- /dev/null +++ b/anthos-bm-gcp-bash/install_admin_cluster.sh @@ -0,0 +1,315 @@ +#!/bin/bash +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if [[ -z "${PROJECT_ID}" ]]; then + printf "šŸšØ Environment variable PROJECT_ID not set. Set it to the Google Cloud Project you intend to use." + exit 1 +fi + +if [[ -z "${ZONE}" ]]; then + printf "šŸšØ Environment variable ZONE not set. Set it to the Google Cloud Zone where the resources must be created." + exit 1 +fi + +if [[ -z "${ADMIN_CLUSTER_NAME}" ]]; then + printf "šŸšØ Environment variable ADMIN_CLUSTER_NAME not set.\n" + while true; do + read -rp "šŸ’” Should the script continue with the default name - 'abm-admin-cluster'? " yn + case $yn in + [Yy]* ) ADMIN_CLUSTER_NAME="abm-admin-cluster"; break;; + [Nn]* ) exit 1;; + * ) echo "Please answer yes or no.";; + esac + done +fi + +printf "\nāœ… Using Project [%s], Zone [%s] and Cluster name [%s].\n\n" "$PROJECT_ID" "$ZONE" "$ADMIN_CLUSTER_NAME" + +# create the GCP Service Account to be used by Anthos on bare metal +printf "šŸ”„ Creating Service Account and Service Account key...\n" +# [START anthos_bm_gcp_bash_admin_create_sa] +gcloud iam service-accounts create baremetal-gcr + +gcloud iam service-accounts keys create bm-gcr.json \ + --iam-account=baremetal-gcr@"${PROJECT_ID}".iam.gserviceaccount.com +# [END anthos_bm_gcp_bash_admin_create_sa] +printf "āœ… Successfully created Service Account and downloaded key file.\n\n" + +# enable all the required APIs for Anthos on bare metal +printf "šŸ”„ Enabling GCP Service APIs...\n" +# [START anthos_bm_gcp_bash_admin_enable_api] +gcloud services enable \ + anthos.googleapis.com \ + anthosaudit.googleapis.com \ + anthosgke.googleapis.com \ + cloudresourcemanager.googleapis.com \ + connectgateway.googleapis.com \ + container.googleapis.com \ + gkeconnect.googleapis.com \ + gkehub.googleapis.com \ + serviceusage.googleapis.com \ + stackdriver.googleapis.com \ + monitoring.googleapis.com \ + logging.googleapis.com \ + opsconfigmonitoring.googleapis.com +# [END anthos_bm_gcp_bash_admin_enable_api] +printf "āœ… Successfully enabled GCP Service APIs.\n\n" + +# add all the required IAM roles to the Service Account +printf "šŸ”„ Adding IAM roles to the Service Account...\n" +# [START anthos_bm_gcp_bash_admin_add_iam_role] +gcloud projects add-iam-policy-binding "$PROJECT_ID" \ + --member="serviceAccount:baremetal-gcr@$PROJECT_ID.iam.gserviceaccount.com" \ + --role="roles/gkehub.connect" \ + --no-user-output-enabled + +gcloud projects add-iam-policy-binding "$PROJECT_ID" \ + --member="serviceAccount:baremetal-gcr@$PROJECT_ID.iam.gserviceaccount.com" \ + --role="roles/gkehub.admin" \ + --no-user-output-enabled + +gcloud projects add-iam-policy-binding "$PROJECT_ID" \ + --member="serviceAccount:baremetal-gcr@$PROJECT_ID.iam.gserviceaccount.com" \ + --role="roles/logging.logWriter" \ + --no-user-output-enabled + +gcloud projects add-iam-policy-binding "$PROJECT_ID" \ + --member="serviceAccount:baremetal-gcr@$PROJECT_ID.iam.gserviceaccount.com" \ + --role="roles/monitoring.metricWriter" \ + --no-user-output-enabled + +gcloud projects add-iam-policy-binding "$PROJECT_ID" \ + --member="serviceAccount:baremetal-gcr@$PROJECT_ID.iam.gserviceaccount.com" \ + --role="roles/monitoring.dashboardEditor" \ + --no-user-output-enabled + +gcloud projects add-iam-policy-binding "$PROJECT_ID" \ + --member="serviceAccount:baremetal-gcr@$PROJECT_ID.iam.gserviceaccount.com" \ + --role="roles/stackdriver.resourceMetadata.writer" \ + --no-user-output-enabled + +gcloud projects add-iam-policy-binding "$PROJECT_ID" \ + --member="serviceAccount:baremetal-gcr@$PROJECT_ID.iam.gserviceaccount.com" \ + --role="roles/opsconfigmonitoring.resourceMetadata.writer" \ + --no-user-output-enabled +# [END anthos_bm_gcp_bash_admin_add_iam_role] +printf "āœ… Successfully added the requires IAM roles to the Service Account.\n\n" + +# declare arrays for VM names and IPs +printf "šŸ”„ Setting up array variables for the VM names and IP addresses...\n" +# [START anthos_bm_gcp_bash_admin_vms_array] +MACHINE_TYPE=n1-standard-8 +VM_PREFIX=abm +VM_WS=$VM_PREFIX-ws +VM_ADMIN_CP=$VM_PREFIX-admin-cluster-cp +VM_USER_CP=$VM_PREFIX-user-cluster-cp +VM_USER_W1=$VM_PREFIX-user-cluster-w1 +VM_USER_W2=$VM_PREFIX-user-cluster-w2 +declare -a VMs=("$VM_WS" "$VM_ADMIN_CP" "$VM_USER_CP" "$VM_USER_W1" "$VM_USER_W2") +declare -a IPs=() +# [END anthos_bm_gcp_bash_admin_vms_array] +printf "āœ… Variables for the VM names and IP addresses setup.\n\n" + +# create GCE VMs +printf "šŸ”„ Creating GCE VMs...\n" +# [START anthos_bm_gcp_bash_admin_create_vm] +for vm in "${VMs[@]}" +do + gcloud compute instances create "$vm" \ + --image-family=ubuntu-2004-lts --image-project=ubuntu-os-cloud \ + --zone="${ZONE}" \ + --boot-disk-size 200G \ + --boot-disk-type pd-ssd \ + --can-ip-forward \ + --network default \ + --tags http-server,https-server \ + --min-cpu-platform "Intel Haswell" \ + --scopes cloud-platform \ + --machine-type "$MACHINE_TYPE" \ + --metadata "cluster_id=${ADMIN_CLUSTER_NAME}" + IP=$(gcloud compute instances describe "$vm" --zone "${ZONE}" \ + --format='get(networkInterfaces[0].networkIP)') + IPs+=("$IP") +done +# [END anthos_bm_gcp_bash_admin_create_vm] +printf "āœ… Successfully created GCE VMs.\n\n" + +# verify SSH access to the Google Compute Engine VMs +printf "šŸ”„ Checking SSH access to the GCE VMs...\n" +# [START anthos_bm_gcp_bash_admin_check_ssh] +for vm in "${VMs[@]}" +do + while ! gcloud compute ssh root@"$vm" --zone "${ZONE}" --command "printf SSH to $vm succeeded" + do + printf "Trying to SSH into %s failed. Sleeping for 5 seconds. zzzZZzzZZ" "$vm" + sleep 5 + done +done +# [END anthos_bm_gcp_bash_admin_check_ssh] +printf "āœ… Successfully connected to all the GCE VMs using SSH.\n\n" + +# setup VxLAN configurations in all the VMs to enable L2-network connectivity +# between them +printf "šŸ”„ Setting up VxLAN in the GCE VMs...\n" +# [START anthos_bm_gcp_bash_admin_add_vxlan] +i=2 # We start from 10.200.0.2/24 +for vm in "${VMs[@]}" +do + gcloud compute ssh root@"$vm" --zone "${ZONE}" << EOF + apt-get -qq update > /dev/null + apt-get -qq install -y jq > /dev/null + set -x + ip link add vxlan0 type vxlan id 42 dev ens4 dstport 0 + current_ip=\$(ip --json a show dev ens4 | jq '.[0].addr_info[0].local' -r) + printf "VM IP address is: \$current_ip" + for ip in ${IPs[@]}; do + if [ "\$ip" != "\$current_ip" ]; then + bridge fdb append to 00:00:00:00:00:00 dst \$ip dev vxlan0 + fi + done + ip addr add 10.200.0.$i/24 dev vxlan0 + ip link set up dev vxlan0 + +EOF + i=$((i+1)) +done +# [END anthos_bm_gcp_bash_admin_add_vxlan] +printf "āœ… Successfully setup VxLAN in the GCE VMs.\n\n" + +# install the necessary tools inside the VMs +printf "šŸ”„ Setting up admin workstation...\n" +# [START anthos_bm_gcp_bash_admin_init_vm] +gcloud compute ssh root@$VM_WS --zone "${ZONE}" << EOF +set -x + +export PROJECT_ID=\$(gcloud config get-value project) + +gcloud iam service-accounts keys create bm-gcr.json \ + --iam-account=baremetal-gcr@\${PROJECT_ID}.iam.gserviceaccount.com + +curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" + +chmod +x kubectl +mv kubectl /usr/local/sbin/ +mkdir baremetal && cd baremetal +gsutil cp gs://anthos-baremetal-release/bmctl/1.13.0/linux-amd64/bmctl . +chmod a+x bmctl +mv bmctl /usr/local/sbin/ + +cd ~ +printf "Installing docker" +curl -fsSL https://get.docker.com -o get-docker.sh +sh get-docker.sh +EOF +# [END anthos_bm_gcp_bash_admin_init_vm] +printf "āœ… Successfully set up admin workstation.\n\n" + +# generate SSH key-pair in the admin workstation VM and copy the public-key +# to all the other (control-plane and worker) VMs +printf "šŸ”„ Setting up SSH access from admin workstation to cluster node VMs...\n" +# [START anthos_bm_gcp_bash_admin_add_ssh_keys] +gcloud compute ssh root@$VM_WS --zone "${ZONE}" << EOF +set -x +ssh-keygen -t rsa -N "" -f /root/.ssh/id_rsa +sed 's/ssh-rsa/root:ssh-rsa/' ~/.ssh/id_rsa.pub > ssh-metadata +for vm in ${VMs[@]} +do + gcloud compute instances add-metadata \$vm --zone ${ZONE} --metadata-from-file ssh-keys=ssh-metadata +done +EOF +# [END anthos_bm_gcp_bash_admin_add_ssh_keys] +printf "āœ… Successfully set up SSH access from admin workstation to cluster node VMs.\n\n" + +# initiate Anthos on bare metal installation from the admin workstation +printf "šŸ”„ Installing Anthos on bare metal...\n" +# [START anthos_bm_gcp_bash_admin_install_abm] +gcloud compute ssh root@$VM_WS --zone "${ZONE}" < bmctl-workspace/\$ADMIN_CLUSTER_NAME/\$ADMIN_CLUSTER_NAME.yaml << EOB +--- +gcrKeyPath: /root/bm-gcr.json +sshPrivateKeyPath: /root/.ssh/id_rsa +gkeConnectAgentServiceAccountKeyPath: /root/bm-gcr.json +gkeConnectRegisterServiceAccountKeyPath: /root/bm-gcr.json +cloudOperationsServiceAccountKeyPath: /root/bm-gcr.json +--- +apiVersion: v1 +kind: Namespace +metadata: + name: cluster-\$ADMIN_CLUSTER_NAME +--- +apiVersion: baremetal.cluster.gke.io/v1 +kind: Cluster +metadata: + name: \$ADMIN_CLUSTER_NAME + namespace: cluster-\$ADMIN_CLUSTER_NAME +spec: + type: admin + anthosBareMetalVersion: 1.13.0 + gkeConnect: + projectID: \$PROJECT_ID + controlPlane: + nodePoolSpec: + clusterName: \$ADMIN_CLUSTER_NAME + nodes: + - address: 10.200.0.3 + clusterNetwork: + pods: + cidrBlocks: + - 192.168.0.0/16 + services: + cidrBlocks: + - 172.26.232.0/24 + loadBalancer: + mode: bundled + ports: + controlPlaneLBPort: 443 + vips: + controlPlaneVIP: 10.200.0.48 + clusterOperations: + # might need to be this location + location: us-central1 + projectID: \$PROJECT_ID + storage: + lvpNodeMounts: + path: /mnt/localpv-disk + storageClassName: node-disk + lvpShare: + numPVUnderSharedPath: 5 + path: /mnt/localpv-share + storageClassName: local-shared + nodeConfig: + podDensity: + maxPodsPerNode: 250 +EOB + +bmctl create cluster -c \$ADMIN_CLUSTER_NAME +EOF +# [END anthos_bm_gcp_bash_admin_install_abm] + +printf "āœ… Installation complete. Please check the logs for any errors!!!\n\n" +printf "āœ… If you do not see any errors in the output log, then you now have the following setup:\n\n" +printf "|---------------------------------------------------------------------------------------------------------|\n" +printf "| VM Name | L2 Network IP (VxLAN) | INFO |\n" +printf "|---------------------------------------------------------------------------------------------------------|\n" +printf "| abm-admin-cluster-cp1 | 10.200.0.3 | Has control plane of admin cluster running inside |\n" +printf "| abm-user-cluster-cp1 | 10.200.0.4 | šŸŒŸ Ready for use as control plane for the user cluster |\n" +printf "| abm-user-cluster-w1 | 10.200.0.5 | šŸŒŸ Ready for use as worker for the user cluster |\n" +printf "| abm-user-cluster-w2 | 10.200.0.6 | šŸŒŸ Ready for use as worker for the user cluster |\n" +printf "|---------------------------------------------------------------------------------------------------------|\n\n" diff --git a/anthos-bm-gcp-bash/install_hybrid_cluster.sh b/anthos-bm-gcp-bash/install_hybrid_cluster.sh new file mode 100644 index 00000000..ae61626d --- /dev/null +++ b/anthos-bm-gcp-bash/install_hybrid_cluster.sh @@ -0,0 +1,300 @@ +#!/bin/bash +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +printf "āœ… Using Project [%s] and Zone [%s].\n\n" "$PROJECT_ID" "$ZONE" + +# create the GCP Service Account to be used by Anthos on bare metal +printf "šŸ”„ Creating Service Account and Service Account key...\n" +# [START anthos_bm_gcp_bash_hybrid_create_sa] +gcloud iam service-accounts create baremetal-gcr + +gcloud iam service-accounts keys create bm-gcr.json \ + --iam-account=baremetal-gcr@"${PROJECT_ID}".iam.gserviceaccount.com +# [END anthos_bm_gcp_bash_hybrid_create_sa] +printf "āœ… Successfully created Service Account and downloaded key file.\n\n" + +# enable all the required APIs for Anthos on bare metal +printf "šŸ”„ Enabling GCP Service APIs...\n" +# [START anthos_bm_gcp_bash_hybrid_enable_api] +gcloud services enable \ + anthos.googleapis.com \ + anthosaudit.googleapis.com \ + anthosgke.googleapis.com \ + cloudresourcemanager.googleapis.com \ + connectgateway.googleapis.com \ + container.googleapis.com \ + gkeconnect.googleapis.com \ + gkehub.googleapis.com \ + serviceusage.googleapis.com \ + stackdriver.googleapis.com \ + monitoring.googleapis.com \ + logging.googleapis.com \ + opsconfigmonitoring.googleapis.com +# [END anthos_bm_gcp_bash_hybrid_enable_api] +printf "āœ… Successfully enabled GCP Service APIs.\n\n" + +# add all the required IAM roles to the Service Account +printf "šŸ”„ Adding IAM roles to the Service Account...\n" +# [START anthos_bm_gcp_bash_hybrid_add_iam_role] +gcloud projects add-iam-policy-binding "$PROJECT_ID" \ + --member="serviceAccount:baremetal-gcr@$PROJECT_ID.iam.gserviceaccount.com" \ + --role="roles/gkehub.connect" \ + --no-user-output-enabled + +gcloud projects add-iam-policy-binding "$PROJECT_ID" \ + --member="serviceAccount:baremetal-gcr@$PROJECT_ID.iam.gserviceaccount.com" \ + --role="roles/gkehub.admin" \ + --no-user-output-enabled + +gcloud projects add-iam-policy-binding "$PROJECT_ID" \ + --member="serviceAccount:baremetal-gcr@$PROJECT_ID.iam.gserviceaccount.com" \ + --role="roles/logging.logWriter" \ + --no-user-output-enabled + +gcloud projects add-iam-policy-binding "$PROJECT_ID" \ + --member="serviceAccount:baremetal-gcr@$PROJECT_ID.iam.gserviceaccount.com" \ + --role="roles/monitoring.metricWriter" \ + --no-user-output-enabled + +gcloud projects add-iam-policy-binding "$PROJECT_ID" \ + --member="serviceAccount:baremetal-gcr@$PROJECT_ID.iam.gserviceaccount.com" \ + --role="roles/monitoring.dashboardEditor" \ + --no-user-output-enabled + +gcloud projects add-iam-policy-binding "$PROJECT_ID" \ + --member="serviceAccount:baremetal-gcr@$PROJECT_ID.iam.gserviceaccount.com" \ + --role="roles/stackdriver.resourceMetadata.writer" \ + --no-user-output-enabled + +gcloud projects add-iam-policy-binding "$PROJECT_ID" \ + --member="serviceAccount:baremetal-gcr@$PROJECT_ID.iam.gserviceaccount.com" \ + --role="roles/opsconfigmonitoring.resourceMetadata.writer" \ + --no-user-output-enabled +# [END anthos_bm_gcp_bash_hybrid_add_iam_role] +printf "āœ… Successfully added the requires IAM roles to the Service Account.\n\n" + +# declare arrays for VM names and IPs +printf "šŸ”„ Setting up array variables for the VM names and IP addresses...\n" +# [START anthos_bm_gcp_bash_hybrid_vms_array] +MACHINE_TYPE=n1-standard-8 +VM_PREFIX=abm +VM_WS=$VM_PREFIX-ws +VM_CP1=$VM_PREFIX-cp1 +VM_CP2=$VM_PREFIX-cp2 +VM_CP3=$VM_PREFIX-cp3 +VM_W1=$VM_PREFIX-w1 +VM_W2=$VM_PREFIX-w2 +declare -a VMs=("$VM_WS" "$VM_CP1" "$VM_CP2" "$VM_CP3" "$VM_W1" "$VM_W2") +declare -a IPs=() +# [END anthos_bm_gcp_bash_hybrid_vms_array] +printf "āœ… Variables for the VM names and IP addresses setup.\n\n" + +# create GCE VMs +printf "šŸ”„ Creating GCE VMs...\n" +# [START anthos_bm_gcp_bash_hybrid_create_vm] +for vm in "${VMs[@]}" +do + gcloud compute instances create "$vm" \ + --image-family=ubuntu-2004-lts --image-project=ubuntu-os-cloud \ + --zone="${ZONE}" \ + --boot-disk-size 200G \ + --boot-disk-type pd-ssd \ + --can-ip-forward \ + --network default \ + --tags http-server,https-server \ + --min-cpu-platform "Intel Haswell" \ + --scopes cloud-platform \ + --machine-type "$MACHINE_TYPE" + IP=$(gcloud compute instances describe "$vm" --zone "${ZONE}" \ + --format='get(networkInterfaces[0].networkIP)') + IPs+=("$IP") +done +# [END anthos_bm_gcp_bash_hybrid_create_vm] +printf "āœ… Successfully created GCE VMs.\n\n" + +# verify SSH access to the Google Compute Engine VMs +printf "šŸ”„ Checking SSH access to the GCE VMs...\n" +# [START anthos_bm_gcp_bash_hybrid_check_ssh] +for vm in "${VMs[@]}" +do + while ! gcloud compute ssh root@"$vm" --zone "${ZONE}" --command "printf SSH to $vm succeeded" + do + printf "Trying to SSH into %s failed. Sleeping for 5 seconds. zzzZZzzZZ" "$vm" + sleep 5 + done +done +# [END anthos_bm_gcp_bash_hybrid_check_ssh] +printf "āœ… Successfully connected to all the GCE VMs using SSH.\n\n" + +# setup VxLAN configurations in all the VMs to enable L2-network connectivity +# between them +printf "šŸ”„ Setting up VxLAN in the GCE VMs...\n" +# [START anthos_bm_gcp_bash_hybrid_add_vxlan] +i=2 # We start from 10.200.0.2/24 +for vm in "${VMs[@]}" +do + gcloud compute ssh root@"$vm" --zone "${ZONE}" << EOF + apt-get -qq update > /dev/null + apt-get -qq install -y jq > /dev/null + set -x + ip link add vxlan0 type vxlan id 42 dev ens4 dstport 0 + current_ip=\$(ip --json a show dev ens4 | jq '.[0].addr_info[0].local' -r) + printf "VM IP address is: \$current_ip" + for ip in ${IPs[@]}; do + if [ "\$ip" != "\$current_ip" ]; then + bridge fdb append to 00:00:00:00:00:00 dst \$ip dev vxlan0 + fi + done + ip addr add 10.200.0.$i/24 dev vxlan0 + ip link set up dev vxlan0 + +EOF + i=$((i+1)) +done +# [END anthos_bm_gcp_bash_hybrid_add_vxlan] +printf "āœ… Successfully setup VxLAN in the GCE VMs.\n\n" + +# install the necessary tools inside the VMs +printf "šŸ”„ Setting up admin workstation...\n" +# [START anthos_bm_gcp_bash_hybrid_init_vm] +gcloud compute ssh root@$VM_WS --zone "${ZONE}" << EOF +set -x + +export PROJECT_ID=\$(gcloud config get-value project) + +gcloud iam service-accounts keys create bm-gcr.json \ + --iam-account=baremetal-gcr@\${PROJECT_ID}.iam.gserviceaccount.com + +curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" + +chmod +x kubectl +mv kubectl /usr/local/sbin/ +mkdir baremetal && cd baremetal +gsutil cp gs://anthos-baremetal-release/bmctl/1.13.0/linux-amd64/bmctl . +chmod a+x bmctl +mv bmctl /usr/local/sbin/ + +cd ~ +printf "Installing docker" +curl -fsSL https://get.docker.com -o get-docker.sh +sh get-docker.sh +EOF +# [END anthos_bm_gcp_bash_hybrid_init_vm] +printf "āœ… Successfully set up admin workstation.\n\n" + +# generate SSH key-pair in the admin workstation VM and copy the public-key +# to all the other (control-plane and worker) VMs +printf "šŸ”„ Setting up SSH access from admin workstation to cluster node VMs...\n" +# [START anthos_bm_gcp_bash_hybrid_add_ssh_keys] +gcloud compute ssh root@$VM_WS --zone "${ZONE}" << EOF +set -x +ssh-keygen -t rsa -N "" -f /root/.ssh/id_rsa +sed 's/ssh-rsa/root:ssh-rsa/' ~/.ssh/id_rsa.pub > ssh-metadata +for vm in ${VMs[@]} +do + gcloud compute instances add-metadata \$vm --zone ${ZONE} --metadata-from-file ssh-keys=ssh-metadata +done +EOF +# [END anthos_bm_gcp_bash_hybrid_add_ssh_keys] +printf "āœ… Successfully set up SSH access from admin workstation to cluster node VMs.\n\n" + +# initiate Anthos on bare metal installation from the admin workstation +printf "šŸ”„ Installing Anthos on bare metal...\n" +# [START anthos_bm_gcp_bash_hybrid_install_abm] +gcloud compute ssh root@$VM_WS --zone "${ZONE}" < bmctl-workspace/\$clusterid/\$clusterid.yaml << EOB +--- +gcrKeyPath: /root/bm-gcr.json +sshPrivateKeyPath: /root/.ssh/id_rsa +gkeConnectAgentServiceAccountKeyPath: /root/bm-gcr.json +gkeConnectRegisterServiceAccountKeyPath: /root/bm-gcr.json +cloudOperationsServiceAccountKeyPath: /root/bm-gcr.json +--- +apiVersion: v1 +kind: Namespace +metadata: + name: cluster-\$clusterid +--- +apiVersion: baremetal.cluster.gke.io/v1 +kind: Cluster +metadata: + name: \$clusterid + namespace: cluster-\$clusterid +spec: + type: hybrid + anthosBareMetalVersion: 1.13.0 + gkeConnect: + projectID: \$PROJECT_ID + controlPlane: + nodePoolSpec: + clusterName: \$clusterid + nodes: + - address: 10.200.0.3 + - address: 10.200.0.4 + - address: 10.200.0.5 + clusterNetwork: + pods: + cidrBlocks: + - 192.168.0.0/16 + services: + cidrBlocks: + - 172.26.232.0/24 + loadBalancer: + mode: bundled + ports: + controlPlaneLBPort: 443 + vips: + controlPlaneVIP: 10.200.0.49 + ingressVIP: 10.200.0.50 + addressPools: + - name: pool1 + addresses: + - 10.200.0.50-10.200.0.70 + clusterOperations: + # might need to be this location + location: us-central1 + projectID: \$PROJECT_ID + storage: + lvpNodeMounts: + path: /mnt/localpv-disk + storageClassName: node-disk + lvpShare: + numPVUnderSharedPath: 5 + path: /mnt/localpv-share + storageClassName: local-shared + nodeConfig: + podDensity: + maxPodsPerNode: 250 +--- +apiVersion: baremetal.cluster.gke.io/v1 +kind: NodePool +metadata: + name: node-pool-1 + namespace: cluster-\$clusterid +spec: + clusterName: \$clusterid + nodes: + - address: 10.200.0.6 + - address: 10.200.0.7 +EOB + +bmctl create cluster -c \$clusterid +EOF +# [END anthos_bm_gcp_bash_hybrid_install_abm] +printf "āœ… Installation complete. Please check the logs for any errors!!!\n\n" From 9942d2a7a02ec3351341f69fb8abeaee4f3f24c1 Mon Sep 17 00:00:00 2001 From: shabirmean Date: Fri, 21 Oct 2022 20:10:51 -0400 Subject: [PATCH 2/7] fix: pr ncomments --- anthos-bm-gcp-bash/docs/admin.md | 4 ++-- anthos-bm-gcp-bash/docs/hybrid.md | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/anthos-bm-gcp-bash/docs/admin.md b/anthos-bm-gcp-bash/docs/admin.md index c1406e83..ce7b5853 100644 --- a/anthos-bm-gcp-bash/docs/admin.md +++ b/anthos-bm-gcp-bash/docs/admin.md @@ -26,7 +26,7 @@ _(which is specific to an admin cluster)_. ```sh git clone https://github.com/GoogleCloudPlatform/anthos-samples - cd anthos-bm-gcp-bash + cd anthos-samples/anthos-bm-gcp-bash ``` 2. Setup environment variables. @@ -51,7 +51,7 @@ _(which is specific to an admin cluster)_. šŸ”„ Installing Anthos on bare metal... Your active configuration is: [shabir-shell-check2] Pseudo-terminal will not be allocated because stdin is not a terminal. - Enter passphrase for key '/Users/shabirmean/.ssh/google_compute_engine': + Enter passphrase for key '/Users/sundarpichai/.ssh/google_compute_engine': Welcome to Ubuntu 20.04.5 LTS (GNU/Linux 5.15.0-1018-gcp x86_64) * Documentation: https://help.ubuntu.com diff --git a/anthos-bm-gcp-bash/docs/hybrid.md b/anthos-bm-gcp-bash/docs/hybrid.md index ca364f0e..40038aac 100644 --- a/anthos-bm-gcp-bash/docs/hybrid.md +++ b/anthos-bm-gcp-bash/docs/hybrid.md @@ -25,7 +25,7 @@ explanation of all the steps included in this script. ```sh git clone https://github.com/GoogleCloudPlatform/anthos-samples - cd anthos-bm-gcp-bash + cd anthos-samples/anthos-bm-gcp-bash ``` 2. Setup environment variables. @@ -47,9 +47,9 @@ explanation of all the steps included in this script. āœ… Successfully set up SSH access from admin workstation to cluster node VMs. šŸ”„ Installing Anthos on bare metal... - Your active configuration is: [shabir-shell-check2] + Your active configuration is: [abm-test-project] Pseudo-terminal will not be allocated because stdin is not a terminal. - Enter passphrase for key '/Users/shabirmean/.ssh/google_compute_engine': + Enter passphrase for key '/Users/sergrybrin/.ssh/google_compute_engine': Welcome to Ubuntu 20.04.5 LTS (GNU/Linux 5.15.0-1018-gcp x86_64) * Documentation: https://help.ubuntu.com @@ -71,8 +71,8 @@ explanation of all the steps included in this script. Run 'do-release-upgrade' to upgrade to it. - + export PROJECT_ID=shabir-shell-check2 - + PROJECT_ID=shabir-shell-check2 + + export PROJECT_ID=abm-test-project + + PROJECT_ID=abm-test-project + export clusterid=cluster-1 + clusterid=cluster-1 + bmctl create config -c cluster-1 From 34555b5f70754b65bd56ceae2ad1e4518d675153 Mon Sep 17 00:00:00 2001 From: shabirmean Date: Fri, 21 Oct 2022 20:15:26 -0400 Subject: [PATCH 3/7] fix: update output --- anthos-bm-gcp-bash/docs/admin.md | 116 ++++++++++++++++++------------- 1 file changed, 66 insertions(+), 50 deletions(-) diff --git a/anthos-bm-gcp-bash/docs/admin.md b/anthos-bm-gcp-bash/docs/admin.md index ce7b5853..5211b4c6 100644 --- a/anthos-bm-gcp-bash/docs/admin.md +++ b/anthos-bm-gcp-bash/docs/admin.md @@ -49,71 +49,87 @@ _(which is specific to an admin cluster)_. āœ… Successfully set up SSH access from admin workstation to cluster node VMs. šŸ”„ Installing Anthos on bare metal... - Your active configuration is: [shabir-shell-check2] Pseudo-terminal will not be allocated because stdin is not a terminal. - Enter passphrase for key '/Users/sundarpichai/.ssh/google_compute_engine': - Welcome to Ubuntu 20.04.5 LTS (GNU/Linux 5.15.0-1018-gcp x86_64) + Enter passphrase for key '/Users/sundarpichai/.ssh/google_compute_engine': + Welcome to Ubuntu 20.04.5 LTS (GNU/Linux 5.15.0-1021-gcp x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage - System information as of Tue Oct 4 19:09:07 UTC 2022 + System information as of Fri Oct 21 23:56:11 UTC 2022 - System load: 0.39 Users logged in: 0 - Usage of /: 1.3% of 193.65GB IPv4 address for docker0: 172.17.0.1 - Memory usage: 1% IPv4 address for ens4: 10.128.0.2 + System load: 0.38 Users logged in: 0 + Usage of /: 1.4% of 193.65GB IPv4 address for docker0: 172.17.0.1 + Memory usage: 1% IPv4 address for ens4: 10.142.0.2 Swap usage: 0% IPv4 address for vxlan0: 10.200.0.2 - Processes: 153 + Processes: 157 - 0 updates can be applied immediately. + 6 updates can be applied immediately. + 5 of these updates are standard security updates. + To see these additional updates run: apt list --upgradable New release '22.04.1 LTS' available. Run 'do-release-upgrade' to upgrade to it. - + export PROJECT_ID=shabir-shell-check2 - + PROJECT_ID=shabir-shell-check2 - + export clusterid=cluster-1 - + clusterid=cluster-1 - + bmctl create config -c cluster-1 - [2022-10-04 19:09:08+0000] Created config: bmctl-workspace/cluster-1/cluster-1.yaml + ++ gcloud config get-value project + + export PROJECT_ID=abm-ame-cluster + + PROJECT_ID=abm-ame-cluster + ++ curl http://metadata.google.internal/computeMetadata/v1/instance/attributes/cluster_id -H 'Metadata-Flavor: Google' + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 100 20 100 20 0 0 10000 0 --:--:-- --:--:-- --:--:-- 10000 + + ADMIN_CLUSTER_NAME=abm-ame-cluster + + export ADMIN_CLUSTER_NAME + + bmctl create config -c abm-ame-cluster + [2022-10-21 23:56:13+0000] Created config: bmctl-workspace/abm-ame-cluster/abm-ame-cluster.yaml + cat - + bmctl create cluster -c cluster-1 - Please check the logs at bmctl-workspace/cluster-1/log/create-cluster-20221004-190908/create-cluster.log - [2022-10-04 19:09:14+0000] Creating bootstrap cluster... OK - [2022-10-04 19:10:24+0000] Installing dependency components... OK - [2022-10-04 19:11:51+0000] Waiting for preflight check job to finish... OK - [2022-10-04 19:13:51+0000] - Validation Category: machines and network - [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.5 - [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.6 - [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.7 - [2022-10-04 19:13:51+0000] - [PASSED] gcp - [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.4-gcp - [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.3-gcp - [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.4 - [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.5-gcp - [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.6-gcp - [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.7-gcp - [2022-10-04 19:13:51+0000] - [PASSED] node-network - [2022-10-04 19:13:51+0000] - [PASSED] pod-cidr - [2022-10-04 19:13:51+0000] - [PASSED] 10.200.0.3 - [2022-10-04 19:13:51+0000] Flushing logs... OK - [2022-10-04 19:13:53+0000] Applying resources for new cluster - [2022-10-04 19:13:53+0000] Waiting for cluster kubeconfig to become ready OK - [2022-10-04 19:17:03+0000] Writing kubeconfig file - [2022-10-04 19:17:03+0000] kubeconfig of cluster being created is present at bmctl-workspace/cluster-1/cluster-1-kubeconfig - [2022-10-04 19:17:03+0000] Please restrict access to this file as it contains authentication credentials of your cluster. - [2022-10-04 19:17:03+0000] Waiting for cluster to become ready OK - [2022-10-04 19:23:43+0000] Please run - [2022-10-04 19:23:43+0000] kubectl --kubeconfig bmctl-workspace/cluster-1/cluster-1-kubeconfig get nodes - [2022-10-04 19:23:43+0000] to get cluster nodes status. - [2022-10-04 19:23:43+0000] Waiting for node pools to become ready OK - [2022-10-04 19:24:03+0000] Waiting for metrics to become ready in GCP OK - [2022-10-04 19:24:13+0000] Moving admin cluster resources to the created admin cluster - [2022-10-04 19:24:20+0000] Waiting for node update jobs to finish OK - [2022-10-04 19:26:40+0000] Flushing logs... OK - [2022-10-04 19:26:40+0000] Deleting bootstrap cluster... OK + + bmctl create cluster -c abm-ame-cluster + Please check the logs at bmctl-workspace/abm-ame-cluster/log/create-cluster-20221021-235613/create-cluster.log + [2022-10-21 23:56:19+0000] Creating bootstrap cluster... OK + [2022-10-21 23:57:35+0000] Installing dependency components... OK + [2022-10-21 23:58:53+0000] Waiting for preflight check job to finish... OK + [2022-10-22 00:00:23+0000] - Validation Category: machines and network + [2022-10-22 00:00:23+0000] - [PASSED] node-network + [2022-10-22 00:00:23+0000] - [PASSED] pod-cidr + [2022-10-22 00:00:23+0000] - [PASSED] 10.200.0.3 + [2022-10-22 00:00:23+0000] - [PASSED] 10.200.0.3-gcp + [2022-10-22 00:00:23+0000] - [PASSED] gcp + [2022-10-22 00:00:23+0000] Flushing logs... OK + [2022-10-22 00:00:25+0000] Applying resources for new cluster + [2022-10-22 00:00:25+0000] Waiting for cluster kubeconfig to become ready OK + [2022-10-22 00:03:35+0000] Writing kubeconfig file + [2022-10-22 00:03:35+0000] kubeconfig of cluster being created is present at bmctl-workspace/abm-ame-cluster/abm-ame-cluster-kubeconfig + [2022-10-22 00:03:35+0000] Please restrict access to this file as it contains authentication credentials of your cluster. + [2022-10-22 00:03:35+0000] Waiting for cluster to become ready OK + [2022-10-22 00:07:35+0000] Please run + [2022-10-22 00:07:35+0000] kubectl --kubeconfig bmctl-workspace/abm-ame-cluster/abm-ame-cluster-kubeconfig get nodes + [2022-10-22 00:07:35+0000] to get cluster nodes status. + [2022-10-22 00:07:35+0000] Waiting for node pools to become ready OK + [2022-10-22 00:07:55+0000] Waiting for metrics to become ready in GCP OK + [2022-10-22 00:08:05+0000] Moving admin cluster resources to the created admin cluster + [2022-10-22 00:08:09+0000] Waiting for node update jobs to finish OK + [2022-10-22 00:09:49+0000] Flushing logs... OK + [2022-10-22 00:09:49+0000] Deleting bootstrap cluster... OK + install_admin_cluster.sh: line 304: red: command not found + install_admin_cluster.sh: line 305: nodeConfig:: command not found + install_admin_cluster.sh: line 306: podDensity:: command not found + install_admin_cluster.sh: line 307: maxPodsPerNode:: command not found + install_admin_cluster.sh: line 308: EOB: command not found + install_admin_cluster.sh: line 310: bmctl: command not found + install_admin_cluster.sh: line 311: EOF: command not found āœ… Installation complete. Please check the logs for any errors!!! + + āœ… If you do not see any errors in the output log, then you now have the following setup: + + |---------------------------------------------------------------------------------------------------------| + | 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 | + |---------------------------------------------------------------------------------------------------------| ``` From 6e8a064275167b0411fc9e2f0f546e5668fcb8ab Mon Sep 17 00:00:00 2001 From: shabirmean Date: Fri, 21 Oct 2022 20:18:34 -0400 Subject: [PATCH 4/7] doc: fix link error --- anthos-bm-gcp-bash/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/anthos-bm-gcp-bash/README.md b/anthos-bm-gcp-bash/README.md index 7b30e882..69f7c96c 100644 --- a/anthos-bm-gcp-bash/README.md +++ b/anthos-bm-gcp-bash/README.md @@ -5,8 +5,8 @@ _(e.g. hybrid, admin, user, standalone)_ Anthos clusters on bare metal in Compute Engine Virtual Machines (VMs). Select the guide for the type of cluster you want to install and follow the guide. -- [Setup and install a **hybrid** Anthos on bare metal cluster](./docs/admin.md) -- [Setup and install a **admin** Anthos on bare metal cluster](./docs/hybrid.md) +- [Setup and install a **hybrid** Anthos on bare metal cluster](./docs/hybrid.md) +- [Setup and install a **admin** Anthos on bare metal cluster](./docs/admin.md) --- The steps inside the script is written with the assumption that you are working From 22062cf0053ec1a7cf5b89684c7938703e261ebd Mon Sep 17 00:00:00 2001 From: shabirmean Date: Fri, 21 Oct 2022 20:30:43 -0400 Subject: [PATCH 5/7] lint: fix whitespace --- anthos-bm-gcp-bash/docs/admin.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/anthos-bm-gcp-bash/docs/admin.md b/anthos-bm-gcp-bash/docs/admin.md index 5211b4c6..bc3c3528 100644 --- a/anthos-bm-gcp-bash/docs/admin.md +++ b/anthos-bm-gcp-bash/docs/admin.md @@ -50,7 +50,7 @@ _(which is specific to an admin cluster)_. šŸ”„ Installing Anthos on bare metal... Pseudo-terminal will not be allocated because stdin is not a terminal. - Enter passphrase for key '/Users/sundarpichai/.ssh/google_compute_engine': + Enter passphrase for key '/Users/sundarpichai/.ssh/google_compute_engine': Welcome to Ubuntu 20.04.5 LTS (GNU/Linux 5.15.0-1021-gcp x86_64) * Documentation: https://help.ubuntu.com From 871bbab985e4b2294b0448f1711b9243bc988fcb Mon Sep 17 00:00:00 2001 From: shabirmean Date: Fri, 21 Oct 2022 20:35:59 -0400 Subject: [PATCH 6/7] doc: remove unnecessary output --- anthos-bm-gcp-bash/docs/admin.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/anthos-bm-gcp-bash/docs/admin.md b/anthos-bm-gcp-bash/docs/admin.md index bc3c3528..7e1730d7 100644 --- a/anthos-bm-gcp-bash/docs/admin.md +++ b/anthos-bm-gcp-bash/docs/admin.md @@ -113,13 +113,6 @@ _(which is specific to an admin cluster)_. [2022-10-22 00:08:09+0000] Waiting for node update jobs to finish OK [2022-10-22 00:09:49+0000] Flushing logs... OK [2022-10-22 00:09:49+0000] Deleting bootstrap cluster... OK - install_admin_cluster.sh: line 304: red: command not found - install_admin_cluster.sh: line 305: nodeConfig:: command not found - install_admin_cluster.sh: line 306: podDensity:: command not found - install_admin_cluster.sh: line 307: maxPodsPerNode:: command not found - install_admin_cluster.sh: line 308: EOB: command not found - install_admin_cluster.sh: line 310: bmctl: command not found - install_admin_cluster.sh: line 311: EOF: command not found āœ… Installation complete. Please check the logs for any errors!!! āœ… If you do not see any errors in the output log, then you now have the following setup: From 712a5c4ca5f1ee180cb61ff52806dc1b33bc30fd Mon Sep 17 00:00:00 2001 From: shabirmean Date: Mon, 24 Oct 2022 16:28:31 -0400 Subject: [PATCH 7/7] doc: fix lint errors --- anthos-bm-gcp-bash/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/anthos-bm-gcp-bash/README.md b/anthos-bm-gcp-bash/README.md index 69f7c96c..4b8cf7a2 100644 --- a/anthos-bm-gcp-bash/README.md +++ b/anthos-bm-gcp-bash/README.md @@ -14,4 +14,4 @@ with a Google Cloud Project that has most of the default settings. This is to keep the different customizations to a minimal and allow for anyone to start at this baseline and make changes as required. Based on the popularity of certain variations, information about them are explained in the [FAQ](./docs/faq.md) -section. \ No newline at end of file +section.