edgectl

package
v1.5.5 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const ExitPrefix = "-- exit "

ExitPrefix is the token used by the daemon ot tell the client to exit with the specified status

View Source
const SecretName = "ambassador-internal"

Variables

View Source
var DaemonHelp = `The Edge Control Daemon is a long-lived background component that manages
connections and network state.

Launch the Edge Control Daemon:
    sudo edgectl daemon

Examine the Daemon's log output in
    ` + logfile + `
to troubleshoot problems.
`
View Source
var Version = "(unknown version)"

Functions

func AESLicense

func AESLicense(cmd *cobra.Command, args []string) error

func AESLogin

func AESLogin(cmd *cobra.Command, args []string) error

func DaemonWorks

func DaemonWorks() bool

DaemonWorks returns whether the daemon can function on this platform

func DisplayVersion

func DisplayVersion() string

DisplayVersion returns a printable version for `edgectl`

func DoLogin

func DoLogin(kubeinfo *k8s.KubeInfo, context, namespace, hostname string, openInBrowser, showURL, showToken, showWelcome bool) error

func GetExe

func GetExe() string

func GetFreePort

func GetFreePort() (int, error)

GetFreePort asks the kernel for a free open port that is ready to use. Similar to telepresence.utilities.find_free_port()

func IsServerRunning

func IsServerRunning() bool

func LaunchDaemon

func LaunchDaemon(ccmd *cobra.Command, _ []string) error

func MainViaDaemon

func MainViaDaemon() error

func NewCmdUsage

func NewCmdUsage(cmd *cobra.Command, groups []CmdGroup) func(*cobra.Command) error

NewCmdUsage constructs a cobra UsageFunc for a command based on the command groups passed in. Requires that the command has exactly the subcommands mentioned in the groups, panicking otherwise.

func NewLoggingWriter

func NewLoggingWriter(l *log.Logger) io.Writer

NewLoggingWriter returns an io.Writer that logs each write line-by-line blindly passing through non-UTF-8 and over-long lines.

func Notify

func Notify(p *supervisor.Process, message string)

Notify displays a desktop banner notification to the user

func RunAsDaemon

func RunAsDaemon(dns, fallback string) error

RunAsDaemon is the main function when executing as the daemon

func RunAsTeleproxyBridge

func RunAsTeleproxyBridge(context, namespace string) error

RunAsTeleproxyBridge is the main function when executing as teleproxy bridge

func RunAsTeleproxyIntercept

func RunAsTeleproxyIntercept(dns, fallback string) error

RunAsTeleproxyIntercept is the main function when executing as teleproxy intercept

func SetUpLogging

func SetUpLogging() supervisor.Logger

SetUpLogging sets up standard Edge Control Daemon logging

func SetVersion

func SetVersion(v string)

SetVersion sets the current version for the executable

func WaitForSignal

func WaitForSignal(p *supervisor.Process) error

WaitForSignal is a Worker that calls Shutdown if SIGINT or SIGTERM is received.

Types

type ClientMessage

type ClientMessage struct {
	Args          []string
	RAI           *RunAsInfo
	APIVersion    int
	ClientVersion string
	InstallID     string
}

ClientMessage contains everything the daemon needs to process a user's command

type CmdGroup

type CmdGroup struct {
	GroupName string
	CmdNames  []string
}

CmdGroup represents a group of commands and the name of that group

type Daemon

type Daemon struct {
	// contains filtered or unexported fields
}

Daemon represents the state of the Edge Control Daemon

func (*Daemon) AddIntercept

func (d *Daemon) AddIntercept(p *supervisor.Process, out *Emitter, ii *InterceptInfo) error

AddIntercept adds one intercept

func (*Daemon) ClearIntercepts

func (d *Daemon) ClearIntercepts(p *supervisor.Process) error

ClearIntercepts removes all intercepts

func (*Daemon) Connect

func (d *Daemon) Connect(
	p *supervisor.Process, out *Emitter, rai *RunAsInfo,
	context, namespace, managerNs string, kargs []string,
	installID string, isCI bool,
) error

Connect the daemon to a cluster

func (*Daemon) Disconnect

func (d *Daemon) Disconnect(p *supervisor.Process, out *Emitter) error

Disconnect from the connected cluster

func (*Daemon) GetRootCommand

func (d *Daemon) GetRootCommand(p *supervisor.Process, out *Emitter, data *ClientMessage) *cobra.Command

func (*Daemon) ListIntercepts

func (d *Daemon) ListIntercepts(_ *supervisor.Process, out *Emitter) error

