rancher / community-catalog

Catalog entries contributed by the community
384 stars 636 forks source link

How to generate dynamic lb_config? #664

Closed lgaticaq closed 6 years ago

lgaticaq commented 6 years ago

Is posible append a variable (REDIS_PASSWORD) in lb_config custom config, like this

.catalog:
  name: "Redis Cluster"
  version: "v1.0.0"
  description: |
    Redis Sentinel Cluster
  questions:
    - variable: REDIS_PASSWORD
      type: password
      required: true
      label: "Redis auth password"
version: '2'
services:
  slave:
    scale: 1
    start_on_create: true
  sentinel:
    scale: 1
    start_on_create: true
  haproxy:
    scale: 1
    start_on_create: true
    lb_config:
      certs: []
      config: "default\n\tmode tcp\n\ttimeout connect 3s\n\ttimeout server 6s\n\t\
        timeout client 6s\n\nbackend 6379_\n\toption tcplog\n\toption tcp-check\n\t\
        tcp-check send AUTH\\ ${REDIS_PASSWORD}\\r\\n\n\ttcp-check\
        \ expect string +OK\n\ttcp-check send PING\\r\\n\n\ttcp-check expect string\
        \ +PONG\n\ttcp-check send info\\ replication\\r\\n\n\ttcp-check expect string\
        \ role:master\n\ttcp-check send QUIT\\r\\n\n\ttcp-check expect string +OK"
      port_rules:
      - priority: 1
        protocol: tcp
        service: master
        source_port: 6379
        target_port: 6379
      - priority: 2
        protocol: tcp
        service: slave
        source_port: 6379
        target_port: 6379
    health_check:
      healthy_threshold: 2
      response_timeout: 2000
      port: 42
      unhealthy_threshold: 3
      initializing_timeout: 60000
      interval: 2000
      reinitializing_timeout: 60000
  master:
    scale: 1
    start_on_create: true
rawmind0 commented 6 years ago

Hi @lgaticaq , yes, it should work. But better version 2 for all compose file...

version: '2'
catalog:
  name: "Redis Cluster"
  version: "v1.0.0"
  description: |
    Redis Sentinel Cluster
  questions:
    - variable: REDIS_PASSWORD
      type: password
      required: true
      label: "Redis auth password"
services:
  slave:
    scale: 1
    start_on_create: true
  sentinel:
    scale: 1
    start_on_create: true
  haproxy:
    scale: 1
    start_on_create: true
    lb_config:
      certs: []
      config: "default\n\tmode tcp\n\ttimeout connect 3s\n\ttimeout server 6s\n\t\
        timeout client 6s\n\nbackend 6379_\n\toption tcplog\n\toption tcp-check\n\t\
        tcp-check send AUTH\\ ${REDIS_PASSWORD}\\r\\n\n\ttcp-check\
        \ expect string +OK\n\ttcp-check send PING\\r\\n\n\ttcp-check expect string\
        \ +PONG\n\ttcp-check send info\\ replication\\r\\n\n\ttcp-check expect string\
        \ role:master\n\ttcp-check send QUIT\\r\\n\n\ttcp-check expect string +OK"
      port_rules:
      - priority: 1
        protocol: tcp
        service: master
        source_port: 6379
        target_port: 6379
      - priority: 2
        protocol: tcp
        service: slave
        source_port: 6379
        target_port: 6379
    health_check:
      healthy_threshold: 2
      response_timeout: 2000
      port: 42
      unhealthy_threshold: 3
      initializing_timeout: 60000
      interval: 2000
      reinitializing_timeout: 60000
  master:
    scale: 1
    start_on_create: true
lgaticaq commented 6 years ago

thanks