Documentation ¶
Index ¶
- func AddAllowFirewallRule()
- func AllContainerIsRunning(pod *corev1.Pod) bool
- func BytesToInt(b []byte) uint32
- func CanI(clientset *kubernetes.Clientset, sa, ns string, resource *rbacv1.PolicyRule) (allowed bool, err error)
- func CleanExtensionLib()
- func ConvertToKubeconfigBytes(factory cmdutil.Factory) ([]byte, string, error)
- func ConvertToTempKubeconfigFile(kubeconfigBytes []byte) (string, error)
- func Deduplicate(cidr []*net.IPNet) (result []*net.IPNet)
- func DeleteAllowFirewallRule()
- func DeleteBlockFirewallRule(_ context.Context)
- func DialSshRemote(conf *SshConfig) (*ssh.Client, error)
- func DoReq(request *http.Request) (body []byte, err error)
- func Download(client *http.Client, url string, filename string, stdout, stderr io.Writer) error
- func FindAllowFirewallRule() bool
- func FindContainerByName(pod *corev1.Pod, name string) (*corev1.Container, int)
- func FindContainerEnv(container *corev1.Container, key string) (value string, found bool)
- func GetAnnotation(f util.Factory, ns string, resources string) (map[string]string, error)
- func GetAvailableTCPPortOrDie() (int, error)
- func GetAvailableUDPPortOrDie() (int, error)
- func GetCIDRElegant(clientset *kubernetes.Clientset, restclient *rest.RESTClient, ...) (result []*net.IPNet, err1 error)
- func GetCIDRFromResourceUgly(clientset *kubernetes.Clientset, namespace string) ([]*net.IPNet, error)
- func GetClient() (*client.Client, *command.DockerCli, error)
- func GetClusterId(client v12.ConfigMapInterface) (types.UID, error)
- func GetDNSIPFromDnsPod(clientset *kubernetes.Clientset) (ips []string, err error)
- func GetDNSServiceIPFromPod(clientset *kubernetes.Clientset, restclient *rest.RESTClient, ...) (*dns.ClientConfig, error)
- func GetEnv(ctx context.Context, f util.Factory, ns, pod string) (map[string][]string, error)
- func GetIPBaseNic() (*net.IPNet, error)
- func GetKrb5Path() string
- func GetKubeconfigPath(f cmdutil.Factory) string
- func GetLocalTunIP(tunName string) (net.IP, net.IP, error)
- func GetManifest(httpCli *http.Client, os string, arch string) (version string, commit string, url string, err error)
- func GetPodTemplateSpecPath(u *unstructured.Unstructured) (*v1.PodTemplateSpec, []string, error)
- func GetTlsDomain(namespace string) string
- func GetTopOwnerReference(factory util.Factory, namespace, workload string) (*resource.Info, error)
- func GetTopOwnerReferenceBySelector(factory util.Factory, namespace, selector string) (sets.Set[string], error)
- func GetTunDevice(ips ...net.IP) (*net.Interface, error)
- func GetTunDeviceByConn(tun net.Conn) (*net.Interface, error)
- func GetUnstructuredObject(f util.Factory, namespace string, workloads string) (*resource.Info, error)
- func GetUnstructuredObjectBySelector(f util.Factory, namespace string, selector string) ([]*resource.Info, error)
- func GetUnstructuredObjectList(f util.Factory, namespace string, workloads []string) ([]*resource.Info, error)
- func Heartbeats()
- func InitLogger(debug bool)
- func InitLoggerForServer(debug bool)
- func IsAdmin() bool
- func IsIPv4(packet []byte) bool
- func IsIPv6(packet []byte) bool
- func IsPortListening(port int) bool
- func IsSameCluster(client v12.ConfigMapInterface, namespace string, ...) (bool, error)
- func IsWindows() bool
- func Merge[K comparable, V any](fromMap, ToMap map[K]V) map[K]V
- func MoveToTemp()
- func ParsePort(str string) v1.ContainerPort
- func Ping(targetIP string) (bool, error)
- func PortForwardPod(config *rest.Config, clientset *rest.RESTClient, podName, namespace string, ...) error
- func PortMapUntil(ctx context.Context, conf *SshConfig, remote, local netip.AddrPort) error
- func Print(writer io.Writer, slogan string)
- func PrintStatus(pod *corev1.Pod, writer io.Writer)
- func PrintStatusInline(pod *corev1.Pod) string
- func PullImage(ctx context.Context, platform *v1.Platform, cli *client.Client, ...) error
- func RemoteRun(client *ssh.Client, cmd string, env map[string]string) (output []byte, errOut []byte, err error)
- func RolloutStatus(ctx1 context.Context, factory cmdutil.Factory, namespace, workloads string, ...) (err error)
- func RunCmd(exe string, args []string) error
- func RunCmdWithElevated(exe string, args []string) error
- func RunWithElevated()
- func RunWithRollingOutWithChecker(cmd *osexec.Cmd, checker func(log string)) (string, string, error)
- func RunningInContainer() bool
- func SCP(client *ssh.Client, stdout, stderr io.Writer, filename, to string) error
- func SCPAndExec(stdout, stderr io.Writer, client *ssh.Client, filename, to string, ...) error
- func Shell(clientset *kubernetes.Clientset, restclient *rest.RESTClient, ...) (string, error)
- func SshJump(ctx context.Context, conf *SshConfig, flags *pflag.FlagSet, print bool) (path string, err error)
- func SshJumpAndSetEnv(ctx context.Context, conf *SshConfig, flags *pflag.FlagSet, print bool) error
- func StartupPProf(port int)
- func TransferImage(ctx context.Context, conf *SshConfig, imageSource, imageTarget string, ...) error
- func UnzipKubeVPNIntoFile(zipFile, filename string) error
- func WaitPod(podInterface v12.PodInterface, list v1.ListOptions, ...) error
- func WaitPodToBeReady(ctx context.Context, podInterface v12.PodInterface, selector v1.LabelSelector) error
- func WaitPortToBeFree(ctx context.Context, port int) error
- type AssetsEntity
- type AuthorEntity
- type ForwardedPort
- type Krb5ClientState
- type Krb5InitiatorClient
- func NewKrb5InitiatorClientWithCache(krb5Conf, cacheFile string) (kcl Krb5InitiatorClient, err error)
- func NewKrb5InitiatorClientWithKeytab(username string, krb5Conf, keytabConf string) (kcl Krb5InitiatorClient, err error)
- func NewKrb5InitiatorClientWithPassword(username, password, krb5Conf string) (kcl Krb5InitiatorClient, err error)
- type PodRouteConfig
- type PortForwarder
- type ReactionsEntity
- type RootEntity
- type SshConfig
- type UploaderEntity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddAllowFirewallRule ¶
func AddAllowFirewallRule()
func AllContainerIsRunning ¶
func BytesToInt ¶
func CanI ¶
func CanI(clientset *kubernetes.Clientset, sa, ns string, resource *rbacv1.PolicyRule) (allowed bool, err error)
func CleanExtensionLib ¶
func CleanExtensionLib()
func DeleteAllowFirewallRule ¶
func DeleteAllowFirewallRule()
func DeleteBlockFirewallRule ¶
func DialSshRemote ¶
DialSshRemote https://github.com/golang/go/issues/21478
func Download ¶
https://api.github.com/repos/kubenetworks/kubevpn/releases https://github.com/kubenetworks/kubevpn/releases/download/v1.1.13/kubevpn-windows-arm64.exe
func FindAllowFirewallRule ¶
func FindAllowFirewallRule() bool
func FindContainerByName ¶ added in v2.2.2
func FindContainerEnv ¶ added in v2.2.2
func GetAnnotation ¶
func GetCIDRElegant ¶
func GetCIDRElegant(clientset *kubernetes.Clientset, restclient *rest.RESTClient, restconfig *rest.Config, namespace string) (result []*net.IPNet, err1 error)
GetCIDRElegant 1) dump cluster info 2) grep cmdline 3) create svc + cat *.conflist 4) create svc + get pod ip with svc mask
func GetCIDRFromResourceUgly ¶
func GetCIDRFromResourceUgly(clientset *kubernetes.Clientset, namespace string) ([]*net.IPNet, error)
GetCIDRFromResourceUgly use podIP/24 and serviceIP/16 as cidr
func GetClusterId ¶
func GetClusterId(client v12.ConfigMapInterface) (types.UID, error)
func GetDNSIPFromDnsPod ¶
func GetDNSIPFromDnsPod(clientset *kubernetes.Clientset) (ips []string, err error)
func GetDNSServiceIPFromPod ¶
func GetDNSServiceIPFromPod(clientset *kubernetes.Clientset, restclient *rest.RESTClient, config *rest.Config, podName, namespace string) (*dns.ClientConfig, error)
func GetIPBaseNic ¶
func GetKrb5Path ¶
func GetKrb5Path() string
func GetKubeconfigPath ¶
func GetManifest ¶
func GetPodTemplateSpecPath ¶
func GetPodTemplateSpecPath(u *unstructured.Unstructured) (*v1.PodTemplateSpec, []string, error)
func GetTlsDomain ¶
func GetTopOwnerReference ¶
func GetTopOwnerReferenceBySelector ¶
func GetTopOwnerReferenceBySelector(factory util.Factory, namespace, selector string) (sets.Set[string], error)
GetTopOwnerReferenceBySelector assume pods, controller has same labels
func GetUnstructuredObject ¶
func Heartbeats ¶
func Heartbeats()
func InitLogger ¶
func InitLogger(debug bool)
func InitLoggerForServer ¶ added in v2.2.2
func InitLoggerForServer(debug bool)
func IsPortListening ¶
func IsSameCluster ¶
func IsSameCluster(client v12.ConfigMapInterface, namespace string, clientB v12.ConfigMapInterface, namespaceB string) (bool, error)
func Merge ¶
func Merge[K comparable, V any](fromMap, ToMap map[K]V) map[K]V
func MoveToTemp ¶
func MoveToTemp()
func ParsePort ¶ added in v2.2.3
func ParsePort(str string) v1.ContainerPort
ParsePort tcp/udp/remote:local
func PortForwardPod ¶
func PortMapUntil ¶ added in v2.2.2
func PrintStatusInline ¶
func RolloutStatus ¶
func RunCmdWithElevated ¶
func RunWithElevated ¶
func RunWithElevated()
func RunningInContainer ¶
func RunningInContainer() bool
RunningInContainer returns true if the current process runs from inside a docker container.
func SCPAndExec ¶ added in v2.2.2
func SCPAndExec(stdout, stderr io.Writer, client *ssh.Client, filename, to string, commands ...string) error
SCPAndExec copy file to remote and exec command
func Shell ¶
func Shell(clientset *kubernetes.Clientset, restclient *rest.RESTClient, config *rest.Config, podName, containerName, namespace string, cmd []string) (string, error)
func SshJumpAndSetEnv ¶ added in v2.2.3
func StartupPProf ¶
func StartupPProf(port int)
func TransferImage ¶
func TransferImage(ctx context.Context, conf *SshConfig, imageSource, imageTarget string, out io.Writer) error
TransferImage 1) if not special ssh config, just pull image and tag and push 2) if special ssh config, pull image, tag image, save image and scp image to remote, load image and push
func UnzipKubeVPNIntoFile ¶
func WaitPod ¶
func WaitPod(podInterface v12.PodInterface, list v1.ListOptions, checker func(*corev1.Pod) bool) error
func WaitPodToBeReady ¶
func WaitPodToBeReady(ctx context.Context, podInterface v12.PodInterface, selector v1.LabelSelector) error
Types ¶
type AssetsEntity ¶
type AssetsEntity struct { Url string `json:"url"` Id int64 `json:"id"` NodeId string `json:"node_id"` Name string `json:"name"` Label string `json:"label"` Uploader UploaderEntity `json:"uploader"` ContentType string `json:"content_type"` State string `json:"state"` Size int64 `json:"size"` DownloadCount int64 `json:"download_count"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` BrowserDownloadUrl string `json:"browser_download_url"` }
type AuthorEntity ¶
type AuthorEntity struct { Login string `json:"login"` Id int64 `json:"id"` NodeId string `json:"node_id"` AvatarUrl string `json:"avatar_url"` GravatarId string `json:"gravatar_id"` Url string `json:"url"` HtmlUrl string `json:"html_url"` FollowersUrl string `json:"followers_url"` FollowingUrl string `json:"following_url"` GistsUrl string `json:"gists_url"` StarredUrl string `json:"starred_url"` SubscriptionsUrl string `json:"subscriptions_url"` OrganizationsUrl string `json:"organizations_url"` ReposUrl string `json:"repos_url"` EventsUrl string `json:"events_url"` ReceivedEventsUrl string `json:"received_events_url"` Type string `json:"type"` SiteAdmin bool `json:"site_admin"` }
type ForwardedPort ¶
ForwardedPort contains a Local:Remote port pairing.
type Krb5ClientState ¶
type Krb5ClientState int
const ( ContextFlagREADY = 128 /* initiator states */ InitiatorStart Krb5ClientState = iota InitiatorRestart InitiatorWaitForMutal InitiatorReady )
type Krb5InitiatorClient ¶
type Krb5InitiatorClient struct {
// contains filtered or unexported fields
}
func NewKrb5InitiatorClientWithCache ¶
func NewKrb5InitiatorClientWithCache(krb5Conf, cacheFile string) (kcl Krb5InitiatorClient, err error)
func NewKrb5InitiatorClientWithKeytab ¶
func NewKrb5InitiatorClientWithKeytab(username string, krb5Conf, keytabConf string) (kcl Krb5InitiatorClient, err error)
func NewKrb5InitiatorClientWithPassword ¶
func NewKrb5InitiatorClientWithPassword(username, password, krb5Conf string) (kcl Krb5InitiatorClient, err error)
func (*Krb5InitiatorClient) DeleteSecContext ¶
func (k *Krb5InitiatorClient) DeleteSecContext() error
func (*Krb5InitiatorClient) GetMIC ¶
func (k *Krb5InitiatorClient) GetMIC(micFiled []byte) ([]byte, error)
func (*Krb5InitiatorClient) InitSecContext ¶
type PodRouteConfig ¶
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 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 ReactionsEntity ¶
type ReactionsEntity struct { Url string `json:"url"` TotalCount int64 `json:"total_count"` Normal1 int64 `json:"+1"` Normal11 int64 `json:"-1"` Laugh int64 `json:"laugh"` Hooray int64 `json:"hooray"` Confused int64 `json:"confused"` Heart int64 `json:"heart"` Rocket int64 `json:"rocket"` Eyes int64 `json:"eyes"` }
type RootEntity ¶
type RootEntity struct { Url string `json:"url"` AssetsUrl string `json:"assets_url"` UploadUrl string `json:"upload_url"` HtmlUrl string `json:"html_url"` Id int64 `json:"id"` NodeId string `json:"node_id"` TagName string `json:"tag_name"` TargetCommitish string `json:"target_commitish"` Name string `json:"name"` Draft bool `json:"draft"` Prerelease bool `json:"prerelease"` CreatedAt string `json:"created_at"` PublishedAt string `json:"published_at"` Assets []AssetsEntity `json:"assets"` TarballUrl string `json:"tarball_url"` ZipballUrl string `json:"zipball_url"` Body string `json:"body"` Reactions ReactionsEntity `json:"reactions"` }
type SshConfig ¶
type SshConfig struct { Addr string User string Password string Keyfile string ConfigAlias string RemoteKubeconfig string // GSSAPI GSSAPIKeytabConf string GSSAPIPassword string GSSAPICacheFile string }
func ParseSshFromRPC ¶
type UploaderEntity ¶
type UploaderEntity struct { Login string `json:"login"` Id int64 `json:"id"` NodeId string `json:"node_id"` AvatarUrl string `json:"avatar_url"` GravatarId string `json:"gravatar_id"` Url string `json:"url"` HtmlUrl string `json:"html_url"` FollowersUrl string `json:"followers_url"` FollowingUrl string `json:"following_url"` GistsUrl string `json:"gists_url"` StarredUrl string `json:"starred_url"` SubscriptionsUrl string `json:"subscriptions_url"` OrganizationsUrl string `json:"organizations_url"` ReposUrl string `json:"repos_url"` EventsUrl string `json:"events_url"` ReceivedEventsUrl string `json:"received_events_url"` Type string `json:"type"` SiteAdmin bool `json:"site_admin"` }