terraform/openstack hosts with no floating ips
Vagrantfile: setup proxy inside virtual machines In corporate networks, it is good to pre-configure proxy variables. Reload docker.socket after installing flannel on coreos Workaround for #569 Swap order in which we reload docker/socket Update README.md Add new var skip_dnsmasq_k8s If skip_dnsmasq is set, it will still not set up dnsmasq k8s pod. This enables independent setup of resolvconf section before kubelet is up. Use tar+register instead of copy/slurp for distributing tokens and certs Related bug: https://github.com/ansible/ansible/issues/15405 Uses tar and register because synchronize module cannot sudo on the remote side correctly and copy is too slow. This patch dramatically cuts down the number of tasks to process for cert synchronization. Update OWNERS Add CI test layouts * Drop Wily from test matrix * Replace the Wily cases dropped with extra cases to test separate roles deployment Signed-off-by: Bogdan Dobrelya <bdobrelia@mirantis.com> Adds functionality to have masters and nodes with no floating IP. Updates ansible group vars on terraform/openstack to follow the inventory/group_vars/all.yml file. Vagrantfile: use Ubuntu 16.04 LTS Use recent supported version of Ubuntu for local development setup with Vagrant. Vagrantfile: setup proxy inside virtual machines In corporate networks, it is good to pre-configure proxy variables. Reload docker.socket after installing flannel on coreos Workaround for #569 Swap order in which we reload docker/socket Update README.md
This commit is contained in:
parent
9581711378
commit
b06a7ea554
3 changed files with 48 additions and 9 deletions
13
Vagrantfile
vendored
13
Vagrantfile
vendored
|
@ -38,6 +38,13 @@ if ! File.exist?(File.join(File.dirname($inventory), "hosts"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if Vagrant.has_plugin?("vagrant-proxyconf")
|
||||||
|
$no_proxy = ENV['NO_PROXY'] || ENV['no_proxy'] || "127.0.0.1,localhost"
|
||||||
|
(1..$num_instances).each do |i|
|
||||||
|
$no_proxy += ",#{$subnet}.#{i+100}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Vagrant.configure("2") do |config|
|
Vagrant.configure("2") do |config|
|
||||||
# always use Vagrants insecure key
|
# always use Vagrants insecure key
|
||||||
config.ssh.insert_key = false
|
config.ssh.insert_key = false
|
||||||
|
@ -52,6 +59,12 @@ Vagrant.configure("2") do |config|
|
||||||
config.vm.define vm_name = "%s-%02d" % [$instance_name_prefix, i] do |config|
|
config.vm.define vm_name = "%s-%02d" % [$instance_name_prefix, i] do |config|
|
||||||
config.vm.hostname = vm_name
|
config.vm.hostname = vm_name
|
||||||
|
|
||||||
|
if Vagrant.has_plugin?("vagrant-proxyconf")
|
||||||
|
config.proxy.http = ENV['HTTP_PROXY'] || ENV['http_proxy'] || ""
|
||||||
|
config.proxy.https = ENV['HTTPS_PROXY'] || ENV['https_proxy'] || ""
|
||||||
|
config.proxy.no_proxy = $no_proxy
|
||||||
|
end
|
||||||
|
|
||||||
if $expose_docker_tcp
|
if $expose_docker_tcp
|
||||||
config.vm.network "forwarded_port", guest: 2375, host: ($expose_docker_tcp + i - 1), auto_correct: true
|
config.vm.network "forwarded_port", guest: 2375, host: ($expose_docker_tcp + i - 1), auto_correct: true
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,14 +5,13 @@ Openstack.
|
||||||
|
|
||||||
## Status
|
## Status
|
||||||
|
|
||||||
This will install a Kubernetes cluster on an Openstack Cloud. It is tested on a
|
This will install a Kubernetes cluster on an Openstack Cloud. It has been tested on a
|
||||||
OpenStack Cloud provided by [BlueBox](https://www.blueboxcloud.com/) and
|
OpenStack Cloud provided by [BlueBox](https://www.blueboxcloud.com/) and on OpenStack at [EMBL-EBI's](http://www.ebi.ac.uk/) [EMBASSY Cloud](http://www.embassycloud.org/). This should work on most modern installs of OpenStack that support the basic
|
||||||
should work on most modern installs of OpenStack that support the basic
|
|
||||||
services.
|
services.
|
||||||
|
|
||||||
There are some assumptions made to try and ensure it will work on your openstack cluster.
|
There are some assumptions made to try and ensure it will work on your openstack cluster.
|
||||||
|
|
||||||
* floating-ips are used for access
|
* floating-ips are used for access, but you can have masters and nodes that don't use floating-ips if needed. You need currently at least 1 floating ip, which we would suggest is used on a master.
|
||||||
* you already have a suitable OS image in glance
|
* you already have a suitable OS image in glance
|
||||||
* you already have both an internal network and a floating-ip pool created
|
* you already have both an internal network and a floating-ip pool created
|
||||||
* you have security-groups enabled
|
* you have security-groups enabled
|
||||||
|
@ -24,16 +23,14 @@ There are some assumptions made to try and ensure it will work on your openstack
|
||||||
|
|
||||||
## Terraform
|
## Terraform
|
||||||
|
|
||||||
Terraform will be used to provision all of the OpenStack resources required to
|
Terraform will be used to provision all of the OpenStack resources. It is also used to deploy and provision the software
|
||||||
run Docker Swarm. It is also used to deploy and provision the software
|
|
||||||
requirements.
|
requirements.
|
||||||
|
|
||||||
### Prep
|
### Prep
|
||||||
|
|
||||||
#### OpenStack
|
#### OpenStack
|
||||||
|
|
||||||
Ensure your OpenStack credentials are loaded in environment variables. This is
|
Ensure your OpenStack credentials are loaded in environment variables. This can be done by downloading a credentials .rc file from your OpenStack dashboard and sourcing it:
|
||||||
how I do it:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
$ source ~/.stackrc
|
$ source ~/.stackrc
|
||||||
|
@ -46,7 +43,7 @@ differences between OpenStack installs the Terraform does not attempt to create
|
||||||
these for you.
|
these for you.
|
||||||
|
|
||||||
By default Terraform will expect that your networks are called `internal` and
|
By default Terraform will expect that your networks are called `internal` and
|
||||||
`external`. You can change this by altering the Terraform variables `network_name` and `floatingip_pool`.
|
`external`. You can change this by altering the Terraform variables `network_name` and `floatingip_pool`. This can be done on a new variables file or through environment variables.
|
||||||
|
|
||||||
A full list of variables you can change can be found at [variables.tf](variables.tf).
|
A full list of variables you can change can be found at [variables.tf](variables.tf).
|
||||||
|
|
||||||
|
@ -76,8 +73,21 @@ $ echo Setting up Terraform creds && \
|
||||||
export TF_VAR_auth_url=${OS_AUTH_URL}
|
export TF_VAR_auth_url=${OS_AUTH_URL}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you want to provision master or node VMs that don't use floating ips, write on a `my-terraform-vars.tfvars` file, for example:
|
||||||
|
|
||||||
|
```
|
||||||
|
number_of_k8s_masters = "1"
|
||||||
|
number_of_k8s_masters_no_floating_ip = "2"
|
||||||
|
number_of_k8s_nodes_no_floating_ip = "1"
|
||||||
|
number_of_k8s_nodes = "0"
|
||||||
|
```
|
||||||
|
This will provision one VM as master using a floating ip, two additional masters using no floating ips (these will only have private ips inside your tenancy) and one VM as node, again without a floating ip.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Provision a Kubernetes Cluster on OpenStack
|
# Provision a Kubernetes Cluster on OpenStack
|
||||||
|
|
||||||
|
If not using a tfvars file for your setup, then execute:
|
||||||
```
|
```
|
||||||
terraform apply -state=contrib/terraform/openstack/terraform.tfstate contrib/terraform/openstack
|
terraform apply -state=contrib/terraform/openstack/terraform.tfstate contrib/terraform/openstack
|
||||||
openstack_compute_secgroup_v2.k8s_master: Creating...
|
openstack_compute_secgroup_v2.k8s_master: Creating...
|
||||||
|
@ -96,6 +106,13 @@ use the `terraform show` command.
|
||||||
State path: contrib/terraform/openstack/terraform.tfstate
|
State path: contrib/terraform/openstack/terraform.tfstate
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Alternatively, if you wrote your terraform variables on a file `my-terraform-vars.tfvars`, your command would look like:
|
||||||
|
```
|
||||||
|
terraform apply -state=contrib/terraform/openstack/terraform.tfstate -var-file=my-terraform-vars.tfvars contrib/terraform/openstack
|
||||||
|
```
|
||||||
|
|
||||||
|
if you choose to add masters or nodes without floating ips (only internal ips on your OpenStack tenancy), this script will create as well a file `contrib/terraform/openstack/k8s-cluster.yml` with an ssh command for ansible to be able to access your machines tunneling through the first floating ip used. If you want to manually handling the ssh tunneling to these machines, please delete or move that file. If you want to use this, just leave it there, as ansible will pick it up automatically.
|
||||||
|
|
||||||
Make sure you can connect to the hosts:
|
Make sure you can connect to the hosts:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -114,6 +131,8 @@ example-k8s-master-1 | SUCCESS => {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
if you are deploying a system that needs bootstrapping, like CoreOS, these might have a state `FAILED` due to CoreOS not having python. As long as the state is not `UNREACHABLE`, this is fine.
|
||||||
|
|
||||||
if it fails try to connect manually via SSH ... it could be somthing as simple as a stale host key.
|
if it fails try to connect manually via SSH ... it could be somthing as simple as a stale host key.
|
||||||
|
|
||||||
Deploy kubernetes:
|
Deploy kubernetes:
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
command: /bin/true
|
command: /bin/true
|
||||||
notify:
|
notify:
|
||||||
- Docker | reload systemd
|
- Docker | reload systemd
|
||||||
|
- Docker | reload docker.socket
|
||||||
- Docker | reload docker
|
- Docker | reload docker
|
||||||
- Docker | pause while Docker restarts
|
- Docker | pause while Docker restarts
|
||||||
- Docker | wait for docker
|
- Docker | wait for docker
|
||||||
|
@ -16,6 +17,12 @@
|
||||||
name: docker
|
name: docker
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
||||||
|
- name: Docker | reload docker.socket
|
||||||
|
service:
|
||||||
|
name: docker.socket
|
||||||
|
state: restarted
|
||||||
|
when: ansible_os_family == 'CoreOS'
|
||||||
|
|
||||||
- name: Docker | pause while Docker restarts
|
- name: Docker | pause while Docker restarts
|
||||||
pause: seconds=10 prompt="Waiting for docker restart"
|
pause: seconds=10 prompt="Waiting for docker restart"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue