karbon

package
v0.0.0-...-4787336 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2021 License: Apache-2.0 Imports: 12 Imported by: 1

README

Nutanix Karbon Go SDK

Available Functions

  • Create
  • Get
  • Delete
  • GetHealth
  • GetKubeConfig
  • GetSSH

Alpha Functions

Alpha functions are only available on systems running with Alpha releases which are not currently covered. Some of these calls are implemented but remain untested.

  • UpdateK8sSecret
  • ListRegistries
  • AddPrivateRegistry
  • RemovePrivateRegistry
  • GetTaskDetails
  • GetVersion

Beta Functions

Beta functions are only available on systems running with Beta releases which are not currently covered. Some of these calls are implemented but remain untested.

  • ListAllClusters
  • GetNodePoolConfig

Documentation

Index

Constants

View Source
const NUTANIX_KARBON_PASS = "NUTANIX_KARBON_PASS"

NUTANIX_KARBON_PASS is the environment variables for the KARBON password

View Source
const NUTANIX_KARBON_URL = "NUTANIX_KARBON_URL"
View Source
const NUTANIX_KARBON_USER = "NUTANIX_KARBON_USER"

NUTANIX_KARBON_USER is the environment variable name for the KARBON username

Variables

This section is empty.

Functions

func CheckConfig

func CheckConfig(conf *ServiceConfig) error

CheckConfig will ensure that the minimal amount of information is present in the config

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse looks for common response errors Need to fill this in at some point

func FormatCredentials

func FormatCredentials(a AuthCredentials) string

FormatCredentials takes in an AuthCredential type and returns a base64 encoded string in the proper format for use by the REST API

Types

type ActivePassiveConfig

type ActivePassiveConfig struct {
	ExternalIpv4Address string `json:"external_ipv4_address"`
}

type AhvConfig

type AhvConfig struct {
	CPU                     int    `json:"cpu"`
	DiskMib                 int    `json:"disk_mib"`
	MemoryMib               int    `json:"memory_mib"`
	NetworkUUID             string `json:"network_uuid"`
	PrismElementClusterUUID string `json:"prism_element_cluster_uuid"`
}

type AuthCredentials

type AuthCredentials struct {
	Username string
	Password string
}

AuthCredentials are the username and password received from ENV variables never hard code these values into any code!

func GetCredentials

func GetCredentials(conf *ServiceConfig) (AuthCredentials, error)

GetCredentials gets the username and password from the ENV variables for use in the application

type CalicoConfig

type CalicoConfig struct {
	IPPoolConfigs []IPPoolConfigs `json:"ip_pool_configs"`
}

type Client

type Client struct {
	KarbonURL *url.URL

	Login AuthCredentials

	Registry *RegistryService
	Cluster  *ClusterService
	Meta     *MetaService
	// contains filtered or unexported fields
}

Client is an HTTP Client

func NewClient

func NewClient(httpClient *http.Client, conf *ServiceConfig) (*Client, error)

NewClient is used for Nutanix Prism client instantiation

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it. If rate limit is exceeded and reset time is in the future, Do returns *RateLimitError immediately without making a network API call.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request

type ClusterAddRegistryRequest

type ClusterAddRegistryRequest struct{}

type ClusterAddRegistryResponse

type ClusterAddRegistryResponse struct{}

type ClusterCreateRequest

type ClusterCreateRequest struct {
	CniConfig          CniConfig          `json:"cni_config"`
	EtcdConfig         CreateEtcdConfig   `json:"etcd_config"`
	MastersConfig      MastersConfig      `json:"masters_config"`
	Metadata           Metadata           `json:"metadata"`
	Name               string             `json:"name"`
	StorageClassConfig StorageClassConfig `json:"storage_class_config"`
	Version            string             `json:"version"`
	WorkersConfig      WorkersConfig      `json:"workers_config"`
}

ClusterCreateRequest Create a k8s cluster with the provided configuration.

type ClusterCreateResponse

type ClusterCreateResponse struct {
	ClusterName string `json:"cluster_name"`
	ClusterUUID string `json:"cluster_uuid"`
	TaskUUID    string `json:"task_uuid"`
}

ClusterCreateResponse cluster create response of new cluster

type ClusterDeleteRequest

type ClusterDeleteRequest struct {
	ClusterName string `json:"cluster_name"`
	SkipChecks  bool   `json:"skip_checks"`
}

ClusterDeleteRequest deletes the identified cluster by name with or without skipping pre-checks

type ClusterDeleteResponse

type ClusterDeleteResponse struct {
	ClusterName string `json:"cluster_name"`
	ClusterUUID string `json:"cluster_uuid"`
	TaskUUID    string `json:"task_uuid"`
}

ClusterDeleteResponse is the task and cluster information for the deleted resource

type ClusterGetHealthRequest

type ClusterGetHealthRequest struct {
	ClusterName string `json:"cluster_name"`
}

ClusterGetHealthRequest requests cluster health by cluster name for k8s

type ClusterGetHealthResponse

type ClusterGetHealthResponse struct {
	Messages []string `json:"messages"`
	Status   bool     `json:"status"`
}

ClusterGetHealthResponse provides the cluster health retrieved by cluster name

type ClusterGetKubeConfigRequest

type ClusterGetKubeConfigRequest struct {
	ClusterName string
}

ClusterGetKubeConfigRequest requests KubeConfig for CLUSTER_NAME

type ClusterGetKubeConfigResponse

type ClusterGetKubeConfigResponse struct {
	KubeConfig string `json:"kube_config"`
}

ClusterGetKubeConfigResponse returns the KubeConfig data to be used directly or placed in a file

type ClusterGetNodePoolRequest

type ClusterGetNodePoolRequest struct{}

type ClusterGetNodePoolResponse

type ClusterGetNodePoolResponse struct{}

type ClusterGetRequest

type ClusterGetRequest struct {
	ClusterName string `json:"cluster_name"`
}

ClusterGetRequest provides a cluster name to get details on the cluster

type ClusterGetResponse

type ClusterGetResponse struct {
	EtcdConfig               EtcdConfig   `json:"etcd_config"`
	KubeapiServerIpv4Address string       `json:"kubeapi_server_ipv4_address"`
	MasterConfig             MasterConfig `json:"master_config"`
	Name                     string       `json:"name"`
	Status                   string       `json:"status"`
	UUID                     string       `json:"uuid"`
	Version                  string       `json:"version"`
	WorkerConfig             WorkerConfig `json:"worker_config"`
}

ClusterGetResponse returns details about a k8s cluster based on provided cluster name

type ClusterGetSSHRequest

type ClusterGetSSHRequest struct {
	ClusterName string `json:"cluster_name"`
}

ClusterGetSSHRequest Get SSH credentials to remotely access nodes belonging to the k8s cluster. The credentials have an expiry time of 24 hours.

type ClusterGetSSHResponse

type ClusterGetSSHResponse struct {
	Certificate string `json:"certificate"`
	ExpiryTime  string `json:"expiry_time"`
	PrivateKey  string `json:"private_key"`
	Username    string `json:"username"`
}

ClusterGetSSHResponse SSH cluster credentials with 24 hour expiration time

type ClusterGetTasksRequest

type ClusterGetTasksRequest struct{}

type ClusterGetTasksResponse

type ClusterGetTasksResponse struct{}

type ClusterListRegistriesRequest

type ClusterListRegistriesRequest struct {
	ClusterName string `json:"cluster_name"`
}

ClusterListRegistriesRequest requests a list of registries by cluster name

type ClusterListRegistriesResponse

type ClusterListRegistriesResponse []struct {
	Endpoint string `json:"endpoint"`
	Name     string `json:"name"`
	UUID     string `json:"uuid"`
}

ClusterListRegistriesResponse provides the list of cluster registries by cluster name

type ClusterListRequest

type ClusterListRequest struct{}

ClusterListRequest requests a full list of k8s clusters

type ClusterListResponse

type ClusterListResponse []struct {
	EtcdConfig               EtcdConfig   `json:"etcd_config"`
	KubeapiServerIpv4Address string       `json:"kubeapi_server_ipv4_address"`
	MasterConfig             MasterConfig `json:"master_config"`
	Name                     string       `json:"name"`
	Status                   string       `json:"status"`
	UUID                     string       `json:"uuid"`
	Version                  string       `json:"version"`
	WorkerConfig             WorkerConfig `json:"worker_config"`
}

ClusterListResponse returns a full list of the clusters along with cluster details in a slice

type ClusterRemoveRegistryRequest

type ClusterRemoveRegistryRequest struct{}

type ClusterRemoveRegistryResponse

type ClusterRemoveRegistryResponse struct{}

type ClusterService

type ClusterService Service

ClusterService handles communication to the clusters REST API endpoint

func (*ClusterService) Create

Create makes the call to cluster create

func (*ClusterService) Delete

Delete identified cluster by name defining whether to allow cluster deletion during cluster deployment with skip-pre-check

func (*ClusterService) Get

Get Get all the k8s cluster objects, which include worker, etcd and master configuration details.

func (*ClusterService) GetHealth

GetHealth will return cluster health for cluster name

func (*ClusterService) GetKubeConfig

GetKubeConfig Get the kubeconfig to access the K8s cluster.

func (*ClusterService) GetSSH

GetSSH Gets the associated k8s SSH credentials to remotely access the k8s cluster. Credentials expire in 24 hours.

func (*ClusterService) List

List Get all the k8s cluster objects, which include worker, etcd and master configuration details.

func (*ClusterService) ListRegistries

ListRegistries will list the private registries associated with a cluster

func (*ClusterService) UpdateSecret

UpdateSecret the k8s secret and docker volume plugin password across k8s clusters deployed in Karbon. The update operation is performed only for the clusters where the provided Prism Element UUID and the username match.

type ClusterUpdateSecretRequest

type ClusterUpdateSecretRequest struct {
	Password                string `json:"password"`
	Username                string `json:"username"`
	PrismElementClusterUUID string `json:"prism_element_cluster_uuid"`
}

type ClusterUpdateSecretResponse

type ClusterUpdateSecretResponse struct {
	TaskUUID string `json:"task_uuid"`
}

type CniConfig

type CniConfig struct {
	CalicoConfig     CalicoConfig  `json:"calico_config"`
	FlannelConfig    FlannelConfig `json:"flannel_config"`
	NodeCidrMaskSize int           `json:"node_cidr_mask_size"`
	PodIpv4Cidr      string        `json:"pod_ipv4_cidr"`
	ServiceIpv4Cidr  string        `json:"service_ipv4_cidr"`
}

type CreateEtcdConfig

type CreateEtcdConfig struct {
	NodePools []NodePools `json:"node_pools"`
}

type DeleteSkipCheck

type DeleteSkipCheck struct {
	SkipCheck bool `url:"skip-prechecks"`
}

DeleteSkipCheck is used within the delete cluster call to pass into query parameters

type EtcdConfig

type EtcdConfig struct {
	NodePools []string `json:"node_pools"`
}

type ExternalLbConfig

type ExternalLbConfig struct {
	ExternalIpv4Address string              `json:"external_ipv4_address"`
	MasterNodesConfig   []MasterNodesConfig `json:"master_nodes_config"`
}

type FlannelConfig

type FlannelConfig struct {
}

type IPPoolConfigs

type IPPoolConfigs struct {
	Cidr string `json:"cidr"`
}

type MasterConfig

type MasterConfig struct {
	DeploymentType string   `json:"deployment_type"`
	NodePools      []string `json:"node_pools"`
}

type MasterNodesConfig

type MasterNodesConfig struct {
	Ipv4Address  string `json:"ipv4_address"`
	NodePoolName string `json:"node_pool_name"`
}

type MastersConfig

type MastersConfig struct {
	ActivePassiveConfig ActivePassiveConfig `json:"active_passive_config"`
	ExternalLbConfig    ExternalLbConfig    `json:"external_lb_config"`
	NodePools           []NodePools         `json:"node_pools"`
	SingleMasterConfig  SingleMasterConfig  `json:"single_master_config"`
}

