operator-proxy

module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2022 License: Apache-2.0

README

简介

本项目包括cita-cloud-operator的代理服务端operator-proxy和客户端cco-cli( cita-cloud-operator command-line interface ) 两部分

  • cita-cloud-operator: 一个管理cita cloud链的生命周期的自定义控制器
  • operator-proxy: cita-cloud-operator 的服务端代理程序,通过RPC暴露接口
  • cco-cli: 连接operator-proxy的客户端工具,可通过命令的方式快速创建链和节点

安装

cita-cloud-operator的安装

cita-cloud-operatorHelm安装方式建该链接: https://github.com/cita-cloud/cita-cloud-operator

operator-proxy的安装

  • 添加Chart仓库
helm repo add cita-cloud-operator-proxy https://cita-cloud.github.io/operator-proxy
  • 创建安装operator-proxy的命名空间
kubectl create ns cita
  • 执行安装
helm install cita-cloud-operator-proxy cita-cloud-operator-proxy/cita-cloud-operator-proxy -n=cita
  • 验证安装
kubectl get pod -ncita | grep cita-cloud-operator-proxy

如果实际输出的STATUS状态是Running, 表示operator-proxy已经成功安装。

cco-cli的安装

  • 最新版本安装
curl -sLS https://raw.githubusercontent.com/cita-cloud/operator-proxy/master/install-cli.sh | bash
kubectl describe service cita-cloud-operator-proxy -ncita | grep NodePort

设置环境变量,以Kubernetes集群的任意一个节点IPNodePort端口作为endpoint

export OPERATOR_PROXY_ENDPOINT=192.168.10.120:30194
  • 执行帮助命令
cco-cli -h
The cita-cloud operator command line interface lets you create and manage CITA-CLOUD chain.

Usage:
  cco-cli [command]

示例

创建一条名为test-chain的链(默认3节点,并创建在名为cita的环境变量中)

该命令是多个子命令的集合

cco-cli all-in-one create test-chain

可以看到有3个Pod被创建出来

kubectl get pod -ncita
NAME                                          READY   STATUS    RESTARTS   AGE
test-chain-9ba8b85938c7-0                     6/6     Running   0          18h
test-chain-af41db9a3064-0                     6/6     Running   0          18h
test-chain-efe071517f54-0                     6/6     Running   0          18h

chain command

$ cco-cli chain -h
Chain related commands

Usage:
  cco-cli chain [command]

Available Commands:
  delete      Delete a chain in the k8s cluster
  describe    Show chain detail in the k8s cluster
  init        Initialize a chain into the k8s cluster
  list        List chain in the k8s cluster
  online      Online a chain into the k8s cluster
  • 初始化一条名为test-chain的链
$ cco-cli chain init test-chain
init chain [cita/test-chain] success
  • 此时,这条链的状态为Publicizing,代表该链的信息需要向各参与方公示,可以通过describe命令查看详情
