fbpx
POSThttps://api.spotinst.io/ocean/gcp/k8s/cluster?accountId={ACCOUNT_ID}

Prerequisites

The Spotinst Controller is used to monitor the cluster resources and report back to Ocean.
To install the Spotinst Controller, complete and run the following script on a machine with kubectl command line tool installed and configured:

#!/usr/bin/env bash
curl -fsSL http://spotinst-public.s3.amazonaws.com/integrations/kubernetes/cluster-controller/scripts/init.sh | \
SPOTINST_TOKEN=<ENTER YOUR TOKEN HERE> \
SPOTINST_ACCOUNT=<ENTER YOUR SPOTINST ACCOUNT ID HERE> \
SPOTINST_CLUSTER_IDENTIFIER=<ENTER YOUR CLUSTER IDENTIFIER HERE> \
bash

You may need Kubernetes admin privileges for this script to work. To assign yourself with admin privileges, run the following command:

kubectl create clusterrolebinding <clusterName> --clusterrole=cluster-admin --user=<userEmail>

For detailed guide please refer to our controller installation guides. Install can be made by kubectl or Helm.

For more on the Spotinst controller and Ocean’s anatomy see the documentation here.

 

URL Parameters

Parameter Type Description
ACCOUNT_ID * String

The Spotinst accountId associated with your token.

Example: act-123abc
Request

Headers
{
  "Authorization": "Bearer ${token}",
  "Content-Type": "application/json"
}
Body
Copied!
Downloaded!
{
	"cluster": {
		"Name": "test",
		"controllerClusterId": "test-123124",
		"gke": {
			"clusterName": "test-cluster",
			"masterLocation": "us-central1-a"
		},
		"autoScaler": {
			"isEnabled": true,
			"cooldown": 30,
      		"down": {
        		"evaluationPeriods": 3,
        		"maxScaleDownPercentage": 30
			},
			"headroom": {
				"cpuPerUnit": 0,
				"memoryPerUnit": 0,
				"gpuPerUnit": 0,
				"numOfUnits": 0
			},
      		"resourceLimits": {
				"maxMemoryGib": 1500,
				"maxVCpu": 750
      		},
      		"isAutoConfig": false
		},
		"capacity": {
			"minimum": 0,
			"maximum": 3,
			"target": 3
		},
        "strategy": {
			"drainingTimeout": 60
		},
        "scheduling": {
			"shutdownHours": {
				"isEnabled": true,
        		"timeWindows": [
		          "Fri:15:30-Wed:14:30",
        		  "Wed:15:30-Thu:18:30"
				]
			}
		},
        "security": {
          "containerImage": {
            "approvedImages": [
	          "gce.io/*",
              "docker.*"
            ]
          }
        },
		"compute": {
			"networkInterfaces": [
				{
					"network": "default",
                  	"projectId": "test-project",
					"accessConfigs": [
						{
							"name": "external-nat",
							"type": "ONE_TO_ONE_NAT"
						}
					],
					"aliasIpRanges": [
						{
							"ipCidrRange": "/24",
							"subnetworkRangeName": "gke-test-native-vpc-pods-5cb557f7"
						}
					]
				}
			],
			"backendServices":[
				{
					"backendServiceName":"test-global-tcp",
					"locationType":"global"
				}
			],
			"subnetName": "default",
			"instanceTypes": {
				"whitelist": [
					"n1-standard-2"
				]
			},
			"launchSpecification": {
				"sourceImage": "https://www.googleapis.com/compute/v1/projects/gke-node-images/global/images/gke-1117-gke12-cos-69-10895-138-0-v190225-pre",
				"metadata": [
					{
						"key": "example_key1",
						"value": "exmample_value1"
					},
					{
						"key": "example_key2",
						"value": "example_value2"
					}
				],
				"tags": [
					"gke-test-native-vpc-5cb557f7-node"
				],
				"ipForwarding": true,
                "minCpuPlatform": "Intel Sandy Bridge",
				"serviceAccount": "265168459660-compute@developer.gserviceaccount.com",
				"labels": [
					{
						"key": "spotinst-gke-original-node-pool",
						"value": "test-native-vpc__default-pool"
					}
				],
				"rootVolumeSizeInGb": 100
			},
			"availabilityZones": [
				"us-central1-a"
			]
		}
	}
}

