-
Notifications
You must be signed in to change notification settings - Fork 69
Arktos API extension with Openstack like VM request with remote test server
Yunwen Bai edited this page Mar 17, 2022
·
12 revisions
With Arktos 1.0 release, Arktos now supports essential Openstack VM APIs and users can use those APIs to create and manage VMs in Arktos platform. For more information about the detailed design, implementation and future works, please refer to the openstack-api-support design doc
This page shows the examples to use the shared test server with CURL commands with the OpenStack APIs and requests in Arktos. The test server IP:port is 34.214.123.51:8080, currently without security or authentication checks for simplicity purpose.
For instructions to setup your own test server, please refer to this wiki page
root@ip-172-31-3-159:~/go/src/k8s.io/arktos# export SERVER_IP=34.214.123.51
root@ip-172-31-3-159:~/go/src/k8s.io/arktos#
root@ip-172-31-3-159:~/go/src/k8s.io/arktos# curl -H "openstack: true" http://${SERVER_IP}:8080/images | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 229 100 229 0 0 702 0 --:--:-- --:--:-- --:--:-- 702
[
{
"id": 1,
"name": "ubuntu-xenial",
"imageRef": "cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img"
},
{
"id": 2,
"name": "cirros-0.5.1",
"imageRef": "download.cirros-cloud.net/0.5.1/cirros-0.5.1-x86_64-disk.img"
}
]
root@ip-172-31-3-159:~/go/src/k8s.io/arktos#
root@ip-172-31-3-159:~/go/src/k8s.io/arktos# curl -H "openstack: true" http://${SERVER_IP}:8080/flavors | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 267 100 267 0 0 819 0 --:--:-- --:--:-- --:--:-- 819
[
{
"id": 5,
"name": "m1.xlarge",
"memoryMb": 16384,
"vcpus": 8
},
{
"id": 1,
"name": "m1.tiny",
"memoryMb": 512,
"vcpus": 1
},
{
"id": 2,
"name": "m1.small",
"memoryMb": 2048,
"vcpus": 1
},
{
"id": 3,
"name": "m1.medium",
"memoryMb": 4096,
"vcpus": 2
},
{
"id": 4,
"name": "m1.large",
"memoryMb": 8192,
"vcpus": 4
}
]
root@ip-172-31-3-159:~/go/src/k8s.io/arktos#
root@ip-172-31-3-159:~/go/src/k8s.io/arktos# cat test/e2e/arktos/testvm.json
{
"server":{
"name":"testvm",
"imageRef":"cirros-0.5.1",
"flavorRef":"m1.tiny",
"networks":[
{
"uuid":"2608d099-c5cb-45c9-a85e-c7daba9f95bf"
}
],
"security_groups": [
{
"name": "default"
}
],
"key_name": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCaJEcFDXEK2ZbX0ZLS1EIYFZRbDAcRfuVjpstSc0De8+sV1aiu+dePxdkuDRwqFtCyk6dEZkssjOkBXtri00MECLkir6FcH3kKOJtbJ6vy3uaJc9w1ERo+wyl6SkAh/+JTJkp7QRXj8oylW5E20LsbnA/dIwWzAF51PPwF7A7FtNg9DnwPqMkxFo1Th/buOMKbP5ZA1mmNNtmzbMpMfJATvVyiv3ccsSJKOiyQr6UG+j7sc/7jMVz5Xk34Vd0l8GwcB0334MchHckmqDB142h/NCWTr8oLakDNvkfC1YneAfAO41hDkUbxPtVBG5M/o7P4fxoqiHEX+ZLfRxDtHB53 me@localhost",
"metadata" : {
"TestKey1" : "TestValue1"
}
}
}
root@ip-172-31-3-159:~/go/src/k8s.io/arktos# curl -L -k -XPOST -H "Content-Type: application/json" -H "User-Agent: kubectl/v0.9.0 (linux/amd64) kubernetes/$Format" -H "Accept: application/json" -H "openstack: true" http://${SERVER_IP}:8080/servers -d @test/e2e/arktos/testvm.json -v | jq
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 34.214.123.51...
* TCP_NODELAY set
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Connected to 34.214.123.51 (34.214.123.51) port 8080 (#0)
> POST /servers HTTP/1.1
> Host: 34.214.123.51:8080
> Content-Type: application/json
> User-Agent: kubectl/v0.9.0 (linux/amd64) kubernetes/
> Accept: application/json
> openstack: true
> Content-Length: 775
>
} [775 bytes data]
* upload completely sent off: 775 out of 775 bytes
< HTTP/1.1 307 Temporary Redirect
< Cache-Control: no-cache, private
< Location: /api/v1/tenants/system/namespaces/kube-system/pods
< Date: Wed, 16 Mar 2022 01:19:46 GMT
< Content-Length: 0
<
100 775 0 0 100 775 0 2370 --:--:-- --:--:-- --:--:-- 2370
* Connection #0 to host 34.214.123.51 left intact
* Issue another request to this URL: 'http://34.214.123.51:8080/api/v1/tenants/system/namespaces/kube-system/pods'
* Found bundle for host 34.214.123.51: 0x56149a27d8d0 [can pipeline]
* Re-using existing connection! (#0) with host 34.214.123.51
* Connected to 34.214.123.51 (34.214.123.51) port 8080 (#0)
> POST /api/v1/tenants/system/namespaces/kube-system/pods HTTP/1.1
> Host: 34.214.123.51:8080
> Content-Type: application/json
> User-Agent: kubectl/v0.9.0 (linux/amd64) kubernetes/
> Accept: application/json
> openstack: true
> Content-Length: 775
>
} [775 bytes data]
* upload completely sent off: 775 out of 775 bytes
< HTTP/1.1 201 Created
< Cache-Control: no-cache, private
< Content-Type: application/json
< Date: Wed, 16 Mar 2022 01:19:46 GMT
< Content-Length: 255
<
{ [255 bytes data]
100 1030 100 255 100 775 514 1562 --:--:-- --:--:-- --:--:-- 2076
* Connection #0 to host 34.214.123.51 left intact
{
"id": "testvm",
"links": [
{
"Link": "/servers/testvm",
"Rel": ""
}
],
"flavor": {
"memoryMb": 512,
"vcpus": 1
},
"image": {
"name": "download.cirros-cloud.net/0.5.1/cirros-0.5.1-x86_64-disk.img"
},
"status": "statusUnknown",
"tenant": "system",
"os_ext_sts_power_state": "nosate"
}
root@ip-172-31-3-159:~/go/src/k8s.io/arktos#
root@ip-172-31-3-159:~/go/src/k8s.io/arktos# curl -L -k -H "Content-Type: application/json" -H "User-Agent: kubectl/v0.9.0 (linux/amd64) kubernetes/$Format" -H "Accept: application/json" -H "openstack: true" http://${SERVER_IP}:8080/servers | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 118 100 118 0 0 361 0 --:--:-- --:--:-- --:--:-- 361
100 76 100 76 0 0 154 0 --:--:-- --:--:-- --:--:-- 154
{
"Servers": [
{
"id": "testvm",
"links": [
{
"Link": "/servers/testvm",
"Rel": ""
}
]
}
]
}
root@ip-172-31-3-159:~/go/src/k8s.io/arktos#
root@ip-172-31-3-159:~/go/src/k8s.io/arktos# curl -L -k -H "Content-Type: application/json" -H "User-Agent: kubectl/v0.9.0 (linux/amd64) kubernetes/$Format" -H "Accept: application/json" -H "openstack: true" http://${SERVER_IP}:8080/servers/testvm | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 125 100 125 0 0 383 0 --:--:-- --:--:-- --:--:-- 383
100 319 100 319 0 0 651 0 --:--:-- --:--:-- --:--:-- 651
{
"id": "testvm",
"links": [
{
"Link": "/servers/testvm",
"Rel": ""
}
],
"flavor": {
"memoryMb": 512,
"vcpus": 1
},
"image": {
"name": "download.cirros-cloud.net/0.5.1/cirros-0.5.1-x86_64-disk.img"
},
"status": "active",
"tenant": "system",
"createdAt": "2022-03-16 01:19:46 +0000 UTC",
"accessIpv4": "10.88.0.31",
"os_ext_sts_power_state": "running"
}
root@ip-172-31-3-159:~/go/src/k8s.io/arktos#
root@ip-172-31-3-159:~/go/src/k8s.io/arktos#
root@ip-172-31-3-159:~/go/src/k8s.io/arktos# cat test/e2e/arktos/testvm-batch.json
{
"server":{
"name":"testvm",
"imageRef":"cirros-0.5.1",
"flavorRef":"m1.tiny",
"networks":[
{
"uuid":"2608d099-c5cb-45c9-a85e-c7daba9f95bf"
}
],
"key_name": "ssh-rsa AAAA"
},
"min_count":3,
"max_count":3,
"return_reservation_id":true
}
root@ip-172-31-3-159:~/go/src/k8s.io/arktos# curl -L -k -XPOST -H "Content-Type: application/json" -H "User-Agent: kubectl/v0.9.0 (linux/amd64) kubernetes/$Format" -H "Accept: application/json" -H "openstack: true" http://${SERVER_IP}:8080/servers -d @test/e2e/arktos/testvm-batch.json -v | jq
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 34.214.123.51...
* TCP_NODELAY set
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Connected to 34.214.123.51 (34.214.123.51) port 8080 (#0)
> POST /servers HTTP/1.1
> Host: 34.214.123.51:8080
> Content-Type: application/json
> User-Agent: kubectl/v0.9.0 (linux/amd64) kubernetes/
> Accept: application/json
> openstack: true
> Content-Length: 275
>
} [275 bytes data]
* upload completely sent off: 275 out of 275 bytes
< HTTP/1.1 307 Temporary Redirect
< Cache-Control: no-cache, private
< Location: /apis/apps/v1/tenants/system/namespaces/kube-system/replicasets
< Date: Wed, 16 Mar 2022 01:21:20 GMT
< Content-Length: 0
<
100 275 0 0 100 275 0 838 --:--:-- --:--:-- --:--:-- 838
* Connection #0 to host 34.214.123.51 left intact
* Issue another request to this URL: 'http://34.214.123.51:8080/apis/apps/v1/tenants/system/namespaces/kube-system/replicasets'
* Found bundle for host 34.214.123.51: 0x55c0bf5c3980 [can pipeline]
* Re-using existing connection! (#0) with host 34.214.123.51
* Connected to 34.214.123.51 (34.214.123.51) port 8080 (#0)
> POST /apis/apps/v1/tenants/system/namespaces/kube-system/replicasets HTTP/1.1
> Host: 34.214.123.51:8080
> Content-Type: application/json
> User-Agent: kubectl/v0.9.0 (linux/amd64) kubernetes/
> Accept: application/json
> openstack: true
> Content-Length: 275
>
} [275 bytes data]
* upload completely sent off: 275 out of 275 bytes
< HTTP/1.1 201 Created
< Cache-Control: no-cache, private
< Content-Type: application/json
< Date: Wed, 16 Mar 2022 01:21:20 GMT
< Content-Length: 28
<
{ [28 bytes data]
100 303 100 28 100 275 56 554 --:--:-- --:--:-- --:--:-- 0
* Connection #0 to host 34.214.123.51 left intact
{
"reservation_id": "testvm"
}
root@ip-172-31-3-159:~/go/src/k8s.io/arktos#
root@ip-172-31-3-159:~/go/src/k8s.io/arktos#
root@ip-172-31-3-159:~/go/src/k8s.io/arktos# cat test/e2e/arktos/testvm-list.json
{
"reservation_id":"testvm"
}
root@ip-172-31-3-159:~/go/src/k8s.io/arktos# curl -L -k -XGET -H "Content-Type: application/json" -H "User-Agent: kubectl/v0.9.0 (linux/amd64) kubernetes/$Format" -H "Accept: application/jsn" -H "openstack: true" http://${SERVER_IP}:8080/servers -d @test/e2e/arktos/testvm-list.json -v | jq
* Trying 34.214.123.51...
* TCP_NODELAY set
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Connected to 34.214.123.51 (34.214.123.51) port 8080 (#0)
> GET /servers HTTP/1.1
> Host: 34.214.123.51:8080
> Content-Type: application/json
> User-Agent: kubectl/v0.9.0 (linux/amd64) kubernetes/
> Accept: application/json
> openstack: true
> Content-Length: 29
>
} [29 bytes data]
* upload completely sent off: 29 out of 29 bytes
< HTTP/1.1 307 Temporary Redirect
< Cache-Control: no-cache, private
< Content-Type: text/html; charset=utf-8
< Location: /api/v1/tenants/system/namespaces/kube-system/pods?labelSelector=openstsckApi=true,ln=testvm
< Date: Wed, 16 Mar 2022 01:22:12 GMT
< Content-Length: 128
<
* Ignoring the response-body
{ [128 bytes data]
100 157 100 128 100 29 390 88 --:--:-- --:--:-- --:--:-- 478
* Connection #0 to host 34.214.123.51 left intact
* Issue another request to this URL: 'http://34.214.123.51:8080/api/v1/tenants/system/namespaces/kube-system/pods?labelSelector=openstsckApi=true,ln=testvm'
* Found bundle for host 34.214.123.51: 0x55d69b023ae0 [can pipeline]
* Re-using existing connection! (#0) with host 34.214.123.51
* Connected to 34.214.123.51 (34.214.123.51) port 8080 (#0)
> GET /api/v1/tenants/system/namespaces/kube-system/pods?labelSelector=openstsckApi=true,ln=testvm HTTP/1.1
> Host: 34.214.123.51:8080
> Content-Type: application/json
> User-Agent: kubectl/v0.9.0 (linux/amd64) kubernetes/
> Accept: application/json
> openstack: true
> Content-Length: 29
>
} [29 bytes data]
* upload completely sent off: 29 out of 29 bytes
< HTTP/1.1 200 OK
< Cache-Control: no-cache, private
< Content-Type: application/json
< Date: Wed, 16 Mar 2022 01:22:12 GMT
< Content-Length: 236
<
{ [236 bytes data]
100 265 100 236 100 29 476 58 --:--:-- --:--:-- --:--:-- 534
* Connection #0 to host 34.214.123.51 left intact
{
"Servers": [
{
"id": "testvm-d5nzm",
"links": [
{
"Link": "/servers/testvm-d5nzm",
"Rel": ""
}
]
},
{
"id": "testvm-dm8ng",
"links": [
{
"Link": "/servers/testvm-dm8ng",
"Rel": ""
}
]
},
{
"id": "testvm-vvfvs",
"links": [
{
"Link": "/servers/testvm-vvfvs",
"Rel": ""
}
]
}
]
}
root@ip-172-31-3-159:~/go/src/k8s.io/arktos#
root@ip-172-31-3-159:~/go/src/k8s.io/arktos#
root@ip-172-31-3-159:~/go/src/k8s.io/arktos# cat test/e2e/arktos/reboot.json
{
"reboot" : {
"type" : "HARD"
}
}
root@ip-172-31-3-159:~/go/src/k8s.io/arktos# curl -L -k -XPOST -H "Content-Type: application/json" -H "User-Agent: kubectl/v0.9.0 (linux/amd64) kubernetes/$Format" -H "Accept: application/json" -H "openstack: true" http://${SERVER_IP}:8080/servers/testvm/action -d @test/e2e/arktos/reboot.json -v | jq
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 34.214.123.51...
* TCP_NODELAY set
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Connected to 34.214.123.51 (34.214.123.51) port 8080 (#0)
> POST /servers/testvm/action HTTP/1.1
> Host: 34.214.123.51:8080
> Content-Type: application/json
> User-Agent: kubectl/v0.9.0 (linux/amd64) kubernetes/
> Accept: application/json
> openstack: true
> Content-Length: 46
>
} [46 bytes data]
* upload completely sent off: 46 out of 46 bytes
< HTTP/1.1 307 Temporary Redirect
< Cache-Control: no-cache, private
< Location: /api/v1/tenants/system/namespaces/kube-system/pods/testvm/action
< Date: Wed, 16 Mar 2022 01:22:44 GMT
< Content-Length: 0
<
100 46 0 0 100 46 0 141 --:--:-- --:--:-- --:--:-- 141
* Connection #0 to host 34.214.123.51 left intact
* Issue another request to this URL: 'http://34.214.123.51:8080/api/v1/tenants/system/namespaces/kube-system/pods/testvm/action'
* Found bundle for host 34.214.123.51: 0x557d66a27ae0 [can pipeline]
* Re-using existing connection! (#0) with host 34.214.123.51
* Connected to 34.214.123.51 (34.214.123.51) port 8080 (#0)
> POST /api/v1/tenants/system/namespaces/kube-system/pods/testvm/action HTTP/1.1
> Host: 34.214.123.51:8080
> Content-Type: application/json
> User-Agent: kubectl/v0.9.0 (linux/amd64) kubernetes/
> Accept: application/json
> openstack: true
> Content-Length: 46
>
} [46 bytes data]
* upload completely sent off: 46 out of 46 bytes
< HTTP/1.1 201 Created
< Cache-Control: no-cache, private
< Date: Wed, 16 Mar 2022 01:22:44 GMT
< Content-Length: 0
<
100 46 0 0 100 46 0 92 --:--:-- --:--:-- --:--:-- 92
* Connection #0 to host 34.214.123.51 left intact
root@ip-172-31-3-159:~/go/src/k8s.io/arktos#
root@ip-172-31-3-159:~/go/src/k8s.io/arktos# # delete the test vm
root@ip-172-31-3-159:~/go/src/k8s.io/arktos# curl -L -XDELETE -H "openstack: true" http://${SERVER_IP}:8080/servers/testvm | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 408 100 408 0 0 800 0 --:--:-- --:--:-- --:--:-- 800
{
"id": "testvm",
"links": [
{
"Link": "/servers/testvm",
"Rel": ""
}
],
"flavor": {
"memoryMb": 512,
"vcpus": 1
},
"image": {
"name": "download.cirros-cloud.net/0.5.1/cirros-0.5.1-x86_64-disk.img"
},
"status": "active",
"tenant": "system",
"createdAt": "2022-03-16 01:19:46 +0000 UTC",
"accessIpv4": "10.88.0.31",
"os_ext_sts_power_state": "running"
}
root@ip-172-31-3-159:~/go/src/k8s.io/arktos#
root@ip-172-31-3-159:~/go/src/k8s.io/arktos# curl -L -k -H "Content-Type: application/json" -H "User-Agent: kubectl/v0.9.0 (linux/amd64) kubernetes/$Format" -H "Accept: application/json" -H "openstack: true" http://${SERVER_IP}:8080/servers/testvm | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 125 100 125 0 0 369 0 --:--:-- --:--:-- --:--:-- 369
100 91 100 91 0 0 179 0 --:--:-- --:--:-- --:--:-- 0
{
"message": "servers \"testvm\" not found",
"errorcode": 404,
"reason": "NotFound"
}
root@ip-172-31-3-159:~/go/src/k8s.io/arktos#
root@ip-172-31-3-159:~/go/src/k8s.io/arktos# curl -XDELETE http://${SERVER_IP}:8080/apis/extensions/v1beta1/tenants/system/namespaces/kube-system/replicasets/testvm -H "Content-Type: application/json" -d '{"kind":"DeleteOptions","apiVersion":"v1","propagationPolicy":"Foreground"}'