utils

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NodeRoleMasterLabel defines the master node's label.
	NodeRoleMasterLabel = "node-role.kubernetes.io/master"
	// NodeRoleWorkerLabel defines the worker node's label.
	NodeRoleWorkerLabel = "node-role.kubernetes.io/node"
)

Variables

This section is empty.

Functions

func ExternalIP

func ExternalIP(n *v1.Node) string

ExternalIP returns external IP for a node. Will be empty string if not External IP found for node.

func IsMaster

func IsMaster(n *v1.Node) bool

IsMaster returns true if the node's labels contains "node-role.kubernetes.io/master".

func IsWorker

func IsWorker(n *v1.Node) bool

IsWorker returns true if the node's labels contains "node-role.kubernetes.io/node".

func NewScpClient

func NewScpClient(sshClient *SSHClient, host string) (*sftp.Client, error)

NewScpClient returns scp client with given host and ssh client.

func Retry

func Retry(attempts int, delay time.Duration, f func() error) error

Retry retries f until f return nil error. It makes max attempts and adds delay between each attempt.

Types

type SSHClient

type SSHClient struct {
	*ssh.ClientConfig
	// contains filtered or unexported fields
}

SSHClient holds config for ssh.

func MustNewSSHClient

func MustNewSSHClient(config *SSHConfig) *SSHClient

MustNewSSHClient returns *SSHClient. Uses default values for SSHConfig.

func (*SSHClient) Exec

func (c *SSHClient) Exec(host, cmd string) (stdout, stderr []byte, err error)

Exec executes the cmd on given host.

func (*SSHClient) ExecWithCtx

func (c *SSHClient) ExecWithCtx(ctx context.Context, host, cmd string) (stdout, stderr []byte, err error)

ExecWithCtx executes cmd on given host, with ctx.

type SSHConfig

type SSHConfig struct {
	// default to `core`
	User string
	// defaults to `22`
	Port int32
	// uses `SSH_AUTH_SOCK` if this is empty
	IdentifyKeyFile string
	// Timeout is the maximum amount of time for the ssh connection to establish.
	// defaults to `30 secs`
	Timeout time.Duration
}

Jump to

Keyboard shortcuts

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