Body Attributes


  • cluster Object
    The Ocean cluster.
  • cluster.name * String
    Add a name for the Ocean cluster.
  • cluster.controllerClusterId * String
    Enter the Ocean cluster identifier.
    Example: ocean.k8s
  • cluster.gke Object
    Use existing GKE cluster
  • cluster.gke.clusterName * String
    Required on cluster.gke object.
  • clusterName.gke.masterLocation * String
    Required on cluster.gke object.
  • cluster.autoScaler Object
    The Ocean Kubernetes Autoscaler object
  • cluster.autoScaler.isEnabled Boolean
    Enable the Ocean Kubernetes Autoscaler.
    Default: true
  • cluster.autoScaler.cooldown Integer
    Cooldown period between scaling actions.
    Default: null
  • cluster.autoScaler.resourceLimits Object
    Optionally set upper and lower bounds on the resource usage of the cluster.
  • cluster.autoScaler. resourceLimits.maxMemoryGib Integer
    The maximum memory in GiB units that can be allocated to the cluster.
  • cluster.autoScaler. resourceLimits.maxVCpu Integer
    The maximum cpu in vCpu units that can be allocated to the cluster.
  • cluster.autoScaler.down Object
    Auto Scaling scale down operations.
  • cluster.autoScaler.down.evaluationPeriods Integer
    The number of evaluation periods that should accumulate before a scale down action takes place.
    Default: null
  • cluster.autoScaler.down.maxScaleDownPercentage Integer
    Would represent the maximum % to scale-down. Number between 1-100
  • cluster.autoScaler.headroom Object
    Spare resource capacity management enabling fast assignment of Pods without waiting for new resources to launch.
  • cluster.autoScaler.headroom.cpuPerUnit Integer
    Optionally configure the number of CPUs to allocate the headroom. CPUs are denoted in millicores, where 1000 millicores = 1 vCPU.
    Example: 2000
  • cluster.autoScaler.headroom.memoryPerUnit Integer
    Optionally configure the amount of memory (MB) to allocate the headroom.
  • cluster.autoScaler.headroom.gpuPerUnit Integer
    How much GPU allocate for headroom unit
  • cluster.autoScaler.headroom.numOfUnits Integer
    The number of units to retain as headroom, where each unit has the defined headroom CPU and memory.
  • cluster.autoScaler.isAutoConfig Boolean
    Automatically configure and optimize headroom resources.
    Default: true
  • cluster.capacity Object
    Capacity specifications for the Ocean cluster.
  • cluster.capacity.target Integer
    Number of instances to launch and maintain in cluster.
  • cluster.capacity.minimum Integer
    The bottom limit of instances that the cluster can scale down to.
  • cluster.capacity.maximum Integer
    The upper limit of instances that the cluster can scale up to.
    Default: 1000
  • cluster.strategy Object
  • cluster.strategy.drainingTimeout Integer
    The draining timeout (in seconds) before terminating the instance. If no draining timeout is defined, the default draining timeout will be used.
    Example: 60
  • cluster.scheduling Object
    Set scheduling object
  • cluster.scheduling.shutdownHours Object
    Set shutdown hours for cluster object
  • cluster.scheduling.isEnabled Boolean
    Flag to enable / disable the shutdown hours.
    Example: True
  • cluster.scheduling.timeWindows * Array<String>
    Set time windows for shutdown hours. specify a list of 'timeWindows' with at least one time window Each string is in the format of - ddd:hh:mm-ddd:hh:mm ddd = day of week = Sun | Mon | Tue | Wed | Thu | Fri | Sat hh = hour 24 = 0 -23 mm = minute = 0 - 59. Time windows should not overlap. required on cluster.scheduling.isEnabled = True.
    Example: Fri:15:30-Wed:14:30
  • cluster.security Object
  • cluster.security.containerImage Object
  • cluster.security.containerImage.approvedImages Array<String>
    Set white list of repositories for container images.
  • cluster.compute * Object
  • cluster.compute.subnetname * String
    Subnet identifier for the Ocean cluster
  • cluster.compute.instanceTypes Object
    The type of instances that may or may not be a part of the Ocean cluster.
  • cluster.compute.instanceTypes.whitelist Array<String>
    Instance types allowed in the Ocean cluster.
  • cluster.compute.launchSpecification * Object
  • cluster.compute.launchSpecification.sourceImage * String
    URL of the image used to launch the instances.
  • cluster.compute.launchSpecification.tags * Array
    Array of tags to instances launched in Ocean cluster.
  • cluster.compute.launchSpecification.metadata * Array<Object>
    Set array of cluster metadata
  • cluster.compute.launchSpecification.metadata.key String
    Key of metadata key-pair
  • cluster.compute.launchSpecification.metadata.value String
    Value of metadata key-pair
  • cluster.compute.launchSpecification.ipForwarding Boolean
  • cluster.compute.launchSpecification.minCpuPlatform String
    Set instance CPU platform
    Example: Intel Sandy Bridge
  • cluster.compute.launchSpecification.serviceAccount * String
  • cluster.compute.launchSpecification.rootVolumeSizeInGb String
    Optionally set root size (GB). Value should be >= 100
  • cluster.compute.launchSpecification.labels Array<Object>
    Set labels on cluster. Can set up to 60 labels
  • cluster.compute.launchSpecification.labels.key String
  • cluster.compute.launchSpecification.labels.value String
  • cluster.compute.networkInterfaces * Object
    Settings for network interfaces
  • cluster.compute.networkInterfaces.network * String
  • cluster.compute.networkInterfaces.projectId String
    Use network resource from different project. set project ID to use it's network resource. This parameter relevant only If the network resource is in different project
  • cluster.compute.networkInterfaces.accessConfigs * Array<Object>
  • cluster.compute.networkInterfaces.accessConfigs.name * String
  • cluster.compute.networkInterfaces.accessConfigs.type * String
    Possible values: ONE_TO_ONE_NAT
  • cluster.compute.networkInterfaces.aliasIpRanges String
  • cluster.compute.networkInterfaces.aliasIpRanges.ipCidrRange * String
    Required on cluster.compute.networkInterfaces.aliasIpRanges object.
  • cluster.compute.networkInterfaces.aliasIpRanges.subnetworkRangeName * String
    Required on cluster.compute.networkInterfaces.aliasIpRanges object.
  • cluster.compute.backendServices Object
    Settings for backend services
  • cluster.compute.backendServices.backendServiceName * String
    Required on cluster.compute.backendServices object.
  • cluster.compute.backendServices.locationType String
  • cluster.compute.backendServices.cluster.compute.backendServices.Scheme String
  • cluster.compute.backendServices.cluster.compute.backendServices.namedPort String
  • cluster.compute.backendServices.cluster.compute.availabilityZones * Array
    Array of availability zones for the cluster
