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.

56 lines
3.0 KiB

  1. AWS
  2. ===============
  3. To deploy kubespray on [AWS](https://aws.amazon.com/) uncomment the `cloud_provider` option in `group_vars/all.yml` and set it to `'aws'`.
  4. Prior to creating your instances, you **must** ensure that you have created IAM roles and policies for both "kubernetes-master" and "kubernetes-node". You can find the IAM policies [here](https://github.com/kubernetes-incubator/kargo/tree/master/contrib/aws_iam/). See the [IAM Documentation](https://aws.amazon.com/documentation/iam/) if guidance is needed on how to set these up. When you bring your instances online, associate them with the respective IAM role. Nodes that are only to be used for Etcd do not need a role.
  5. The next step is to make sure the hostnames in your `inventory` file are identical to your internal hostnames in AWS. This may look something like `ip-111-222-333-444.us-west-2.compute.internal`. You can then specify how Ansible connects to these instances with `ansible_ssh_host` and `ansible_ssh_user`.
  6. You can now create your cluster!
  7. ### Dynamic Inventory ###
  8. There is also a dynamic inventory script for AWS that can be used if desired. However, be aware that it makes some certain assumptions about how you'll create your inventory. It also does not handle all use cases and groups that we may use as part of more advanced deployments. Additions welcome.
  9. This will produce an inventory that is passed into Ansible that looks like the following:
  10. ```
  11. {
  12. "_meta": {
  13. "hostvars": {
  14. "ip-172-31-3-xxx.us-east-2.compute.internal": {
  15. "ansible_ssh_host": "172.31.3.xxx"
  16. },
  17. "ip-172-31-8-xxx.us-east-2.compute.internal": {
  18. "ansible_ssh_host": "172.31.8.xxx"
  19. }
  20. }
  21. },
  22. "etcd": [
  23. "ip-172-31-3-xxx.us-east-2.compute.internal"
  24. ],
  25. "k8s-cluster": {
  26. "children": [
  27. "kube-master",
  28. "kube-node"
  29. ]
  30. },
  31. "kube-master": [
  32. "ip-172-31-3-xxx.us-east-2.compute.internal"
  33. ],
  34. "kube-node": [
  35. "ip-172-31-8-xxx.us-east-2.compute.internal"
  36. ]
  37. }
  38. ```
  39. Guide:
  40. - Create instances in AWS as needed.
  41. - Either during or after creation, add tags to the instances with a key of `kargo-role` and a value of `kube-master`, `etcd`, or `kube-node`. You can also share roles like `kube-master, etcd`
  42. - Copy the `kargo-aws-inventory.py` script from `kargo/contrib/aws_inventory` to the `kargo/inventory` directory.
  43. - Set the following AWS credentials and info as environment variables in your terminal:
  44. ```
  45. export AWS_ACCESS_KEY_ID="xxxxx"
  46. export AWS_SECRET_ACCESS_KEY="yyyyy"
  47. export REGION="us-east-2"
  48. ```
  49. - We will now create our cluster. There will be either one or two small changes. The first is that we will specify `-i inventory/kargo-aws-inventory.py` as our inventory script. The other is conditional. If your AWS instances are public facing, you can set the `VPC_VISIBILITY` variable to `public` and that will result in public IP and DNS names being passed into the inventory. This causes your cluster.yml command to look like `VPC_VISIBILITY="public" ansible-playbook ... cluster.yml`