Skip to content

Instantly share code, notes, and snippets.

@MuellerMH
Last active March 4, 2023 17:12
Show Gist options
  • Select an option

  • Save MuellerMH/7ad98744e50045905daa019603cf53fe to your computer and use it in GitHub Desktop.

Select an option

Save MuellerMH/7ad98744e50045905daa019603cf53fe to your computer and use it in GitHub Desktop.

Rest Api Structure

Endpoints List

URI GET POST PUT PATCH DELETE
/cluster List Create
/cluster/["platform"] List Create Upgrade Rollback Destroy
/addons List Install Destroy
/addons/["name"]/ List Update Destroy
/addons/["name"]/["actions"] List Use

All endpoints should be defined and should have HATEOAS in the resultset. Every CMD and Entity should have a endpoint.

GET /cluster

List the avaible and supported platforms with ref links and versions

GET Result

    [
        {
            "name": "aws",
            "version": "0.0.1",
            "refs": [
                {
                    "action":"create",
                    "method":"POST",
                    "url": "/cluster/aws"
                },
                {
                    "action":"install",
                    "method":"PUT",
                    "url": "/cluster/aws"
                },
                {
                    "action":"destroy",
                    "method":"DELETE",
                    "url": "/cluster/aws"
                },
            ]
        },
        // ...
    ]

POST /cluster

POST Request /cluster

As Request it could be a option to send some configs needed for the init But the question is if this part needed, because the rest api is not avaible without init tk8. But for multi plattform solution it is needed

{
    // config fileds for the init
}

POST Result /cluster

{
    "status": "sucess|failed",
    "message": ""
}

GET /cluster/["platform"]

Return the status of this cluster

GET Result /cluster/["platform"]

{
    "status": "sucess|failed|initialized",
    "message": ""
}

POST /cluster/["platform"]

Create the platform

POST Request /cluster/["platform"]

{
    // config fileds for the platform
}

POST Result /cluster/["platform"]

{
    "status": "sucess|failed",
    "message": ""
}

PUT /cluster/["platform"]

Install or Upgrade the platform

PUT Request /cluster/["platform"]

{
    // config fileds for the platform
}

PUT Result /cluster/["platform"]

{
    "status": "sucess|failed",
    "message": ""
}

PATCH /cluster/["platform"]

could be used for a roolback

PATCH Request /cluster/["platform"]

{
    // config fileds for the platform
}

PATCH Result /cluster/["platform"]

{
    "status": "sucess|failed",
    "message": ""
}

DELETE /cluster/["platform"]

destroy the platform

DELETE Result /cluster/["platform"]

{
    "status": "sucess|failed",
    "message": ""
}

definition ["platform"]

Private and public clouds which are supported

  • aws
  • azure
  • gcp
  • baremetal
  • openstack

or for later use

  • federation

definition ["actions"]

Different actions to interact with for example to scale a pod, create some pod or destroy a pod

definition addons ["name"]

the name of a specifical addon

definition addons ["actions"]

some addons could have some extra actions so it can managed here

Not needed at the moment maybe for a addon

|URI|GET|POST|PUT|PATCH|DELETE| |/cluster/["platform"]/{namespace}|List|Create|Upgrade||Destroy| |/cluster/["platform"]/{namespace}/pods|List|Create|Upgrade||Destroy| |/cluster/["platform"]/{namespace}/pods/{name}|List|Create|Upgrade||Destroy| |/cluster/["platform"]/{namespace}/pods/{name}/["actions"]|List|Create|Upgrade|Rollback|Destroy| |/cluster/["platform"]/{namespace}/services|List|Create|Upgrade||Destroy| |/cluster/["platform"]/{namespace}/services/{name}|List|Create|Upgrade||Destroy| |/cluster/["platform"]/{namespace}/services/{name}/["actions"]|List|Create|Upgrade|Rollback|Destroy| |/cluster/["platform"]/{namespace}/nodes|List|Create|Upgrade||Destroy| |/cluster/["platform"]/{namespace}/nodes/{id}|List|Configure|Upgrade||Destroy| |/cluster/["platform"]/{namespace}/configs|List|Create|Upgrade||Destroy|

@arush-sal
Copy link

As we just support the following commands:

  • cluster init
  • cluster -c/-i/-d --loadbalancer(only for baremetal)
  • addon -l/-p/-m

& we doesn't directly manage k8s cluster resource, therefore, I think we don't need {namespace}/{nodes/pods/services}. But rather it should be /cluster/["platform"]/["actions"]. Rest /addons/["name"]/["actions"] is awesome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment