UCS 微服务构建器 CLI

UCS 微服务构建器 CLI 工具可用于创建和构建微服务。它可用于列出和查看有关可用微服务的信息,并执行一些 NGC 存储库操作。

该工具名为 ucf_ms_builder_cli

基本操作

查看帮助

$ ucf_ms_builder_cli -h
usage: ucf_ms_builder_cli [-h] [-v] [-va]  ...

positional arguments:

    service           Perform actions on a microservice
    registry          Perform actions on registry
    component         Perform actions on components

optional arguments:
  -h, --help          show this help message and exit
  -v, --version       Print MS Builder Version
  -va, --version-all  Print all versions

检查工具版本

$ ucf_ms_builder_cli -v
Version:
        MS Builder: v2.5.0
$ ucf_ms_builder_cli --version-all
Versions:
        MS Builder: v2.5.0
        UCF MS Spec: v2.5.0

Service 命令 service

Service 命令 service 可用于创建和构建微服务,以及列出和查看有关可用微服务的信息。

$ ucf_ms_builder_cli service [-h]  ...

positional arguments:

    create    Create a microservice scaffolding
    clone     Clone an existing microservice to a new version in prod
    build     Build a microservice
    validate  Validate a microservice
    list      List microservices
    versions  List versions of a microservice
    remove    Remove microservice from repo
    info      Info about a microservice
    sync      Sync a microservice from NGC to cache

optional arguments:
  -h, --help  show this help message and exit

创建微服务脚手架

ucf_ms_builder_cli service create [-h] [-d DESCRIPTION] [-o OUTPUT_DIR] -n NAME -i
                                     {container-image,container-config,helm-chart} [-c CHART]

optional arguments:
  -h, --help            show this help message and exit
  -d DESCRIPTION, --description DESCRIPTION
                        description of microservice
  -o OUTPUT_DIR, --output_dir OUTPUT_DIR
                        output directory to place the created microservice

required arguments:
  -n NAME, --name NAME  name of the microservice
  -i {container-image,container-config,helm-chart}, --input {container-image,container-config,helm-chart}
                        Input:
                        container image
                        container builder config
                        helm chart
  -c CHART, --chart CHART
                        Chart path when using prebuilt helm chart (type=3)

例如:

$ ucf_ms_builder_cli service create -n myservice -i container-image

构建微服务

ucf_ms_builder_cli service build [-h] -d DIRECTORY [-t TARGET] [--push] [--skip-tests] [--skip-compliance] [-f]
                                 [--keep-app-specs]

optional arguments:
  -h, --help            show this help message and exit
  --push                Push service to staging repo if it build is successful
  --skip-tests          Skip building of tests
  --skip-compliance     Skip compliance checks
  -f, --force-cleanup   Output directory contents will be cleaned up without user confirmation
  --keep-app-specs      Create app specs folder in user directory

required arguments:
  -d DIRECTORY, --directory DIRECTORY
                        path to microservice directory
  -t TARGET, --target TARGET
                        Target file path when using container builder config (type=2) (required by container builder)

例如:

$ ucf_ms_builder_cli service build -d myservice/

列出可用的微服务

ucf_ms_builder_cli service list [-h] [-r REPO_NAME]

optional arguments:
  -h, --help            show this help message and exit
  -r REPO_NAME, --repo-name REPO_NAME
                        Select an repository name

例如:

$ ucf_ms_builder_cli service list

列出可用的微服务版本

ucf_ms_builder_cli service versions [-h] -n NAME [-r REPO_NAME]

optional arguments:
  -h, --help            show this help message and exit
  -n NAME, --name NAME  Name of the microservice
  -r REPO_NAME, --repo-name REPO_NAME
                        Select an repository name

例如:

$ ucf_ms_builder_cli service versions -n ucf.svc.myservice

查看微服务信息

ucf_ms_builder_cli service info [-h] [-v MS-VERSION] [--show-compliance-details] [--show-license] [--show-docs]
                                 [--show-changelog] -n NAME

optional arguments:
  -h, --help            show this help message and exit
  -v MS-VERSION, --version MS-VERSION
                        Version of the microservice to get info for
  --show-compliance-details
                        Show compliance check details for the microservice
  --show-license        Show license text for the microservice
  --show-docs           Show detailed documentation for the microservice
  --show-changelog      Show changelog for the microservice

required arguments:
  -n NAME, --name NAME  name of the ms

