跳转至

远程运行

当您在 Kubernetes 群集中启动新容器时,Kubernetes 将不会在此容器中启动任何进程。Nocalhost 可以使用运行配置在 Kubernetes 群集中运行代码,类似在 IDE 内使用运行功能。

支持的 IDE

Language IDE Edition Required Plugin
Java IntelliJ IDEA Ultimate N/A
Go IntelliJ IDEA Ultimate Go plugin
GoLand Professional N/A
Python IntelliJ IDEA Ultimate Python plugin
PyCharm Professional N/A
PHP IntelliJ IDEA Ultimate PHP plugin
PHPStorm Professional N/A
Node.js IntelliJ IDEA Ultimate Node.js plugin
WebStrom Professional N/A

远程运行过程

  1. 选择要运行的工作负载
  2. Right-click the workload and select Dev Config, configure your run configuration
  3. Then right-click this workload again and select Remote Run
  4. Nocalhost will automatically enter the DevMode and start remote run

IDE 中的远程运行配置

Before starting remote run, if you do not have a Nocalhost IDE run configuration under an existing workload, Nocalhost will create a new IDE run configuration according to your Nocalhost configuration. Different IDE has different configuration names and templates.

Multi Configs

If you already have a Nocalhost IDE run configuration under the existing workload, Nocalhost will use the first one to start running. You can change the order in the Run/Debug Configurations window within IDE.

Nocalhost run configurations in IDE

配置

开发环境之间的开发环境不同。您应该根据实际情况配置远程运行配置。

示例配置

Nocalhost Configs
name: java-remote-run
serviceType: deployment
containers:
  - name: ""
    dev:
        ...
        command:
          run:
            - /home/nocalhost-dev/gradlew
            - bootRun
        ...
Nocalhost Configs
name: python-remote-run
serviceType: deployment
containers:
  - name: ""
    dev:
      ...
        command:
          run:
            - ./run.sh
        ...
run.sh
1
2
3
4
5
6
7
8
9
#! /bin/sh

pip3 install --no-cache-dir -r ./requirements.txt

export DEBUG_DEV=0
export FLASK_DEBUG=0
export FLASK_ENV=development

flask run --host=0.0.0.0 --port=9999
Nocalhost Configs
name: go-remote-run
serviceType: deployment
containers:
  - name: ""
    dev:
        ...
        command:
          run:
            - ./run.sh
        ...
run.sh
1
2
3
4
#! /bin/sh

export GOPROXY=https://goproxy.cn
go run app.go
Nocalhost Configs
name: php-remote-run
serviceType: deployment
containers:
  - name: ""
    dev:
        ...
        command:
          run:
            - ./run.sh
        ...
run.sh
1
2
3
#!/bin/sh

php -t ./ -S 0.0.0.0:9999;
Nocalhost Configs
name: node-remote-run
serviceType: deployment
containers:
  - name: ""
    dev:
        ...
        command:
          run:
            - ./run.sh
        ...
run.sh
1
2
3
#!/bin/sh

npm install && node ratings.js 9080