Kubernetes Clusters

This chapter describes details about the resource “kubeclusters” which represents client Kubernetes clusters managed by CloudCasa.

Note

The samples shown in the following sections may not be exhaustive. In particular, some headers might have been skipped for the sake of brevity.

Registering a Kubernetes Cluster

  • Create a kubecluster resource by doing POST. For details, see Create a Cluster resource.

  • Poll the resource by doing GET until “status” appears, as can be seen here:.

{
  ...

  "status": {
      "agentURL": "https://<CC-SERVER-NAME-OR-IP>/kubeclusteragents/agent-gpq6w/RiFmKE3W1zgeIZACmTA8Z-iZrKXcdM0jEC7RiCu0lT4=.yaml",
      "state": "PENDING"
}
  • At this point, the cluster is in “PENDING” state and is waiting for the user to apply the yaml file (which installs a lightweight agent).

  • Apply the agent YAML, like so:

$ kubectl apply -f \
    https://<CC-SERVER-NAME-OR-IP>/kubeclusteragents/agent-gpq6w/RiFmKE3W1zgeIZACmTA8Z-iZrKXcdM0jEC7RiCu0lT4=.yaml
  • This starts “kubemanager” pod (in cloudcasa-io namespace) which will connect to CloudCasa server and fetches few resources, including “kubeagent”. You will see “kubeagent” pod coming up at this time and the cluster should eventually move to “ACTIVE” state.

Create a Cluster resource

POST /api/v1/kubeclusters

{
    "name": "testcluster",
    "description": "Created for testing purposes",
    "tags": {
        "testkey": "testval"
    },
    "image_pull_secret_name": "<PULL-SECRET-NAME>"
}

HTTP/1.1 201 CREATED
Location: http://<CC-SERVER-NAME-OR-IP>/api/v1/v1/kubeclusters/5eb599e603f7a77d5223efee
{
    "_created": "Fri, 08 May 2020 17:41:58 GMT",
    "_etag": "27114931c62a2ea2f7f2fd21c4c8f62ba7b55a0c",
    "_id": "5eb599e603f7a77d5223efee",
    "_links": {
        "self": {
            "href": "/v1/kubeclusters/5eb599e603f7a77d5223efee",
            "title": "Kubecluster"
        }
    },
    "_status": "OK",
    "_updated": "Fri, 08 May 2020 17:41:58 GMT",
    "description": "Created for testing purposes",
    "tags": {
        "testkey": "testval"
    },
    "name": "testcluster",
    "image_pull_secret_name": "myregistrykey",
    ...
}

Input Spec

name

Name of the cluster. Required.

image_pull_secret_name

Optional. This is the name of the “secret” that is needed to pull images. Users should create this secret in the “cloudcasa-io” namespace before registering the cluster.

description

Optional. Helpful text to identify the cluster.

tags

Optional. Key value pairs.

Getting a cluster resource

GET /api/v1/kubeclusters/5eb599e603f7a77d5223efee

HTTP/1.1 200 OK

Listing Clusters

GET /api/v1/kubeclusters

Updating Cluster

PATCH /api/v1/kubeclusters/5eb599e603f7a77d5223efee
If-Match: 27114931c62a2ea2f7f2fd21c4c8f62ba7b55a0c

{
    "name": "newname",
    "description": "New description"
}

HTTP/1.1 200 OK

<Full Resource>

It is also possible to do a PUT which requires entire resource to be sent in the request body. See “Overview” for some details in this regard.

“If-Match” header is required.

Deleting a cluster resource

DELETE /api/v1/kubeclusters/5eb599e603f7a77d5223efee
If-Match: 27114931c62a2ea2f7f2fd21c4c8f62ba7b55a0c

HTTP/1.1 204 NO CONTENT

Deletion of a cluster fails if there is a backup definition for it, or otherwise being used in any other way.

Notes

  • Once the cluster resource is deleted, users should remove CloudCasa components from their clusters. This can be done by removing the namespace cloudcasa-io.