hypersh

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2018 License: Apache-2.0 Imports: 31 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() v1.ResourceList

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

func (*HyperProvider) CreatePod

func (p *HyperProvider) CreatePod(pod *v1.Pod) error

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

func (*HyperProvider) DeletePod

func (p *HyperProvider) DeletePod(pod *v1.Pod) (err error)

DeletePod deletes the specified pod out of hyper.sh.

func (*HyperProvider) GetContainerLogs

func (p *HyperProvider) GetContainerLogs(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(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) GetPodStatus

func (p *HyperProvider) GetPodStatus(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() ([]*v1.Pod, error)

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

func (*HyperProvider) NodeAddresses

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

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

func (*HyperProvider) NodeConditions

func (p *HyperProvider) NodeConditions() []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() *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(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