Skip to content
This repository was archived by the owner on Jan 13, 2023. It is now read-only.

Commit

Permalink
Fixes #132: Allow for flexible number of nodes.
Browse files Browse the repository at this point in the history
  • Loading branch information
geerlingguy committed Dec 29, 2018
1 parent 3e7ab1f commit 8f4500a
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 41 deletions.
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ Read the rest of this README and the official [Dramble Wiki](http://www.pidrambl

I'm doing presentations on Ansible, and how easy it makes infrastructure configuration, even for high-performance/high-availability Drupal sites. WiFi/Internet access is spotty at most conferences, so deploying to AWS, DigitalOcean, or other live public cloud instances that require a stable Internet connection is a Bad Idea™.

Deploying to VMs on my own presentation laptop is an option (and I've done this in the past), but it's not quite as impactful as deploying to real, live, 'in-the-flesh' servers. Especially if you can say you're carrying around a datacenter in your bag!
I'm also presenting on Kubernetes, and how easy it is to have self-healing, almost-infinitely-scalable infrastructure (managed with Ansible), and it's more fun to build with Kubernetes on bare metal... at least when the RAM on the Kubernetes master isn't all eaten up!

But really, it's just plain awesome. How many people can say they carry their entire datacenter in a travel bag, and can run it from a USB battery pack?

A cluster of servers, in my hand, at the presentation. With blinking LEDs!

Expand All @@ -24,11 +26,11 @@ You can browse more information about _geerlingguy_'s Dramble on [http://www.pid

## Specs

- 24 ARMv7 CPU Cores
- 5.4 GHz combined compute power
- 6 GB RAM
- 96 GB microSD flash-based storage
- 1 Gbps private network
- 16+ ARMv7 CPU Cores
- 5.6 GHz combined compute power
- 4 GB RAM
- 128 GB microSD flash-based storage
- 1 Gbps private network with PoE

## Getting the Pis (and other accessories)

Expand Down Expand Up @@ -79,6 +81,16 @@ Until the official Pi Dramble Wiki is updated (see TODOs above), this section of

> Note that for the hosts file, you can point the domain at any of the non-master nodes (e.g. `10.0.100.62`, `10.0.100.63`, etc.); they are all running the Traefik ingress controller as a Kubernetes DaemonSet, meaning any single host can direct traffic on port 80 to the `drupal8` service. Technically, you could use DNS round robin to point one domain at all the Pis, but the best solution is to have another load balancer in front of all the Pis, redirecting the traffic to them using a more intelligent load balancing and health monitoring solution.
#### Adding more nodes

You can add more than four nodes, if you desire; add additional hosts in the same sequence in the following files:

- `setup/networking/inventory`
- `setup/networking/vars.yml`
- `inventory`

If you need to change the IP subnet (default is `10.0.100.x`), make sure to also update `hosts.j2` to use the new subnet so hostnames resolve correctly.

#### Private Docker Registry Usage

The Pi Dramble includes a built-in Docker registry that is used to host Drupal images for deployment to Kubernetes. To use the Docker Registry manually (to push or pull images):
Expand All @@ -89,8 +101,6 @@ The Pi Dramble includes a built-in Docker registry that is used to host Drupal i

2. Configure Docker to work with `registry.pidramble.test` as an [insecure HTTP registry](https://docs.docker.com/registry/insecure/#deploy-a-plain-http-registry).

Eventually, the registry will be secure (see GitHub issue TODO), but for now the Dramble uses an insecure HTTP registry for ease of installation.

## Benchmarks - Testing the performance of the Dramble

See the [Pi Dramble Benchmarks](http://www.pidramble.com/wiki/benchmarks) section of the Wiki for current benchmarks and statistics.
Expand Down
1 change: 0 additions & 1 deletion inventory
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ kube1 ansible_host=10.0.100.61 kubernetes_role=master
kube2 ansible_host=10.0.100.62 kubernetes_role=node
kube3 ansible_host=10.0.100.63 kubernetes_role=node
kube4 ansible_host=10.0.100.64 kubernetes_role=node
kube5 ansible_host=10.0.100.65 kubernetes_role=node

[dramble:vars]
ansible_ssh_user=pi
Expand Down
25 changes: 14 additions & 11 deletions k8s-manifests/docker-registry/docker-registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
apiVersion: v1
kind: Namespace
metadata:
name: docker-registry
name: registry

---
# PersistentVolume definition for NFS mount for Docker registry.
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: docker-registry-pv
namespace: docker-registry
namespace: registry
labels:
app: docker-registry
spec:
Expand All @@ -21,14 +21,14 @@ spec:
- ReadWriteOnce
nfs:
path: {{ nfs_share_dir }}/docker-registry
server: {{ groups.dramble[0] }}
server: {{ kubernetes_master_ip }}
persistentVolumeReclaimPolicy: Recycle
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: docker-registry-pvc
namespace: docker-registry
namespace: registry
labels:
app: docker-registry
spec:
Expand All @@ -37,13 +37,14 @@ spec:
resources:
requests:
storage: 8Gi
---

# Docker registry Deployment definition.
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: docker-registry
namespace: docker-registry
namespace: registry
spec:
replicas: 1
selector:
Expand Down Expand Up @@ -74,13 +75,14 @@ spec:
- name: docker-registry-data
persistentVolumeClaim:
claimName: docker-registry-pvc
---

# Docker registry Service definition.
---
kind: Service
apiVersion: v1
metadata:
name: docker-registry
namespace: docker-registry
namespace: registry
labels:
app: docker-registry
spec:
Expand All @@ -90,8 +92,9 @@ spec:
- name: http
port: 5000
targetPort: 5000
---

# Docker registry Ingress definition.
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
Expand All @@ -100,7 +103,7 @@ metadata:
nginx.ingress.kubernetes.io/proxy-read-timeout: "600"
nginx.ingress.kubernetes.io/proxy-send-timeout: "600"
name: docker-registry
namespace: docker-registry
namespace: registry
spec:
rules:
- host: {{ docker_registry_domain }}
Expand Down
2 changes: 1 addition & 1 deletion k8s-manifests/drupal8/drupal8-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spec:
- ReadWriteOnce
nfs:
path: {{ nfs_share_dir }}/drupal8-db
server: {{ groups.dramble[0] }}
server: {{ kubernetes_master_ip }}
persistentVolumeReclaimPolicy: Recycle
---
apiVersion: v1
Expand Down
2 changes: 1 addition & 1 deletion k8s-manifests/drupal8/drupal8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spec:
- ReadWriteOnce
nfs:
path: {{ nfs_share_dir }}/drupal8-files
server: {{ groups.dramble[0] }}
server: {{ kubernetes_master_ip }}
persistentVolumeReclaimPolicy: Recycle
---
apiVersion: v1
Expand Down
5 changes: 5 additions & 0 deletions main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
- import_tasks: tasks/disable-swap.yml
tags: ['always']

- name: Set the master node IP.
set_fact:
kubernetes_master_ip: "{{ hostvars['kube1']['ansible_host'] }}"
tags: ['always']

roles:
# TODO: Re-enable firewall once I can figure out exactly which ports are
# required to get cni, flannel, etc. all working correctly.
Expand Down
4 changes: 2 additions & 2 deletions setup/networking/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ The playbook and configuration in this directory will automatically perform all

To run the playbook:

1. Copy `example.inventory` to `inventory`, and list all your Raspberry Pi's _current_ IP addresses under `[pis]`
1. Copy `example.inventory` to `inventory`, and list all your Raspberry Pi's _current_ IP addresses under `[dramble]`
2. Copy `example.vars.yml` to `vars.yml`, and make sure each Pi's MAC address is mapped to the desired final IP addresses and hostnames.
3. Run `ansible-playbook -i inventory main.yml`.

> _Note_: If you don't have your SSH key installed on all the Pis yet, you will also need to pass `-k` to the above command and enter your SSH password (the default for Raspbian is `raspberry`).
Assuming everything went well, the Pis should switch over to their new IP addresses quickly; if they don't, you can forcefully reboot them with the command:

$ ansible pis -i inventory -a "reboot" -b
$ ansible dramble -i inventory -a "reboot" -b

Now you should be able to run the main Dramble playbooks on your Pi cluster!

Expand Down
1 change: 0 additions & 1 deletion setup/networking/example.inventory
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[pis]
10.0.1.60
10.0.1.61
10.0.1.62
10.0.1.63
Expand Down
3 changes: 0 additions & 3 deletions setup/networking/example.vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ mac_address_mapping:
"b8:27:eb:09:4f:46":
name: kube4.pidramble.com
ip: "10.0.100.64"
"b8:27:eb:26:d9:08":
name: kube5.pidramble.com
ip: "10.0.100.65"

# Nameservers to use in resolv.conf.
dns_nameservers:
Expand Down
2 changes: 1 addition & 1 deletion setup/networking/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- hosts: pis
- hosts: dramble
become: yes

vars_files:
Expand Down
9 changes: 4 additions & 5 deletions setup/networking/templates/hosts.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ ff02::2 ip6-allrouters

127.0.1.1 {{ dramble_hostname }}

10.0.100.61 kube1 kube1.pidramble.com
10.0.100.62 kube2 kube2.pidramble.com
10.0.100.63 kube3 kube3.pidramble.com
10.0.100.64 kube4 kube4.pidramble.com
10.0.100.65 kube5 kube5.pidramble.com
{# Add an entry for each host in the cluster, using the loop index to map IPs #}
{% for host in groups['dramble'] %}
10.0.100.{{ 60 + loop.index }} kube{{ loop.index }} kube{{ loop.index }}.pidramble.com
{% endfor %}
2 changes: 1 addition & 1 deletion tasks/nfs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
- name: Ensure the NFS volume is mounted.
mount:
name: "{{ nfs_mount_dir }}"
src: "{{ groups.dramble[0] }}:{{ nfs_share_dir }}"
src: "{{ kubernetes_master_ip }}:{{ nfs_share_dir }}"
fstype: nfs
opts: "noauto,x-systemd.automount,x-systemd.device-timeout=10,timeo=14"
state: mounted
Expand Down
9 changes: 4 additions & 5 deletions testing/vagrant/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,17 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
{ :name => "kube1", :ip => "192.168.77.2" },
{ :name => "kube2", :ip => "192.168.77.3" },
{ :name => "kube3", :ip => "192.168.77.4" },
{ :name => "kube4", :ip => "192.168.77.5" },
{ :name => "kube5", :ip => "192.168.77.6" }
{ :name => "kube4", :ip => "192.168.77.5" }
]

# Provision each of the VMs.
boxes.each do |opts|
# Configure each of the VMs.
boxes.each_with_index do |opts, index|
config.vm.define opts[:name] do |config|
config.vm.hostname = opts[:name] + ".pidramble.com"
config.vm.network :private_network, ip: opts[:ip]

# Provision all the VMs using Ansible after last VM is up.
if opts[:name] == "kube5"
if index == boxes.size - 1
config.vm.provision "ansible" do |ansible|
ansible.compatibility_mode = "2.0"
ansible.playbook = "../../main.yml"
Expand Down
1 change: 0 additions & 1 deletion testing/vagrant/inventory
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ kube1 ansible_host=192.168.77.2 kubernetes_role=master
kube2 ansible_host=192.168.77.3 kubernetes_role=node
kube3 ansible_host=192.168.77.4 kubernetes_role=node
kube4 ansible_host=192.168.77.5 kubernetes_role=node
kube5 ansible_host=192.168.77.6 kubernetes_role=node

[dramble:vars]
ansible_ssh_user=vagrant
Expand Down

0 comments on commit 8f4500a

Please sign in to comment.