我如何对 jelastic 安装清单中最后创建的节点进行操作?

How can I act on the last created node in my jelastic installation manifest?

我有以下 jps 清单:

jpsVersion: 1.3
jpsType: update
application:
  id: test
  name: Test
  version: 0.0

  onInstall:
  - addNodes:
    - nodeType: docker
      count: 1
      fixedCloudlets: 1
      cloudlets: 16
      dockerName: gitlab/gitlab-runner

  onAfterAddNode:
  - installDocker

  actions:
    installDocker:
    - cmd:
      - myDockerInstallScript.sh

我的问题是 onAfterAddNode 操作没有被调用,即使节点已成功添加。我究竟做错了什么?我如何保证命令仅在添加的节点上 运行?

编辑

我的用例如下:我刚才创建了一个环境,我想向其中添加新节点。因此,我需要通过添加新节点并在这些新节点上执行一些安装步骤来更新该环境。

环境中其他事件的执行仅在 onInstall 事件成功完成后发生。 onAfterAddNode 事件将在下次添加节点时 运行。 Here你可以看到事件的顺序。如果你只是需要在安装过程中调用动作,那么你需要在onInstall中这样做:

示例:

jpsVersion: 1.3
jpsType: update
application:
  id: test
  name: Test
  version: 0.0
  onInstall:
  - addNodes:
    - nodeType: docker
      count: 1
      fixedCloudlets: 1
      cloudlets: 16
      dockerName: gitlab/gitlab-runner
  - installDocker
  actions:
    installDocker:
    - cmd:
      - myDockerInstallScript.sh

如果需要在每次将节点添加到环境的拓扑结构时也执行某个操作,那么您可以这样做:

jpsVersion: 1.3
jpsType: update
application:
  id: test
  name: Test
  version: 0.0
  onInstall:
  - addNodes:
    - nodeType: docker
      count: 1
      nodeGroup: runner
      fixedCloudlets: 1
      cloudlets: 16
      dockerName: gitlab/gitlab-runner
  - installDocker
 onAfterAddNode [runner]:
  - installDocker
  actions:
    installDocker:
    - cmd [runner]:
      - myDockerInstallScript.sh

如果你想在缩放整个图层后执行特定的操作,那么你可以这样做:

jpsVersion: 1.3
jpsType: update
application:
  id: test
  name: Test
  version: 0.0
  onInstall:
  - addNodes:
    - nodeType: docker
      count: 1
      nodeGroup: runner
      fixedCloudlets: 1
      cloudlets: 16
      dockerName: gitlab/gitlab-runner
  - installDocker
 onAfterScaleOut [runner]:
  forEach(event.response.nodes):
    installDocker: ${@i.id} 
  actions:
    installDocker:
    - cmd [${this}]:
      - myDockerInstallScript.sh

如果您只需要在新创建的节点中执行操作,那么您可以这样做:

jpsVersion: 1.3
jpsType: update
application:
  id: test
  name: Test
  version: 0.0
  onInstall:
  - addNodes:
      nodeType: docker
      count: 1
      nodeGroup: runner
      fixedCloudlets: 1
      cloudlets: 16
      dockerName: gitlab/gitlab-runner
  - installDocker: ${nodes.runner.last.id}
  actions:
    installDocker:
    - cmd [${this}]:
      - myDockerInstallScript.sh

另外,感谢您对文档的评论,我们已经对其进行了更新:https://docs.cloudscripting.com/creating-manifest/actions/#addnodes