hypersh

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2018 License: Apache-2.0 Imports: 35 Imported by: 0

README

hyper.sh provider for virtual-kubelet

Configure for hyper.sh

Use environment variable

  • necessary
    • HYPER_ACCESS_KEY
    • HYPER_SECRET_KEY
  • optional
    • HYPER_INSTANCE_TYPE: default s4
    • HYPER_DEFAULT_REGION: default us-west-1
    • HYPER_HOST: tcp://${HYPER_DEFAULT_REGION}.hyper.sh:443

You can use You can use either HYPER_HOST or HYPER_DEFAULT_REGION

Use config file

default config file for hyper.sh is ~/.hyper/config.json

//example configuration file for Hyper.sh
{
	"auths": {
		"https://index.docker.io/v1/": {
			"auth": "xxxxxx",
			"email": "xxxxxx"
		},
	},
	"clouds": {
		"tcp://*.hyper.sh:443": {
			"accesskey": "xxxxxx",
			"secretkey": "xxxxxx",
			"region": "us-west-1"
		}
	}
}

Usage of virtual-kubelet cli

// example 1 : use environment variable
export HYPER_ACCESS_KEY=xxxxxx
export HYPER_SECRET_KEY=xxxxxx
export HYPER_DEFAULT_REGION=eu-central-1
export HYPER_INSTANCE_TYPE=s4
./virtual-kubelet --provider=hyper


// example 2 : use default config file(~/.hyper/config.json)
unset HYPER_ACCESS_KEY
unset HYPER_SECRET_KEY
export HYPER_DEFAULT_REGION=eu-central-1
./virtual-kubelet --provider=hyper


// example 3 : use custom config file, eg: ~/.hyper2/config.json
$ ./virtual-kubelet --provider=hyper --provider-config=$HOME/.hyper2

Quick Start

create pod yaml

$ cat pod-nginx
apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  nodeName: virtual-kubelet
  containers:
  - name: nginx
    image: nginx:latest
    ports:
    - containerPort: 80

create pod

$ kubectl create -f pod-nginx

list container on hyper.sh

$ hyper ps
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS         PORTS                NAMES            PUBLIC IP
a0ae3d4112d5   nginx:latest   "nginx -g 'daemon off"   9 seconds ago   Up 4 seconds   0.0.0.0:80->80/tcp   pod-nginx-nginx

server log

$ export HYPER_DEFAULT_REGION=eu-central-1
$ ./virtual-kubelet --provider=hyper --provider-config=$HOME/.hyper3
/home/demo/.kube/config
2017/12/20 17:30:30 config file under "/home/demo/.hyper3" was loaded
2017/12/20 17:30:30 
 Host: tcp://eu-central-1.hyper.sh:443
 AccessKey: K**********
 SecretKey: 4**********
 InstanceType: s4
2017/12/20 17:30:31 Node 'virtual-kubelet' with OS type 'Linux' registered
2017/12/20 17:30:31 receive GetPods
2017/12/20 17:30:32 found 0 pods
2017/12/20 17:30:37 receive GetPods
2017/12/20 17:30:37 found 0 pods
2017/12/20 17:30:38 Error retrieving pod 'nginx' from provider: Error: No such container: pod-nginx-nginx
2017/12/20 17:30:38 receive CreatePod "nginx"
2017/12/20 17:30:38 container "a0ae3d4112d53023b5972906f2f15c0d34360c132b3c273b286473afad613b63" for pod "nginx" was created
2017/12/20 17:30:43 container "a0ae3d4112d53023b5972906f2f15c0d34360c132b3c273b286473afad613b63" for pod "nginx" was started
2017/12/20 17:30:43 Pod 'nginx' created.
2017/12/20 17:30:43 receive GetPods
2017/12/20 17:30:43 found 1 pods
2017/12/20 17:30:47 receive GetPods
2017/12/20 17:30:47 found 1 pods

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HyperProvider

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

HyperProvider implements the virtual-kubelet provider interface and communicates with hyper.sh APIs.

func NewHyperProvider

func NewHyperProvider(config string, rm *manager.ResourceManager, nodeName, operatingSystem string) (*HyperProvider, error)

NewHyperProvider creates a new HyperProvider

func (*HyperProvider) Capacity

func (p *HyperProvider) Capacity(ctx context.Context) v1.ResourceList

Capacity returns a resource list containing the capacity limits set for hyper.sh.

func (*HyperProvider) CreatePod

func (p *HyperProvider) CreatePod(ctx context.Context, pod *v1.Pod) error

CreatePod accepts a Pod definition and creates a hyper.sh deployment

func (*HyperProvider) DeletePod

func (p *HyperProvider) DeletePod(ctx context.Context, pod *v1.Pod) (err error)

DeletePod deletes the specified pod out of hyper.sh.

func (*HyperProvider) ExecInContainer added in v0.4.1

func (p *HyperProvider) ExecInContainer(name string, uid apitypes.UID, container string, cmd []string, in io.Reader, out, err io.WriteCloser, tty bool, resize <-chan remotecommand.TerminalSize, timeout time.Duration) error

ExecInContainer executes a command in a container in the pod, copying data between in/out/err and the container's stdin/stdout/stderr. TODO: Implementation

func (*HyperProvider) GetContainerLogs

func (p *HyperProvider) GetContainerLogs(ctx context.Context, namespace, podName, containerName string, tail int) (string, error)

GetContainerLogs retrieves the logs of a container by name from the provider.

func (*HyperProvider) GetPod

func (p *HyperProvider) GetPod(ctx context.Context, namespace, name string) (pod *v1.Pod, err error)

GetPod returns a pod by name that is running inside hyper.sh returns nil if a pod by that name is not found.

func (*HyperProvider) GetPodFullName added in v0.4.1

func (p *HyperProvider) GetPodFullName(namespace string, pod string) string

Get full pod name as defined in the provider context TODO: Implementation

func (*HyperProvider) GetPodStatus

func (p *HyperProvider) GetPodStatus(ctx context.Context, namespace, name string) (*v1.PodStatus, error)

GetPodStatus returns the status of a pod by name that is running inside hyper.sh returns nil if a pod by that name is not found.

func (*HyperProvider) GetPods

func (p *HyperProvider) GetPods(ctx context.Context) ([]*v1.Pod, error)

GetPods returns a list of all pods known to be running within hyper.sh.

func (*HyperProvider) NodeAddresses

func (p *HyperProvider) NodeAddresses(ctx context.Context) []v1.NodeAddress

NodeAddresses returns a list of addresses for the node status within Kubernetes.

func (*HyperProvider) NodeConditions

func (p *HyperProvider) NodeConditions(ctx context.Context) []v1.NodeCondition

NodeConditions returns a list of conditions (Ready, OutOfDisk, etc), for updates to the node status within Kubernetes.

func (*HyperProvider) NodeDaemonEndpoints

func (p *HyperProvider) NodeDaemonEndpoints(ctx context.Context) *v1.NodeDaemonEndpoints

NodeDaemonEndpoints returns NodeDaemonEndpoints for the node status within Kubernetes.

func (*HyperProvider) OperatingSystem

func (p *HyperProvider) OperatingSystem() string

OperatingSystem returns the operating system for this provider. This is a noop to default to Linux for now.

func (*HyperProvider) UpdatePod

func (p *HyperProvider) UpdatePod(ctx context.Context, pod *v1.Pod) error

UpdatePod is a noop, hyper.sh currently does not support live updates of a pod.

Jump to

Keyboard shortcuts

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