Search code examples
spring-cloud-dataflow

Spring Cloud Data Flow java DSL: container properties


I have a SCDF local deployment where I want to deploy a custom docker-based sink. This sink internally consists of a java part that acts as translation wrapper between SCDF and another bit of nonjava code.

I need to be able to control

  1. Name of container
  2. Number of instances
  3. volumes mounted to container
  4. Ports mapped to container
  5. Environment variables passed to the nonjava code

Looking at LocalAppDeployer and DockerCommandBuilder it seems I should be able to do (1) and (2) with something like

HashMap<String,String> params = new HashMap<>();
params.put(AppDeployer.COUNT_PROPERTY_KEY,2);
params.put(AppDeployer.GROUP_PROPERTY_KEY,"foo");

Stream.builder(scdf)
                .name("mystream")
                .definition("file|bar")
                .create()
                .deploy(props);

which I expect to give me 2 containers: foo-bar-1 and foo-bar-2 My question is how can I archive (3),(4) and (5)?


Solution

  • For any future searches:
    TL;DR: use deployer.<appName>.local.docker.volume-mounts and deployer.<appName>s.local.docker.port-mappings

    e.g:

    Map<String, String> properties = new HashMap<>();
     
    properties.put(String.format("deployer.%s.local.docker.volume-mounts", "myApp"),"/tmp/foo:/bar");
    
    properties.put(String.format("deployer.%s.local.docker.port-mappings", "myApp"),"9090:80");
    
    Stream.builder(scdf).name("myStream").definition("time|log").create().deploy(properties)
    

    See PR. Thank you to the SCDF team for their help