k8sinfo

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package k8sinfo used to create k8s client and get some k8s info

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatchLabel

func MatchLabel(selector, labels map[string]string) bool

Types

type K8sClient

type K8sClient struct {
	*kubernetes.Clientset
}

func NewK8sClientFromBearerToken

func NewK8sClientFromBearerToken(baseURL, path string) (*K8sClient, error)

func NewK8sClientFromBearerTokenString

func NewK8sClientFromBearerTokenString(baseURL, token string) (*K8sClient, error)

func (*K8sClient) GetDeployment

func (c *K8sClient) GetDeployment(ns string) (map[string]*K8sDeployment, error)

func (*K8sClient) GetEndpointNet

func (c *K8sClient) GetEndpointNet(ns string) (map[string]*K8sEndpointsNet, error)

func (*K8sClient) GetNamespaces

func (c *K8sClient) GetNamespaces() ([]string, error)

func (*K8sClient) GetPodNet

func (c *K8sClient) GetPodNet(ns string) (map[string][]*K8sPodNet, error)

func (*K8sClient) GetServiceNet

func (c *K8sClient) GetServiceNet(ns string) (map[string]*K8sServicesNet, error)

type K8sDeployment

type K8sDeployment struct {
	Namespace string
	Name      string

	MatchLabels map[string]string
}

type K8sEndpointsNet

type K8sEndpointsNet struct {
	Namespace string
	Name      string // == service name
	IPPort    map[string][]Port
}

type K8sNetInfo

type K8sNetInfo struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewK8sNetInfo

func NewK8sNetInfo(cli *K8sClient) (*K8sNetInfo, error)

func (*K8sNetInfo) AutoUpdate

func (kinfo *K8sNetInfo) AutoUpdate(ctx context.Context)

func (*K8sNetInfo) IsServer

func (kinfo *K8sNetInfo) IsServer(srcIP string, srcPort uint32, protocol string) bool

func (*K8sNetInfo) QueryPodInfo

func (kinfo *K8sNetInfo) QueryPodInfo(ip string, port uint32, protocol string) (
	string, string, string, string, error,
)

QueryPodInfo returns pod name, svc name, namespace, deployment,port, err).

func (*K8sNetInfo) QuerySvcInfo

func (kinfo *K8sNetInfo) QuerySvcInfo(ip string, port uint32, protocol string) (string, string, string, error)

QuerySvcInfo returns (svc name, namespace, error).

func (*K8sNetInfo) Update

func (kinfo *K8sNetInfo) Update() error

type K8sPodNet

type K8sPodNet struct {
	Namespace   string
	ClusterName string
	Name        string

	DeploymentName string
	ServiceName    string
	NodeName       string

	Labels map[string]string
	PodIPs []string

	HostIPC     bool
	HostNetwork bool
	HostPID     bool
}

type K8sServicesNet

type K8sServicesNet struct {
	Namespace      string
	Name           string
	DeploymentName string

	ClusterIPs  []string
	ExternalIPs []string
	// format: <port>/protocol 9529/TCP, 80/TCP, 53/UDP, ...
	Port       []Port
	NodePort   []Port
	TargetPort []Port

	// NodePort, ...
	Type string

	Selector map[string]string
}

type Port

type Port struct {
	Port     uint32
	Protocol string
}

func (Port) String

func (p Port) String() string

Jump to

Keyboard shortcuts

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