k8sclient

package
v0.0.0-...-61190b0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetKubeconfig

func GetKubeconfig() string

GetKubeconfig gets default kubeconfig

func NamespaceListToNames

func NamespaceListToNames(list *v1.NamespaceList) []string

NamespaceListToNames extracts and returns namespace list

func PodListToNames

func PodListToNames(list *v1.PodList) []string

PodListToNames extracts and returns podname list

func SprintlnContainers

func SprintlnContainers(items []*Container) string

SprintlnContainers returns tabular output of ContainerList

func SprintlnDeployments

func SprintlnDeployments(items []*Deployment) string

SprintlnDeployments returns tabular output of DeploymentList

func SprintlnIngresses

func SprintlnIngresses(items []*Ingress) string

SprintlnIngresses returns tabular output of IngressList

func SprintlnPods

func SprintlnPods(items []*Pod) string

SprintlnPods returns tabular output of PodList

func SprintlnServices

func SprintlnServices(items []*Service) string

SprintlnDeployments returns tabular output of DeploymentList

func ToIngressAddress

func ToIngressAddress(s *networkingv1.IngressStatus) string

ToIngressAddress behaves mostly like a string interface and converts the given status to a string

func ToIngressPorts

func ToIngressPorts(ingresses []v1.LoadBalancerIngress) (ingressPorts []string)

ToIngressPorts returns a list of ports from the given []LoadBalancerIngress

func ToPorts

func ToPorts(p []v1.ServicePort) []string

ToPorts tansforms v1.ServicePort to ports string

Types

type Client

type Client struct {
	*kubernetes.Clientset
}

func NewK8sClient

func NewK8sClient(kubeconfig string) (c *Client, err error)

NewK8sClient returns a k8s restClient

func (*Client) DescribeDeployments

func (c *Client) DescribeDeployments(namespace string) ([]*Deployment, error)

DescribeDeployments returns DeploymentList

func (*Client) DescribeIngresses

func (c *Client) DescribeIngresses(namespace string) ([]*Ingress, error)

DescribeIngresses returns IngressList

func (*Client) DescribeNamespace

func (c *Client) DescribeNamespace(
	namespace string, tail int, podNames ...string) (n *Namespace, err error)

DescribeNamespace gets and returns all msg in specific namespace

func (*Client) DescribePod

func (c *Client) DescribePod(namespace, podName string, tail int) (*Pod, error)

DescribePod returns specific Pod

func (*Client) DescribePods

func (c *Client) DescribePods(namespace string, tail int) ([]*Pod, error)

DescribePods returns PodList

func (*Client) DescribeServices

func (c *Client) DescribeServices(namespace string) ([]*Service, error)

DescribeServices returns ServiceList

func (*Client) GetContainersFromPod

func (c *Client) GetContainersFromPod(p *v1.Pod, tail int) ([]*Container, error)

GetContainersFromPod fills a pod with it's containers

func (*Client) GetDeploymentList

func (c *Client) GetDeploymentList(namespace string) (*appsv1.DeploymentList, error)

GetDeploymentList returns DeploymentList from k8s api

func (*Client) GetIngressList

func (c *Client) GetIngressList(namespace string) (*networkingv1.IngressList, error)

GetIngressList returns IngressList from k8s api

func (*Client) GetLog

func (c *Client) GetLog(namespace, pod, container string, tail int) (string, error)

GetLog returns log of one container

func (*Client) GetNamespace

func (c *Client) GetNamespace(namespace string) (*v1.Namespace, error)

GetNamespaceList returns specific namespace from k8s api

func (*Client) GetNamespaceList

func (c *Client) GetNamespaceList() (*v1.NamespaceList, error)

GetNamespaceList returns namespaceList from k8s api

func (*Client) GetPod

func (c *Client) GetPod(namespace, pod string) (*v1.Pod, error)

GetPod returns specific Pod from k8s api

func (*Client) GetPodList

func (c *Client) GetPodList(namespace string) (*v1.PodList, error)

GetPodList returns PodList from k8s api

func (*Client) GetService

func (c *Client) GetService(namespace, service string) (*v1.Service, error)

GetService returns specific v1.Service from k8s api

func (*Client) GetServiceList

func (c *Client) GetServiceList(namespace string) (*v1.ServiceList, error)

GetServiceList returns v1.ServiceList from k8s api

type Container

type Container struct {
	Name        string
	Status      string
	Ready       bool
	Image       string
	ImageID     string
	ContainerID string
	Log         string
}

type Deployment

type Deployment struct {
	Name                string
	Replicas            int
	UpdatedReplicas     int
	ReadyReplicas       int
	AvailableReplicas   int
	UnavailableReplicas int
}

func ToDeployment

func ToDeployment(d *appsv1.Deployment) *Deployment

ToDeployment tansforms appsv1.Deployment to Deployment

type HostPath

type HostPath struct {
	Path     string
	PathType string
	Backend  string
}

type Ingress

type Ingress struct {
	Name              string
	Class             string
	Rules             []IngressRule
	Address           string
	Ports             []string
	CreationTimestamp time.Time
}

func ToIngress

func ToIngress(i *networkingv1.Ingress) *Ingress

ToIngress tansforms networkingv1.Ingress to Ingress

type IngressRule

type IngressRule struct {
	Host string
	Path []HostPath
}

func ToIngressRules

func ToIngressRules(rules []networkingv1.IngressRule) []IngressRule

ToIngressRules returns a list of IngressRule

type Namespace

type Namespace struct {
	Name        string
	Ingresses   []*Ingress
	Services    []*Service
	Deployments []*Deployment
	Pods        []*Pod
}

func ToNamespace

func ToNamespace(n *v1.Namespace) *Namespace

ToNamespace tansforms v1.Namespace to Namespace

type Pod

type Pod struct {
	Name              string
	Status            string
	Ready             string
	Containers        []*Container
	CreationTimestamp time.Time
}

func ToPod

func ToPod(p *v1.Pod) *Pod

ToPod tansforms v1.Pod to Pod

type Service

type Service struct {
	Name              string
	Type              string
	ClusterIP         string
	ExternalIPs       []string
	Ports             []string
	CreationTimestamp time.Time
}

func ToService

func ToService(s *v1.Service) *Service

ToService tansforms v1.Service to Service

Jump to

Keyboard shortcuts

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