Octelium APIs are all developed over gRPC. Currently the Golang implementation is officially supported and as it is the primary programming language for developing Octelium itself. For example, most octeliumctl
commands are nothing but wrappers over the Cluster's Core API (or service methods according to the gRPC nomenclature). The octelium-go
library makes it easy for Golang-based applications to actually authenticate to the Cluster, mainly using an authentication token (read more about authentication token Credentials here), interact with its APIs, and also be able to access the Cluster's Services without having to worry about manually re-authentcating their Session before its access token expires.
Here is a simple example that uses octelium-go
client to create a gRPC client that can access the Core API service methods to manage the different Core API resources such as User and ClusterConfig:
1package main23import (4"context"5"fmt"6"os"78"github.com/octelium/octelium/apis/main/corev1"9"github.com/octelium/octelium/apis/main/metav1"10"github.com/octelium/octelium/octelium-go"11)1213func main() {14if err := doMain(context.Background()); err != nil {15panic(err)16}17}1819func doMain(ctx context.Context) error {20octeliumC, err := octelium.NewClient(ctx, &octelium.ClientConfig{21Domain: "example.com",22AuthenticationToken: os.Getenv("AUTH_TOKEN"),23})24if err != nil {25return err26}2728defer octeliumC.Close()2930grpcConn, err := octeliumC.GRPC().GetConn(ctx)31if err != nil {32return err33}34coreC := corev1.NewMainServiceClient(grpcConn)35{3637usr, err := coreC.CreateUser(ctx, &corev1.User{38Metadata: &metav1.Metadata{39Name: "usr-01",40},41Spec: &corev1.User_Spec{42Type: corev1.User_Spec_HUMAN,4344},45})46if err != nil {47return err48}4950userList, err := coreC.ListUser(ctx, &corev1.ListUserOptions{})51if err != nil {52return err53}54fmt.Printf("%+v\n", userList)5556usr, err = coreC.GetUser(ctx, &metav1.GetOptions{57Name: usr.Metadata.Name,58})59if err != nil {60return err61}6263_, err = coreC.DeleteUser(ctx, &metav1.DeleteOptions{64Uid: usr.Metadata.Uid,65})66if err != nil {67return err68}69}7071{72cc, err := coreC.GetClusterConfig(ctx, &corev1.GetClusterConfigRequest{})73if err != nil {74return err75}76cc.Spec.Session = &corev1.ClusterConfig_Spec_Session{77Human: &corev1.ClusterConfig_Spec_Session_Human{78MaxPerUser: 16,79},80}81_, err = coreC.UpdateClusterConfig(ctx, cc)82if err != nil {83return err84}85}8687return nil88}
You can also use the Octelium Golang client in your HTTP and gRPC clients to access the Cluster publicly exposed/BeyondCorp Services. You can discover more examples about using the GO SDK to access APIs and Kubernetes clusters here and here.