首页 技术 正文
技术 2022年11月15日
0 收藏 900 点赞 5,009 浏览 4260 个字

1、鉴权模块

1.1 Login,获取token

POST  http://192.168.31.149:8080/auth/login

Headers

Content-Type: application/json

Body:

{

“username”: “admin”,

“password”: “shipyard”

}

response

{

“auth_token”: “$2a$10$kwlWJbgjkEWnN.JhHJINZOp6grcuio1.USA.io28tTLkKzuCnLl.m”,

“user_agent”: “Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0”

}

2、容器管理

2.1 获取容器列表

GET  http://192.168.31.149:8080/api/containers

Headers

User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0

X-Access-Token: admin:$ $2a$10$kwlWJbgjkEWnN.JhHJINZOp6grcuio1.USA.io28tTLkKzuCnLl.m

response

[

{

“id”: “5c12b9ad2961cba3a57947ef5a927dd01545bfe8a73785f7c3b13cb7d0704e38”,

“name”: “/shipyard”,

“image”: {

“name”: “shipyard/shipyard:latest”,

“entrypoint”: [

“/controller”

],

“hostname”: “5c12b9ad2961”,

“bind_ports”: [

{

“proto”: “tcp”,

“host_ip”: “0.0.0.0”,

“port”: 8080,

“container_port”: 8080

}

],

“restart_policy”: {},

“network_mode”: “bridge”

},

“engine”: {

“id”: “compute2”,

“addr”: “http://192.168.31.149:4243”,

“cpus”: 4,

“memory”: 4096,

“labels”: [

“dd”

]

},

“state”: “running”,

“ports”: [

{

“proto”: “tcp”,

“host_ip”: “0.0.0.0”,

“port”: 8080,

“container_port”: 8080

}

]

},

{

“id”: “4a5f16641c2a5ecca0b05b399bfdaf3c62abf3681289189ee5336feeeb96b4a9”,

“name”: “/gloomy_darwin”,

“image”: {

“name”: “mysql_test:latest”,

“environment”: {

“CLOUD_URL”: “http://192.168.31.147:8080/starott_cloud_client/cloud/commomconfig/”

},

“hostname”: “mysqls”,

“restart_policy”: {},

“network_mode”: “bridge”

},

“engine”: {

“id”: “compute2”,

“addr”: “http://192.168.31.149:4243”,

“cpus”: 4,

“memory”: 4096,

“labels”: [

“dd”

]

},

“state”: “stopped”

},

 

2.2 创建容器

POST  /api/containers

Headers

User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0

X-Access-Token: admin:$2a$10$P8jnLva2KnYP0xWOLCmYruD0B11z0JIpH3cOnDHplxFdbBIZv.iOW

Request body

{

“name”: “ehazlett/go-demo”,

“container_name”: “demo”,

“cpus”: 0.1,

“memory”: 32,

“type”: “service”,

“hostname”: “”,

“domain”: “”,

“labels”: [“local”],

“args”: [],

“environment”: {

“FOO”: “bar”

},

“restart_policy”: {

“name”: “always”

},

“bind_ports”: [

{

“host_ip”: “10.1.2.3”,

“proto”: “tcp”,

“container_port”: 8080

},

{

“proto”: “tcp”,

“port”: 80,

“container_port”: 8080

}

],

“links”: {

“redis”: “db”

}

}

Reponse

       [
  {
    "state": {
      "started_at": "2014-09-12T00:48:23.824260519Z",
      "pid": 5890,
      "running": true
    }, 
    "ports": [
      {
        "container_port": 8080,
        "host_ip": "10.1.2.3",
        "port": 49172,
        "proto": "tcp"
      }
    ],
    "engine": {
      "labels": [
        "local",
        "dev"
      ],
      "memory": 4096,
      "cpus": 4,
      "addr": "http://172.16.1.50:2375",
      "id": "local"
    },
    "image": {
      "restart_policy": {
        "name": "always"  
      },
      "labels": [
        "local"
      ],
      "bind_ports": [
        {
          "proto": "tcp",
          "port": 49153,
          "container_port": 8080
        },
        {
          "proto": "tcp",
          "port": 80,
          "container_port": 8080
        }
      ],
      "links": {
        "redis": "db"
      },
      "type": "service",
      "memory": 32,
      "cpus": 0.1,
      "name": "ehazlett/go-demo"
    },
    "id": "4a5da04b8428e7241a9d9993699513d11b89948399dedfa12"
  }
]

 

2.3 重启容器

GET /api/containers/<id>/restart
Restart a container
Request
GET /api/containers/3e532/restart HTTP/1.1
Response
HTTP/1.1 204 No Content

2.4 停止容器

GET /api/containers/<id>/stop
Stop a container
Request
GET /api/containers/3e532/stop HTTP/1.1
Response
HTTP/1.1 204 No Content

2.5 销毁容器

DELETE /api/containers/<id>
Destroy a container
Request
DELETE /api/containers/3e532 HTTP/1.1
Response
HTTP/1.1 204 No Content

 

3、计算节点管理

3.1 获取计算节点列表

GET  http://192.168.31.149:8080/api/engines

Headers

User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0

X-Access-Token: admin:$2a$10$P8jnLva2KnYP0xWOLCmYruD0B11z0JIpH3cOnDHplxFdbBIZv.iOW

response

[

{

“id”: “c589bf34-513e-4a15-8164-146511c5e177”,

“engine”: {

“id”: “compute2”,

“addr”: “http://192.168.31.149:4243”,

“cpus”: 4,

“memory”: 4096,

“labels”: [

“dd”

]

},

“health”: {

“status”: “up”,

“response_time”: 1375306

},

“docker_version”: “1.5.0-dev”

}

]

3.2 添加计算节点

POST /api/engines

Add an engine to the cluster

Request

POST /api/engines HTTP/1.1
Content-Type application/json
 
{
  "id": "local",
  "ssl_cert": "",
  "ssl_key": "",
  "ca_cert": "",
  "engine": {
    "id": "local",
    "addr": "http://10.1.2.3:2375",
    "cpus": 4.0,
    "memory": 8192,
    "labels": [
      "local",
      "dev"
    ]
  }
}
Response
HTTP/1.1 201 Created

3.3 删除计算节点

DELETE /api/engines/<id>

Remove an engine from the cluster

Request

DELETE /api/engines/99095f5f-7579-4a70-9369-04ad73c21312 HTTP/1.1

Response

HTTP/1.1 204 No Content

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,918
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,444
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,255
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,069
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,701
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,741