Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
Signed-off-by: Marques Johansson <[email protected]>
  • Loading branch information
displague committed Feb 21, 2024
1 parent 93c3050 commit cb5693d
Show file tree
Hide file tree
Showing 22 changed files with 181 additions and 361 deletions.
94 changes: 94 additions & 0 deletions INSTALL_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@

# Manual Installation

## Step 1: Deploy L2 Gateway

Assuming we don't have another gateway deployed, we'll need to create one.

<!-- TODO: migrate this script to live in the TF repo -->
We'll be using the helper scripts developed for running the test suite for Nutanix to simplify this installation.

```sh
#!/bin/bash

export EMAPI_AUTH_TOKEN=<your-metal-auth-token-here>
export L2GATEWAY_VLAN_DESCRIPTION=ntnx-demo

curl https://artifacts.platformequinix.com/images/nutanix/misc/scripts/install-l2gateway.sh | sh 2>&1 | tee /root/install-l2gw.log
```

## Step 2: Deploy one or more Nutanix Nodes (m3.xlarge)

## Step 3: Once installation is complete, move nodes to L2 mode

## Step 4: Reboot Nutanix nodes (to allow them to re-dhcp from new l2 gateway)

## Step 5: Discover CVM IPs

Look at the lease table on the dhcp server, and find all the kvm mac leases.

```sh
curl -s http://192.168.0.1/leases
```

## Step 5: Login to Nutanix CVM node and create cluster

```sh
ssh nutanix@$CVM_IP
cluster -s "CVM_IP1,CVM_IP2,CVM_IP3" create
```

## Step 6: Access Prism's UI

Open `https://$CVM_IP:9440` in your browser

Default login is `admin` and `nutanix/4u`

A password change will be required, we'll use `Nutanix.123`

Follow the account steps.

### Spawning a VM

#### Step 1: Configure DNS

Settings -> Name Servers
Add
8.8.8.8

#### Step 2: Add image

Settings -> Image Configuration
Upload Image

Name: Rocky8
Type: ISO
URL: <https://download.rockylinux.org/pub/rocky/8/isos/x86_64/Rocky-8.5-x86_64-minimal.iso>

#### Step 3: Configure a network

Settings -> Network Configuration

Create Network

Network Name: vlan0
VLAN ID: 0

#### Step 4: Create VM

Settings -> VM

Create VM

Name: rocky8
vCPU(s): 8
Memory: 8

Disks
CDROM: Edit, use rocky8
Add New Disk:
Size: 100

Save

Power on
76 changes: 24 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,42 @@
# terraform-equinix-template
# Nutanix Cluster on Equinix Metal