$ cco-cli chain describe test-chain
Chain Base Info:
+-----------------+--------------------------------------------------------------------+
|      FIELD      |                               VALUE                                |
+-----------------+--------------------------------------------------------------------+
| Name            | test-chain                                                         |
| Namespace       | cita                                                               |
| Id              | 63586a3c0255f337c77a777ff54f0040b8c388da04f23ecee6bfd4953a6512b4   |
| Timestamp       | 1644466132459760                                                   |
| PrevHash        | 0x0000000000000000000000000000000000000000000000000000000000000000 |
| BlockInterval   | 3                                                                  |
| BlockLimit      | 100                                                                |
| EnableTls       | false                                                              |
| ConsensusType   | Raft                                                               |
| NetworkImage    | citacloud/network_p2p:v6.3.0                                       |
| ConsensusImage  | citacloud/consensus_raft:v6.3.0                                    |
| ExecutorImage   | citacloud/executor_evm:v6.3.0                                      |
| StorageImage    | citacloud/storage_rocksdb:v6.3.0                                   |
| ControllerImage | citacloud/controller:v6.3.0                                        |
| KmsImage        | citacloud/kms_sm:v6.3.0                                            |
| Status          | Publicizing                                                             |
+-----------------+--------------------------------------------------------------------+
Admin Account:
+-------+-----------+------------+-------+--------+
| NAME  | NAMESPACE |   CHAIN    | ROLE  | DOMAIN |
+-------+-----------+------------+-------+--------+
| admin |   cita    | test-chain | Admin |        |
+-------+-----------+------------+-------+--------+
Node Info:
+--------+-----------+------------+---------+------+---------+
|  NAME  | NAMESPACE |   CHAIN    | ACCOUNT | SIZE | STATUS  |
+--------+-----------+------------+---------+------+---------+
| node-1 |   cita    | test-chain |  alice  | 10Gi | Running |
| node-2 |   cita    | test-chain |   bob   | 10Gi | Running |
| node-3 |   cita    | test-chain | carlos  | 10Gi | Running |
+--------+-----------+------------+---------+------+---------+
  • 经各方确认通过后,上线这条链,上线前需要创建好Admin账户和共识节点账户,参考[account command](#account command)
$ cco-cli chain online test-chain
online chain [cita/test-chain] success
  • 查看一条链的详情
$ cco-cli chain describe test-chain
Chain Base Info:
+-----------------+--------------------------------------------------------------------+
|      FIELD      |                               VALUE                                |
+-----------------+--------------------------------------------------------------------+
| Name            | test-chain                                                         |
| Namespace       | cita                                                               |
| Id              | 63586a3c0255f337c77a777ff54f0040b8c388da04f23ecee6bfd4953a6512b4   |
| Timestamp       | 1644466132459760                                                   |
| PrevHash        | 0x0000000000000000000000000000000000000000000000000000000000000000 |
| BlockInterval   | 3                                                                  |
| BlockLimit      | 100                                                                |
| EnableTls       | false                                                              |
| ConsensusType   | Raft                                                               |
| NetworkImage    | citacloud/network_p2p:v6.3.0                                       |
| ConsensusImage  | citacloud/consensus_raft:v6.3.0                                    |
| ExecutorImage   | citacloud/executor_evm:v6.3.0                                      |
| StorageImage    | citacloud/storage_rocksdb:v6.3.0                                   |
| ControllerImage | citacloud/controller:v6.3.0                                        |
| KmsImage        | citacloud/kms_sm:v6.3.0                                            |
| Status          | Online                                                             |
+-----------------+--------------------------------------------------------------------+
Admin Account:
+-------+-----------+------------+-------+--------+
| NAME  | NAMESPACE |   CHAIN    | ROLE  | DOMAIN |
+-------+-----------+------------+-------+--------+
| admin |   cita    | test-chain | Admin |        |
+-------+-----------+------------+-------+--------+
Node Info:
+--------+-----------+------------+---------+------+---------+
|  NAME  | NAMESPACE |   CHAIN    | ACCOUNT | SIZE | STATUS  |
+--------+-----------+------------+---------+------+---------+
| node-1 |   cita    | test-chain |  alice  | 10Gi | Running |
| node-2 |   cita    | test-chain |   bob   | 10Gi | Running |
| node-3 |   cita    | test-chain | carlos  | 10Gi | Running |
+--------+-----------+------------+---------+------+---------+
  • 列出命名空间下的所有链
$ cco-cli chain list -n cita
+------------+-----------+--------+
|    NAME    | NAMESPACE | STATUS |
+------------+-----------+--------+
| test-chain |   cita    | Online |
+------------+-----------+--------+
  • 删除一条链
$ cco-cli chain delete test-chain -n cita
delete chain [cita/test-chain] success

account command

$ cco-cli account -h
Account related commands

Usage:
  cco-cli account [command]

Available Commands:
  create      Create a node account for chain
  list        List node account in the k8s cluster
  • 创建Admin账户: admin
$ cco-cli account create admin --chain test-chain --kmsPassword 123456 --role Admin
create account [cita/admin] success

若创建时指定address字段,则不会生成新的admin账户地址,链的配置会将此地址作为admin账户的地址

  • 创建共识账户: alice,若链的网络选择tls,则必须加上domain参数
$ cco-cli account create alice --chain test-chain --kmsPassword 123456 --role Consensus --domain alice.cita.com
create account [cita/alice] success
  • 创建普通账户: davis,若链的网络选择tls,则必须加上domain参数
$ cco-cli account create davis --chain test-chain --kmsPassword 123456 --role Ordinary --domain davis.cita.com
create account [cita/davis] success
  • 查看命名空间下所有用户
$ cco-cli account list -n cita
+--------+-----------+------------+-----------+-----------------+
|  NAME  | NAMESPACE |   CHAIN    |   ROLE    |   DOMAIN        |
+--------+-----------+------------+-----------+-----------------+
| admin  |   cita    | test-chain |   Admin   |                 |
| alice  |   cita    | test-chain | Consensus | alice.cita.com  |
|  bob   |   cita    | test-chain | Consensus |  bob.cita.com   |
| carlos |   cita    | test-chain | Consensus | carlos.cita.com |
| davis  |   cita    | test-chain | Ordinary  | davis.cita.com  |
+--------+-----------+------------+-----------+-----------------+

node command

$ cco-cli node -h
Node related commands

Usage:
  cco-cli node [command]

Available Commands:
  delete      Delete a node
  init        Init a node for chain
  list        List node in the k8s cluster
  reload      Reload the node config, usually used to add or delete nodes in a chain
  start       Start a node
  stop        Stop a node
  • 初始化链下的一个节点:node1,需匹配对应的链名和账户 可初始化与共识账户对应的节点数量
$ cco-cli node init node-1 --account alice --chain test-chain --storageClassName nas-client-provisioner --storageSize 10737418240
init node [cita/node-1] success
  • 启动对应的各个节点
$ cco-cli node start node-1
start node [cita/node-1] success

其他共识节点同上

  • 列出对应链下的所有节点
$ cco-cli node list --chain test-chain
+--------+-----------+------------+---------+------+---------+
|  NAME  | NAMESPACE |   CHAIN    | ACCOUNT | SIZE | STATUS  |
+--------+-----------+------------+---------+------+---------+
| node-2 |   cita    | test-chain |   bob   | 10Gi | Running |
| node-3 |   cita    | test-chain | carlos  | 10Gi | Running |
| node-1 |   cita    | test-chain |  alice  | 10Gi | Running |
+--------+-----------+------------+---------+------+---------+
  • 新增普通节点node-4,对应账户为davis
# 初始化
cco-cli node init node-4 --account davis --chain test-chain
# 启动
cco-cli node start node-4

新增节点后,原有节点均需要执行reload操作,以便能与新节点进行网络交互

$ cco-cli node reload node-1
reload node [cita/node-1] success
$ cco-cli node reload node-2
reload node [cita/node-2] success
$ cco-cli node reload node-3
reload node [cita/node-3] success
$ cco-cli node reload node-4
reload node [cita/node-4] success

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL