k8s

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeploymentState

type DeploymentState struct {
	Name             string            `json:"name"`
	Replicas         int32             `json:"replicas"`
	AvailableRelicas int32             `json:"availableReplicas"`
	ReadyReplicas    int32             `json:"readyReplicas"`
	Status           string            `json:"status"`
	Labels           map[string]string `json:"labels"`
	CreatedAt        time.Time         `json:"createdAt"`
}

type KubeClient

type KubeClient struct {
	Client *kubernetes.Clientset
	Logger *slog.Logger
	Config *rest.Config
}

func NewInClusterKube

func NewInClusterKube(logger *slog.Logger) *KubeClient

func NewOutClusterKube

func NewOutClusterKube(logger *slog.Logger) *KubeClient

func (*KubeClient) CreateService

func (k *KubeClient) CreateService(ctx context.Context, svc *ServiceOptions) (*corev1.Service, error)

func (*KubeClient) DeleteServiceByName

func (k *KubeClient) DeleteServiceByName(ctx context.Context, ns string, name string) error

func (*KubeClient) GetAllPodsInfo

func (k *KubeClient) GetAllPodsInfo(ctx context.Context) ([]PodInfo, error)

func (*KubeClient) GetAllServicesByNs

func (k *KubeClient) GetAllServicesByNs(ctx context.Context, ns string) ([]ServiceInfo, error)

func (*KubeClient) GetConfigMapByName

func (k *KubeClient) GetConfigMapByName(ctx context.Context, ns string, name string) (map[string]string, error)

func (*KubeClient) GetConfigMaps

func (k *KubeClient) GetConfigMaps(ctx context.Context, ns string) ([]string, error)

func (*KubeClient) GetContainersInDeployment

func (k *KubeClient) GetContainersInDeployment(ctx context.Context, ns string, name string) ([]PodDetails, error)

func (*KubeClient) GetCronJobs

func (k *KubeClient) GetCronJobs()

func (*KubeClient) GetDeploymentLogs

func (k *KubeClient) GetDeploymentLogs(ctx context.Context, ns string, name string) ([]*rest.Request, error)

func (*KubeClient) GetDeploymentYaml

func (k *KubeClient) GetDeploymentYaml(ctx context.Context, ns string, name string) (string, error)

func (*KubeClient) GetNamespaces

func (k *KubeClient) GetNamespaces(ctx context.Context) ([]string, error)

func (*KubeClient) GetNodesInfo

func (k *KubeClient) GetNodesInfo(ctx context.Context) ([]NodeInfo, error)

func (*KubeClient) GetPodLogs

func (k *KubeClient) GetPodLogs(ctx context.Context, ns string, name string) *rest.Request

func (*KubeClient) ListDeploymentsByNamespace

func (k *KubeClient) ListDeploymentsByNamespace(ctx context.Context, ns string) ([]DeploymentState, error)

func (*KubeClient) ScaleDeploymentsByName

func (k *KubeClient) ScaleDeploymentsByName(ctx context.Context, ns string, name string, replicas int32) (DeploymentState, error)

func (*KubeClient) SetConfigMapByName

func (k *KubeClient) SetConfigMapByName(ctx context.Context, ns string, name string, data map[string]string) error

func (*KubeClient) UpdateDeploymentYaml

func (k *KubeClient) UpdateDeploymentYaml(ctx context.Context, ns string, name string, updatedSpecYaml string) (string, error)

type NSListOpts

type NSListOpts struct {
}

TODO: map options from api

type NodeCondition

type NodeCondition struct {
	Type          string    `json:"type"`
	Status        string    `json:"status"`
	Message       string    `json:"message"`
	LastHeartBeat time.Time `json:"lastBeat"`
}

type NodeInfo

type NodeInfo struct {
	NodeName       string          `json:"nodeName"`
	CpuQuantity    float64         `json:"cpuQuantity"`
	MemoryQuantity float64         `json:"memoryQuantity"`
	CpuUsage       float64         `json:"cpuUsage"`
	MemoryUsage    float64         `json:"memoryUsage"`
	PodQuantity    float64         `json:"podQuantity"`
	ContainerCount int             `json:"containerCount"`
	Conditions     []NodeCondition `json:"conditions"`
	Ready          bool            `json:"ready"`
}

type PodDetails

type PodDetails struct {
	Name   string                   `json:"name"`
	Status []corev1.ContainerStatus `json:"status"`
}

type PodInfo

type PodInfo struct {
	Namespace string  `json:"namespace"`
	Name      string  `json:"name"`
	Restarts  int32   `json:"restarts"`
	CPU       float64 `json:"cpu"`
	Memory    float64 `json:"memory"`
	Status    string  `json:"status"`
}

type ServiceInfo

type ServiceInfo struct {
	Name       string  `json:"name"`
	Type       string  `json:"type"`
	ClusterIp  string  `json:"clusterIp"`
	ExternalIp string  `json:"externalIp"`
	Ports      string  `json:"ports"`
	CreatedAt  v1.Time `json:"createdAt"`
}

type ServiceOptions

type ServiceOptions struct {
	Name          string            `json:"name"`
	Namespace     string            `json:"namespace"`
	Labels        map[string]string `json:"labels"`
	ContainerPort int               `json:"containerPort"`
	ServicePort   int               `json:"servicePort"`
	Protocol      string            `json:"protocol"`
	Selector      map[string]string `json:"selector"`
	Type          string            `json:"type"`
}

Jump to

Keyboard shortcuts

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