<!-- TEMPLATE: Review all "TEMPLATE" comments and remove them when applied. -->
<!-- TEMPLATE: replace "template" with the name of your project. The prefix "terraform-equinix-" informs the Terraform registry that this project is a Terraform module associated with the Equinix provider, preserve this prefix. -->
[![Experimental](https://img.shields.io/badge/Stability-Experimental-red.svg)](https://github.com/equinix-labs/standards#about-uniform-standards)
[![run-pre-commit-hooks](https://github.com/equinix-labs/terraform-equinix-template/actions/workflows/pre-commit.yaml/badge.svg)](https://github.com/equinix-labs/terraform-equinix-template/actions/workflows/pre-commit.yaml)
[![generate-terraform-docs](https://github.com/equinix-labs/terraform-equinix-template/actions/workflows/documentation.yaml/badge.svg)](https://github.com/equinix-labs/terraform-equinix-template/actions/workflows/documentation.yaml)
This Terraform module will deploy a demonstrative Nutanix Cluster in Layer 2 isolation on Equinix Metal. The cluster IPAM and Internet Access is managed by a Rocky bastion/gateway node.

`terraform-equinix-template` is a minimal Terraform module that utilizes [Terraform providers for Equinix](https://registry.terraform.io/namespaces/equinix) to provision digital infrastructure and demonstrate higher level integrations.
## Acronyms and Terms

<!-- TEMPLATE: Insert an image here of the infrastructure diagram. You can generate a starting image using instructions found at https://www.terraform.io/docs/cli/commands/graph.html#generating-images -->
* AOS: Acropolis Operating System
* NOS: Nutanix Operating System (Used interchangably with AOS)
* AHV: AOS Hypervisor
* Phoenix: The AOS/NOS Installer
* CVM: Cluster Virtual Machine
* Prism: AOS Cluster Web UI

## Usage
## Nutanix Installation in a nutshell

This project is experimental and supported by the user community. Equinix does not provide support for this project.
For those who are unfamiliar with Nutanix. Nutanix is a virtual machine management suite, similar to VMWare ESXi.

Install Terraform using the [tfenv](https://github.com/tfutils/tfenv) utility.
Nutanix is typically deployed in a private network without public IPs assigned directly to the host.
This experience is different than what many cloud users would expect in an OS deployment.

This project may be forked, cloned, or downloaded and modified as needed as the base in your integrations and deployments.
Due to this, we'll be deploying Nutanix with only private management IPs and later converting the nodes to full Layer-2.

This project may also be used as a [Terraform module](https://learn.hashicorp.com/collections/terraform/modules).
To allow access to the internet and make it easier to access these hosts, we'll be deploying a server in Hybrid networking mode to act as a router and jump box.

To use this module in a new project, create a file such as:
To begin, we'll start by provisioning a c3.small which has two NICs. Allowing us to have one in layer-3 with a public IP,
and one in layer-2 to access the internal layer-2 network.

```hcl
# main.tf
terraform {
required_providers {
equinix = {
source = "equinix/equinix"
}
}
## Manual Installation

module "example" {
source = "github.com/equinix-labs/template"
# TEMPLATE: replace "template" with the name of the repo after the terraform-equinix- prefix.
See [INSTALL_GUIDE.md](INSTALL_GUIDE.md) to install by hand. Otherwise, skip to the following section to let Terraform do all the work.

# Published modules can be sourced as:
# source = "equinix-labs/template/equinix"
# See https://www.terraform.io/docs/registry/modules/publish.html for details.
## Terraform installation

# version = "0.1.0"
# TEMPLATE: insert required variables here
}
```sh
terraform init
eval $(metal env -o terraform --export)
terraform apply
```

Install [pre-commit](https://pre-commit.com/#install) with its prerequesites: [python](https://docs.python.org/3/using/index.html) and [pip](https://pip.pypa.io/en/stable/installation/).

Configure pre-commit: `pre-commit install`.

Install required packages: [tflint](https://github.com/terraform-linters/tflint), [tfsec](https://aquasecurity.github.io/tfsec/v1.0.11/getting-started/installation/), [shfmt](https://github.com/mvdan/sh), [shellcheck](https://github.com/koalaman/shellcheck), and [markdownlint](https://github.com/markdownlint/markdownlint).

Run `terraform init -upgrade` and `terraform apply`.

## Module Documentation

The main README.md, the modules README.md and the examples README.md are populated by [terraform-docs worflow job](.github/workflows/documentation.yaml). The following sections are appended between the terraform-docs delimeters: Requiremenents, Providers, Modules, Resources, Inputs, and Outputs.

## Module Release and Changelog Generation

The module git release and [changelog](CHANGELOG.md) are generated by the [release workflow job](.github/workflows/release.yaml). The release worflow follows the [conventional commits convention](https://www.conventionalcommits.org/). To submit a commit, please follow the [commit message format guidelines](https://www.conventionalcommits.org/en/v1.0.0/#specification). This job is set to run manually by default.

Example commit message: `fix: disabled log generation for system services`

For more examples, please see [conventional commit message examples](https://www.conventionalcommits.org/en/v1.0.0/#examples).

## Examples

To view examples for how you can leverage this module, please see the [examples](examples/) directory.
Expand Down
1 change: 0 additions & 1 deletion docs/template-doc.md

This file was deleted.

Empty file added examples/.keep
Empty file.
47 changes: 0 additions & 47 deletions examples/simple/README.md

This file was deleted.

12 changes: 0 additions & 12 deletions examples/simple/main.tf

This file was deleted.

24 changes: 0 additions & 24 deletions examples/simple/outputs.tf

This file was deleted.

21 changes: 0 additions & 21 deletions examples/simple/variables.tf

This file was deleted.

1 change: 0 additions & 1 deletion files/static-file.txt

This file was deleted.

1 change: 0 additions & 1 deletion helpers/helper-script.sh

This file was deleted.

79 changes: 38 additions & 41 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,50 +1,47 @@
# TEMPLATE: Before using "provider" blocks, consider https://www.terraform.io/docs/language/modules/develop/providers.html#implicit-provider-inheritance
# TEMPLATE:
# TEMPLATE: All ".tf" files are parsed at once. There is no benefit to numerically prefixed filenames. Keep all resource definitions in "main.tf".
# TEMPLATE:
# TEMPLATE: When main.tf becomes unwieldy, consider submodules (https://www.terraform.io/docs/language/modules/develop/structure.html)
# TEMPLATE: and dependency inversion (https://www.terraform.io/docs/language/modules/develop/composition.html).
# TEMPLATE:

# TEMPLATE: Replace sample provider described below with your own.
terraform {
required_version = ">= 1.3"

provider_meta "equinix" {
# TEMPLATE: Replace the module name with your own.
module_name = "template"
}

required_providers {
equinix = {
source = "equinix/equinix"
version = ">= 1.8.0"
}
}
data "equinix_metal_project" "nutanix" {
name = "devrel-marques-testing"
}

# TEMPLATE: Replace sample provider described below with your own.
provider "equinix" {
auth_token = var.metal_auth_token
resource "equinix_metal_vlan" "test" {
project_id = data.equinix_metal_project.nutanix.id
description = var.metal_vlan_description
metro = "da"
}

# TEMPLATE: Replace sample resource described below with your own.
resource "equinix_metal_device" "example_device" {
hostname = "example-device"
resource "equinix_metal_device" "bastion" {
project_id = data.equinix_metal_project.nutanix.id
hostname = "bastion"
user_data = templatefile("bastion-userdata.tmpl", {
metal_auth_token = var.metal_auth_token
metal_vlan_description = var.metal_vlan_description
})
operating_system = "rocky_9"
plan = "c3.small.x86"
metro = "sv"
operating_system = "ubuntu_20_04"
billing_cycle = "hourly"
project_id = var.metal_project_id
metro = "da"
}

# TEMPLATE: Run `terraform get` to install local module
# TEMPLATE: Run `terraform init` to initialize backends and install plugins
# TEMPLATE: Replace sample in-line local module described below with your own.
# TEMPLATE
module "inline_module" {
source = "./modules/inline-module"
resource "equinix_metal_port" "bastion_bond0" {
port_id = [for p in equinix_metal_device.bastion.ports : p.id if p.name == "bond0"][0]
layer2 = false
bonded = true
vlan_ids = [equinix_metal_vlan.test.id]
}

# Define any required variables
inline_module_project_id = var.metal_project_id
resource "equinix_metal_device" "nutanix" {
count = 1
project_id = data.equinix_metal_project.nutanix.id
hostname = "nutanix-devrel-test-{count.index}"
user_data = templatefile("nutanix-userdata.tmpl", {})
operating_system = "nutanix_lts_6_5"
plan = "m3.large.x86"
metro = "da"
}

resource "equinix_metal_port" "nutanix_bond0" {
for_each = equinix_metal_device.nutanix
port_id = [for p in each.value.ports : p.id if p.name == "bond0"][0]
layer2 = true
bonded = true
vlan_ids = [equinix_metal_vlan.test.id]
}

Loading

0 comments on commit cb5693d

Please sign in to comment.