From c09b9f62d73176fb05b7433020e394ebd46d2096 Mon Sep 17 00:00:00 2001 From: Jeffrey Sica Date: Fri, 21 Jul 2017 14:06:22 -0400 Subject: [PATCH 1/6] initial copy from internal repo --- .../keepalived/0/1/docker-compose.yml | 37 +++ .../keepalived/0/1/rancher-compose.yml | 40 +++ .../keepalived/0/docker-compose.yml | 37 +++ .../keepalived/0/rancher-compose.yml | 22 ++ infra-templates/keepalived/README.md | 12 + .../keepalived/catalogIcon-keepalived.svg | 293 ++++++++++++++++++ infra-templates/keepalived/config.yml | 7 + 7 files changed, 448 insertions(+) create mode 100755 infra-templates/keepalived/0/1/docker-compose.yml create mode 100755 infra-templates/keepalived/0/1/rancher-compose.yml create mode 100755 infra-templates/keepalived/0/docker-compose.yml create mode 100755 infra-templates/keepalived/0/rancher-compose.yml create mode 100644 infra-templates/keepalived/README.md create mode 100644 infra-templates/keepalived/catalogIcon-keepalived.svg create mode 100755 infra-templates/keepalived/config.yml diff --git a/infra-templates/keepalived/0/1/docker-compose.yml b/infra-templates/keepalived/0/1/docker-compose.yml new file mode 100755 index 0000000..e110845 --- /dev/null +++ b/infra-templates/keepalived/0/1/docker-compose.yml @@ -0,0 +1,37 @@ +version: '2' +services: + keepalived-master: + restart: always + image: arcts/keepalived + network_mode: host + cap_add: + - NET_ADMIN + environment: + KEEPALIVED_AUTOCONF: true + KEEPALIVED_STATE: MASTER + KEEPALIVED_INTERFACE: eth0 + KEEPALIVED_VIRTUAL_ROUTER_ID: 2 + KEEPALIVED_UNICAST_SRC_IP: ${master_ip} + KEEPALIVED_UNICAST_PEER_0: ${backup_ip} + KEEPALIVED_TRACK_INTERFACE_1: eth0 + KEEPALIVED_VIRTUAL_IPADDRESS_1: "\"${virtual_ip}\"" + labels: + io.rancher.scheduler.affinity:host_label: ${host_label}=${master_host_label} + + keepalived-backup: + restart: always + image: arcts/keepalived + network_mode: host + cap_add: + - NET_ADMIN + environment: + KEEPALIVED_AUTOCONF: true + KEEPALIVED_STATE: BACKUP + KEEPALIVED_INTERFACE: eth0 + KEEPALIVED_VIRTUAL_ROUTER_ID: 2 + KEEPALIVED_UNICAST_SRC_IP: ${backup_ip} + KEEPALIVED_UNICAST_PEER_0: ${master_ip} + KEEPALIVED_TRACK_INTERFACE_1: eth0 + KEEPALIVED_VIRTUAL_IPADDRESS_1: "\"${virtual_ip}\"" + labels: + io.rancher.scheduler.affinity:host_label: ${host_label}=${backup_host_label} diff --git a/infra-templates/keepalived/0/1/rancher-compose.yml b/infra-templates/keepalived/0/1/rancher-compose.yml new file mode 100755 index 0000000..bd13ebc --- /dev/null +++ b/infra-templates/keepalived/0/1/rancher-compose.yml @@ -0,0 +1,40 @@ +.catalog: + name: "keepalived" + version: v1.0.0 + description: "Autostart Keepalived (ONLY IF YOU KNOW WHAT YOU'RE DOING)" + minimum_rancher_version: v0.46.0 + uuid: keepalived:v1.0.0 + questions: + - variable: host_label + label: "Keepalived Host Label" + description: "Host Label used to schedule keepalived master and backup instances" + type: "string" + default: "edge" + required: true + - variable: master_host_label + label: "Master Host Label" + description: "The value of the Keepalived Host Label to signifify the master instance" + type: "string" + default: "MASTER" + required: true + - variable: backup_host_label + label: "Backup Host Label" + description: "The value of the Keepalived Host Label to signifify the backup instance" + type: "string" + default: "BACKUP" + required: true + - variable: master_ip + description: "Host IP of master edge node" + label: "Master IP" + type: "string" + required: true + - variable: backup_ip + description: "Host IP of backup edge node" + label: "Backup IP" + type: "string" + required: true + - variable: virtual_ip + label: "Virtual IP" + description: "Virtual IP to be created." + type: "string" + required: true diff --git a/infra-templates/keepalived/0/docker-compose.yml b/infra-templates/keepalived/0/docker-compose.yml new file mode 100755 index 0000000..837b46f --- /dev/null +++ b/infra-templates/keepalived/0/docker-compose.yml @@ -0,0 +1,37 @@ +version: '2' +services: + keepalived-master: + restart: always + image: arcts/keepalived + network_mode: host + cap_add: + - NET_ADMIN + environment: + KEEPALIVED_AUTOCONF: true + KEEPALIVED_STATE: MASTER + KEEPALIVED_INTERFACE: eth0 + KEEPALIVED_VIRTUAL_ROUTER_ID: 2 + KEEPALIVED_UNICAST_SRC_IP: ${master_ip} + KEEPALIVED_UNICAST_PEER_0: ${backup_ip} + KEEPALIVED_TRACK_INTERFACE_1: eth0 + KEEPALIVED_VIRTUAL_IPADDRESS_1: "\"${virtual_ip}\"" + labels: + io.rancher.scheduler.affinity:host_label: edge=master + + keepalived-backup: + restart: always + image: arcts/keepalived + network_mode: host + cap_add: + - NET_ADMIN + environment: + KEEPALIVED_AUTOCONF: true + KEEPALIVED_STATE: BACKUP + KEEPALIVED_INTERFACE: eth0 + KEEPALIVED_VIRTUAL_ROUTER_ID: 2 + KEEPALIVED_UNICAST_SRC_IP: ${backup_ip} + KEEPALIVED_UNICAST_PEER_0: ${master_ip} + KEEPALIVED_TRACK_INTERFACE_1: eth0 + KEEPALIVED_VIRTUAL_IPADDRESS_1: "\"${virtual_ip}\"" + labels: + io.rancher.scheduler.affinity:host_label: edge=backup diff --git a/infra-templates/keepalived/0/rancher-compose.yml b/infra-templates/keepalived/0/rancher-compose.yml new file mode 100755 index 0000000..ebdf5ef --- /dev/null +++ b/infra-templates/keepalived/0/rancher-compose.yml @@ -0,0 +1,22 @@ +.catalog: + name: "keepalived" + version: v0.2.0 + description: "Autostart Keepalived (ONLY IF YOU KNOW WHAT YOU'RE DOING)" + minimum_rancher_version: v0.46.0 + uuid: keepalived:v0.2.0 + questions: + - variable: virtual_ip + label: "Virtual IP" + description: "Virtual IP in ip command format" + type: "string" + required: true + - variable: master_ip + description: "IP of master edge node" + label: "Master IP" + type: "string" + required: true + - variable: backup_ip + description: "IP of backup edge node" + label: "Backup IP" + type: "string" + required: true diff --git a/infra-templates/keepalived/README.md b/infra-templates/keepalived/README.md new file mode 100644 index 0000000..d97addd --- /dev/null +++ b/infra-templates/keepalived/README.md @@ -0,0 +1,12 @@ +## Keepalived +Manages VRRP failover + +### Usage + +This service is intended to be deployed to edge nodes with a MASTER and BACKUP deployed respectively. +Additional IPs should be managed via environment variables once deployed with entries following the below pattern: + +`KEEPALIVED_VIRTUAL_IPADDRESS_[0-9]{1,3}` + +Format should mimic the ip command +`10.255.33.100/24 dev eth0` diff --git a/infra-templates/keepalived/catalogIcon-keepalived.svg b/infra-templates/keepalived/catalogIcon-keepalived.svg new file mode 100644 index 0000000..7b82b7a --- /dev/null +++ b/infra-templates/keepalived/catalogIcon-keepalived.svg @@ -0,0 +1,293 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + ka + + + + diff --git a/infra-templates/keepalived/config.yml b/infra-templates/keepalived/config.yml new file mode 100755 index 0000000..6be3c47 --- /dev/null +++ b/infra-templates/keepalived/config.yml @@ -0,0 +1,7 @@ +name: keepalived +description: | + KeepaliveD, provides VRRP failover across multiple nodes +version: v1.0.0 +category: Networking +labels: + io.rancher.orchestration.supported: 'cattle,mesos,swarm,kubernetes' From 8459f2b0645620baa4778e5962f1cecdc6ee572e Mon Sep 17 00:00:00 2001 From: Jeffrey Sica Date: Fri, 21 Jul 2017 14:10:36 -0400 Subject: [PATCH 2/6] mixed up copied files --- .../keepalived/0/1/docker-compose.yml | 37 ----------------- .../keepalived/0/1/rancher-compose.yml | 40 ------------------- .../keepalived/0/docker-compose.yml | 4 +- .../keepalived/0/rancher-compose.yml | 32 +++++++++++---- 4 files changed, 27 insertions(+), 86 deletions(-) delete mode 100755 infra-templates/keepalived/0/1/docker-compose.yml delete mode 100755 infra-templates/keepalived/0/1/rancher-compose.yml diff --git a/infra-templates/keepalived/0/1/docker-compose.yml b/infra-templates/keepalived/0/1/docker-compose.yml deleted file mode 100755 index e110845..0000000 --- a/infra-templates/keepalived/0/1/docker-compose.yml +++ /dev/null @@ -1,37 +0,0 @@ -version: '2' -services: - keepalived-master: - restart: always - image: arcts/keepalived - network_mode: host - cap_add: - - NET_ADMIN - environment: - KEEPALIVED_AUTOCONF: true - KEEPALIVED_STATE: MASTER - KEEPALIVED_INTERFACE: eth0 - KEEPALIVED_VIRTUAL_ROUTER_ID: 2 - KEEPALIVED_UNICAST_SRC_IP: ${master_ip} - KEEPALIVED_UNICAST_PEER_0: ${backup_ip} - KEEPALIVED_TRACK_INTERFACE_1: eth0 - KEEPALIVED_VIRTUAL_IPADDRESS_1: "\"${virtual_ip}\"" - labels: - io.rancher.scheduler.affinity:host_label: ${host_label}=${master_host_label} - - keepalived-backup: - restart: always - image: arcts/keepalived - network_mode: host - cap_add: - - NET_ADMIN - environment: - KEEPALIVED_AUTOCONF: true - KEEPALIVED_STATE: BACKUP - KEEPALIVED_INTERFACE: eth0 - KEEPALIVED_VIRTUAL_ROUTER_ID: 2 - KEEPALIVED_UNICAST_SRC_IP: ${backup_ip} - KEEPALIVED_UNICAST_PEER_0: ${master_ip} - KEEPALIVED_TRACK_INTERFACE_1: eth0 - KEEPALIVED_VIRTUAL_IPADDRESS_1: "\"${virtual_ip}\"" - labels: - io.rancher.scheduler.affinity:host_label: ${host_label}=${backup_host_label} diff --git a/infra-templates/keepalived/0/1/rancher-compose.yml b/infra-templates/keepalived/0/1/rancher-compose.yml deleted file mode 100755 index bd13ebc..0000000 --- a/infra-templates/keepalived/0/1/rancher-compose.yml +++ /dev/null @@ -1,40 +0,0 @@ -.catalog: - name: "keepalived" - version: v1.0.0 - description: "Autostart Keepalived (ONLY IF YOU KNOW WHAT YOU'RE DOING)" - minimum_rancher_version: v0.46.0 - uuid: keepalived:v1.0.0 - questions: - - variable: host_label - label: "Keepalived Host Label" - description: "Host Label used to schedule keepalived master and backup instances" - type: "string" - default: "edge" - required: true - - variable: master_host_label - label: "Master Host Label" - description: "The value of the Keepalived Host Label to signifify the master instance" - type: "string" - default: "MASTER" - required: true - - variable: backup_host_label - label: "Backup Host Label" - description: "The value of the Keepalived Host Label to signifify the backup instance" - type: "string" - default: "BACKUP" - required: true - - variable: master_ip - description: "Host IP of master edge node" - label: "Master IP" - type: "string" - required: true - - variable: backup_ip - description: "Host IP of backup edge node" - label: "Backup IP" - type: "string" - required: true - - variable: virtual_ip - label: "Virtual IP" - description: "Virtual IP to be created." - type: "string" - required: true diff --git a/infra-templates/keepalived/0/docker-compose.yml b/infra-templates/keepalived/0/docker-compose.yml index 837b46f..e110845 100755 --- a/infra-templates/keepalived/0/docker-compose.yml +++ b/infra-templates/keepalived/0/docker-compose.yml @@ -16,7 +16,7 @@ services: KEEPALIVED_TRACK_INTERFACE_1: eth0 KEEPALIVED_VIRTUAL_IPADDRESS_1: "\"${virtual_ip}\"" labels: - io.rancher.scheduler.affinity:host_label: edge=master + io.rancher.scheduler.affinity:host_label: ${host_label}=${master_host_label} keepalived-backup: restart: always @@ -34,4 +34,4 @@ services: KEEPALIVED_TRACK_INTERFACE_1: eth0 KEEPALIVED_VIRTUAL_IPADDRESS_1: "\"${virtual_ip}\"" labels: - io.rancher.scheduler.affinity:host_label: edge=backup + io.rancher.scheduler.affinity:host_label: ${host_label}=${backup_host_label} diff --git a/infra-templates/keepalived/0/rancher-compose.yml b/infra-templates/keepalived/0/rancher-compose.yml index ebdf5ef..bd13ebc 100755 --- a/infra-templates/keepalived/0/rancher-compose.yml +++ b/infra-templates/keepalived/0/rancher-compose.yml @@ -1,22 +1,40 @@ .catalog: name: "keepalived" - version: v0.2.0 + version: v1.0.0 description: "Autostart Keepalived (ONLY IF YOU KNOW WHAT YOU'RE DOING)" minimum_rancher_version: v0.46.0 - uuid: keepalived:v0.2.0 + uuid: keepalived:v1.0.0 questions: - - variable: virtual_ip - label: "Virtual IP" - description: "Virtual IP in ip command format" + - variable: host_label + label: "Keepalived Host Label" + description: "Host Label used to schedule keepalived master and backup instances" type: "string" + default: "edge" + required: true + - variable: master_host_label + label: "Master Host Label" + description: "The value of the Keepalived Host Label to signifify the master instance" + type: "string" + default: "MASTER" + required: true + - variable: backup_host_label + label: "Backup Host Label" + description: "The value of the Keepalived Host Label to signifify the backup instance" + type: "string" + default: "BACKUP" required: true - variable: master_ip - description: "IP of master edge node" + description: "Host IP of master edge node" label: "Master IP" type: "string" required: true - variable: backup_ip - description: "IP of backup edge node" + description: "Host IP of backup edge node" label: "Backup IP" type: "string" required: true + - variable: virtual_ip + label: "Virtual IP" + description: "Virtual IP to be created." + type: "string" + required: true From 99e1add6b4ccb93ca09c1c73805edb87b49e493c Mon Sep 17 00:00:00 2001 From: Jeffrey Sica Date: Fri, 21 Jul 2017 14:25:16 -0400 Subject: [PATCH 3/6] added variables table to readme --- infra-templates/keepalived/README.md | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) mode change 100644 => 100755 infra-templates/keepalived/README.md diff --git a/infra-templates/keepalived/README.md b/infra-templates/keepalived/README.md old mode 100644 new mode 100755 index d97addd..f8aab6b --- a/infra-templates/keepalived/README.md +++ b/infra-templates/keepalived/README.md @@ -1,7 +1,20 @@ ## Keepalived -Manages VRRP failover +Manages VRRP failover within Rancher. -### Usage +This is useful for highly available load balancers or other HA services that you can't load balance. + +### Form Fields + +| Variable | Description | +| ----------------- | ---------------------------------------- | +| Host Label | Host Label used to schedule keepalived master and backup instances | +| Master Host Label | Keepalived Host Label to signifify the master instance | +| Backup Host Label | Keepalived Host Label to signifify the backup instance | +| Master IP | Host IP of master edge node | +| Backup IP | Host IP of backup edge node | +| Virtual IP | Virtual IP to be created | + +### Advanced Usage This service is intended to be deployed to edge nodes with a MASTER and BACKUP deployed respectively. Additional IPs should be managed via environment variables once deployed with entries following the below pattern: @@ -9,4 +22,4 @@ Additional IPs should be managed via environment variables once deployed with en `KEEPALIVED_VIRTUAL_IPADDRESS_[0-9]{1,3}` Format should mimic the ip command -`10.255.33.100/24 dev eth0` +`10.255.33.100/24 dev eth0` \ No newline at end of file From 9dfcd9be5b3eefb724dcb6490dfb8aa6592a4dbf Mon Sep 17 00:00:00 2001 From: Bob Killen Date: Fri, 28 Jul 2017 14:32:52 -0400 Subject: [PATCH 4/6] move keepalived from infra and update config --- .../keepalived/0/rancher-compose.yml | 40 -------------- infra-templates/keepalived/README.md | 25 --------- infra-templates/keepalived/config.yml | 7 --- templates/keepalived/0/README.md | 48 +++++++++++++++++ .../keepalived/0/docker-compose.yml | 24 +++++---- templates/keepalived/0/rancher-compose.yml | 52 +++++++++++++++++++ .../keepalived/catalogIcon-keepalived.svg | 0 templates/keepalived/config.yml | 5 ++ 8 files changed, 119 insertions(+), 82 deletions(-) delete mode 100755 infra-templates/keepalived/0/rancher-compose.yml delete mode 100755 infra-templates/keepalived/README.md delete mode 100755 infra-templates/keepalived/config.yml create mode 100755 templates/keepalived/0/README.md rename {infra-templates => templates}/keepalived/0/docker-compose.yml (63%) create mode 100755 templates/keepalived/0/rancher-compose.yml rename {infra-templates => templates}/keepalived/catalogIcon-keepalived.svg (100%) create mode 100755 templates/keepalived/config.yml diff --git a/infra-templates/keepalived/0/rancher-compose.yml b/infra-templates/keepalived/0/rancher-compose.yml deleted file mode 100755 index bd13ebc..0000000 --- a/infra-templates/keepalived/0/rancher-compose.yml +++ /dev/null @@ -1,40 +0,0 @@ -.catalog: - name: "keepalived" - version: v1.0.0 - description: "Autostart Keepalived (ONLY IF YOU KNOW WHAT YOU'RE DOING)" - minimum_rancher_version: v0.46.0 - uuid: keepalived:v1.0.0 - questions: - - variable: host_label - label: "Keepalived Host Label" - description: "Host Label used to schedule keepalived master and backup instances" - type: "string" - default: "edge" - required: true - - variable: master_host_label - label: "Master Host Label" - description: "The value of the Keepalived Host Label to signifify the master instance" - type: "string" - default: "MASTER" - required: true - - variable: backup_host_label - label: "Backup Host Label" - description: "The value of the Keepalived Host Label to signifify the backup instance" - type: "string" - default: "BACKUP" - required: true - - variable: master_ip - description: "Host IP of master edge node" - label: "Master IP" - type: "string" - required: true - - variable: backup_ip - description: "Host IP of backup edge node" - label: "Backup IP" - type: "string" - required: true - - variable: virtual_ip - label: "Virtual IP" - description: "Virtual IP to be created." - type: "string" - required: true diff --git a/infra-templates/keepalived/README.md b/infra-templates/keepalived/README.md deleted file mode 100755 index f8aab6b..0000000 --- a/infra-templates/keepalived/README.md +++ /dev/null @@ -1,25 +0,0 @@ -## Keepalived -Manages VRRP failover within Rancher. - -This is useful for highly available load balancers or other HA services that you can't load balance. - -### Form Fields - -| Variable | Description | -| ----------------- | ---------------------------------------- | -| Host Label | Host Label used to schedule keepalived master and backup instances | -| Master Host Label | Keepalived Host Label to signifify the master instance | -| Backup Host Label | Keepalived Host Label to signifify the backup instance | -| Master IP | Host IP of master edge node | -| Backup IP | Host IP of backup edge node | -| Virtual IP | Virtual IP to be created | - -### Advanced Usage - -This service is intended to be deployed to edge nodes with a MASTER and BACKUP deployed respectively. -Additional IPs should be managed via environment variables once deployed with entries following the below pattern: - -`KEEPALIVED_VIRTUAL_IPADDRESS_[0-9]{1,3}` - -Format should mimic the ip command -`10.255.33.100/24 dev eth0` \ No newline at end of file diff --git a/infra-templates/keepalived/config.yml b/infra-templates/keepalived/config.yml deleted file mode 100755 index 6be3c47..0000000 --- a/infra-templates/keepalived/config.yml +++ /dev/null @@ -1,7 +0,0 @@ -name: keepalived -description: | - KeepaliveD, provides VRRP failover across multiple nodes -version: v1.0.0 -category: Networking -labels: - io.rancher.orchestration.supported: 'cattle,mesos,swarm,kubernetes' diff --git a/templates/keepalived/0/README.md b/templates/keepalived/0/README.md new file mode 100755 index 0000000..9bf3c91 --- /dev/null +++ b/templates/keepalived/0/README.md @@ -0,0 +1,48 @@ +# 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 + +| Variable | Default | Description | +|:---------------------:|:-----------:|:--------------------------------------------------------------------------------------:| +| **Host Label Name** | `vrrp_role` | Host label key name used to schedule keepalived master and backup instances. | +| **Master Label** | `master` | The value of the keepalived host Label to signify the master instance. | +| **Backup Label** | `backup` | The value of the keepalived host Label to signify the backup instance. | +| **Interface Name** | `eth0` | The host interface that keepalived will monitor and use for VRRP traffic. | +| **Virtual Router ID** | `2` | 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 ` | + +### 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/infra-templates/keepalived/0/docker-compose.yml b/templates/keepalived/0/docker-compose.yml similarity index 63% rename from infra-templates/keepalived/0/docker-compose.yml rename to templates/keepalived/0/docker-compose.yml index e110845..b7c44f5 100755 --- a/infra-templates/keepalived/0/docker-compose.yml +++ b/templates/keepalived/0/docker-compose.yml @@ -2,36 +2,40 @@ version: '2' services: keepalived-master: restart: always - image: arcts/keepalived + image: arcts/keepalived:1.1.0 network_mode: host cap_add: - NET_ADMIN environment: KEEPALIVED_AUTOCONF: true KEEPALIVED_STATE: MASTER - KEEPALIVED_INTERFACE: eth0 - KEEPALIVED_VIRTUAL_ROUTER_ID: 2 + 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: eth0 + KEEPALIVED_TRACK_INTERFACE_1: ${interface} KEEPALIVED_VIRTUAL_IPADDRESS_1: "\"${virtual_ip}\"" labels: - io.rancher.scheduler.affinity:host_label: ${host_label}=${master_host_label} + io.rancher.scheduler.affinity:host_label: ${host_label}=${master_label} + sysctls: + - net.ipv4.ip_nonlocal_bind=1 keepalived-backup: restart: always - image: arcts/keepalived + image: arcts/keepalived:1.1.0 network_mode: host cap_add: - NET_ADMIN environment: KEEPALIVED_AUTOCONF: true KEEPALIVED_STATE: BACKUP - KEEPALIVED_INTERFACE: eth0 - KEEPALIVED_VIRTUAL_ROUTER_ID: 2 + 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: eth0 + KEEPALIVED_TRACK_INTERFACE_1: ${interface} KEEPALIVED_VIRTUAL_IPADDRESS_1: "\"${virtual_ip}\"" labels: - io.rancher.scheduler.affinity:host_label: ${host_label}=${backup_host_label} + io.rancher.scheduler.affinity:host_label: ${host_label}=${backup_label} + sysctls: + - net.ipv4.ip_nonlocal_bind=1 diff --git a/templates/keepalived/0/rancher-compose.yml b/templates/keepalived/0/rancher-compose.yml new file mode 100755 index 0000000..47f53d6 --- /dev/null +++ b/templates/keepalived/0/rancher-compose.yml @@ -0,0 +1,52 @@ +.catalog: + name: "keepalived" + version: v1.0.1 + description: "Keepalived VRRP based HA service." + minimum_rancher_version: v0.46.0 + uuid: keepalived-1 + questions: + - 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/infra-templates/keepalived/catalogIcon-keepalived.svg b/templates/keepalived/catalogIcon-keepalived.svg similarity index 100% rename from infra-templates/keepalived/catalogIcon-keepalived.svg rename to templates/keepalived/catalogIcon-keepalived.svg 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 From 21e91402d76f0436515a899a8d2d982d5a2efd5b Mon Sep 17 00:00:00 2001 From: Bob Killen Date: Tue, 1 Aug 2017 09:38:06 -0400 Subject: [PATCH 5/6] update readme, remove sysctl settings from compose --- templates/keepalived/0/README.md | 21 +++++++++++---------- templates/keepalived/0/docker-compose.yml | 4 ---- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/templates/keepalived/0/README.md b/templates/keepalived/0/README.md index 9bf3c91..2064345 100755 --- a/templates/keepalived/0/README.md +++ b/templates/keepalived/0/README.md @@ -4,17 +4,18 @@ This catalog recipe enables unicast VRRP based failover for one or more floating ### Form Fields +* **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 ` -| Variable | Default | Description | -|:---------------------:|:-----------:|:--------------------------------------------------------------------------------------:| -| **Host Label Name** | `vrrp_role` | Host label key name used to schedule keepalived master and backup instances. | -| **Master Label** | `master` | The value of the keepalived host Label to signify the master instance. | -| **Backup Label** | `backup` | The value of the keepalived host Label to signify the backup instance. | -| **Interface Name** | `eth0` | The host interface that keepalived will monitor and use for VRRP traffic. | -| **Virtual Router ID** | `2` | 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 diff --git a/templates/keepalived/0/docker-compose.yml b/templates/keepalived/0/docker-compose.yml index b7c44f5..0ed4174 100755 --- a/templates/keepalived/0/docker-compose.yml +++ b/templates/keepalived/0/docker-compose.yml @@ -17,8 +17,6 @@ services: KEEPALIVED_VIRTUAL_IPADDRESS_1: "\"${virtual_ip}\"" labels: io.rancher.scheduler.affinity:host_label: ${host_label}=${master_label} - sysctls: - - net.ipv4.ip_nonlocal_bind=1 keepalived-backup: restart: always @@ -37,5 +35,3 @@ services: KEEPALIVED_VIRTUAL_IPADDRESS_1: "\"${virtual_ip}\"" labels: io.rancher.scheduler.affinity:host_label: ${host_label}=${backup_label} - sysctls: - - net.ipv4.ip_nonlocal_bind=1 From b7c07f27b8756e0c3ab8cc652bc31ef625f97118 Mon Sep 17 00:00:00 2001 From: Bob Killen Date: Thu, 3 Aug 2017 08:50:15 -0400 Subject: [PATCH 6/6] add update sysctl setting --- templates/keepalived/0/README.md | 1 + ...ker-compose.yml => docker-compose.yml.tpl} | 19 +++++++++++++++++++ templates/keepalived/0/rancher-compose.yml | 11 +++++++++++ 3 files changed, 31 insertions(+) rename templates/keepalived/0/{docker-compose.yml => docker-compose.yml.tpl} (70%) diff --git a/templates/keepalived/0/README.md b/templates/keepalived/0/README.md index 2064345..0c5e43b 100755 --- a/templates/keepalived/0/README.md +++ b/templates/keepalived/0/README.md @@ -4,6 +4,7 @@ This catalog recipe enables unicast VRRP based failover for one or more floating ### 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. diff --git a/templates/keepalived/0/docker-compose.yml b/templates/keepalived/0/docker-compose.yml.tpl similarity index 70% rename from templates/keepalived/0/docker-compose.yml rename to templates/keepalived/0/docker-compose.yml.tpl index 0ed4174..0d6cec3 100755 --- a/templates/keepalived/0/docker-compose.yml +++ b/templates/keepalived/0/docker-compose.yml.tpl @@ -17,6 +17,9 @@ services: 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 @@ -35,3 +38,19 @@ services: 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 index 47f53d6..00df4a4 100755 --- a/templates/keepalived/0/rancher-compose.yml +++ b/templates/keepalived/0/rancher-compose.yml @@ -5,6 +5,17 @@ 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:"