0

I want to create a Jelastic environment with a load balancer and a cp node. I want to add the cp node with the addNodes api method, because it needs specific data to start. My manifest looks like this:

jpsVersion: 1.3
jpsType: install
application:
  id: test-app
  name: Test App
  version: 0.0

  env:
    topology:
      nodes:
        - nodeGroup: bl
          nodeType: nginx-dockerized
          tag: 1.16.1
          displayName: Node balancing
          count: 1
          fixedCloudlets: 1
          cloudlets: 4

  onInstall:
  - addFile
  - setup

  actions:
    addFile:
    - cmd [bl]:
      - mkdir /data
      - echo "Hello world" > /data/test.txt
      user: root
    setup:
    - addNodes:
      - nodeGroup: cp
        nodeType: docker
        displayName: Test Mount
        count: 1
        fixedCloudlets: 1
        cloudlets: 4
        dockerName: alpine
        volumeMounts:
          /kickstart:
            readOnly: true
            sourcePath: /data
            sourceNodeGroup: bl
        dockerVolumes:
        - /kickstart

For some reason, I want my alpine image to be provided with the data I am storing in the folder /kickstart. Of course, in that case, it's completely irrelevant. The example above is just kept simple enough to be reproducible. In my real use-case, the docker image I want to mount will not be able to run without some application-specific data that are filled up with the manifest's settings completed upon user input. That's why it is necessary that the data be available upon docker node addition.

My problem is that the above simple manifest does not work. Indeed, on my docker node, I have no access to /kickstart/test.txt folder. What am I doing wrong?

Laurent Michel
  • 1,069
  • 3
  • 14
  • 29

1 Answers1

1

volumeMounts option is not available for action addNodes

Here is an example how to implement it:

type: install
name: Test App
​
nodes:
  - nodeGroup: bl
    nodeType: nginx
    tag: 1.16.1
    displayName: Node balancing    
    cloudlets: 4
​
  - nodeGroup: cp
    displayName: Test Mount
    cloudlets: 4
    image: alpine
    startServiceOnCreation: false
    volumes: 
      - /kickstart
    volumeMounts: 
      /kickstart:       
        sourcePath: /data
        sourceNodeGroup: bl     
        readOnly: true

onInstall:
  - cmd [bl]: |-
      echo "Hello world" > /data/test.txt
    user: root    

  - env.control.ExecDockerRunCmd [${nodes.cp.join(id,)}] 

also you can use non-existent directories in volumeMounts

it will create everything by itself

Virtuozzo
  • 1,993
  • 1
  • 10
  • 13
  • 1
    It's also possible to use API call in combination with addNodes action. Here is an example https://github.com/jelastic-jps/wildfly/blob/master/addons/auto-clustering/auto-cluster.jps#L100 – Ruslan May 08 '20 at 20:00