ListIntercepts lists active intercepts

func (*Daemon) MakeNetOverride

func (d *Daemon) MakeNetOverride(p *supervisor.Process) error

MakeNetOverride sets up the network override resource for the daemon

func (*Daemon) RemoveIntercept

func (d *Daemon) RemoveIntercept(p *supervisor.Process, out *Emitter, name string) error

RemoveIntercept removes one intercept by name

func (*Daemon) Status

func (d *Daemon) Status(_ *supervisor.Process, out *Emitter) error

Status reports the current status of the daemon

type DaemonFormatter

type DaemonFormatter struct {
	TimestampFormat string
}

DaemonFormatter formats log messages for the Edge Control Daemon

func (*DaemonFormatter) Format

func (f *DaemonFormatter) Format(entry *logrus.Entry) ([]byte, error)

Format implement logrus.Formatter

type Emitter

type Emitter struct {
	// contains filtered or unexported fields
}

Emitter provides a convenient way to send data to the client and handle errors in one spot.

func NewEmitter

func NewEmitter(w io.Writer) *Emitter

NewEmitter returns a new Emitter to write to conn

func (*Emitter) Err

func (out *Emitter) Err() error

Err returns the first non-EOF error that was encountered by the Emitter.

func (*Emitter) Print

func (out *Emitter) Print(a ...interface{})

Print formats using the default formats for its operands and writes to the client. Errors are collected and returned by Err().

func (*Emitter) Printf

func (out *Emitter) Printf(format string, a ...interface{})

Printf formats according to a format specifier and writes to the client. Errors are collected and returned by Err().

func (*Emitter) Println

func (out *Emitter) Println(a ...interface{})

Println formats using the default formats for its operands and writes to the client, ending output with a newline. Errors are collected and returned by Err().

func (*Emitter) Send

func (out *Emitter) Send(key string, value interface{})

Send a key/value pair to the client if the Emitter is in key/value mode. Errors are collected and returned by Err().

func (*Emitter) SendExit

func (out *Emitter) SendExit(code int)

SendExit tells the client to exit with the specified return code. Errors are collected and returned by Err().

func (*Emitter) SetKV

func (out *Emitter) SetKV()

type Intercept

type Intercept struct {
	ResourceBase
	// contains filtered or unexported fields
}

Intercept is a Resource handle that represents a live intercept

func MakeIntercept

func MakeIntercept(p *supervisor.Process, out *Emitter, tm *TrafficManager, cluster *KCluster, ii *InterceptInfo) (*Intercept, error)

MakeIntercept acquires an intercept and returns a Resource handle for it

type InterceptInfo

type InterceptInfo struct {
	Name       string // Name of the intercept (user/logging)
	Namespace  string // Namespace in which to create the Intercept mapping
	Deployment string // Name of the deployment being intercepted
	Prefix     string // Prefix to intercept (default /)
	Patterns   map[string]string
	TargetHost string
	TargetPort int
}

InterceptInfo tracks one intercept operation

func (*InterceptInfo) Acquire

func (ii *InterceptInfo) Acquire(_ *supervisor.Process, tm *TrafficManager) (int, error)

Acquire an intercept from the traffic manager

func (*InterceptInfo) PreviewURL

func (ii *InterceptInfo) PreviewURL(hostname string) (url string)

PreviewURL returns the Service Preview URL for this intercept if it is configured appropriately, or the empty string otherwise.

func (*InterceptInfo) Release

func (ii *InterceptInfo) Release(_ *supervisor.Process, tm *TrafficManager, port int) error

Release the given intercept.

func (*InterceptInfo) Retain

func (ii *InterceptInfo) Retain(_ *supervisor.Process, tm *TrafficManager, port int) error

Retain the given intercept. This likely needs to be called every five seconds or so.

type KCluster

type KCluster struct {
	ResourceBase
	// contains filtered or unexported fields
}

KCluster is a Kubernetes cluster reference

func TrackKCluster

func TrackKCluster(
	p *supervisor.Process, rai *RunAsInfo, context, namespace string, kargs []string,
) (*KCluster, error)

TrackKCluster tracks connectivity to a cluster

func (*KCluster) Context

func (c *KCluster) Context() string

Context returns the cluster's context name

func (*KCluster) GetKubectlArgs

func (c *KCluster) GetKubectlArgs(args ...string) []string

GetKubectlArgs returns the kubectl command arguments to run a kubectl command with this cluster, including the namespace argument.

func (*KCluster) GetKubectlArgsNoNamespace

