|
| 1 | +📙 **Disclaimer: Community supported repository. Not supported by Mesosphere directly.** |
| 2 | + |
| 3 | +# Open DC/OS on OpenStack with Terraform |
| 4 | + |
| 5 | +## Things to Know |
| 6 | + |
| 7 | +The current implemenetation ... |
| 8 | + |
| 9 | +* Does not setup or use OpenStack load balancers |
| 10 | +* Does apply floating IPs on the bootstrap and master nodes |
| 11 | +* Does create separate security groups for bootstrap, master, public agent, and private agent. Currently, all the security groups are the same and very open. |
| 12 | +* Does not use OpenStack compute server groups. Should we? |
| 13 | +* Does use cloud init to partially provision servers and not via remote ssh execution |
| 14 | +* Has been tested with CoreOS |
| 15 | +* Has not been tested with CentOS |
| 16 | +* Defaults to static DC/OS master discovery |
| 17 | +* Has not been tested with exhibitor |
| 18 | + |
| 19 | +Was tested with OpenStack Mirantis |
| 20 | + |
| 21 | +## Getting Started |
| 22 | + |
| 23 | +### Configure your Cloud Provider Credentials |
| 24 | + |
| 25 | +[Source your OpenStack RC file](https://docs.openstack.org/zh_CN/user-guide/common/cli-set-environment-variables-using-openstack-rc.html) and activate it by running the shell script. |
| 26 | + |
| 27 | +### Pull down the DC/OS terraform scripts below |
| 28 | + |
| 29 | +There is a module called `dcos-tested-openstack-oses` that contains all the tested scripts per operating system. The deployment strategy is based on a bare image coupled with a prereq `script.sh` to get it ready to install dcos-core components. |
| 30 | + |
| 31 | +OS | Version | Tested |
| 32 | +---|---------|------- |
| 33 | +CoreOS | 1576.4.0 | Yes |
| 34 | + |
| 35 | +NOTE: The default value for the variable `os` is `coreos`. |
| 36 | + |
| 37 | +### Quick Start |
| 38 | + |
| 39 | +We've provided sensible defaults that you would want to play around with DC/OS for setting up DC/OS. The default will setup a multi-master deployment. Three agents will be deployed for you. Two private agents, one public agent. |
| 40 | + |
| 41 | +There are several OpenStack related [variables](/openstack/variables.tf) that must be provided because these are unique to the OpenStack install that is being used: |
| 42 | + |
| 43 | +* `master_instance_flavor` |
| 44 | +* `bootstrap_instance_flavor` |
| 45 | +* `private_agent_instance_flavor` |
| 46 | +* `public_agent_instance_flavor` |
| 47 | +* `os_floating_ip_pool` |
| 48 | +* `os_image_name` |
| 49 | +* `os_external_network_id` |
| 50 | + |
| 51 | +You can create a [tfvars file](https://www.terraform.io/intro/getting-started/variables.html) to store the appropriate values for the required variables above. Assume that your tfvars file is called `desired_cluster_profile.tfvars`. |
| 52 | + |
| 53 | +- There is no git clone of this repo required. Terraform does this for you under the hood. |
| 54 | + |
| 55 | +_*Note:* Create a new directory before the command below as terraform will write its files within the current directory._ |
| 56 | + |
| 57 | +```bash |
| 58 | +mkdir dcos-installer |
| 59 | +cd dcos-installer |
| 60 | +terraform init -from-module github.com/dcos/terraform-dcos//openstack |
| 61 | +terraform apply -var-file desired_cluster_profile.tfvars |
| 62 | +``` |
| 63 | + |
| 64 | +#### Advance YAML Configuration |
| 65 | + |
| 66 | +We have designed this project to be flexible. Here are the example working variables that allows very deep customization by using a single `tfvars` file. |
| 67 | + |
| 68 | +For advance users with stringent requirements, here are the DC/OS flags examples where you can simply paste your YAML configuration in your desired_cluster_profile.tfvars. The alternative to YAML is to convert it to JSON. |
| 69 | + |
| 70 | +```bash |
| 71 | +$ cat desired_cluster_profile.tfvars |
| 72 | +dcos_version = "1.10.2" |
| 73 | +os = "centos_7.3" |
| 74 | +num_of_masters = "3" |
| 75 | +num_of_private_agents = "2" |
| 76 | +num_of_public_agents = "1" |
| 77 | +expiration = "6h" |
| 78 | +dcos_security = "permissive" |
| 79 | +dcos_cluster_docker_credentials_enabled = "true" |
| 80 | +dcos_cluster_docker_credentials_write_to_etc = "true" |
| 81 | +dcos_cluster_docker_credentials_dcos_owned = "false" |
| 82 | +dcos_cluster_docker_registry_url = "https://index.docker.io" |
| 83 | +dcos_use_proxy = "yes" |
| 84 | +dcos_http_proxy = "example.com" |
| 85 | +dcos_https_proxy = "example.com" |
| 86 | +dcos_no_proxy = <<EOF |
| 87 | +# YAML |
| 88 | + - "internal.net" |
| 89 | + - "168.63.129.16" |
| 90 | +EOF |
| 91 | +dcos_overlay_network = <<EOF |
| 92 | +# YAML |
| 93 | + vtep_subnet: 44.128.0.0/20 |
| 94 | + vtep_mac_oui: 70:B3:D5:00:00:00 |
| 95 | + overlays: |
| 96 | + - name: dcos |
| 97 | + subnet: 12.0.0.0/8 |
| 98 | + prefix: 26 |
| 99 | +EOF |
| 100 | +dcos_rexray_config = <<EOF |
| 101 | +# YAML |
| 102 | + rexray: |
| 103 | + loglevel: warn |
| 104 | + modules: |
| 105 | + default-admin: |
| 106 | + host: tcp://127.0.0.1:61003 |
| 107 | + storageDrivers: |
| 108 | + - ec2 |
| 109 | + volume: |
| 110 | + unmount: |
| 111 | + ignoreusedcount: true |
| 112 | +EOF |
| 113 | +dcos_cluster_docker_credentials = <<EOF |
| 114 | +# YAML |
| 115 | + auths: |
| 116 | + 'https://index.docker.io/v1/': |
| 117 | + auth: Ze9ja2VyY3licmljSmVFOEJrcTY2eTV1WHhnSkVuVndjVEE= |
| 118 | +EOF |
| 119 | +ssh_pub_key = "INSERT_PUBLIC_KEY_HERE" |
| 120 | +``` |
| 121 | +_Note: The YAML comment is required for the DC/OS specific YAML settings._ |
| 122 | + |
| 123 | +## Upgrading DC/OS |
| 124 | + |
| 125 | +You can upgrade your DC/OS cluster with a single command. This terraform script was built to perform installs and upgrades from the inception of this project. With the upgrade procedures below, you can also have finer control on how masters or agents upgrade at a given time. This will give you the ability to change the parallelism of master or agent upgrades. |
| 126 | + |
| 127 | +### DC/OS Upgrades |
| 128 | + |
| 129 | +#### Rolling Upgrade |
| 130 | +###### Supported upgraded by dcos.io |
| 131 | + |
| 132 | +##### Prerequisite: |
| 133 | +Update your terraform scripts to gain access to the latest DC/OS version with this command below: |
| 134 | + |
| 135 | +``` |
| 136 | +terraform get --update |
| 137 | +``` |
| 138 | + |
| 139 | +##### Masters Sequentially, Agents Parellel: |
| 140 | +```bash |
| 141 | +terraform apply -var-file desired_cluster_profile.tfvars -var state=upgrade -target null_resource.bootstrap -target null_resource.master -parallelism=1 |
| 142 | +terraform apply -var-file desired_cluster_profile.tfvars -var state=upgrade |
| 143 | +``` |
| 144 | + |
| 145 | +##### All Roles Simultaniously |
| 146 | +###### Not supported by dcos.io but it works without dcos_skip_checks enabled. |
| 147 | + |
| 148 | +```bash |
| 149 | +terraform apply -var-file desired_cluster_profile.tfvars -var state=upgrade |
| 150 | +``` |
| 151 | + |
| 152 | +## Maintenance |
| 153 | + |
| 154 | +If you would like to add more or remove (private) agents or public agents from your cluster, you can do so by telling terraform your desired state and it will make sure it gets you there. |
| 155 | + |
| 156 | +### Adding Agents |
| 157 | + |
| 158 | +```bash |
| 159 | +# update num_of_private_agents = "5" in desired_cluster_profile.tfvars |
| 160 | +terraform apply -var-file desired_cluster_profile.tfvars |
| 161 | +``` |
| 162 | + |
| 163 | +### Removing Agents |
| 164 | + |
| 165 | +```bash |
| 166 | +# update num_of_private_agents = "2" in desired_cluster_profile.tfvars |
| 167 | +terraform apply -var-file desired_cluster_profile.tfvars |
| 168 | +``` |
| 169 | + |
| 170 | +**Important**: Always remember to save your desired state in your `desired_cluster_profile.tfvars` |
| 171 | + |
| 172 | +## Redeploy an existing Master |
| 173 | + |
| 174 | +If you wanted to redeploy a problematic master (ie. storage filled up, not responsive, etc), you can tell terraform to redeploy during the next cycle. |
| 175 | + |
| 176 | +**NOTE:** This only applies to DC/OS clusters that have set their `dcos_master_discovery` to `master_http_loadbalancer` and not `static`. |
| 177 | + |
| 178 | +### Master Node |
| 179 | + |
| 180 | +#### Taint Master Node |
| 181 | + |
| 182 | +```bash |
| 183 | +terraform taint openstack_compute_instance_v2.masters.0 # The number represents the agent in the list |
| 184 | +``` |
| 185 | + |
| 186 | +#### Redeploy Master Node |
| 187 | + |
| 188 | +```bash |
| 189 | +terraform apply -var-file desired_cluster_profile.tfvars |
| 190 | +``` |
| 191 | + |
| 192 | +## Redeploy an existing Agent |
| 193 | + |
| 194 | +If you wanted to redeploy a problematic agent, (ie. storage filled up, not responsive, etc), you can tell terraform to redeploy during the next cycle. |
| 195 | + |
| 196 | + |
| 197 | +### Private Agents |
| 198 | + |
| 199 | +#### Taint Private Agent |
| 200 | + |
| 201 | +```bash |
| 202 | +terraform taint openstack_compute_instance_v2.agent.0 # The number represents the agent in the list |
| 203 | +``` |
| 204 | + |
| 205 | +#### Redeploy Agent |
| 206 | + |
| 207 | +```bash |
| 208 | +terraform apply -var-file desired_cluster_profile.tfvars |
| 209 | +``` |
| 210 | + |
| 211 | + |
| 212 | +### Public Agents |
| 213 | + |
| 214 | +#### Taint Private Agent |
| 215 | + |
| 216 | +```bash |
| 217 | +terraform taint openstack_compute_instance_v2.public-agent.0 # The number represents the agent in the list |
| 218 | +``` |
| 219 | + |
| 220 | +#### Redeploy Agent |
| 221 | + |
| 222 | +```bash |
| 223 | +terraform apply -var-file desired_cluster_profile.tfvars |
| 224 | +``` |
| 225 | + |
| 226 | +### Experimental |
| 227 | + |
| 228 | +#### Adding GPU Private Agents |
| 229 | + |
| 230 | +Coming soon! |
| 231 | + |
| 232 | +### Destroy Cluster |
| 233 | + |
| 234 | +You can shutdown/destroy all resources from your environment by running this command below |
| 235 | + |
| 236 | +```bash |
| 237 | +terraform destroy -var-file desired_cluster_profile.tfvars |
| 238 | +``` |
0 commit comments