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