2021-05-27 18:58:24 +00:00
|
|
|
# Equinix Metal
|
2019-02-26 04:07:38 +00:00
|
|
|
|
2021-05-27 18:58:24 +00:00
|
|
|
Kubespray provides support for bare metal deployments using the [Equinix Metal](http://metal.equinix.com).
|
2019-02-26 04:07:38 +00:00
|
|
|
Deploying upon bare metal allows Kubernetes to run at locations where an existing public or private cloud might not exist such
|
2021-05-27 18:58:24 +00:00
|
|
|
as cell tower, edge collocated installations. The deployment mechanism used by Kubespray for Equinix Metal is similar to that used for
|
|
|
|
AWS and OpenStack clouds (notably using Terraform to deploy the infrastructure). Terraform uses the Equinix Metal provider plugin
|
2019-02-26 04:07:38 +00:00
|
|
|
to provision and configure hosts which are then used by the Kubespray Ansible playbooks. The Ansible inventory is generated
|
|
|
|
dynamically from the Terraform state file.
|
|
|
|
|
|
|
|
## Local Host Configuration
|
|
|
|
|
2021-05-27 18:58:24 +00:00
|
|
|
To perform this installation, you will need a localhost to run Terraform/Ansible (laptop, VM, etc) and an account with Equinix Metal.
|
2019-02-26 04:07:38 +00:00
|
|
|
In this example, we're using an m1.large CentOS 7 OpenStack VM as the localhost to kickoff the Kubernetes installation.
|
|
|
|
You'll need Ansible, Git, and PIP.
|
|
|
|
|
|
|
|
```bash
|
|
|
|
sudo yum install epel-release
|
|
|
|
sudo yum install ansible
|
|
|
|
sudo yum install git
|
|
|
|
sudo yum install python-pip
|
|
|
|
```
|
|
|
|
|
|
|
|
## Playbook SSH Key
|
|
|
|
|
|
|
|
An SSH key is needed by Kubespray/Ansible to run the playbooks.
|
|
|
|
This key is installed into the bare metal hosts during the Terraform deployment.
|
|
|
|
You can generate a key new key or use an existing one.
|
|
|
|
|
|
|
|
```bash
|
|
|
|
ssh-keygen -f ~/.ssh/id_rsa
|
|
|
|
```
|
|
|
|
|
|
|
|
## Install Terraform
|
|
|
|
|
|
|
|
Terraform is required to deploy the bare metal infrastructure. The steps below are for installing on CentOS 7.
|
|
|
|
[More terraform installation options are available.](https://learn.hashicorp.com/terraform/getting-started/install.html)
|
|
|
|
|
|
|
|
Grab the latest version of Terraform and install it.
|
2019-12-04 15:22:57 +00:00
|
|
|
|
2019-02-26 04:07:38 +00:00
|
|
|
```bash
|
2020-04-16 20:07:07 +00:00
|
|
|
echo "https://releases.hashicorp.com/terraform/$(curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r -M '.current_version')/terraform_$(curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r -M '.current_version')_linux_amd64.zip"
|
2019-02-26 04:07:38 +00:00
|
|
|
sudo yum install unzip
|
2021-04-12 16:47:39 +00:00
|
|
|
sudo unzip terraform_0.14.10_linux_amd64.zip -d /usr/local/bin/
|
2019-02-26 04:07:38 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
## Download Kubespray
|
|
|
|
|
|
|
|
Pull over Kubespray and setup any required libraries.
|
|
|
|
|
|
|
|
```bash
|
|
|
|
git clone https://github.com/kubernetes-sigs/kubespray
|
|
|
|
cd kubespray
|
|
|
|
sudo pip install -r requirements.txt
|
|
|
|
```
|
|
|
|
|
|
|
|
## Cluster Definition
|
|
|
|
|
2019-12-04 15:22:57 +00:00
|
|
|
In this example, a new cluster called "alpha" will be created.
|
2019-02-26 04:07:38 +00:00
|
|
|
|
|
|
|
```bash
|
|
|
|
cp -LRp contrib/terraform/packet/sample-inventory inventory/alpha
|
|
|
|
cd inventory/alpha/
|
|
|
|
ln -s ../../contrib/terraform/packet/hosts
|
|
|
|
```
|
|
|
|
|
|
|
|
Details about the cluster, such as the name, as well as the authentication tokens and project ID
|
2021-05-27 18:58:24 +00:00
|
|
|
for Equinix Metal need to be defined. To find these values see [Equinix Metal API Accounts](https://metal.equinix.com/developers/docs/accounts/).
|
2019-02-26 04:07:38 +00:00
|
|
|
|
|
|
|
```bash
|
2019-12-04 15:20:58 +00:00
|
|
|
vi cluster.tfvars
|
2019-02-26 04:07:38 +00:00
|
|
|
```
|
2019-12-04 15:22:57 +00:00
|
|
|
|
2019-02-26 04:07:38 +00:00
|
|
|
* cluster_name = alpha
|
|
|
|
* packet_project_id = ABCDEFGHIJKLMNOPQRSTUVWXYZ123456
|
|
|
|
* public_key_path = 12345678-90AB-CDEF-GHIJ-KLMNOPQRSTUV
|
|
|
|
|
|
|
|
## Deploy Bare Metal Hosts
|
|
|
|
|
|
|
|
Initializing Terraform will pull down any necessary plugins/providers.
|
|
|
|
|
|
|
|
```bash
|
|
|
|
terraform init ../../contrib/terraform/packet/
|
|
|
|
```
|
|
|
|
|
|
|
|
Run Terraform to deploy the hardware.
|
|
|
|
|
|
|
|
```bash
|
2019-12-04 15:20:58 +00:00
|
|
|
terraform apply -var-file=cluster.tfvars ../../contrib/terraform/packet
|
2019-02-26 04:07:38 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
## Run Kubespray Playbooks
|
|
|
|
|
|
|
|
With the bare metal infrastructure deployed, Kubespray can now install Kubernetes and setup the cluster.
|
|
|
|
|
|
|
|
```bash
|
|
|
|
ansible-playbook --become -i inventory/alpha/hosts cluster.yml
|
|
|
|
```
|