例如:

$ ucf_ms_builder_cli service info -n ucf.svc.myservice -v 0.0.1

同步微服务

ucf_ms_builder_cli service sync [-h] -n NAME [-v MS-VERSION]

optional arguments:
  -h, --help            show this help message and exit
  -v MS-VERSION, --version MS-VERSION
                        Version of the microservice to sync (default: latest)

required arguments:
  -n NAME, --name NAME  Name of the microservice to sync

例如:

$ ucf_ms_builder_cli service sync -n ucf.svc.myservice -v 0.0.1

Registry 命令 registry

Registry 命令 registry 可用于执行各种注册表操作,例如设置 NGC API 密钥、从 NGC 存储库同步所有微服务、缓存管理。

$ ucf_ms_builder_cli registry -h
usage: ucf_ms_builder_cli registry [-h]  ...

positional arguments:

    repo      Registry repository operations
    cache     Registry cache operations

optional arguments:
  -h, --help  show this help message and exit

设置 NGC API 密钥

ucf_ms_builder_cli registry repo set-api-key [-h] -a API_KEY

optional arguments:
  -h, --help            show this help message and exit

required arguments:
  -a API_KEY, --api-key API_KEY
                        Select a API key

例如:

ucf_ms_builder_cli registry repo set-api-key -a XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

列出可用的存储库

ucf_ms_builder_cli registry repo list [-h]

optional arguments:
  -h, --help  show this help message and exit

例如:

ucf_ms_builder_cli registry repo list

查看存储库的信息

ucf_ms_builder_cli registry repo info [-h] -n REPO_NAME

optional arguments:
  -h, --help            show this help message and exit

required arguments:
  -n REPO_NAME, --repo-name REPO_NAME
                        Select an repository name

例如:

ucf_ms_builder_cli registry repo info -n public

同步存储库中的所有微服务

ucf_ms_builder_cli registry repo sync [-h] -n REPO_NAME [-a]

optional arguments:
  -h, --help            show this help message and exit
  -a, --all             Sync all versions of a microservice

required arguments:
  -n REPO_NAME, --repo-name REPO_NAME
                        Select an repository name

例如:

ucf_ms_builder_cli registry repo sync -n public

清除本地存储库

ucf_ms_builder_cli registry repo clear [-h]

optional arguments:
  -h, --help  show this help message and exit

例如:

ucf_ms_builder_cli registry repo clear

设置 Registry 缓存路径

ucf_ms_builder_cli registry cache set [-h] -p CACHE_PATH

optional arguments:
  -h, --help            show this help message and exit

required arguments:
  -p CACHE_PATH, --cache-path CACHE_PATH
                        Select a cache path

例如:

ucf_ms_builder_cli registry cache set -p /home/ubuntu/ucf_cache

查看 Registry 缓存路径

ucf_ms_builder_cli registry cache view [-h]

optional arguments:
  -h, --help            show this help message and exit

例如:

ucf_ms_builder_cli registry cache view

清除 Registry 缓存

ucf_ms_builder_cli registry cache clear [-h]

optional arguments:
  -h, --help            show this help message and exit

例如:

ucf_ms_builder_cli registry cache clear

Component 命令 component

Component 命令 component 可用于列出和查看有关可用于实现微服务的组件的信息。

$ ucf_ms_builder_cli component [-h]  ...

positional arguments:

    add       Recursively scan directory for components and add them to cache
    list      List available components
    info      Display info of a component

optional arguments:
  -h, --help  show this help message and exit

列出组件

ucf_ms_builder_cli component list [-h]

optional arguments:
  -h, --help  show this help message and exit

例如:

ucf_ms_builder_cli component list

查看组件的信息

ucf_ms_builder_cli component info [-h] -c COMPONENT_NAME

optional arguments:
  -h, --help            show this help message and exit

required arguments:
  -c COMPONENT_NAME, --component COMPONENT_NAME
                        List component info

例如:

ucf_ms_builder_cli component info -c ucf.k8s.container

添加自定义组件

ucf_ms_builder_cli component add [-h] -d DIR_PATH [--overwrite]

optional arguments:
  -h, --help            show this help message and exit

required arguments:
  -d DIR_PATH, --directory DIR_PATH
                        Directory path containing components
  --overwrite           Overwrite components in cache having the same type

例如:

ucf_ms_builder_cli component add -d /home/nvidia/ucf_custom_components