k8s

package
v0.0.0-...-6e34d32 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	ID     string
	Cores  int
	Memory int // in MB
	Image  string
	Ports  []*PortProto
}

App contains the information for deploying an application with Kubernetes.

type Client

type Client struct {
	// Host must be a host string, a host:port pair, or a URL to the base of the apiserver.
	// If a URL is given then the (optional) Path of that URL represents a prefix that must
	// be appended to all request URIs used to access the apiserver. This allows a frontend
	// proxy to easily relocate all of the apiserver endpoints.
	Host string

	// APIPath is a sub-path that points to an API root.
	APIPath string

	// Authentication info
	Username string
	CertFile string
	KeyFile  string
	CAFile   string

	// ImagePullPolicy specifies container retrieval policy. If not provided,
	// PullNever policy will be used. This field is intended for overriding default
	// policy for testing.
	ImagePullPolicy apiV1.PullPolicy

	// NewClientSet creates a new Kubernetes clientset interface. If it is nil,
	// a REST client with TLS will be used. This field is intended for use
	// mocking an external connection.
	NewClientSet func() (kubernetes.Interface, error)
	// contains filtered or unexported fields
}

Client abstracts calls to k8s master API

func (*Client) ApplyNetworkPolicy

func (ks *Client) ApplyNetworkPolicy(ctx context.Context,
	nodeID, appID string, policy *networkingV1.NetworkPolicy) error

ApplyNetworkPolicy applies network policy for app on specified node

func (*Client) DeleteNetworkPolicy

func (ks *Client) DeleteNetworkPolicy(ctx context.Context, nodeID, appID string) error

DeleteNetworkPolicy deletes network policy for app on specified node

func (*Client) Deploy

func (ks *Client) Deploy(ctx context.Context, nodeID string, app App) error

Deploy creates a kubernetes deployment

func (*Client) GetAppIDByIP

func (ks *Client) GetAppIDByIP(ctx context.Context, nodeID, ipAddr string) (string, error)

GetAppIDByIP gets the ID of an application running on a node by its pod IP address

func (*Client) GetNetworkPolicy

func (ks *Client) GetNetworkPolicy(ctx context.Context, nodeID, appID string) (*networkingV1.NetworkPolicy, error)

GetNetworkPolicy returns network policy for app on specified node

func (*Client) Ping

func (ks *Client) Ping() error

Ping checks the connection to the Kubernetes server.

func (*Client) Restart

func (ks *Client) Restart(ctx context.Context, nodeID, appID string) error

Restart scales down the number of replicas of kubernetes deployment to 0 and then scale up to 1.

func (*Client) Start

func (ks *Client) Start(ctx context.Context, nodeID, appID string) error

Start scales up the number of replicas of kubernetes deployment to 1.

func (*Client) Status

func (ks *Client) Status(ctx context.Context, nodeID, appID string) (LifecycleStatus, error)

Status gets the status of kubernetes app

func (*Client) Stop

func (ks *Client) Stop(ctx context.Context, nodeID, appID string) error

Stop scales down the number of replicas of kubernetes deployment to 0.

func (*Client) Undeploy

func (ks *Client) Undeploy(ctx context.Context, nodeID, appID string) error

Undeploy cascade deletes a kubernetes deployment

type LifecycleStatus

type LifecycleStatus string

LifecycleStatus is a kubernetes deployment's status.

const (
	// Unknown means status of the pod is currently unknown
	Unknown LifecycleStatus = "unknown"

	// Deployed means the deployment is created, but no pod is running
	Deployed LifecycleStatus = "deployed"

	// Pending means the deployment is created and pod is yet to be created
	Pending LifecycleStatus = "pending"

	// Starting means the pod is starting
	Starting LifecycleStatus = "starting"

	// Running means the pod is currently running
	Running LifecycleStatus = "running"

	// Terminating means the pod is being terminated
	Terminating LifecycleStatus = "terminating"

	// Error means error occurred
	Error LifecycleStatus = "error"
)

type PortProto

type PortProto struct {
	Port     int32
	Protocol string
}

PortProto is a port and protocol tuple

Jump to

Keyboard shortcuts

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