Documentation
¶
Overview ¶
pkg/client/client.go
pkg/client/crd_client.go
pkg/client/debug.go
pkg/client/kube.go
pkg/client/node.go - Complete file with all disk operations
pkg/client/node_crd.go
pkg/client/replica.go
pkg/client/replica_crd.go
pkg/client/stubs.go
pkg/client/types.go
pkg/client/volume_crd.go
Index ¶
- Variables
- func GetCurrentNamespace(configPath, contextName string) (string, error)
- func NewKubeClient(config *KubeConfig) (*kubernetes.Clientset, *rest.Config, error)
- type Backup
- type BackupCreateInput
- type BackupInterface
- type BackupTarget
- type Client
- func (c *Client) Backups() BackupInterface
- func (c *Client) EngineImages() EngineImageInterface
- func (c *Client) Events() EventInterface
- func (c *Client) Nodes() NodeInterface
- func (c *Client) Replicas() ReplicaInterface
- func (c *Client) Settings() SettingsInterface
- func (c *Client) Volumes() VolumeInterface
- func (c *Client) VolumesCRD() VolumeInterface
- type Config
- type Controller
- type Disk
- type DiskUpdate
- type EngineImage
- type EngineImageInterface
- type ErrorResponse
- type Event
- type EventInterface
- type EventListOptions
- type KubeConfig
- type LonghornCRDClient
- type Node
- type NodeInterface
- type NodeList
- type NodeUpdate
- type RecurringJob
- type Replica
- type ReplicaInterface
- type Setting
- type SettingDefinition
- type SettingsInterface
- type Status
- type Volume
- type VolumeAttachInput
- type VolumeCreateInput
- type VolumeInterface
- type VolumeUpdateInput
Constants ¶
This section is empty.
Variables ¶
var EnableDebug = os.Getenv("LHCLI_DEBUG") != ""
EnableDebug enables debug output
Functions ¶
func GetCurrentNamespace ¶
GetCurrentNamespace gets the current namespace from kubeconfig context
func NewKubeClient ¶
func NewKubeClient(config *KubeConfig) (*kubernetes.Clientset, *rest.Config, error)
NewKubeClient creates a new Kubernetes client from kubeconfig
Types ¶
type Backup ¶
type Backup struct {
Name string `json:"name"`
State string `json:"state"`
Progress int `json:"progress"`
Error string `json:"error"`
URL string `json:"url"`
SnapshotName string `json:"snapshotName"`
SnapshotCreated string `json:"snapshotCreated"`
Created string `json:"created"`
Size string `json:"size"`
Labels map[string]string `json:"labels"`
VolumeName string `json:"volumeName"`
VolumeSize string `json:"volumeSize"`
VolumeCreated string `json:"volumeCreated"`
}
Backup represents a volume backup
type BackupCreateInput ¶
type BackupCreateInput struct {
SnapshotName string `json:"snapshotName"`
Labels map[string]string `json:"labels"`
}
BackupCreateInput represents backup creation parameters
type BackupInterface ¶
type BackupInterface interface {
List(volumeName string) ([]Backup, error)
Get(backupName string) (*Backup, error)
Create(volumeName string, input *BackupCreateInput) (*Backup, error)
Delete(backupName string) error
GetTarget() (*BackupTarget, error)
SetTarget(target *BackupTarget) error
}
BackupInterface defines backup operations
type BackupTarget ¶
type BackupTarget struct {
BackupTargetURL string `json:"backupTargetURL"`
CredentialSecret string `json:"credentialSecret"`
Available bool `json:"available"`
Message string `json:"message"`
}
BackupTarget represents the backup target configuration
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the Longhorn API client
func NewClientFromKubeconfig ¶
func NewClientFromKubeconfig(kubeConfig *KubeConfig) (*Client, error)
NewClientFromKubeconfig creates a Longhorn client using kubeconfig
func NewLonghornCRDClient ¶
NewLonghornCRDClient creates a new client that uses Kubernetes CRDs
func (*Client) Backups ¶
func (c *Client) Backups() BackupInterface
Backups returns the backup interface
func (*Client) EngineImages ¶
func (c *Client) EngineImages() EngineImageInterface
EngineImages returns the engine image interface
func (*Client) Replicas ¶
func (c *Client) Replicas() ReplicaInterface
Replicas returns the replica interface
func (*Client) Settings ¶
func (c *Client) Settings() SettingsInterface
Settings returns the settings interface
func (*Client) Volumes ¶
func (c *Client) Volumes() VolumeInterface
Volumes returns the volume interface
func (*Client) VolumesCRD ¶
func (c *Client) VolumesCRD() VolumeInterface
Volumes returns the volume interface for CRD operations
type Config ¶
type Config struct {
Endpoint string
Namespace string
Token string
Timeout time.Duration
Insecure bool
}
Config represents the client configuration
type Controller ¶
type Controller struct {
Name string `json:"name"`
NodeID string `json:"nodeID"`
Endpoint string `json:"endpoint"`
CurrentImage string `json:"currentImage"`
InstanceManagerName string `json:"instanceManagerName"`
}
Controller represents a volume controller
type Disk ¶
type Disk struct {
Path string `json:"path"`
AllowScheduling bool `json:"allowScheduling"`
EvictionRequested bool `json:"evictionRequested"`
StorageMaximum int64 `json:"storageMaximum"`
StorageAvailable int64 `json:"storageAvailable"`
StorageReserved int64 `json:"storageReserved"`
StorageScheduled int64 `json:"storageScheduled"`
DiskUUID string `json:"diskUUID"`
DiskType string `json:"diskType"`
Conditions map[string]Status `json:"conditions"`
ScheduledReplica map[string]int64 `json:"scheduledReplica"`
Tags []string `json:"tags"`
}
Disk represents a disk on a node
type DiskUpdate ¶
type DiskUpdate struct {
Path string `json:"path"`
AllowScheduling *bool `json:"allowScheduling,omitempty"`
EvictionRequested *bool `json:"evictionRequested,omitempty"`
StorageReserved int64 `json:"storageReserved,omitempty"`
Tags []string `json:"tags,omitempty"`
}
DiskUpdate represents disk update parameters
type EngineImage ¶
type EngineImage struct {
Name string `json:"name"`
Image string `json:"image"`
Default bool `json:"default"`
State string `json:"state"`
RefCount int `json:"refCount"`
Created string `json:"created"`
NodeDeploymentMap map[string]bool `json:"nodeDeploymentMap"`
Conditions map[string]Status `json:"conditions"`
}
EngineImage represents a Longhorn engine image
type EngineImageInterface ¶
type EngineImageInterface interface {
List() ([]EngineImage, error)
Get(name string) (*EngineImage, error)
Delete(name string) error
}
EngineImageInterface defines engine image operations
type ErrorResponse ¶
type ErrorResponse struct {
Type string `json:"type"`
Status int `json:"status"`
Code string `json:"code"`
Message string `json:"message"`
}
ErrorResponse from Longhorn API
type Event ¶
type Event struct {
Type string `json:"type"`
Object string `json:"object"`
Reason string `json:"reason"`
Message string `json:"message"`
FirstTimestamp time.Time `json:"firstTimestamp"`
LastTimestamp time.Time `json:"lastTimestamp"`
Count int `json:"count"`
}
Event represents a Longhorn event
type EventInterface ¶
type EventInterface interface {
List(opts EventListOptions) ([]Event, error)
Watch(ctx context.Context, opts EventListOptions, callback func(Event)) error
}
EventInterface defines event operations
type EventListOptions ¶
EventListOptions represents event listing options
type KubeConfig ¶
KubeConfig represents Kubernetes configuration
type LonghornCRDClient ¶
type LonghornCRDClient struct {
// contains filtered or unexported fields
}
LonghornCRDClient uses Kubernetes API to interact with Longhorn CRDs
type Node ¶
type Node struct {
Name string `json:"name"`
Namespace string `json:"namespace,omitempty"`
Address string `json:"address"`
AllowScheduling bool `json:"allowScheduling"`
EvictionRequested bool `json:"evictionRequested"`
Conditions map[string]Status `json:"conditions"`
Disks map[string]Disk `json:"disks"`
Region string `json:"region"`
Zone string `json:"zone"`
Tags []string `json:"tags"`
EngineManagerCPURequest int `json:"engineManagerCPURequest"`
ReplicaManagerCPURequest int `json:"replicaManagerCPURequest"`
}
Node represents a Longhorn node
type NodeInterface ¶
type NodeInterface interface {
List() ([]Node, error)
Get(name string) (*Node, error)
Update(name string, update *NodeUpdate) (*Node, error)
EnableScheduling(name string) error
DisableScheduling(name string) error
EvictNode(name string) error
AddDisk(nodeName string, disk DiskUpdate) error
RemoveDisk(nodeName, diskID string) error
UpdateDiskTags(nodeName, diskID string, tags []string) error
AddNodeTag(nodeName, tag string) error
RemoveNodeTag(nodeName, tag string) error
EnableDiskScheduling(nodeName, diskID string) error
DisableDiskScheduling(nodeName, diskID string) error
}
NodeInterface defines node operations
type NodeList ¶
type NodeList struct {
Items []Node `json:"data"`
}
NodeList represents a list of nodes
type NodeUpdate ¶
type NodeUpdate struct {
AllowScheduling *bool `json:"allowScheduling,omitempty"`
EvictionRequested *bool `json:"evictionRequested,omitempty"`
Tags []string `json:"tags,omitempty"`
Disks map[string]DiskUpdate `json:"disks,omitempty"`
}
NodeUpdate represents node update parameters
type RecurringJob ¶
type RecurringJob struct {
Name string `json:"name"`
Task string `json:"task"`
Cron string `json:"cron"`
Retain int `json:"retain"`
Concurrency int `json:"concurrency"`
Labels map[string]string `json:"labels"`
}
RecurringJob represents a recurring job configuration
type Replica ¶
type Replica struct {
Name string `json:"name"`
NodeID string `json:"nodeID"`
DiskID string `json:"diskID"`
VolumeName string `json:"volumeName"`
DiskPath string `json:"diskPath,omitempty"`
DataPath string `json:"dataPath"`
Mode string `json:"mode"`
FailedAt string `json:"failedAt"`
Running bool `json:"running"`
SpecSize string `json:"specSize"` // Keep for API compatibility
VolumeSize string `json:"volumeSize"` // K8s CRD field
ActualSize string `json:"actualSize"`
IP string `json:"ip"`
Port int `json:"port"`
InstanceManager string `json:"instanceManager"`
Image string `json:"image"`
StorageIP string `json:"storageIP"`
StoragePort int `json:"storagePort"`
DataEngine string `json:"dataEngine"`
Conditions map[string]Status `json:"conditions"`
CurrentState string `json:"currentState"` // K8s status field
CurrentImage string `json:"currentImage"` // K8s status field
}
Replica represents a volume replica Replica represents a volume replica
type ReplicaInterface ¶
type ReplicaInterface interface {
List() ([]Replica, error)
Get(name string) (*Replica, error)
Delete(name string) error
}
ReplicaInterface defines replica operations
type Setting ¶
type Setting struct {
Name string `json:"name"`
Value string `json:"value"`
Default string `json:"default"`
Definition SettingDefinition `json:"definition"`
}
Setting represents a Longhorn setting
type SettingDefinition ¶
type SettingDefinition struct {
Description string `json:"description"`
Type string `json:"type"`
Required bool `json:"required"`
ReadOnly bool `json:"readOnly"`
Default string `json:"default"`
Options []string `json:"options"`
}
SettingDefinition represents setting metadata
type SettingsInterface ¶
type SettingsInterface interface {
List() (map[string]Setting, error)
Get(name string) (*Setting, error)
Update(name string, value string) (*Setting, error)
}
SettingsInterface defines settings operations
type Status ¶
type Status struct {
Type string `json:"type"`
Status string `json:"status"`
LastProbeTime string `json:"lastProbeTime"`
LastTransitionTime string `json:"lastTransitionTime"`
Reason string `json:"reason"`
Message string `json:"message"`
}
Status represents a condition status
type Volume ¶
type Volume struct {
Name string `json:"name"`
Namespace string `json:"namespace,omitempty"`
Size string `json:"size"`
ActualSize int64 `json:"actualSize,omitempty"` // Add this field
NumberOfReplicas int `json:"numberOfReplicas"`
State string `json:"state"`
Robustness string `json:"robustness"`
Frontend string `json:"frontend"`
DataLocality string `json:"dataLocality"`
AccessMode string `json:"accessMode"`
Migratable bool `json:"migratable"`
Encrypted bool `json:"encrypted"`
Image string `json:"image"`
LastBackup string `json:"lastBackup"`
LastBackupAt string `json:"lastBackupAt"`
Created string `json:"created"`
Conditions map[string]Status `json:"conditions"`
Replicas []Replica `json:"replicas"`
Labels map[string]string `json:"labels,omitempty"`
}
Volume represents a Longhorn volume
type VolumeAttachInput ¶
type VolumeAttachInput struct {
HostID string `json:"hostId"`
DisableFrontend bool `json:"disableFrontend"`
AttachedBy string `json:"attachedBy"`
}
VolumeAttachInput represents volume attach parameters
type VolumeCreateInput ¶
type VolumeCreateInput struct {
Name string `json:"name"`
Size string `json:"size"`
NumberOfReplicas int `json:"numberOfReplicas"`
Frontend string `json:"frontend"`
DataLocality string `json:"dataLocality"`
AccessMode string `json:"accessMode"`
Migratable bool `json:"migratable"`
Encrypted bool `json:"encrypted"`
NodeSelector []string `json:"nodeSelector"`
DiskSelector []string `json:"diskSelector"`
RecurringJobs []RecurringJob `json:"recurringJobs"`
Labels map[string]string `json:"labels"`
}
VolumeCreateInput represents volume creation parameters
type VolumeInterface ¶
type VolumeInterface interface {
List() ([]Volume, error)
Get(name string) (*Volume, error)
Create(volume *VolumeCreateInput) (*Volume, error)
Delete(name string) error
Update(name string, volume *VolumeUpdateInput) (*Volume, error)
Attach(name string, input *VolumeAttachInput) (*Volume, error)
Detach(name string) error
}
VolumeInterface defines volume operations
type VolumeUpdateInput ¶
type VolumeUpdateInput struct {
NumberOfReplicas *int `json:"numberOfReplicas,omitempty"`
DataLocality string `json:"dataLocality,omitempty"`
AccessMode string `json:"accessMode,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
}
VolumeUpdateInput represents volume update parameters