Documentation ¶
Index ¶
- Constants
- Variables
- func AddFirewallRule()
- func BytesToInt(b []byte) uint32
- func DeleteConfigMap(clientset *kubernetes.Clientset, namespace, configMapName string)
- func DeletePod(clientset *kubernetes.Clientset, namespace, podName string) error
- func DeleteWindowsFirewallRule()
- func FindRule() bool
- func GenerateKey(kubeconfigBytes []byte, namespace string) string
- func GetAvailableUDPPortOrDie() int
- func GetClientSetByKubeconfigBytes(kubeconfigBytes []byte) (*kubernetes.Clientset, error)
- func GetContextWithLogger(writer io.WriteCloser) context.Context
- func GetLoggerFromContext(ctx context.Context) *log.Logger
- func GetMacAddress() net.HardwareAddr
- func GetOwnerReferences(object k8sruntime.Object) *metav1.OwnerReference
- func GetScale(object k8sruntime.Object) int
- func GetTopControllerBaseOnPodLabel(factory cmdutil.Factory, clientset coreV1.PodInterface, namespace string, ...) (info *runtimeresource.Info, err error)
- func GetUnstructuredObject(f cmdutil.Factory, namespace string, workloads string) (*runtimeresource.Info, error)
- func InitLogger(debug bool)
- func IsAdmin() bool
- func IsContainerNotFoundError(err error) bool
- func IsPortListening(port int) bool
- func IsSudoDaemonServing() bool
- func IsWindows() bool
- func MergeOrReplaceAnnotation(c rest.Interface, namespace, resource, name, k, v string) error
- func NewLogger(writer io.WriteCloser) *log.Logger
- func Ping(targetIP string) (bool, error)
- func PortForwardPod(config *rest.Config, clientset *rest.RESTClient, ...) error
- func RunWithElevated() error
- func Shell(clientset *kubernetes.Clientset, restclient *rest.RESTClient, ...) (string, error)
- func ShellWithStream(clientset *kubernetes.Clientset, restclient *rest.RESTClient, ...) error
- func UpdateReplicasScale(clientset *kubernetes.Clientset, namespace string, ...) error
- func WaitPortToBeFree(port int, timeout time.Duration) error
- type Format
- type ForwardedPort
- type PatchOperation
- type PortForwarder
- type ResourceTuple
- type ResourceTupleWithScale
Constants ¶
const ( TrafficManager string = "kubevpn.traffic.manager" OriginData string = "origin_data" REVERSE string = "REVERSE" Connect string = "Connect" MacToIP string = "MAC_TO_IP" DHCP string = "DHCP" Splitter string = "#" EndSignOK string = "EndSignOk" EndSignFailed string = "EndSignFailed" )
Variables ¶
var ( SPool = sync.Pool{ New: func() interface{} { return make([]byte, smallBufferSize) }, } MPool = sync.Pool{ New: func() interface{} { return make([]byte, mediumBufferSize) }, } LPool = sync.Pool{ New: func() interface{} { return make([]byte, largeBufferSize) }, } )
var ( // KeepAliveTime is the keep alive time period for TCP connection. KeepAliveTime = 180 * time.Second // DialTimeout is the timeout of dial. DialTimeout = 10 * time.Second )
var Debug bool
Debug is a flag that enables the debug log.
var ( // network layer ip needs 20 bytes // transport layer UDP header needs 8 bytes // UDP over TCP header needs 22 bytes DefaultMTU = 1500 - 20 - 8 - 21 )
var IpMask net.IPMask
var IpRange net.IP
var RouterIP net.IPNet
Functions ¶
func AddFirewallRule ¶
func AddFirewallRule()
func BytesToInt ¶
func DeleteConfigMap ¶
func DeleteConfigMap(clientset *kubernetes.Clientset, namespace, configMapName string)
func DeleteWindowsFirewallRule ¶
func DeleteWindowsFirewallRule()
DeleteWindowsFirewallRule Delete all action block firewall rule
func GenerateKey ¶
GenerateKey todo jetbrains rename will modify cluster name, it will make this function invalid
func GetAvailableUDPPortOrDie ¶
func GetAvailableUDPPortOrDie() int
func GetClientSetByKubeconfigBytes ¶
func GetClientSetByKubeconfigBytes(kubeconfigBytes []byte) (*kubernetes.Clientset, error)
func GetContextWithLogger ¶
func GetContextWithLogger(writer io.WriteCloser) context.Context
func GetMacAddress ¶
func GetMacAddress() net.HardwareAddr
func GetOwnerReferences ¶
func GetOwnerReferences(object k8sruntime.Object) *metav1.OwnerReference
func GetScale ¶
func GetScale(object k8sruntime.Object) int
func GetTopControllerBaseOnPodLabel ¶
func GetTopControllerBaseOnPodLabel(factory cmdutil.Factory, clientset coreV1.PodInterface, namespace string, selector labels.Selector) (info *runtimeresource.Info, err error)
func GetUnstructuredObject ¶
func InitLogger ¶
func InitLogger(debug bool)
func IsContainerNotFoundError ¶
IsContainerNotFoundError checks whether the error is container not found error.
func IsPortListening ¶
func IsSudoDaemonServing ¶
func IsSudoDaemonServing() bool
func PortForwardPod ¶
func RunWithElevated ¶
func RunWithElevated() error
func Shell ¶
func Shell(clientset *kubernetes.Clientset, restclient *rest.RESTClient, config *rest.Config, podName, containerName, namespace, cmd string) (string, error)
func ShellWithStream ¶
func ShellWithStream(clientset *kubernetes.Clientset, restclient *rest.RESTClient, config *rest.Config, podName, namespace, cmd string, writer io.Writer) error
func UpdateReplicasScale ¶
func UpdateReplicasScale(clientset *kubernetes.Clientset, namespace string, controller ResourceTupleWithScale) error
Types ¶
type ForwardedPort ¶
ForwardedPort contains a Local:Remote port pairing.
type PatchOperation ¶
type PortForwarder ¶
type PortForwarder struct { Ready chan struct{} // contains filtered or unexported fields }
PortForwarder knows how to listen for local connections and forward them to a remote pod via an upgraded HTTP request.
func New ¶
func New(dialer httpstream.Dialer, ports []string, stopChan <-chan struct{}, readyChan chan struct{}, out, errOut io.Writer) (*PortForwarder, error)
New creates a new PortForwarder with localhost listen addresses.
func NewOnAddresses ¶
func NewOnAddresses(dialer httpstream.Dialer, addresses []string, ports []string, stopChan <-chan struct{}, readyChan chan struct{}, out, errOut io.Writer) (*PortForwarder, error)
NewOnAddresses creates a new PortForwarder with custom listen addresses.
func (*PortForwarder) Close ¶
func (pf *PortForwarder) Close()
Close stops all listeners of PortForwarder.
func (*PortForwarder) ForwardPorts ¶
func (pf *PortForwarder) ForwardPorts() error
ForwardPorts formats and executes a port forwarding request. The connection will remain open until stopChan is closed.
func (*PortForwarder) GetPorts ¶
func (pf *PortForwarder) GetPorts() ([]ForwardedPort, error)
GetPorts will return the ports that were forwarded; this can be used to retrieve the locally-bound port in cases where the input was port 0. This function will signal an error if the Ready channel is nil or if the listeners are not ready yet; this function will succeed after the Ready channel has been closed.
type ResourceTuple ¶
func SplitResourceTypeName ¶
func SplitResourceTypeName(s string) (ResourceTuple, bool, error)
splitResourceTypeName handles type/name resource formats and returns a resource tuple (empty or not), whether it successfully found one, and an error
func (ResourceTuple) String ¶
func (r ResourceTuple) String() string