Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenLab快速使用指南 #76

Open
Yikun opened this issue Apr 12, 2019 · 0 comments
Open

OpenLab快速使用指南 #76

Yikun opened this issue Apr 12, 2019 · 0 comments

Comments

@Yikun
Copy link
Owner

Yikun commented Apr 12, 2019

希望本篇文章帮助你快速地了解如何快速地上手OpenLab。

1. Hello OpenLab

OpenLab提供的核心能力之一,就是可以为项目提供计算资源(目前以虚拟机为主),用户可以通过配置来完成任务的定义,那么,先以"Hello OpenLab"为例介绍如何使用OpenLab的资源。

Step 0 申请资源

Step 1 配置Job

首先,我们要通过配置文件,来告诉OpenLab,哪个项目需要跑什么脚本,具体如下:

  1. 配置项目,例如https://github.com/Yikun/arm-openlab-test的项目名称为Yikun/arm-openlab-test
  2. 配置任务,任务里定义了这个任务需要跑在哪个节点(nodeset),需要跑哪个脚本。
  3. 脚本,配置脚本中需要执行哪些命令。

举个栗子:

配置文件(.zuul.yaml):

- project:
    name: Yikun/hello-openlab
    check:
      jobs:
        - hello-openlab-test

- job:
    name: hello-openlab-test
    parent: init-test
    description: |
      Hello OpenLab in OpenLab ARM cluster.
    run: .zuul/playbooks/arm-openlab-test/run.yaml
    nodeset: ubuntu-xenial-arm64

脚本文件(.zuul/playbooks/arm-openlab-test/run.yaml):

- hosts: all
  tasks:
    - name: Hello OpenLab
      shell:
        cmd: |
          set -xe
          echo "Hello OpenLab"
        executable: /bin/bash

2. roles——减少重复工作的利器

为了让用户减少重复工作,OpenLab也提供了一些常用的脚本完成基本的安装。如下所示:

- hosts: all
  roles:
    - role: config-golang
      arch: arm64
  tasks:
    - name: Hello OpenLab
      shell:
        cmd: |
          set -xe
          echo "Hello OpenLab"
        executable: /bin/bash

用户只需要指定config-golang,即可完成环境上golang的arm64版本的安装。

  roles:
    - role: config-golang
      arch: arm64

当然,如果发现了更好的role,也可以直接贡献到OpenLab。

3. 实例参考

实例参考:Yikun/hello-openlab#2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant