> ## Documentation Index
> Fetch the complete documentation index at: https://www.latitude.sh/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a Kubernetes Cluster

> Creates a new managed Kubernetes cluster. Maximum of 1 cluster per project.

Cluster names must follow Kubernetes naming rules: lowercase alphanumeric characters or hyphens, must start and end with an alphanumeric character, and be at most 63 characters long.




## OpenAPI

````yaml https://spec.speakeasy.com/latitude/latitude/latitude-sh-api-with-code-samples post /kubernetes_clusters
openapi: 3.0.1
info:
  title: Latitude.sh API
  version: '2023-06-01'
  description: >-
    The Latitude.sh API is a RESTful API to manage your Latitude.sh account. It
    allows you to perform the same actions as the Latitude.sh dashboard.
servers:
  - url: https://api.latitude.sh
    variables:
      latitude_api_key:
        default: <insert your api key here>
  - url: http://api.latitude.sh
    variables:
      latitude_api_key:
        default: <insert your api key here>
security: []
tags:
  - name: API keys
  - name: Billing
  - name: Elastic Ips
  - name: Events
  - name: Firewalls
  - name: IP Addresses
  - name: Kubernetes Clusters
  - name: Operating Systems
  - name: Plans
  - name: Private Networks
  - name: Projects
  - name: Regions
  - name: Roles
  - name: SSH Keys
  - name: Servers
  - name: Storage
  - name: Tags
  - name: Teams
  - name: Team members
  - name: Traffic
  - name: User data
  - name: User profile
  - name: VPN Sessions
  - name: Virtual machines
paths:
  /kubernetes_clusters:
    post:
      tags:
        - Kubernetes Clusters
      summary: Create a Kubernetes Cluster
      description: >
        Creates a new managed Kubernetes cluster. Maximum of 1 cluster per
        project.


        Cluster names must follow Kubernetes naming rules: lowercase
        alphanumeric characters or hyphens, must start and end with an
        alphanumeric character, and be at most 63 characters long.
      operationId: create-kubernetes-cluster
      parameters: []
      requestBody:
        content:
          application/vnd.api+json:
            schema:
              $ref: '#/components/schemas/create_kubernetes_cluster'
            examples:
              Created:
                summary: Create a cluster
                value:
                  data:
                    type: kubernetes_clusters
                    attributes:
                      name: my-cluster
                      project_id: proj_6059EqYkOQj8p
                      site: SAN3
                      plan: c2-small-x86
                      ssh_keys:
                        - ssh_VkE1DwV37dnZJ
        required: true
      responses:
        '201':
          description: Created
          content:
            application/vnd.api+json:
              examples:
                Created:
                  value:
                    data:
                      type: kubernetes_clusters
                      id: kc_pRMLydp0dQKr1
                      attributes:
                        name: my-cluster
                        status: provisioning
                        control_plane_endpoint: https://api.my-cluster.example.com:6443
              schema:
                $ref: '#/components/schemas/kubernetes_cluster_create_response'
        '400':
          description: Bad Request
          content:
            application/vnd.api+json:
              examples:
                ValidationError:
                  value:
                    errors:
                      - code: VALIDATION_ERROR
                        message: Project ID is required
                InvalidSshKeys:
                  value:
                    errors:
                      - code: VALIDATION_ERROR
                        message: >-
                          One or more SSH keys not found or not owned by your
                          team
              schema:
                $ref: '#/components/schemas/error_object'
        '422':
          description: Unprocessable Entity
          content:
            application/vnd.api+json:
              examples:
                ClusterLimitExceeded:
                  value:
                    errors:
                      - code: CLUSTER_LIMIT_EXCEEDED
                        message: Only 1 cluster per project is allowed
                NoAvailableIP:
                  value:
                    errors:
                      - code: NO_AVAILABLE_IP
                        message: >-
                          Failed to allocate LoadBalancer IP: No available IP
                          found
                InvalidSite:
                  value:
                    errors:
                      - code: INVALID_SITE
                        message: Site not found
                SiteNotSupported:
                  value:
                    errors:
                      - code: SITE_NOT_SUPPORTED
                        message: >-
                          Managed Kubernetes is not available at site MIA.
                          Available sites: FRA, ASH
                InvalidClusterName:
                  value:
                    errors:
                      - code: INVALID_CLUSTER_NAME
                        message: >-
                          Cluster name must contain only lowercase letters,
                          numbers, and hyphens
                InsufficientStock:
                  value:
                    errors:
                      - code: INSUFFICIENT_STOCK
                        message: >-
                          No stock available of plan suitable for Kubernetes
                          cluster
                PlanNotFound:
                  value:
                    errors:
                      - code: PLAN_NOT_FOUND
                        message: Plan 'invalid-plan' not found
              schema:
                $ref: '#/components/schemas/error_object'
        '503':
          description: Service Unavailable
          content:
            application/vnd.api+json:
              examples:
                ManagementClusterError:
                  value:
                    errors:
                      - code: MANAGEMENT_CLUSTER_ERROR
                        message: Failed to communicate with the management cluster
              schema:
                $ref: '#/components/schemas/error_object'
      security:
        - Bearer: []
      x-codeSamples:
        - lang: python
          label: Python (SDK)
          source: |-
            import latitudesh_python_sdk
            from latitudesh_python_sdk import Latitudesh
            import os


            with Latitudesh(
                bearer=os.getenv("LATITUDESH_BEARER", ""),
            ) as latitudesh:

                res = latitudesh.kubernetes_clusters.create_kubernetes_cluster(data={
                    "type": latitudesh_python_sdk.CreateKubernetesClusterType.KUBERNETES_CLUSTERS,
                    "attributes": {
                        "name": "my-cluster",
                        "project_id": "proj_6059EqYkOQj8p",
                        "site": "SAN3",
                        "plan": "c2-small-x86",
                        "ssh_keys": [
                            "ssh_VkE1DwV37dnZJ",
                        ],
                    },
                })

                # Handle response
                print(res)
        - lang: go
          label: Go (SDK)
          source: "package main\n\nimport(\n\t\"context\"\n\t\"os\"\n\tlatitudeshgosdk \"github.com/latitudesh/latitudesh-go-sdk\"\n\t\"github.com/latitudesh/latitudesh-go-sdk/models/components\"\n\t\"log\"\n)\n\nfunc main() {\n    ctx := context.Background()\n\n    s := latitudeshgosdk.New(\n        latitudeshgosdk.WithSecurity(os.Getenv(\"LATITUDESH_BEARER\")),\n    )\n\n    res, err := s.KubernetesClusters.CreateKubernetesCluster(ctx, components.CreateKubernetesCluster{\n        Data: components.CreateKubernetesClusterData{\n            Type: components.CreateKubernetesClusterTypeKubernetesClusters,\n            Attributes: components.CreateKubernetesClusterAttributes{\n                Name: latitudeshgosdk.Pointer(\"my-cluster\"),\n                ProjectID: \"proj_6059EqYkOQj8p\",\n                Site: \"SAN3\",\n                Plan: \"c2-small-x86\",\n                SSHKeys: []string{\n                    \"ssh_VkE1DwV37dnZJ\",\n                },\n            },\n        },\n    })\n    if err != nil {\n        log.Fatal(err)\n    }\n    if res.KubernetesClusterCreateResponse != nil {\n        // handle response\n    }\n}"
        - lang: typescript
          label: Typescript (SDK)
          source: |-
            import { Latitudesh } from "latitudesh-typescript-sdk";

            const latitudesh = new Latitudesh({
              bearer: process.env["LATITUDESH_BEARER"] ?? "",
            });

            async function run() {
              const result = await latitudesh.kubernetesClusters.createKubernetesCluster({
                data: {
                  type: "kubernetes_clusters",
                  attributes: {
                    name: "my-cluster",
                    projectId: "proj_6059EqYkOQj8p",
                    site: "SAN3",
                    plan: "c2-small-x86",
                    sshKeys: [
                      "ssh_VkE1DwV37dnZJ",
                    ],
                  },
                },
              });

              console.log(result);
            }

            run();
