Skip to content

How to use REST API

Sooyoung Kim edited this page Dec 19, 2022 · 8 revisions

https://raw.githubusercontent.com/cloud-barista/cb-ladybug/master/src/docs/swagger.yaml

Create a cluster

curl -sX POST -H "Content-Type: application/json" ${BASE_URL}/ns/${NAMESPACE_NAME}/clusters  -d @- <<EOF
{
  "name": "<Cluster Name>",
  "label": "",
  "description": "",
  "config": {
    "installMonAgent": "<Install Y/N dragonfly agent>",
    "kubernetes": {
      "version": "<Supported Kubernetes Version>"
      "etcd": "<ETCD topology>",
      "loadbalancer": "<Loadbalancer>",
      "networkCni": "<Network CNI addon>",
      "podCidr": "<Pod CIDR>",
      "serviceCidr": "<Service CIDR>",
      "serviceDnsDomain": "<Service DNS Domain>"
      "storageclass": {
        "nfs": {
          "path": "<NFS path>",
          "server": "<NFS ip address>"
        }
      },
    }
  },
  "controlPlane": [{
    "connection": "<Connection info. Name>",
    "count": <Node Count>,
    "spec": "<CSP Machine Spec.>",
    "rootDisk": {
      "type": "defalut",
      "size": "defalut"
    },
  }],
  "worker": [{
    "connection": "<Connection info. Name>",
    "count": <Node Count>,
    "spec": "<CSP Machine Spec.>",
    "rootDisk": {
      "type": "defalut",
      "size": "defalut"
    }
  }]
}
EOF
  • URL

    • BASE_URL : CB-Ladybug Base URL
    • NAMESPACE_NAME : Cloud-Barista 네임스페이스 이름
  • Values

    • Network CNI addon : "kilo", "canal"
    • Pod CIDR : K8s Pod CIDR (default) 10.244.0.0/16
    • Service CIDR : K8s Service CIDR (default) 10.96.0.0/12
    • Service DNS Domain : Service 기본 도메인 이름 (default) cluster.local
    • Connection info. Name : Cloud-Barista Cloud Connection Info.
    • Node Count : 생성할 노드 갯수 (ex.) 1,3,5, ...
    • CSP Machine Sepc. : CSP별 VM 인스턴스 타입 (ex.) t2.medium, n1-standard-2, Standard_B2s, ..
    • Install Y/N dragonfly agent : CB-Dragonfly Agent 설치 여부 ("yes", "no", default:"no")
    • Supported Kubernetes Version : 쿠버네티스 버전 ("1.23.* / 1.18.*)
    • ETCD topology : ETCD 토플로지 ("local", "external", default:"local")
    • Loadbalancer : Control-plane Loadbalancer ("haproxy", "nlb", default:"haproxy")
    • NFS path : NetworkFileSystem 패스
    • NFS ip address : NetworkFileSystem IP주소
  • Example

$ curl -sX POST -H "Content-Type: application/json" http://localhost:1470/ladybug/ns/demo-ns/clusters  -d @- <<EOF
{
  "name": "cluster-1",
  "description": "",
  "label": "",
  "config": {
    "installMonAgent": "no",
    "kubernetes": {
      "version": "1.23.13"
      "etcd": "local",
      "loadbalancer": "haproxy",
      "networkCni": "kilo",
      "podCidr": "10.244.0.0/16",
      "serviceCidr": "10.96.0.0/12",
      "serviceDnsDomain": "cluster.local",
      "storageclass": {
        "nfs": {
          "path": "/nfs/data",
          "server": "163.154.154.89"
        }
      }
    }
  },
  "controlPlane": [
    {
      "connection": "config-aws-ap-northeast-2",
      "count": 3,
      "rootDisk": {
        "size": "default",
        "type": "default"
      },
      "spec": "t2.medium"
    }
  ],
  "worker": [
    {
      "connection": "config-aws-ap-northeast-2",
      "count": 3,
      "rootDisk": {
        "size": "default",
        "type": "default"
      },
      "spec": "t2.medium"
    }
  ]
}EOF

Get a cluster

curl -sX GET -H "Content-Type: application/json" ${BASE_URL}/ns/${NAMESPACE_NAME}/clusters/${CLUSTER_NAME}
  • URL

    • BASE_URL : CB-Ladybug Base URL
    • NAMESPACE_NAME : Cloud-Barista 네임스페이스 이름
    • CLUSTER_NAME : 클러스터 이름
  • Example

$ curl -sX GET -H "Content-Type: application/json" http://localhost:1470/ladybug/ns/demo-ns/clusters/cluster-1

Get clusters

curl -sX GET -H "Content-Type: application/json" ${BASE_URL}/ns/${NAMESPACE_NAME}/clusters
  • URL

    • BASE_URL : CB-Ladybug Base URL
    • NAMESPACE_NAME : Cloud-Barista 네임스페이스 이름
  • Example

$ curl -sX GET -H "Content-Type: application/json" http://localhost:1470/ladybug/ns/demo-ns/clusters

Delete a cluster

curl -sX DELETE -H "Content-Type: application/json" ${BASE_URL}/ns/${NAMESPACE_NAME}/clusters/${CLUSTER_NAME}
  • URL

    • BASE_URL : CB-Ladybug Base URL
    • NAMESPACE_NAME : Cloud-Barista 네임스페이스 이름
    • CLUSTER_NAME : 클러스터 이름
  • Example

$ curl -sX DELETE -H "Content-Type: application/json" http://localhost:1470/ladybug/ns/demo-ns/clusters/cluster-1

Add a Node

only worker node

curl -sX POST -H "Content-Type: application/json" ${BASE_URL}/ns/${NAMESPACE_NAME}/clusters/${CLUSTER_NAME}/nodes -d @- <<EOF
{
  "worker": [
    {
      "connection": "<Connection info. Name>",
      "count": <Node Count>,
      "spec": "<CSP Machine Sepc>",
      "rootDisk": {
        "size": "default",
        "type": "default"
      },
    }
  ]
}
EOF
  • URL

    • BASE_URL : CB-Ladybug Base URL
    • NAMESPACE_NAME : Cloud-Barista 네임스페이스 이름
    • CLUSTER_NAME : 클러스터 이름
  • Values

    • Connection info. Name : Cloud-Barista Cloud Connection Info.
    • Node Count : 추가할 노드 갯수 (ex.) 1,3,5, ...
    • CSP Machine Sepc. : CSP별 VM 인스턴스 타입 (ex.) t2.medium, n1-standard-2, Standard_B2s, ..
  • Example

$ curl -sX POST -H "Content-Type: application/json" http://localhost:1470/ladybug/ns/demo-ns/clusters/cluster-1/nodes -d @- <<EOF
{
  "controlPlane": [
    {
      "connection": "config-aws-ap-northeast-2",
      "count": 3,
      "rootDisk": {
        "size": "default",
        "type": "default"
      },
      "spec": "t2.medium"
    }
  ],
  "worker": [
    {
      "connection": "config-aws-ap-northeast-2",
      "count": 3,
      "rootDisk": {
        "size": "default",
        "type": "default"
      },
      "spec": "t2.medium"
    }
  ]
}
EOF

Get a Node

curl -sX GET -H "Content-Type: application/json" ${BASE_URL}/ns/${NAMESPACE_NAME}/clusters/${CLUSTER_NAME}/nodes/${NODE_NAME}
  • URL

    • BASE_URL : CB-Ladybug Base URL
    • NAMESPACE_NAME : Cloud-Barista 네임스페이스 이름
    • CLUSTER_NAME : 클러스터 이름
    • NODE_NAME : 노드 이름
  • Example

$ curl -sX GET -H "Content-Type: application/json" http://localhost:1470/ladybug/ns/demo-ns/clusters/cluster-1/nodes/cluster-worker-1-asefv

Get Nodes

curl -sX GET -H "Content-Type: application/json" ${BASE_URL}/ns/${NAMESPACE_NAME}/clusters/${CLUSTER_NAME}/nodes
  • URL

    • BASE_URL : CB-Ladybug Base URL
    • NAMESPACE_NAME : Cloud-Barista 네임스페이스 이름
    • CLUSTER_NAME : 클러스터 이름
  • Example

$ curl -sX GET -H "Content-Type: application/json" http://localhost:1470/ladybug/ns/demo-ns/clusters/cluster-1/nodes

Remove a Node

only worker node

curl -sX DELETE -H "Content-Type: application/json" ${BASE_URL}/ns/${NAMESPACE_NAME}/clusters/${CLUSTER_NAME}/nodes/${NODE_NAME}
  • URL

    • BASE_URL : CB-Ladybug Base URL
    • NAMESPACE_NAME : Cloud-Barista 네임스페이스 이름
    • CLUSTER_NAME : 클러스터 이름
    • NODE_NAME : 노드 이름
  • Example

$ curl -sX DELETE -H "Content-Type: application/json" http://localhost:1470/ladybug/ns/demo-ns/clusters/cluster-1/nodes/cluster-worker-1-asefv