type MetaGetRequest

type MetaGetRequest struct{}

MetaGetRequest gets a detailed list of version data

type MetaGetResponse

type MetaGetResponse struct {
	BuildDate string `json:"build_date"`
	GitCommit string `json:"git_commit"`
	Version   string `json:"version"`
}

MetaGetResponse are the version details

type MetaService

type MetaService Service

MetaService handles communication to the clusters REST API endpoint

func (*MetaService) GetVersion

func (ms *MetaService) GetVersion(reqdata *MetaGetRequest) (*MetaGetResponse, *http.Response, error)

GetVersion Get the Karbon controller version of the k8 cluster.

type Metadata

type Metadata struct {
	APIVersion string `json:"api_version"`
}

type NodePools

type NodePools struct {
	AhvConfig     AhvConfig `json:"ahv_config"`
	Name          string    `json:"name"`
	NodeOsVersion string    `json:"node_os_version"`
	NumInstances  int       `json:"num_instances"`
}

type RegistryCreateRequest

type RegistryCreateRequest struct {
	Cert string
	Name string
	Port int
	URL  string
}

RegistryCreateRequest is the request needed to create registries

type RegistryCreateResponse

type RegistryCreateResponse struct {
	Endpoint string `json:"endpoint"`
	Name     string `json:"name"`
	UUID     string `json:"uuid"`
}

RegistryCreateResponse is the request needed to create registries

type RegistryDeleteRequest

type RegistryDeleteRequest struct {
	Name string `json:"name"`
}

RegistryDeleteRequest is the request needed to delete registries

type RegistryDeleteResponse

type RegistryDeleteResponse struct {
	RegistryName string `json:"registry_name"`
}

RegistryDeleteResponse is the request needed to delete registries

type RegistryGetRequest

type RegistryGetRequest struct {
	Name string `json:"name"`
}

RegistryGetRequest is the request needed to get registries

type RegistryGetResponse

type RegistryGetResponse struct {
	Endpoint string `json:"endpoint"`
	Name     string `json:"name"`
	UUID     string `json:"uuid"`
}

RegistryGetResponse is the request needed to get registries

type RegistryListRequest

type RegistryListRequest struct{}

RegistryListRequest is the request needed to get a list of registries

type RegistryListResponse

type RegistryListResponse struct {
	Endpoint string `json:"endpoint"`
	Name     string `json:"name"`
	UUID     string `json:"uuid"`
}

RegistryListResponse is the request needed to get a list of registries

type RegistryService

type RegistryService Service

RegistryService handles communication to the clusters REST API endpoint

func (*RegistryService) Create

Create makes the call to cluster list

func (*RegistryService) Delete

Delete will delete the virtual machine associated with the provided UUID

func (*RegistryService) Get

Get passes as name of a specific registry to get information about that registry

func (*RegistryService) List

List returns a list of all registries

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is used to create endpoint specific services to utilize concurrency with timeouts

type ServiceConfig

type ServiceConfig struct {
	URL  *string
	User *string
	Pass *string
}

ServiceConfig is the configuration to use PC

type SingleMasterConfig

type SingleMasterConfig struct {
}

type StorageClassConfig

type StorageClassConfig struct {
	DefaultStorageClass bool          `json:"default_storage_class"`
	Name                string        `json:"name"`
	ReclaimPolicy       string        `json:"reclaim_policy"`
	VolumesConfig       VolumesConfig `json:"volumes_config"`
}

type VolumesConfig

type VolumesConfig struct {
	FileSystem              string `json:"file_system"`
	FlashMode               bool   `json:"flash_mode"`
	Password                string `json:"password"`
	PrismElementClusterUUID string `json:"prism_element_cluster_uuid"`
	StorageContainer        string `json:"storage_container"`
	Username                string `json:"username"`
}

type WorkerConfig

type WorkerConfig struct {
	NodePools []string `json:"node_pools"`
}

type WorkersConfig

type WorkersConfig struct {
	NodePools []NodePools `json:"node_pools"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL