---
title: "Create Cluster"
method: POST
path: "/ocean/gcp/k8s/cluster"
tags: ["Ocean GKE"]
---

# Create Cluster

`POST /ocean/gcp/k8s/cluster`

## Prerequisites:
  The Ocean Controller is used to monitor the cluster resources and report back to Ocean.|
  To install the Ocean Controller, complete and run the following script on a machine with the 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 grant yourself admin privileges, run the following command:
```
  kubectl create clusterrolebinding <clusterName> --clusterrole=cluster-admin --user=<userEmail>
```
For more information, refer to our [controller installation guides](https://docs.flexera.com/spot/ocean/tutorials/spot-kubernetes-controller/). You can install with Helm, Kubectl or Terraform.
For more about Ocean and the Ocean Controller, see the documentation [here](https://docs.flexera.com/spot/ocean/overview-kubernetes).

## Parameters

- `#/paths/~1azure~1costs/get/parameters/0` — unresolved $ref

## Request body

- object
  - `cluster` object, required — The specification of the Ocean cluster.
    - `id` string — Ocean cluster identifier.
    - `name` string, required — Add a name for the Ocean cluster.
    - `controllerClusterId` string, required — Enter the Ocean cluster identifier.
    - `gke` object — Use existing GKE cluster.
      - `clusterName` string, required — Required for the cluster.gke object.
      - `masterLocation` string, required — Required for the cluster.gke object.
    - `autoScaler` object — The Ocean Kubernetes Autoscaler object.
      - `isEnabled` boolean — Enable the Ocean Kubernetes Autoscaler.
      - `cooldown` integer — Cooldown period between scaling actions.
      - `resourceLimits` object — Optionally set upper and lower bounds on the resource usage of the cluster.
        - `maxMemoryGib` integer — The maximum memory in GiB units that can be allocated to the cluster.
        - `maxVcpu` integer — The maximum CPU in vCPU units that can be allocated to the cluster.
      - `down` object — Autoscaling scale down operations.
        - `evaluationPeriods` integer — Number of minutes a node should be eligible for scale down before it is scaled down.
        - `maxScaleDownPercentage` integer — The maximum percentage allowed to scale down in a single scaling action.
        - `aggressiveScaleDown` object — Enable and configure the Accelerated Scale Down feature to allow the Ocean autoscaler to immediately scale down eligible nodes without any waiting period.
          - `isEnabled` boolean — When set to 'true', Accelerated Scale Down is enabled.
      - `headRoom` object — Spare resource capacity management enabling fast assignment of pods without waiting for new resources to launch.
        - `cpuPerUnit` integer — Optionally configure the number of CPUs to allocate the headroom. CPUs are denoted in millicores where 1000 millicores = 1 vCPU.
        - `memoryPerUnit` integer — Optionally configure the amount of memory (MiB) to allocate the headroom.
        - `gpuPerUnit` integer — How much GPU to allocate to a headroom unit.
        - `numOfUnit` integer — The number of units to retain as headroom, where each unit has the defined headroom CPU and memory.
      - `isAutoConfig` boolean — Use automatic headroom. When set to true, the values under cluster.autoScaler.headroom are not effective, as Ocean configures and optimizes headroom automatically.
      - `autoHeadroomPercentage` integer — Optionally set the auto headroom percentage. Set a number between 0-200 to control the headroom percent of the cluster. Relevant when isAutoConfig=true.
      - `enableAutomaticAndManualHeadroom` boolean — When set to true, both automatic and per-VNG manual headroom to be saved concurrently and independently in the cluster. prerequisite: isAutoConfig must be true
    - `autoUpdate` object — The Ocean Kubernetes AutoUpdate object. If set to 'true', Ocean will ensure that your clusters have an up-to-date configuration according to the respective GKE cluster.
      - `isEnabled` boolean — Enable the Ocean Kubernetes AutoUpdate.
    - `capacity` object — Capacity specifications for the Ocean cluster.
      - `minimum` integer — The bottom limit of instances that the cluster can scale down to.
      - `maximum` integer — The upper limit of instances that the cluster can scale up to.
      - `target` integer — Number of instances to launch and maintain in the cluster.
    - `strategy` object
      - `drainingTimeout` integer — The draining timeout (in seconds) before terminating the instance. If no draining timeout is defined, the default draining timeout will be used.
      - `provisioningModel` 'SPOT' | 'PREEMPTIBLE' — Define the provisioning model of the launched instances
      - `scalingOrientation` 'COST' | 'AVAILABILITY' | 'BALANCED' — Set this value to control the approach that Ocean takes when launching nodes.
      - `preemptiblePercentage` integer — The desired percentage of Spot/Preemptible instances out of all running instances.\ Only available when the field is **not** set in any VNG directly (launchSpec.strategy.preemptiblePercentage).
      - `shouldUtilizeCommitments` boolean — Enable committed use discounts utilization.
      - `revertToPreferred` object — Allow the replacement of instances to Preferred ones if available.
        - `shouldPerform` boolean — If enabled, replacements will be performed for all of your cluster, unless configured on VNG level. TRUE is the default.
        - `maxBatchPercentage` integer — Decide on the % of instances that will be replaced simultaneously.
    - `scheduling` object — Schedule an action such as a planned shutdown or a cluster roll.
      - `shutdownHours` object — Define time(s) for a scheduled shutdown.
        - `isEnabled` boolean — Flag to enable or disable the shutdown hours mechanism. When false, the mechanism is deactivated and the cluster remains in its current state.
        - `timeWindows` string[], required — Set time windows for shutdown hours. Specify a list of timeWindows that includes 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 when cluster.scheduling.isEnabled = True.
      - `tasks` object[]
        - `isEnabled` boolean, required — Describes whether the task is enabled. When true, the task runs. When false, it does not run. Required for the cluster.scheduling.tasks object.
        - `cronExpression` string, required — A valid cron expression. For example : " * * * * * ". The cron is running in UTC time zone and is in Unix cron format [Cron Expression Validator Script](http://www.unix.com/man-page/linux/5/crontab/). Frequency and cronExpression cannot be used at a time.
        - `taskType` 'clusterRoll', required — Valid values: "clusterRoll". Required for the cluster.scheduling.tasks object.
        - `parameters` object
          - `clusterRoll` object
            - `batchSizePercentage` integer — Value as a percent to set the size of a batch in a roll. Valid values are 0-100.
            - `comment` string — Add a comment description for the roll. The comment is limited to 256 chars
            - `batchMinHealthyPercentage` integer — Indicates the threshold of minimum healthy instances in single batch. If the amount of healthy instances in single batch is under the threshold, the cluster roll will fail. If exists, the parameter value will be in range of 1-100. In case of null as value, the default value in the backend will be 50%. Value of param should represent the number in percentage (%) of the batch.
            - `respectPdb` boolean — During the roll, if the parameter is set to true we honor PDB during the instance replacement.
    - `security` object
      - `containerImage` object
        - `approvedImages` string[] — Set list of permitted repositories for container images.
    - `compute` object, required
      - `networkInterfaces` object, required — Settings for network interfaces
        - `network` string, required
        - `projectId` string — Use a network resource from a different project. Set the project identifier to use its network resource. This parameter is relevant only if the network resource is in a different project.
        - `accessConfigs` object, required
          - `name` string, required
          - `type` string, required — Possible values: ONE_TO_ONE_NAT
        - `aliasIpRanges` object
          - `ipCidrRange` string, required — Required for the cluster.compute.networkInterfaces.aliasIpRanges object.
          - `subnetworkRangeName` string, required — Required for the cluster.compute.networkInterfaces.aliasIpRanges object.
      - `backendServices` object — Settings for backend services.
        - `backendServiceName` string, required — Required for the cluster.compute.backendServices object.
        - `locationType` 'regional' | 'global'
        - `scheme` 'EXTERNAL' | 'INTERNAL' — Required if locationType is set to "regional".
        - `namedPorts` object
          - `name` string, required
          - `ports` integer[], required
      - `subnetName` string, required — Subnet identifier for the Ocean cluster
      - `availabilityZones` string[], required — Availability zone(s) used by the Ocean cluster.
      - `instanceTypes` object — The type of instances that may or may not be a part of the Ocean cluster.
        - `whitelist` string[] — Instance types allowed in the Ocean cluster. Cannot be configured if a deny list is configured.
        - `blacklist` string[] — Instance types to avoid launching in the Ocean cluster. Cannot be configured if a permit list is configured.
        - `filters` Filters — unresolved $ref
        - `preferredTypes` PreferredTypes — unresolved $ref
      - `launchSpecification` object, required
        - `sourceImage` string, required — URL of the image used to launch the instances.
        - `metadata` object, required — Set array of cluster metadata.
          - `key` string — Key of metadata key pair.
          - `value` string — Value of metadata key pair.
        - `tags` string[], required — Every node launched from this configuration will be tagged with those tags.
        - `ipForwarding` boolean
        - `minCpuPlatform` string — Set instance CPU platform.
        - `serviceAccount` string, required — The service account used by applications running on the VM to call GCP APIs.
        - `labels` object[] — Set labels on cluster. Can set up to 60 labels
          - `key` string
          - `value` string
        - `rootVolumeSizeInGb` integer — Optionally set root size (GB). Value should be greater than or equal to 100.
        - `rootVolumeType` 'pd-standard' | 'pd-ssd' | 'pd-balanced' | 'pd-extreme' | 'hyperdisk-balanced' | 'hyperdisk-balanced-high-availability' — Set the root volume disk type.
        - `shieldedInstanceConfig` ShieldedInstanceConfig — unresolved $ref
        - `useAsTemplateOnly` boolean — The configuration specified on the Ocean object will function only as a template for virtual node groups.
    - `createdAt` string, date-time — A timestamp of the Ocean creation.
    - `updatedAt` string, date-time — A timestamp of the latest Ocean update.

## Other responses

- `400` — Bad Request

---

[API](https://skmtc.net/spot/apis/spot-by-flexera-api.md) · [All operations](https://skmtc.net/spot/apis/spot-by-flexera-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/spot/spot-by-flexera-api/revisions/72813baf8d47/schema)
