Python (SDK)
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)package main
import(
"context"
"os"
latitudeshgosdk "github.com/latitudesh/latitudesh-go-sdk"
"github.com/latitudesh/latitudesh-go-sdk/models/components"
"log"
)
func main() {
ctx := context.Background()
s := latitudeshgosdk.New(
latitudeshgosdk.WithSecurity(os.Getenv("LATITUDESH_BEARER")),
)
res, err := s.KubernetesClusters.CreateKubernetesCluster(ctx, components.CreateKubernetesCluster{
Data: components.CreateKubernetesClusterData{
Type: components.CreateKubernetesClusterTypeKubernetesClusters,
Attributes: components.CreateKubernetesClusterAttributes{
Name: latitudeshgosdk.Pointer("my-cluster"),
ProjectID: "proj_6059EqYkOQj8p",
Site: "SAN3",
Plan: "c2-small-x86",
SSHKeys: []string{
"ssh_VkE1DwV37dnZJ",
},
},
},
})
if err != nil {
log.Fatal(err)
}
if res.KubernetesClusterCreateResponse != nil {
// handle response
}
}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();curl --request POST \
--url https://api.latitude.sh/kubernetes_clusters \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/vnd.api+json' \
--data '
{
"data": {
"type": "kubernetes_clusters",
"attributes": {
"name": "my-cluster",
"project_id": "proj_6059EqYkOQj8p",
"site": "SAN3",
"plan": "c2-small-x86",
"ssh_keys": [
"ssh_VkE1DwV37dnZJ"
]
}
}
}
'const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/vnd.api+json'},
body: JSON.stringify({
data: {
type: 'kubernetes_clusters',
attributes: {
name: 'my-cluster',
project_id: 'proj_6059EqYkOQj8p',
site: 'SAN3',
plan: 'c2-small-x86',
ssh_keys: ['ssh_VkE1DwV37dnZJ']
}
}
})
};
fetch('https://api.latitude.sh/kubernetes_clusters', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.latitude.sh/kubernetes_clusters",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
'type' => 'kubernetes_clusters',
'attributes' => [
'name' => 'my-cluster',
'project_id' => 'proj_6059EqYkOQj8p',
'site' => 'SAN3',
'plan' => 'c2-small-x86',
'ssh_keys' => [
'ssh_VkE1DwV37dnZJ'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/vnd.api+json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://api.latitude.sh/kubernetes_clusters")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/vnd.api+json")
.body("{\n \"data\": {\n \"type\": \"kubernetes_clusters\",\n \"attributes\": {\n \"name\": \"my-cluster\",\n \"project_id\": \"proj_6059EqYkOQj8p\",\n \"site\": \"SAN3\",\n \"plan\": \"c2-small-x86\",\n \"ssh_keys\": [\n \"ssh_VkE1DwV37dnZJ\"\n ]\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.latitude.sh/kubernetes_clusters")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/vnd.api+json'
request.body = "{\n \"data\": {\n \"type\": \"kubernetes_clusters\",\n \"attributes\": {\n \"name\": \"my-cluster\",\n \"project_id\": \"proj_6059EqYkOQj8p\",\n \"site\": \"SAN3\",\n \"plan\": \"c2-small-x86\",\n \"ssh_keys\": [\n \"ssh_VkE1DwV37dnZJ\"\n ]\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"type": "kubernetes_clusters",
"id": "kc_pRMLydp0dQKr1",
"attributes": {
"name": "my-cluster",
"status": "provisioning",
"control_plane_endpoint": "https://api.my-cluster.example.com:6443"
}
}
}Kubernetes Clusters
Create a Kubernetes Cluster
Creates a new managed Kubernetes cluster. Maximum of 1 cluster per project.
Note: Only users with the owner, administrator, or collaborator role can create clusters. Users with the billing role cannot perform this action.
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.
POST
/
kubernetes_clusters
Python (SDK)
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)package main
import(
"context"
"os"
latitudeshgosdk "github.com/latitudesh/latitudesh-go-sdk"
"github.com/latitudesh/latitudesh-go-sdk/models/components"
"log"
)
func main() {
ctx := context.Background()
s := latitudeshgosdk.New(
latitudeshgosdk.WithSecurity(os.Getenv("LATITUDESH_BEARER")),
)
res, err := s.KubernetesClusters.CreateKubernetesCluster(ctx, components.CreateKubernetesCluster{
Data: components.CreateKubernetesClusterData{
Type: components.CreateKubernetesClusterTypeKubernetesClusters,
Attributes: components.CreateKubernetesClusterAttributes{
Name: latitudeshgosdk.Pointer("my-cluster"),
ProjectID: "proj_6059EqYkOQj8p",
Site: "SAN3",
Plan: "c2-small-x86",
SSHKeys: []string{
"ssh_VkE1DwV37dnZJ",
},
},
},
})
if err != nil {
log.Fatal(err)
}
if res.KubernetesClusterCreateResponse != nil {
// handle response
}
}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();curl --request POST \
--url https://api.latitude.sh/kubernetes_clusters \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/vnd.api+json' \
--data '
{
"data": {
"type": "kubernetes_clusters",
"attributes": {
"name": "my-cluster",
"project_id": "proj_6059EqYkOQj8p",
"site": "SAN3",
"plan": "c2-small-x86",
"ssh_keys": [
"ssh_VkE1DwV37dnZJ"
]
}
}
}
'const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/vnd.api+json'},
body: JSON.stringify({
data: {
type: 'kubernetes_clusters',
attributes: {
name: 'my-cluster',
project_id: 'proj_6059EqYkOQj8p',
site: 'SAN3',
plan: 'c2-small-x86',
ssh_keys: ['ssh_VkE1DwV37dnZJ']
}
}
})
};
fetch('https://api.latitude.sh/kubernetes_clusters', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.latitude.sh/kubernetes_clusters",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
'type' => 'kubernetes_clusters',
'attributes' => [
'name' => 'my-cluster',
'project_id' => 'proj_6059EqYkOQj8p',
'site' => 'SAN3',
'plan' => 'c2-small-x86',
'ssh_keys' => [
'ssh_VkE1DwV37dnZJ'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/vnd.api+json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://api.latitude.sh/kubernetes_clusters")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/vnd.api+json")
.body("{\n \"data\": {\n \"type\": \"kubernetes_clusters\",\n \"attributes\": {\n \"name\": \"my-cluster\",\n \"project_id\": \"proj_6059EqYkOQj8p\",\n \"site\": \"SAN3\",\n \"plan\": \"c2-small-x86\",\n \"ssh_keys\": [\n \"ssh_VkE1DwV37dnZJ\"\n ]\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.latitude.sh/kubernetes_clusters")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/vnd.api+json'
request.body = "{\n \"data\": {\n \"type\": \"kubernetes_clusters\",\n \"attributes\": {\n \"name\": \"my-cluster\",\n \"project_id\": \"proj_6059EqYkOQj8p\",\n \"site\": \"SAN3\",\n \"plan\": \"c2-small-x86\",\n \"ssh_keys\": [\n \"ssh_VkE1DwV37dnZJ\"\n ]\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"type": "kubernetes_clusters",
"id": "kc_pRMLydp0dQKr1",
"attributes": {
"name": "my-cluster",
"status": "provisioning",
"control_plane_endpoint": "https://api.my-cluster.example.com:6443"
}
}
}Was this page helpful?
⌘I