You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
3.3 KiB

  1. Packet Host
  2. ===============
  3. Kubespray provides support for bare metal deployments using the [Packet Host bare metal cloud](http://www.packet.com).
  4. Deploying upon bare metal allows Kubernetes to run at locations where an existing public or private cloud might not exist such
  5. as cell tower, edge collocated installations. The deployment mechanism used by Kubespray for Packet is similar to that used for
  6. AWS and OpenStack clouds (notably using Terraform to deploy the infrastructure). Terraform uses the Packet provider plugin
  7. to provision and configure hosts which are then used by the Kubespray Ansible playbooks. The Ansible inventory is generated
  8. dynamically from the Terraform state file.
  9. ## Local Host Configuration
  10. To perform this installation, you will need a localhost to run Terraform/Ansible (laptop, VM, etc) and an account with Packet Host.
  11. In this example, we're using an m1.large CentOS 7 OpenStack VM as the localhost to kickoff the Kubernetes installation.
  12. You'll need Ansible, Git, and PIP.
  13. ```bash
  14. sudo yum install epel-release
  15. sudo yum install ansible
  16. sudo yum install git
  17. sudo yum install python-pip
  18. ```
  19. ## Playbook SSH Key
  20. An SSH key is needed by Kubespray/Ansible to run the playbooks.
  21. This key is installed into the bare metal hosts during the Terraform deployment.
  22. You can generate a key new key or use an existing one.
  23. ```bash
  24. ssh-keygen -f ~/.ssh/id_rsa
  25. ```
  26. ## Install Terraform
  27. Terraform is required to deploy the bare metal infrastructure. The steps below are for installing on CentOS 7.
  28. [More terraform installation options are available.](https://learn.hashicorp.com/terraform/getting-started/install.html)
  29. Grab the latest version of Terraform and install it.
  30. ```bash
  31. 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')_darwin_amd64.zip"
  32. sudo yum install unzip
  33. sudo unzip terraform_0.11.11_linux_amd64.zip -d /usr/local/bin/
  34. ```
  35. ## Download Kubespray
  36. Pull over Kubespray and setup any required libraries.
  37. ```bash
  38. git clone https://github.com/kubernetes-sigs/kubespray
  39. cd kubespray
  40. sudo pip install -r requirements.txt
  41. ```
  42. ## Cluster Definition
  43. In this example, a new cluster called "alpha" will be created.
  44. ```bash
  45. cp -LRp contrib/terraform/packet/sample-inventory inventory/alpha
  46. cd inventory/alpha/
  47. ln -s ../../contrib/terraform/packet/hosts
  48. ```
  49. Details about the cluster, such as the name, as well as the authentication tokens and project ID
  50. for Packet need to be defined. To find these values see [Packet API Integration](https://support.packet.com/kb/articles/api-integrations)
  51. ```bash
  52. vi cluster.tf
  53. ```
  54. * cluster_name = alpha
  55. * packet_project_id = ABCDEFGHIJKLMNOPQRSTUVWXYZ123456
  56. * public_key_path = 12345678-90AB-CDEF-GHIJ-KLMNOPQRSTUV
  57. ## Deploy Bare Metal Hosts
  58. Initializing Terraform will pull down any necessary plugins/providers.
  59. ```bash
  60. terraform init ../../contrib/terraform/packet/
  61. ```
  62. Run Terraform to deploy the hardware.
  63. ```bash
  64. terraform apply -var-file=cluster.tf ../../contrib/terraform/packet
  65. ```
  66. ## Run Kubespray Playbooks
  67. With the bare metal infrastructure deployed, Kubespray can now install Kubernetes and setup the cluster.
  68. ```bash
  69. ansible-playbook --become -i inventory/alpha/hosts cluster.yml
  70. ```