diff --git a/templates/keepalived/0/README.md b/templates/keepalived/0/README.md new file mode 100755 index 0000000..0c5e43b --- /dev/null +++ b/templates/keepalived/0/README.md @@ -0,0 +1,50 @@ +# Keepalived + +This catalog recipe enables unicast VRRP based failover for one or more floating IP Addresses. It's intended deployment is for use on a pair edge or ingress nodes where forward-facing load-balancers or other like services will be scheduled. + + +### Form Fields +* **Update Host Sysctl** - If `true` automatically sets the needed sysctl setting on the host. +* **Host Label Name** - Host label key name used to schedule keepalived master and backup instances. +* **Master Label** - The value of the keepalived host Label to signify the master instance. +* **Backup Label** - The value of the keepalived host Label to signify the backup instance. +* **Interface Name** - The host interface that keepalived will monitor and use for VRRP traffic. +* **Virtual Router ID** - A unique number from 0 to 255 that should identify the VRRP group. +* **Master IP** - The IP on the master host that the keepalived daemon should bind to. +* **Backup IP** - The IP on the backup host that the keepalived daemon should bind to. +* **Virtual IP** - Virtual IP to be created. Must be in ip notation: `/ dev ` + +### Requirements + +The host must have the sysctl setting `net.ipv4.ip_nonlocal_bind=1` configured. + +### Usage + +This service is intended to be deployed to edge nodes with a `master` and `backup` deployed respectively. One or more Virtual IPs may then be bound to hosts. These hosts should have an additional label used for load-balancer scheduling e.g. `ingress=true` + +#### Adding an HA Load Balancer Service + +**Ensure your edge hosts have an additional host label before proceeding** + +1. From the Stack menu add a new `Load Balancer`. +2. Set `Scale` to be `Always run one instance of this container on every host`. +3. Add an appropriate `Name` and `Description`. +4. In the `Port Rules` section, click `Show host IP address options.` This enables the Host IP Field. +5. Update the `Port Rules` with the `Host IP` field set to your `Virtual IP` as defined in the keepalived config. Configure the rest of the fields as needed for your application. +6. Click on the `Scheduling` tab and click on `Add Scheduling Rule`. +7. Create a rule where "The host `must` have a `host label` of `` = ``. +8. Click Create. + +#### Adding additional Virtual IPs to the keepalived Service + +1. From the Stack menu expand the `keepalived` service. +2. Select upgrade on the `keepalived-backup` service. +3. Add a new Environment Variable called `KEEPALIVED_VIRTUAL_IPADDRESS_`. Where `` should be a unique value from 0-999. e.g. `KEEPALIVED_VIRTUAL_IPADDRESS_2`. +4. Set the value to be a **QUOTED STRING** with an additional virtual IP following the standard ip format of `/ dev `. e.g. `10.255.33.102/24 dev eth0`. +5. Press `Upgrade`. +6. Repeat the same steps for the `keepalived-master` service. + + +### Troubleshooting + +For further help see the main [arc-ts/keepalived git repo](https://github.com/arc-ts/keepalived) \ No newline at end of file diff --git a/templates/keepalived/0/docker-compose.yml.tpl b/templates/keepalived/0/docker-compose.yml.tpl new file mode 100755 index 0000000..0d6cec3 --- /dev/null +++ b/templates/keepalived/0/docker-compose.yml.tpl @@ -0,0 +1,56 @@ +version: '2' +services: + keepalived-master: + restart: always + image: arcts/keepalived:1.1.0 + network_mode: host + cap_add: + - NET_ADMIN + environment: + KEEPALIVED_AUTOCONF: true + KEEPALIVED_STATE: MASTER + KEEPALIVED_INTERFACE: ${interface} + KEEPALIVED_VIRTUAL_ROUTER_ID: ${router_id} + KEEPALIVED_UNICAST_SRC_IP: ${master_ip} + KEEPALIVED_UNICAST_PEER_0: ${backup_ip} + KEEPALIVED_TRACK_INTERFACE_1: ${interface} + KEEPALIVED_VIRTUAL_IPADDRESS_1: "\"${virtual_ip}\"" + labels: + io.rancher.scheduler.affinity:host_label: ${host_label}=${master_label} + {{- if eq .Values.update_sysctl "true" }} + io.rancher.sidekicks: keepalived-sysctl + {{- end}} + + keepalived-backup: + restart: always + image: arcts/keepalived:1.1.0 + network_mode: host + cap_add: + - NET_ADMIN + environment: + KEEPALIVED_AUTOCONF: true + KEEPALIVED_STATE: BACKUP + KEEPALIVED_INTERFACE: ${interface} + KEEPALIVED_VIRTUAL_ROUTER_ID: ${router_id} + KEEPALIVED_UNICAST_SRC_IP: ${backup_ip} + KEEPALIVED_UNICAST_PEER_0: ${master_ip} + KEEPALIVED_TRACK_INTERFACE_1: ${interface} + KEEPALIVED_VIRTUAL_IPADDRESS_1: "\"${virtual_ip}\"" + labels: + io.rancher.scheduler.affinity:host_label: ${host_label}=${backup_label} + {{- if eq .Values.update_sysctl "true" }} + io.rancher.sidekicks: keepalived-sysctl + {{- end}} + +{{- if eq .Values.update_sysctl "true" }} + keepalived-sysctl: + image: rawmind/alpine-sysctl:0.1-1 + network_mode: none + privileged: true + environment: + SYSCTL_KEY: net.ipv4.ip_nonlocal_bind + SYSCTL_VALUE: 1 + labels: + io.rancher.container.start_once: true +{{- end}} + diff --git a/templates/keepalived/0/rancher-compose.yml b/templates/keepalived/0/rancher-compose.yml new file mode 100755 index 0000000..00df4a4 --- /dev/null +++ b/templates/keepalived/0/rancher-compose.yml @@ -0,0 +1,63 @@ +.catalog: + name: "keepalived" + version: v1.0.1 + description: "Keepalived VRRP based HA service." + minimum_rancher_version: v0.46.0 + uuid: keepalived-1 + questions: + - variable: "update_sysctl" + description: | + Set true to update sysctl. + WARN: If set to true, sysctl key net.ipv4.ip_nonlocal_bind will be set to 1. + label: "Update Host Sysctl:" + type: "enum" + default: "false" + options: + - "true" + - "false" + required: true + - variable: "host_label" + description: "Host label key name used to schedule keepalived master and backup instances." + label: "Host Label Name:" + type: "string" + default: "vrrp_role" + required: true + - variable: "master_label" + description: "The value of the keepalived host Label to signify the master instance." + label: "Master Label:" + type: "string" + default: "master" + required: true + - variable: "backup_label" + description: "The value of the keepalived host Label to signify the backup instance." + label: "Backup Label:" + type: "string" + default: "backup" + required: true + - variable: "interface" + description: "The name of the host interface." + label: "Interface Name:" + type: "string" + default: "eth0" + required: true + - variable: "router_id" + description: "The virtual Router ID to assign to the VRRP Pair." + label: "Virtual Router ID:" + type: "int" + default: "2" + required: true + - variable: "master_ip" + description: "Host IP of master node" + label: "Master IP:" + type: "string" + required: true + - variable: "backup_ip" + description: "Host IP of backup node" + label: "Backup IP:" + type: "string" + required: true + - variable: "virtual_ip" + description: "Virtual IP to be created. MUST be in ip notation: / dev " + label: "Virtual IP:" + type: "string" + required: true diff --git a/templates/keepalived/catalogIcon-keepalived.svg b/templates/keepalived/catalogIcon-keepalived.svg new file mode 100644 index 0000000..7b82b7a --- /dev/null +++ b/templates/keepalived/catalogIcon-keepalived.svg @@ -0,0 +1,293 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + ka + + + + diff --git a/templates/keepalived/config.yml b/templates/keepalived/config.yml new file mode 100755 index 0000000..b0e0aaf --- /dev/null +++ b/templates/keepalived/config.yml @@ -0,0 +1,5 @@ +name: keepalived +description: | + Keepalived enables services to be deployed in HA with VRRP based failover across multiple hosts. +version: v1.0.1 +category: Networking