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.

95 lines
3.9 KiB

6 years ago
  1. Hashicorp Vault Role
  2. ====================
  3. Overview
  4. --------
  5. The Vault role is a two-step process:
  6. 1. Bootstrap
  7. You cannot start your certificate management service securely with SSL (and
  8. the datastore behind it) without having the certificates in-hand already. This
  9. presents an unfortunate chicken and egg scenario, with one requiring the other.
  10. To solve for this, the Bootstrap step was added.
  11. This step spins up a temporary instance of Vault to issue certificates for
  12. Vault itself. It then leaves the temporary instance running, so that the Etcd
  13. role can generate certs for itself as well. Eventually, this may be improved
  14. to allow alternate backends (such as Consul), but currently the tasks are
  15. hardcoded to only create a Vault role for Etcd.
  16. 2. Cluster
  17. This step is where the long-term Vault cluster is started and configured. Its
  18. first task, is to stop any temporary instances of Vault, to free the port for
  19. the long-term. At the end of this task, the entire Vault cluster should be up
  20. and ready to go.
  21. Keys to the Kingdom
  22. -------------------
  23. The two most important security pieces of Vault are the ``root_token``
  24. and ``unsealing_keys``. Both of these values are given exactly once, during
  25. the initialization of the Vault cluster. For convenience, they are saved
  26. to the ``vault_secret_dir`` (default: /etc/vault/secrets) of every host in the
  27. vault group.
  28. It is *highly* recommended that these secrets are removed from the servers after
  29. your cluster has been deployed, and kept in a safe location of your choosing.
  30. Naturally, the seriousness of the situation depends on what you're doing with
  31. your Kubespray cluster, but with these secrets, an attacker will have the ability
  32. to authenticate to almost everything in Kubernetes and decode all private
  33. (HTTPS) traffic on your network signed by Vault certificates.
  34. For even greater security, you may want to remove and store elsewhere any
  35. CA keys generated as well (e.g. /etc/vault/ssl/ca-key.pem).
  36. Vault by default encrypts all traffic to and from the datastore backend, all
  37. resting data, and uses TLS for its TCP listener. It is recommended that you
  38. do not change the Vault config to disable TLS, unless you absolutely have to.
  39. Usage
  40. -----
  41. To get the Vault role running, you must to do two things at a minimum:
  42. 1. Assign the ``vault`` group to at least 1 node in your inventory
  43. 1. Change ``cert_management`` to be ``vault`` instead of ``script``
  44. Nothing else is required, but customization is possible. Check
  45. ``roles/vault/defaults/main.yml`` for the different variables that can be
  46. overridden, most common being ``vault_config``, ``vault_port``, and
  47. ``vault_deployment_type``.
  48. As a result of the Vault role will be create separated Root CA for `etcd`,
  49. `kubernetes` and `vault`. Also, if you intend to use a Root or Intermediate CA
  50. generated elsewhere, you'll need to copy the certificate and key to the hosts in the vault group prior to running the vault role. By default, they'll be located at:
  51. * vault:
  52. * ``/etc/vault/ssl/ca.pem``
  53. * ``/etc/vault/ssl/ca-key.pem``
  54. * etcd:
  55. * ``/etc/ssl/etcd/ssl/ca.pem``
  56. * ``/etc/ssl/etcd/ssl/ca-key.pem``
  57. * kubernetes:
  58. * ``/etc/kubernetes/ssl/ca.pem``
  59. * ``/etc/kubernetes/ssl/ca-key.pem``
  60. Additional Notes:
  61. - ``groups.vault|first`` is considered the source of truth for Vault variables
  62. - ``vault_leader_url`` is used as pointer for the current running Vault
  63. - Each service should have its own role and credentials. Currently those
  64. credentials are saved to ``/etc/vault/roles/<role>/``. The service will
  65. need to read in those credentials, if they want to interact with Vault.
  66. Potential Work
  67. --------------
  68. - Change the Vault role to not run certain tasks when ``root_token`` and
  69. ``unseal_keys`` are not present. Alternatively, allow user input for these
  70. values when missing.
  71. - Add the ability to start temp Vault with Host, Rkt, or Docker
  72. - Add a dynamic way to change out the backend role creation during Bootstrap,
  73. so other services can be used (such as Consul)