Go (SDK)
package main
import(
"context"
"os"
latitudeshgosdk "github.com/latitudesh/latitudesh-go-sdk"
"log"
)
func main() {
ctx := context.Background()
s := latitudeshgosdk.New(
latitudeshgosdk.WithSecurity(os.Getenv("LATITUDESH_BEARER")),
)
res, err := s.Lks.GetLksClusterKubeconfig(ctx, "<id>")
if err != nil {
log.Fatal(err)
}
if res.LksClusterKubeconfig != nil {
// handle response
}
}curl --request GET \
--url https://api.latitude.sh/lks/clusters/{id}/kubeconfig \
--header 'Authorization: <api-key>'import requests
url = "https://api.latitude.sh/lks/clusters/{id}/kubeconfig"
headers = {"Authorization": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.latitude.sh/lks/clusters/{id}/kubeconfig', 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/lks/clusters/{id}/kubeconfig",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.latitude.sh/lks/clusters/{id}/kubeconfig")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.latitude.sh/lks/clusters/{id}/kubeconfig")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"data": {
"id": "lksc_pRMLydp0dQKr1",
"type": "lks_cluster_kubeconfigs",
"attributes": {
"kubeconfig": "apiVersion: v1\nkind: Config\nclusters:\n- cluster:\n server: https://lksc-prmlydp0dqkr1.lks.latitude.sh:6443\n name: production\n"
}
}
}{
"errors": [
{
"code": "USER_AUTHORIZATION_ERROR",
"title": "User Authorization Error",
"detail": "You are not authorized to perform this action.",
"status": "403",
"meta": {}
}
]
}{
"errors": [
{
"code": "NOT_FOUND",
"title": "Cluster Not Found",
"detail": "Cluster 'lksc_pRMLydp0dQKr1' not found",
"status": "404",
"meta": {}
}
]
}{
"errors": [
{
"code": "NOT_READY",
"message": "Kubeconfig is not available yet"
}
]
}{
"errors": [
{
"code": "UPSTREAM_SERVICE_ERROR",
"title": "Bad Gateway",
"detail": "NetBox is temporarily unavailable. Please try again.",
"status": "502",
"meta": {}
}
]
}LKS
Get the cluster kubeconfig
Returns the kubeconfig for the cluster. It only exists once the control plane is up, so this endpoint answers 409 NOT_READY while the cluster is still provisioning — poll GET /lks/clusters/{id} until kubeconfig_url is set.
GET
/
lks
/
clusters
/
{id}
/
kubeconfig
Go (SDK)
package main
import(
"context"
"os"
latitudeshgosdk "github.com/latitudesh/latitudesh-go-sdk"
"log"
)
func main() {
ctx := context.Background()
s := latitudeshgosdk.New(
latitudeshgosdk.WithSecurity(os.Getenv("LATITUDESH_BEARER")),
)
res, err := s.Lks.GetLksClusterKubeconfig(ctx, "<id>")
if err != nil {
log.Fatal(err)
}
if res.LksClusterKubeconfig != nil {
// handle response
}
}curl --request GET \
--url https://api.latitude.sh/lks/clusters/{id}/kubeconfig \
--header 'Authorization: <api-key>'import requests
url = "https://api.latitude.sh/lks/clusters/{id}/kubeconfig"
headers = {"Authorization": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.latitude.sh/lks/clusters/{id}/kubeconfig', 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/lks/clusters/{id}/kubeconfig",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.latitude.sh/lks/clusters/{id}/kubeconfig")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.latitude.sh/lks/clusters/{id}/kubeconfig")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"data": {
"id": "lksc_pRMLydp0dQKr1",
"type": "lks_cluster_kubeconfigs",
"attributes": {
"kubeconfig": "apiVersion: v1\nkind: Config\nclusters:\n- cluster:\n server: https://lksc-prmlydp0dqkr1.lks.latitude.sh:6443\n name: production\n"
}
}
}{
"errors": [
{
"code": "USER_AUTHORIZATION_ERROR",
"title": "User Authorization Error",
"detail": "You are not authorized to perform this action.",
"status": "403",
"meta": {}
}
]
}{
"errors": [
{
"code": "NOT_FOUND",
"title": "Cluster Not Found",
"detail": "Cluster 'lksc_pRMLydp0dQKr1' not found",
"status": "404",
"meta": {}
}
]
}{
"errors": [
{
"code": "NOT_READY",
"message": "Kubeconfig is not available yet"
}
]
}{
"errors": [
{
"code": "UPSTREAM_SERVICE_ERROR",
"title": "Bad Gateway",
"detail": "NetBox is temporarily unavailable. Please try again.",
"status": "502",
"meta": {}
}
]
}Was this page helpful?