Response - 200

Body
Copied!
Downloaded!
{
	"cluster": {
		"autoScaler": {
      		"isEnabled": true,
      		"cooldown": 30,
      		"down": {
        		"evaluationPeriods": 3,
        		"maxScaleDownPercentage": 30
			},
			"headroom": {
				"cpuPerUnit": 0,
				"memoryPerUnit": 0,
				"gpuPerUnit": 0,
				"numOfUnits": 0
			},
      		"resourceLimits": {
				"maxMemoryGib": 1500,
				"maxVCpu": 750
      		},
      		"isAutoConfig": false
		},
		"capacity": {
			"minimum": 0,
			"maximum": 3,
			"target": 3
		},
        "strategy": {
			"drainingTimeout": 60
		},
		"scheduling": {
			"shutdownHours": {
				"isEnabled": true,
                "timeWindows": [
                	"Fri:15:30-Wed:14:30",
                    "Wed:15:30-Thu:18:30"
				]
			}
		},
        "security": {
          "containerImage": {
            "approvedImages": [
              "gce.io/*",
              "docker.*"
            ]
          }
        },
		"compute": {
                    "networkInterfaces": [
                        {
                            "network": "default",
                            "accessConfigs": [
                                {
                                    "name": "external-nat",
                                    "type": "ONE_TO_ONE_NAT"
                                }
                            ],
                            "aliasIpRanges": [
                                {
                                    "ipCidrRange": "/24",
                                    "subnetworkRangeName": "gke-test-native-vpc-pods-5cb557f7"
                                }
                            ]
                        }
                    ],
					"backendServices":[
        				{
        				"backendServiceName":"test-global-tcp",
        				"locationType":"global"
        				}
					],
                    "subnetName": "default",
                    "instanceTypes": {
                        "whitelist": [
                            "n1-standard-2"
                        ]
                    },
                    "launchSpecification": {
                        "sourceImage": "https://www.googleapis.com/compute/v1/projects/gke-node-images/global/images/gke-1117-gke12-cos-69-10895-138-0-v190225-pre",
                        "metadata": [
			              {
							"key": "example_key1",
                             "value": "exmample_value1"
                          },
                          {
                              "key": "example_key2",
                              "value": "example_value2"
                          }
                        ],
                        "tags": [
                            "gke-test-native-vpc-5cb557f7-node"
                        ],
                        "ipForwarding": true,
						"minCpuPlatform": "Intel Sandy Bridge",
                        "serviceAccount": "265168459660-compute@developer.gserviceaccount.com",
                        "labels": [
                            {
                                "key": "spotinst-gke-original-node-pool",
                                "value": "test-native-vpc__default-pool"
                            }
                        ],
                        "rootVolumeSizeInGb": 100
                    },
                    "availabilityZones": [
                        "us-central1-a"
                    ]
                }
			}
}