From 2970f77271fdc2b5b93f84ffb49bd5a1692ccf1f Mon Sep 17 00:00:00 2001 From: Josh Cox Date: Mon, 14 Aug 2017 11:25:47 -0500 Subject: [PATCH 1/5] Added volume driver selection for postgres, and the possibility to choose hosts by label, and a little bit of cleanup --- templates/postgres/1/docker-compose.yml | 41 +++++++++++++ templates/postgres/1/rancher-compose.yml | 76 ++++++++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 templates/postgres/1/docker-compose.yml create mode 100644 templates/postgres/1/rancher-compose.yml diff --git a/templates/postgres/1/docker-compose.yml b/templates/postgres/1/docker-compose.yml new file mode 100644 index 0000000..de6fedc --- /dev/null +++ b/templates/postgres/1/docker-compose.yml @@ -0,0 +1,41 @@ +version: '2' +services: + postgres-lb: + image: rancher/lb-service-haproxy + ports: + - ${lb_port} + {{- if ne .Values.host_label ""}} + labels: + io.rancher.scheduler.affinity:host_label: ${host_label} + {{- end}} + + postgres-data: + image: busybox + labels: + io.rancher.container.start_once: true + {{- if ne .Values.host_label ""}} + io.rancher.scheduler.affinity:host_label: ${host_label} + {{- end}} + volumes: + - pgdata:/var/lib/postgresql/data/pgdata + + postgres: + image: postgres:latest + environment: + PGDATA: /var/lib/postgresql/data/pgdata + POSTGRES_DB: ${postgres_db} + POSTGRES_USER: ${postgres_user} + POSTGRES_PASSWORD: ${postgres_password} + tty: true + stdin_open: true + labels: + io.rancher.sidekicks: postgres-data + {{- if ne .Values.host_label ""}} + io.rancher.scheduler.affinity:host_label: ${host_label} + {{- end}} + volumes_from: + - postgres-data +volumes: + pgdata: + driver: ${VOLUME_DRIVER} + per_container: true diff --git a/templates/postgres/1/rancher-compose.yml b/templates/postgres/1/rancher-compose.yml new file mode 100644 index 0000000..255d648 --- /dev/null +++ b/templates/postgres/1/rancher-compose.yml @@ -0,0 +1,76 @@ +version: '2' +catalog: + name: "Postgres" + version: "v0.0.2" + description: "PostgreSQL" + uuid: postgres-0 + minimum_rancher_version: v0.9.0 + questions: + - variable: lb_port + description: "Port to access PostgreSQL from external services" + label: "Postgres LB Port" + required: true + default: 5432 + type: "int" + - variable: postgres_db + description: "Postgres Database" + label: "Postgres Database" + required: true + default: "postgres_sb" + type: "string" + - variable: postgres_user + description: "Postgres User" + label: "Postgres User" + required: true + default: "postgres_user" + type: "string" + - variable: postgres_password + description: "Postgres Password" + label: "Postgres Password" + required: true + default: "postgres_password" + type: "string" + - variable: "VOLUME_DRIVER" + description: "The VOLUME driver to associate with this server" + label: "VOLUME Driver" + required: true + default: "local" + type: enum + options: # List of options if using type of `enum` + - local + - rancher-nfs + - rancher-efs + - rancher-ebs + - variable: host_label + label: "Host with Label to put postgres on" + description: | + Host label to use as postgres 'value' tag. + Example: 'postgres=true' + required: false + default: "" + type: "string" + +services: + postgres-lb: + scale: 1 + lb_config: + certs: [] + port_rules: + - protocol: tcp + service: postgres + source_port: ${lb_port} + target_port: 5432 + health_check: + port: 42 + interval: 2000 + unhealthy_threshold: 3 + healthy_threshold: 2 + response_timeout: 2000 + postgres: + scale: 1 + health_check: + port: 5432 + interval: 2000 + unhealthy_threshold: 3 + healthy_threshold: 2 + response_timeout: 2000 From b5e6c3d52400a34a09f3814fc2cb9acd382c44ff Mon Sep 17 00:00:00 2001 From: Josh Cox Date: Mon, 14 Aug 2017 11:54:09 -0500 Subject: [PATCH 2/5] tpl --- templates/postgres/1/docker-compose.yml | 41 ------------------------- 1 file changed, 41 deletions(-) delete mode 100644 templates/postgres/1/docker-compose.yml diff --git a/templates/postgres/1/docker-compose.yml b/templates/postgres/1/docker-compose.yml deleted file mode 100644 index de6fedc..0000000 --- a/templates/postgres/1/docker-compose.yml +++ /dev/null @@ -1,41 +0,0 @@ -version: '2' -services: - postgres-lb: - image: rancher/lb-service-haproxy - ports: - - ${lb_port} - {{- if ne .Values.host_label ""}} - labels: - io.rancher.scheduler.affinity:host_label: ${host_label} - {{- end}} - - postgres-data: - image: busybox - labels: - io.rancher.container.start_once: true - {{- if ne .Values.host_label ""}} - io.rancher.scheduler.affinity:host_label: ${host_label} - {{- end}} - volumes: - - pgdata:/var/lib/postgresql/data/pgdata - - postgres: - image: postgres:latest - environment: - PGDATA: /var/lib/postgresql/data/pgdata - POSTGRES_DB: ${postgres_db} - POSTGRES_USER: ${postgres_user} - POSTGRES_PASSWORD: ${postgres_password} - tty: true - stdin_open: true - labels: - io.rancher.sidekicks: postgres-data - {{- if ne .Values.host_label ""}} - io.rancher.scheduler.affinity:host_label: ${host_label} - {{- end}} - volumes_from: - - postgres-data -volumes: - pgdata: - driver: ${VOLUME_DRIVER} - per_container: true From 771d29502d66fd30ce09dfc5482437c6b5918730 Mon Sep 17 00:00:00 2001 From: Josh Cox Date: Mon, 14 Aug 2017 11:54:32 -0500 Subject: [PATCH 3/5] Added tpl file --- templates/postgres/1/docker-compose.yml.tpl | 41 +++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 templates/postgres/1/docker-compose.yml.tpl diff --git a/templates/postgres/1/docker-compose.yml.tpl b/templates/postgres/1/docker-compose.yml.tpl new file mode 100644 index 0000000..de6fedc --- /dev/null +++ b/templates/postgres/1/docker-compose.yml.tpl @@ -0,0 +1,41 @@ +version: '2' +services: + postgres-lb: + image: rancher/lb-service-haproxy + ports: + - ${lb_port} + {{- if ne .Values.host_label ""}} + labels: + io.rancher.scheduler.affinity:host_label: ${host_label} + {{- end}} + + postgres-data: + image: busybox + labels: + io.rancher.container.start_once: true + {{- if ne .Values.host_label ""}} + io.rancher.scheduler.affinity:host_label: ${host_label} + {{- end}} + volumes: + - pgdata:/var/lib/postgresql/data/pgdata + + postgres: + image: postgres:latest + environment: + PGDATA: /var/lib/postgresql/data/pgdata + POSTGRES_DB: ${postgres_db} + POSTGRES_USER: ${postgres_user} + POSTGRES_PASSWORD: ${postgres_password} + tty: true + stdin_open: true + labels: + io.rancher.sidekicks: postgres-data + {{- if ne .Values.host_label ""}} + io.rancher.scheduler.affinity:host_label: ${host_label} + {{- end}} + volumes_from: + - postgres-data +volumes: + pgdata: + driver: ${VOLUME_DRIVER} + per_container: true From 91623ff2581c89a178766fd9df25f72ac0dae11c Mon Sep 17 00:00:00 2001 From: Josh Cox Date: Fri, 18 Aug 2017 11:05:54 -0500 Subject: [PATCH 4/5] postgresTAG --- templates/postgres/1/docker-compose.yml.tpl | 2 +- templates/postgres/1/rancher-compose.yml | 22 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/templates/postgres/1/docker-compose.yml.tpl b/templates/postgres/1/docker-compose.yml.tpl index de6fedc..70084d2 100644 --- a/templates/postgres/1/docker-compose.yml.tpl +++ b/templates/postgres/1/docker-compose.yml.tpl @@ -20,7 +20,7 @@ services: - pgdata:/var/lib/postgresql/data/pgdata postgres: - image: postgres:latest + image: postgres:${POSTGRES_TAG} environment: PGDATA: /var/lib/postgresql/data/pgdata POSTGRES_DB: ${postgres_db} diff --git a/templates/postgres/1/rancher-compose.yml b/templates/postgres/1/rancher-compose.yml index 255d648..b636956 100644 --- a/templates/postgres/1/rancher-compose.yml +++ b/templates/postgres/1/rancher-compose.yml @@ -30,6 +30,28 @@ catalog: required: true default: "postgres_password" type: "string" + - variable: "POSTGRES_TAG" + description: "The postgres tag to associate with this server" + label: "Postgres tag" + required: true + default: "9.6-alpine" + type: enum + options: # List of options if using type of `enum` + - latest + - 10-alpine + - 10 + - 9-alpine + - 9 + - 9.6-alpine + - 9.6 + - 9.5-alpine + - 9.5 + - 9.4-alpine + - 9.4 + - 9.3-alpine + - 9.3 + - 9.2-alpine + - 9.2 - variable: "VOLUME_DRIVER" description: "The VOLUME driver to associate with this server" label: "VOLUME Driver" From d088b221992cdd8c1cb3472416a158d526231580 Mon Sep 17 00:00:00 2001 From: Josh Cox Date: Mon, 21 Aug 2017 07:36:23 -0500 Subject: [PATCH 5/5] versionBump --- templates/postgres/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/postgres/config.yml b/templates/postgres/config.yml index 48437e3..5d3e681 100644 --- a/templates/postgres/config.yml +++ b/templates/postgres/config.yml @@ -1,5 +1,5 @@ name: PostgreSQL description: | PostgreSQL — an object-relational database (ORDBMS) -version: v0.0.1 +version: v0.0.2 category: Databases