primitives

package
v0.3.3-rc1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2020 License: Apache-2.0 Imports: 31 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// ContainerReservation type
	ContainerReservation provision.ReservationType = "container"
	// VolumeReservation type
	VolumeReservation provision.ReservationType = "volume"
	// NetworkReservation type
	NetworkReservation provision.ReservationType = "network"
	// ZDBReservation type
	ZDBReservation provision.ReservationType = "zdb"
	// DebugReservation type
	DebugReservation provision.ReservationType = "debug"
	// KubernetesReservation type
	KubernetesReservation provision.ReservationType = "kubernetes"
)

Variables

View Source
var ErrUnsupportedWorkload = errors.New("workload type not supported")

ErrUnsupportedWorkload is return when a workload of a type not supported by provisiond is received from the explorer

ProvisionOrder is used to sort the workload type in the right order for provision engine

Functions

func NetResourceToProvisionType

func NetResourceToProvisionType(r workloads.NetworkNetResource) (pkg.NetResource, error)

NetResourceToProvisionType converts TfgridNetworkNetResource1 to pkg.NetResource

func NetworkToProvisionType

func NetworkToProvisionType(n workloads.Network) (pkg.Network, error)

NetworkToProvisionType convert TfgridReservationNetwork1 to pkg.Network

func ResultToSchemaType

func ResultToSchemaType(r provision.Result) (*workloads.Result, error)

ResultToSchemaType converts result to schema type

func WireguardToProvisionType

func WireguardToProvisionType(p workloads.WireguardPeer) (pkg.Peer, error)

WireguardToProvisionType converts WireguardPeer1 to pkg.Peer

func WorkloadToProvisionType

func WorkloadToProvisionType(w workloads.ReservationWorkload) (*provision.Reservation, error)

WorkloadToProvisionType TfgridReservationWorkload1 to provision.Reservation

Types

type Container

type Container struct {
	// URL of the flist
	FList string `json:"flist"`
	// URL of the storage backend for the flist
	FlistStorage string `json:"flist_storage"`
	// Env env variables to container in format
	Env map[string]string `json:"env"`
	// Env env variables to container that the value is encrypted
	// with the node public key. the env will be exposed to plain
	// text to the entrypoint.
	SecretEnv map[string]string `json:"secret_env"`
	// Entrypoint the process to start inside the container
	Entrypoint string `json:"entrypoint"`
	// Interactivity enable Core X as PID 1 on the container
	Interactive bool `json:"interactive"`
	// Mounts extra mounts in the container
	Mounts []Mount `json:"mounts"`
	// Network network info for container
	Network Network `json:"network"`
	// ContainerCapacity is the amount of resource to allocate to the container
	Capacity ContainerCapacity `json:"capacity"`
	// Logs contains a list of endpoint where to send containerlogs
	Logs []logger.Logs `json:"logs,omitempty"`
	// StatsAggregator container metrics backend
	StatsAggregator []stats.Aggregator
}

Container creation info

func ContainerToProvisionType

func ContainerToProvisionType(c workloads.Container, reservationID string) (Container, string, error)

ContainerToProvisionType converts TfgridReservationContainer1 to Container

type ContainerCapacity

type ContainerCapacity struct {
	// Number of CPU
	CPU uint `json:"cpu"`
	// Memory in MiB
	Memory uint64 `json:"memory"`
	//DiskType is the type of disk to use for root fs
	DiskType pkg.DeviceType `json:"disk_type"`
	// DiskSize of the root fs in MiB
	DiskSize uint64 `json:"disk_size"`
}

ContainerCapacity is the amount of resource to allocate to the container

type ContainerResult

type ContainerResult struct {
	ID   string `json:"id"`
	IPv6 string `json:"ipv6"`
	IPv4 string `json:"ipv4"`
}

ContainerResult is the information return to the BCDB after deploying a container

type Counter

type Counter interface {
	// Increment counter atomically by v
	Increment(v uint64) uint64
	// Decrement counter atomically by v
	Decrement(v uint64) uint64
	// Current returns the current value
	Current() uint64
}

Counter interface

type CounterUint64

type CounterUint64 uint64

CounterUint64 value for safe increment/decrement

func (*CounterUint64) Current

func (c *CounterUint64) Current() uint64

Current returns the current value

func (*CounterUint64) Decrement

func (c *CounterUint64) Decrement(v uint64) uint64

Decrement counter atomically by one

func (*CounterUint64) Increment

func (c *CounterUint64) Increment(v uint64) uint64

Increment counter atomically by one

type Counters

type Counters struct {
	SRU CounterUint64 // SSD storage in bytes
	HRU CounterUint64 // HDD storage in bytes
	MRU CounterUint64 // Memory storage in bytes
	CRU CounterUint64 // CPU count absolute
	// contains filtered or unexported fields
}