components:
  schemas:
    create_kubernetes_cluster:
      type: object
      required:
        - data
      properties:
        data:
          type: object
          required:
            - type
            - attributes
          properties:
            type:
              type: string
              enum:
                - kubernetes_clusters
            attributes:
              type: object
              required:
                - project_id
                - site
                - plan
              properties:
                name:
                  type: string
                  nullable: true
                  description: >-
                    The cluster name. Must follow Kubernetes naming rules:
                    lowercase alphanumeric or hyphens, must start and end with
                    alphanumeric, max 63 characters. Auto-generated if omitted.
                project_id:
                  type: string
                  description: The project ID where the cluster will be created
                site:
                  type: string
                  description: >-
                    The site/region code where to deploy the cluster (e.g.,
                    SAN3)
                plan:
                  type: string
                  description: >-
                    The machine plan for control plane nodes (e.g.,
                    c2-small-x86)
                ssh_keys:
                  type: array
                  nullable: true
                  items:
                    type: string
                  description: >-
                    Array of SSH key IDs to use for node access. All keys must
                    exist and belong to your team.
                worker_plan:
                  type: string
                  nullable: true
                  description: >-
                    The machine plan for worker nodes. Defaults to the control
                    plane plan if not specified.
                kubernetes_version:
                  type: string
                  nullable: true
                  description: >-
                    The Kubernetes version to install. Defaults to
                    v1.34.3+rke2r1.
                control_plane_count:
                  type: integer
                  nullable: true
                  description: Number of control plane nodes. Defaults to 1.
                worker_count:
                  type: integer
                  nullable: true
                  description: Number of worker nodes. Defaults to 1.
                operating_system:
                  type: string
                  nullable: true
                  description: >-
                    The operating system for the nodes. Defaults to
                    ubuntu_24_04_x64_lts.
    kubernetes_cluster_create_response:
      type: object
      description: >-
        Response schema for cluster creation (minimal fields returned during
        provisioning)
      properties:
        data:
          type: object
          properties:
            id:
              type: string
              description: The cluster ID in hashed format (kc_<hash>)
            type:
              type: string
            attributes:
              type: object
              properties:
                name:
                  type: string
                  description: The cluster name
                status:
                  type: string
                  description: The cluster status (always 'provisioning' on creation)
                control_plane_endpoint:
                  type: string
                  nullable: true
                  description: The URL endpoint for the Kubernetes API server
    error_object:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              code:
                type: string
                nullable: true
              status:
                type: string
              title:
                type: string
              detail:
                type: string
              source:
                type: object
                properties:
                  pointer:
                    type: string
                  parameter:
                    type: string
              meta:
                type: object
  securitySchemes:
    Bearer:
      type: apiKey
      name: Authorization
      in: header

````