This is the Go client for Krucible, the platform for creating ephemeral Kubernetes clusters optimised for testing and development.
The Krucible Go client is built using Go modules and thus that is the recommended way of including the Krucible client into your project.
go get github.com/Krucible/krucible-go-client
To get started, import the krucible
package and create a client:
import "github.com/Krucible/krucible-go-client/krucible"
client := krucible.NewClient(krucible.ClientConfig{
AccountID: "4ad69a63-bb6c-49a8-9c6f-6a166fb5acff",
APIKeyId: "146d98c4-327d-4a2d-b85a-49590246e136",
APIKeySecret: "0da8afd2911904aa9bad8862a3e7478a",
})
You should then be able to create new Krucible clusters with CreateCluster
:
cluster, clientset, err := client.CreateCluster(krucible.CreateClusterConfig{
DisplayName: "my-krucible-cluster",
})
CreateCluster returns a krucible.Cluster
struct, containing metadata about
your cluster, and a
kubernetes.Clientset
that is set up to connect to the new cluster.
Getting the cluster expiry time:
fmt.Println(cluster.ExpiresAt)
Listing the pods in the default namespace:
pods, err := clientset.CoreV1().
Pods("default").
List(
context.Background(),
metav1.ListOptions{},
)
Get existing clusters with GetCluster
:
cluster, err = client.GetCluster("51b831d4-a9d6-4489-913e-6df70fcc8ea8")
Here cluster
is a krucible.Cluster
struct, containing metadata about the
cluster.
Get a Kubernetes client-go Clientset, configured to connect to a given cluster:
cs, err := client.GetClusterClientset("51b831d4-a9d6-4489-913e-6df70fcc8ea8")