Counters tracks the amount of primitives workload deployed and the amount of resource unit used

func (*Counters) CurrentUnits

func (c *Counters) CurrentUnits() directory.ResourceAmount

CurrentUnits return the number of each resource units reserved on the system

func (*Counters) CurrentWorkloads

func (c *Counters) CurrentWorkloads() directory.WorkloadAmount

CurrentWorkloads return the number of each workloads provisioned on the system

func (*Counters) Decrement

func (c *Counters) Decrement(r *provision.Reservation) error

Decrement is called by the provision.Engine when a reservation has been decommissioned

func (*Counters) Increment

func (c *Counters) Increment(r *provision.Reservation) error

Increment is called by the provision.Engine when a reservation has been provisionned

type Debug

type Debug struct {
	Host    string `json:"host"`
	Port    int    `json:"port"`
	Channel string `json:"channel"`
}

Debug provision schema

type Kubernetes

type Kubernetes struct {
	// Size of the vm, this defines the amount of vCpu, memory, and the disk size
	// Docs: docs/kubernetes/sizes.md
	Size uint8 `json:"size"`

	// NetworkID of the network namepsace in which to run the VM. The network
	// must be provisioned previously.
	NetworkID pkg.NetID `json:"network_id"`
	// IP of the VM. The IP must be part of the subnet available in the network
	// resource defined by the networkID on this node
	IP net.IP `json:"ip"`

	// ClusterSecret is the hex encoded encrypted cluster secret.
	ClusterSecret string `json:"cluster_secret"`
	// MasterIPs define the URL's for the kubernetes master nodes. If this
	// list is empty, this node is considered to be a master node.
	MasterIPs []net.IP `json:"master_ips"`
	// SSHKeys is a list of ssh keys to add to the VM. Keys can be either
	// a full ssh key, or in the form of `github:${username}`. In case of
	// the later, the VM will retrieve the github keys for this username
	// when it boots.
	SSHKeys []string `json:"ssh_keys"`

	PlainClusterSecret string `json:"-"`
}

Kubernetes reservation data

func K8SToProvisionType

func K8SToProvisionType(k workloads.K8S) (Kubernetes, string, error)

K8SToProvisionType converts type to internal provision type

type KubernetesResult

type KubernetesResult struct {
	ID string `json:"id"`
	IP string `json:"ip"`
}

KubernetesResult result returned by k3s reservation

type Mount

type Mount struct {
	VolumeID   string `json:"volume_id"`
	Mountpoint string `json:"mountpoint"`
}

Mount defines a container volume mounted inside the container

type Network

type Network struct {
	NetworkID pkg.NetID `json:"network_id"`
	// IP to give to the container
	IPs       []net.IP `json:"ips"`
	PublicIP6 bool     `json:"public_ip6"`
}

Network struct

type Provisioner

type Provisioner struct {
	Provisioners    map[provision.ReservationType]provision.ProvisionerFunc
	Decommissioners map[provision.ReservationType]provision.DecomissionerFunc
	// contains filtered or unexported fields
}

Provisioner hold all the logic responsible to provision and decomission the different primitives workloads defined by this package

func NewProvisioner

func NewProvisioner(cache provision.ReservationCache, zbus zbus.Client) *Provisioner

NewProvisioner creates a new 0-OS provisioner

type Volume

type Volume struct {
	// Size of the volume in GiB
	Size uint64 `json:"size"`
	// Type of disk underneath the volume
	Type pkg.DeviceType `json:"type"`
}

Volume defines a mount point

func VolumeToProvisionType

func VolumeToProvisionType(v workloads.Volume) (Volume, string, error)

VolumeToProvisionType converts TfgridReservationVolume1 to Volume

type VolumeResult

type VolumeResult struct {
	ID string `json:"volume_id"`
}

VolumeResult is the information return to the BCDB after deploying a volume

type ZDB

type ZDB struct {
	Size     uint64         `json:"size"`
	Mode     pkg.ZDBMode    `json:"mode"`
	Password string         `json:"password"`
	DiskType pkg.DeviceType `json:"disk_type"`
	Public   bool           `json:"public"`

	PlainPassword string `json:"-"`
}

ZDB namespace creation info

func ZDBToProvisionType

func ZDBToProvisionType(z workloads.ZDB) (ZDB, string, error)

ZDBToProvisionType converts TfgridReservationZdb1 to ZDB

type ZDBResult

type ZDBResult struct {
	Namespace string
	IP        string
	Port      uint
}

ZDBResult is the information return to the BCDB after deploying a 0-db namespace

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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