func (c *KCluster) GetKubectlArgsNoNamespace(args ...string) []string

GetKubectlArgsNoNamespace returns the kubectl command arguments to run a kubectl command with this cluster, but without the namespace argument.

func (*KCluster) GetKubectlCmd

func (c *KCluster) GetKubectlCmd(p *supervisor.Process, args ...string) *supervisor.Cmd

GetKubectlCmd returns a Cmd that runs kubectl with the given arguments and the appropriate environment to talk to the cluster

func (*KCluster) GetKubectlCmdNoNamespace

func (c *KCluster) GetKubectlCmdNoNamespace(p *supervisor.Process, args ...string) *supervisor.Cmd

GetKubectlCmdNoNamespace returns a Cmd that runs kubectl with the given arguments and the appropriate environment to talk to the cluster, but it doesn't supply a namespace arg.

func (*KCluster) RAI

func (c *KCluster) RAI() *RunAsInfo

RAI returns the RunAsInfo for this cluster

func (*KCluster) Server

func (c *KCluster) Server() string

Server returns the cluster's server configuration

func (*KCluster) SetBridgeCheck

func (c *KCluster) SetBridgeCheck(isBridgeOkay func() bool)

SetBridgeCheck sets the callable used to check whether the Teleproxy bridge is functioning. If this is nil/unset, cluster monitoring checks the cluster directly (via kubectl)

type LoginClaimsV1

type LoginClaimsV1 struct {
	LoginTokenVersion string `json:"login_token_version"`
	jwt.StandardClaims
}

type Resource

type Resource interface {
	Name() string
	IsOkay() bool
	Close() error
}

Resource represents one thing managed by edgectl daemon. Examples include network intercepts (via teleproxy intercept) and cluster connectivity.

func CheckedRetryingCommand

func CheckedRetryingCommand(
	p *supervisor.Process, name string, args []string, rai *RunAsInfo,
	check func(*supervisor.Process) error, startGrace time.Duration,
) (Resource, error)

CheckedRetryingCommand launches a command, restarting it repeatedly if it quits, and killing and restarting it if it fails the given check.

type ResourceBase

type ResourceBase struct {
	// contains filtered or unexported fields
}

ResourceBase has helpers to create a monitored resource

func (*ResourceBase) Close

func (rb *ResourceBase) Close() error

Close shuts down this resource

func (*ResourceBase) IsOkay

func (rb *ResourceBase) IsOkay() bool

IsOkay returns whether the resource is okay as far as monitoring is aware

func (*ResourceBase) Name

func (rb *ResourceBase) Name() string

Name implements Resource

type RunAsInfo

type RunAsInfo struct {
	Name string
	Cwd  string
	Env  []string
}

RunAsInfo contains the information required to launch a subprocess as the user such that it is likely to function as if the user launched it themselves.

func GetRunAsInfo

func GetRunAsInfo() (*RunAsInfo, error)

GetRunAsInfo returns an RAI for the current user context

func GuessRunAsInfo

func GuessRunAsInfo(p *supervisor.Process) (*RunAsInfo, error)

GuessRunAsInfo attempts to construct a RunAsInfo for the user logged in at the primary display

func (*RunAsInfo) Command

func (rai *RunAsInfo) Command(p *supervisor.Process, args ...string) *supervisor.Cmd

Command returns a supervisor.Cmd that is configured to run a subprocess as the user in this context.

type Scout

type Scout struct {
	Reporter *metriton.Reporter
	// contains filtered or unexported fields
}

func NewScout

func NewScout(mode string) (s *Scout)

func (*Scout) Report

func (s *Scout) Report(action string, meta ...ScoutMeta) error

func (*Scout) SetMetadatum

func (s *Scout) SetMetadatum(key string, value interface{})

type ScoutMeta

type ScoutMeta struct {
	Key   string
	Value interface{}
}

type TrafficManager

type TrafficManager struct {
	// contains filtered or unexported fields
}

TrafficManager is a handle to access the Traffic Manager in a cluster.

func NewTrafficManager

func NewTrafficManager(p *supervisor.Process, cluster *KCluster, managerNs string, installID string, isCI bool) (*TrafficManager, error)

NewTrafficManager returns a TrafficManager resource for the given cluster if it has a Traffic Manager service.

func (*TrafficManager) Close

func (tm *TrafficManager) Close() error

Close implements Resource

func (*TrafficManager) IsOkay

func (tm *TrafficManager) IsOkay() bool

IsOkay implements Resource

func (*TrafficManager) Name

func (tm *TrafficManager) Name() string

Name implements Resource

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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